public function importAction() { $request = $this->getRequest(); if ($request->getQuery('document_id')) { $_REQUEST["document_id"] = $request->getQuery('document_id'); $category_details = \Carecoordination\Controller\CarecoordinationController::getCarecoordinationTable()->fetch_cat_id('CCD'); \Documents\Controller\DocumentsController::getDocumentsTable()->updateDocumentCategory($category_details[0]['id'], $_REQUEST["document_id"]); } $document_id = $_REQUEST["document_id"]; $xml_content = \Carecoordination\Controller\CarecoordinationController::getCarecoordinationTable()->getDocument($document_id); $xmltoarray = new \Zend\Config\Reader\Xml(); $array = $xmltoarray->fromString((string) $xml_content); $this->getCcdTable()->import($array, $document_id); $view = new ViewModel(); $view->setTerminal(true); return $view; }
public function importAction() { $request = $this->getRequest(); if ($request->getQuery('document_id')) { $_REQUEST["document_id"] = $request->getQuery('document_id'); $category_details = $this->getCcrTable()->fetch_cat_id('CCR'); \Documents\Controller\DocumentsController::getDocumentsTable()->updateDocumentCategory($category_details[0]['id'], $_REQUEST["document_id"]); } $doc_id = $_REQUEST["document_id"]; $content = $this->getCcrTable()->getDocument($doc_id); if ($request->getQuery('document_id')) { $replace = array('<ccr:ContinuityOfCareRecord xsi:schemaLocation="urn:astm-org:CCR CCRV1.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:ccr="urn:astm-org:CCR">', 'ccr:'); $to_replace = array('<ContinuityOfCareRecord xmlns="urn:astm-org:CCR">', ''); $content = str_replace($replace, $to_replace, $content); $content = preg_replace('/BirthName/', 'CurrentName', $content, 2); } //fields to which the corresponding elements are to be inserted //format - level 1 key is the main tag in the XML eg:- //Problems or //Problems/Problem according to the content in the XML. //level 2 key is 'table name:field name' and level 2 value is the sub tag under the main tag given in level 1 key //eg:- 'Type/Text' if the XML format is '//Problems/Problem/Type/Text' or 'id/@extension' if it is an attribute //level 2 key can be 'table name:#some value' for checking whether a particular tag exits in the XML section $field_mapping = array('//Problems/Problem' => array('lists1:diagnosis' => 'Description/Code/Value', 'lists1:comments' => 'CommentID', 'lists1:activity' => 'Status/Text', 'lists1:title' => 'Description/Text', 'lists1:date' => 'DateTime/ExactDateTime'), '//Alerts/Alert' => array('lists2:type' => 'Type/Text', 'lists2:diagnosis' => 'Description/Code/Value', 'lists2:date' => 'Agent/EnvironmentalAgents/EnvironmentalAgent/DateTime/ExactDateTime', 'lists2:title' => 'Agent/EnvironmentalAgents/EnvironmentalAgent/Description/Text', 'lists2:reaction' => 'Reaction/Description/Text'), '//Medications/Medication' => array('prescriptions:date_added' => 'DateTime/ExactDateTime', 'prescriptions:active' => 'Status/Text', 'prescriptions:drug' => 'Product/ProductName/Text', 'prescriptions:size' => 'Product/Strength/Value', 'prescriptions:unit' => 'Product/Strength/Units/Unit', 'prescriptions:form' => 'Product/Form/Text', 'prescriptions:quantity' => 'Quantity/Value', 'prescriptions:note' => 'PatientInstructions/Instruction/Text', 'prescriptions:refills' => 'Refills/Refill/Number'), '//Immunizations/Immunization' => array('immunizations:administered_date' => 'DateTime/ExactDateTime', 'immunizations:note' => 'Directions/Direction/Description/Text'), '//Results/Result' => array('procedure_result:date' => 'DateTime/ExactDateTime', 'procedure_type:name' => 'Test/Description/Text', 'procedure_result:result' => 'Test/TestResult/Value', 'procedure_result:range' => 'Test/NormalResult/Normal/Value', 'procedure_result:abnormal' => 'Test/Flag/Text'), '//Actors/Actor' => array('patient_data:fname' => 'Person/Name/CurrentName/Given', 'patient_data:lname' => 'Person/Name/CurrentName/Family', 'patient_data:DOB' => 'Person/DateOfBirth/ExactDateTime', 'patient_data:sex' => 'Person/Gender/Text', 'patient_data:abname' => 'InformationSystem/Name', 'patient_data:#Type' => 'InformationSystem/Type', 'patient_data:pubpid' => 'IDs/ID', 'patient_data:street' => 'Address/Line1', 'patient_data:city' => 'Address/City', 'patient_data:state' => 'Address/State', 'patient_data:postal_code' => 'Address/PostalCode', 'patient_data:phone_contact' => 'Telephone/Value')); if (!empty($content)) { $var = array(); $res = $this->getCcrTable()->parseXmlStream($content, $field_mapping); $var = array('approval_status' => 1, 'type' => 11, 'ip_address' => $_SERVER['REMOTE_ADDR']); foreach ($res as $sections => $details) { foreach ($details as $cnt => $vals) { foreach ($vals as $key => $val) { if (array_key_exists('#Type', $res[$sections][$cnt])) { if ($key == 'postal_code') { $var['field_name_value_array']['misc_address_book'][$cnt]['zip'] = $val; } elseif ($key == 'phone_contact') { $var['field_name_value_array']['misc_address_book'][$cnt]['phone'] = $val; } elseif ($key == 'abname') { $values = explode(' ', $val); if ($values[0]) { $var['field_name_value_array']['misc_address_book'][$cnt]['lname'] = $values[0]; } if ($values[1]) { $var['field_name_value_array']['misc_address_book'][$cnt]['fname'] = $values[1]; } } else { $var['field_name_value_array']['misc_address_book'][$cnt][$key] = $val; } $var['entry_identification_array']['misc_address_book'][$cnt] = $cnt; } else { if ($sections == 'lists1' && $key == 'activity') { if ($val == 'Active') { $val = 1; } else { $val = 0; } } if ($sections == 'lists2' && $key == 'type') { if (strpos($val, "-")) { $vals = explode("-", $val); $val = $vals[0]; } else { $val = ""; } } if ($sections == 'prescriptions' && $key == 'active') { if ($val == 'Active') { $val = 1; } else { $val = 0; } } $var['field_name_value_array'][$sections][$cnt][$key] = $val; $var['entry_identification_array'][$sections][$cnt] = $cnt; } } if (array_key_exists('#Type', $var['field_name_value_array']['misc_address_book'][$cnt])) { unset($var['field_name_value_array']['misc_address_book'][$cnt]['#Type']); } } } $var['field_name_value_array']['documents'][0]['id'] = $doc_id; $audit_master_id = $this->getCcrTable()->insert_ccr_into_audit_data($var); $this->getCcrTable()->update_imported($doc_id); $this->getCcrTable()->update_document($doc_id, $audit_master_id); if ($_REQUEST["batch_import"] == 'YES') { return; } else { //echo('Imported'); //exit; } } else { //exit('Could not read the file'); } }
public function importAction() { $request = $this->getRequest(); if ($request->getQuery('document_id')) { $_REQUEST["document_id"] = $request->getQuery('document_id'); $category_details = $this->getCarecoordinationTable()->fetch_cat_id('CCDA'); \Documents\Controller\DocumentsController::getDocumentsTable()->updateDocumentCategory($category_details[0]['id'], $_REQUEST["document_id"]); } $document_id = $_REQUEST["document_id"]; $xml_content = $this->getCarecoordinationTable()->getDocument($document_id); $xml_content_new = preg_replace('#<br />#', '', $xml_content); $xml_content_new = preg_replace('#<br/>#', '', $xml_content_new); $xmltoarray = new \Zend\Config\Reader\Xml(); $array = $xmltoarray->fromString((string) $xml_content_new); $patient_role = $array['recordTarget']['patientRole']; $patient_pub_pid = $patient_role['id'][0]['extension']; $patient_ssn = $patient_role['id'][1]['extension']; $patient_address = $patient_role['addr']['streetAddressLine']; $patient_city = $patient_role['addr']['city']; $patient_state = $patient_role['addr']['state']; $patient_postalcode = $patient_role['addr']['postalCode']; $patient_country = $patient_role['addr']['country']; $patient_phone_type = $patient_role['telecom']['use']; $patient_phone_no = $patient_role['telecom']['value']; $patient_fname = $patient_role['patient']['name']['given'][0]; $patient_lname = $patient_role['patient']['name']['given'][1]; $patient_family_name = $patient_role['patient']['name']['family']; $patient_gender_code = $patient_role['patient']['administrativeGenderCode']['code']; $patient_gender_name = $patient_role['patient']['administrativeGenderCode']['displayName']; $patient_dob = $patient_role['patient']['birthTime']['value']; $patient_marital_status = $patient_role['patient']['religiousAffiliationCode']['code']; $patient_marital_status_display = $patient_role['patient']['religiousAffiliationCode']['displayName']; $patient_race = $patient_role['patient']['raceCode']['code']; $patient_race_display = $patient_role['patient']['raceCode']['displayName']; $patient_ethnicity = $patient_role['patient']['ethnicGroupCode']['code']; $patient_ethnicity_display = $patient_role['patient']['ethnicGroupCode']['displayName']; $patient_language = $patient_role['patient']['languageCommunication']['languageCode']['code']; $author = $array['recordTarget']['author']['assignedAuthor']; $author_id = $author['id']['extension']; $author_address = $author['addr']['streetAddressLine']; $author_city = $author['addr']['city']; $author_state = $author['addr']['state']; $author_postalCode = $author['addr']['postalCode']; $author_country = $author['addr']['country']; $author_phone_use = $author['telecom']['use']; $author_phone = $author['telecom']['value']; $author_name_given = $author['assignedPerson']['name']['given']; $author_name_family = $author['assignedPerson']['name']['family']; $data_enterer = $array['recordTarget']['dataEnterer']['assignedEntity']; $data_enterer_id = $data_enterer['id']['extension']; $data_enterer_address = $data_enterer['addr']['streetAddressLine']; $data_enterer_city = $data_enterer['addr']['city']; $data_enterer_state = $data_enterer['addr']['state']; $data_enterer_postalCode = $data_enterer['addr']['postalCode']; $data_enterer_country = $data_enterer['addr']['country']; $data_enterer_phone_use = $data_enterer['telecom']['use']; $data_enterer_phone = $data_enterer['telecom']['value']; $data_enterer_name_given = $data_enterer['assignedPerson']['name']['given']; $data_enterer_name_family = $data_enterer['assignedPerson']['name']['family']; $informant = $array['recordTarget']['informant'][0]['assignedEntity']; $informant_id = $informant['id']['extension']; $informant_address = $informant['addr']['streetAddressLine']; $informant_city = $informant['addr']['city']; $informant_state = $informant['addr']['state']; $informant_postalCode = $informant['addr']['postalCode']; $informant_country = $informant['addr']['country']; $informant_phone_use = $informant['telecom']['use']; $informant_phone = $informant['telecom']['value']; $informant_name_given = $informant['assignedPerson']['name']['given']; $informant_name_family = $informant['assignedPerson']['name']['family']; $personal_informant = $array['recordTarget']['informant'][1]['relatedEntity']; $personal_informant_name = $personal_informant['relatedPerson']['name']['given']; $personal_informant_family = $personal_informant['relatedPerson']['name']['family']; $custodian = $array['recordTarget']['custodian']['assignedCustodian']['representedCustodianOrganization']; $custodian_name = $custodian['name']; $custodian_address = $custodian['addr']['streetAddressLine']; $custodian_city = $custodian['addr']['city']; $custodian_state = $custodian['addr']['state']; $custodian_postalCode = $custodian['addr']['postalCode']; $custodian_country = $custodian['addr']['country']; $custodian_phone = $custodian['telecom']['value']; $custodian_phone_use = $custodian['telecom']['use']; $informationRecipient = $array['recordTarget']['informationRecipient']['intendedRecipient']; $informationRecipient_name = $informationRecipient['informationRecipient']['name']['given']; $informationRecipient_name = $informationRecipient['informationRecipient']['name']['family']; $informationRecipient_org = $informationRecipient['receivedOrganization']['name']; $legalAuthenticator = $array['recordTarget']['legalAuthenticator']; $legalAuthenticator_signatureCode = $legalAuthenticator['signatureCode']['code']; $legalAuthenticator_id = $legalAuthenticator['assignedEntity']['id']['extension']; $legalAuthenticator_address = $legalAuthenticator['assignedEntity']['addr']['streetAddressLine']; $legalAuthenticator_city = $legalAuthenticator['assignedEntity']['addr']['city']; $legalAuthenticator_state = $legalAuthenticator['assignedEntity']['addr']['state']; $legalAuthenticator_postalCode = $legalAuthenticator['assignedEntity']['addr']['postalCode']; $legalAuthenticator_country = $legalAuthenticator['assignedEntity']['addr']['country']; $legalAuthenticator_phone = $legalAuthenticator['assignedEntity']['telecom']['value']; $legalAuthenticator_phone_use = $legalAuthenticator['assignedEntity']['telecom']['use']; $legalAuthenticator_name_given = $legalAuthenticator['assignedEntity']['assignedPerson']['name']['given']; $legalAuthenticator_name_family = $legalAuthenticator['assignedEntity']['assignedPerson']['name']['family']; $authenticator = $array['recordTarget']['authenticator']; $authenticator_signatureCode = $authenticator['signatureCode']['code']; $authenticator_id = $authenticator['assignedEntity']['id']['extension']; $authenticator_address = $authenticator['assignedEntity']['addr']['streetAddressLine']; $authenticator_city = $authenticator['assignedEntity']['addr']['city']; $authenticator_state = $authenticator['assignedEntity']['addr']['state']; $authenticator_postalCode = $authenticator['assignedEntity']['addr']['postalCode']; $authenticator_country = $authenticator['assignedEntity']['addr']['country']; $authenticator_phone = $authenticator['assignedEntity']['telecom']['value']; $authenticator_phone_use = $authenticator['assignedEntity']['telecom']['use']; $authenticator_name_given = $authenticator['assignedEntity']['assignedPerson']['name']['given']; $authenticator_name_family = $authenticator['assignedEntity']['assignedPerson']['name']['family']; $this->getCarecoordinationTable()->import($array, $document_id); $view = new ViewModel(); $view->setTerminal(true); return $view; }