コード例 #1
0
 public function getEncounters($data, $getCount = null)
 {
     $query_data = array();
     $query = "SELECT pd.fname, pd.lname, pd.mname, date(fe.date) as date, fe.pid, fe.encounter,\n                        u.fname as doc_fname, u.mname as doc_mname, u.lname as doc_lname, (select count(encounter) from form_encounter where pid=fe.pid) as enc_count,\n                        (SELECT DATE(date) FROM form_encounter WHERE pid=fe.pid ORDER BY date DESC LIMIT 1) as last_visit_date,\n\t\t\t\t\t\t(select count(*) from ccda where pid=fe.pid and transfer=1) as ccda_transfer_count,\n\t\t\t\t\t\t(select count(*) from ccda where pid=fe.pid and transfer=1 and status=1) as ccda_successfull_transfer_count\n                        FROM form_encounter AS fe\n                        JOIN patient_data AS pd ON pd.pid=fe.pid\n                        LEFT JOIN users AS u ON u.id=fe.provider_id ";
     if ($data['status']) {
         $query .= " LEFT JOIN combination_form AS cf ON cf.encounter = fe.encounter ";
     }
     $query .= " WHERE 1=1 ";
     if ($data['status'] == "signed") {
         $query .= " AND cf.encounter IS NOT NULL AND cf.encounter !=''";
     }
     if ($data['status'] == "unsigned") {
         $query .= " AND (cf.encounter IS  NULL OR cf.encounter ='')";
     }
     if ($data['from_date'] && $data['to_date']) {
         $query .= " AND fe.date BETWEEN ? AND ? ";
         $query_data[] = $data['from_date'];
         $query_data[] = $data['to_date'];
     }
     if ($data['pid']) {
         $query .= " AND (fe.pid = ? OR pd.fname like ? OR pd.mname like ? OR pd.lname like ? OR CONCAT_WS(' ',pd.fname,pd.lname) like ?) ";
         $query_data[] = $data['pid'];
         $query_data[] = "%" . $data['pid'] . "%";
         $query_data[] = "%" . $data['pid'] . "%";
         $query_data[] = "%" . $data['pid'] . "%";
         $query_data[] = "%" . $data['pid'] . "%";
     }
     if ($data['encounter']) {
         $query .= " AND fe.encounter = ? ";
         $query_data[] = $data['encounter'];
     }
     $query .= " GROUP BY fe.pid ";
     $query .= " ORDER BY fe.pid, fe.date ";
     $appTable = new ApplicationTable();
     if ($getCount) {
         $res = $appTable->zQuery($query, $query_data);
         $resCount = $res->count();
         return $resCount;
     }
     $query .= " LIMIT " . \Application\Plugin\CommonPlugin::escapeLimit($data['limit_start']) . "," . \Application\Plugin\CommonPlugin::escapeLimit($data['results']);
     $resDetails = $appTable->zQuery($query, $query_data);
     return $resDetails;
 }
コード例 #2
0
ファイル: CcdTable.php プロジェクト: katopenzz/openemr
 public function import($xml, $document_id)
 {
     $audit_master_approval_status = $this->ccd_data_array['approval_status'] = 1;
     $this->ccd_data_array['ip_address'] = $_SERVER['REMOTE_ADDR'];
     $this->ccd_data_array['type'] = '13';
     //Patient Details
     $this->ccd_data_array['field_name_value_array']['patient_data'][1]['fname'] = $xml['recordTarget']['patientRole']['patient']['name']['given'][0];
     $this->ccd_data_array['field_name_value_array']['patient_data'][1]['mname'] = $xml['recordTarget']['patientRole']['patient']['name']['given'][1];
     $this->ccd_data_array['field_name_value_array']['patient_data'][1]['lname'] = $xml['recordTarget']['patientRole']['patient']['name']['family'];
     $this->ccd_data_array['field_name_value_array']['patient_data'][1]['DOB'] = $xml['recordTarget']['patientRole']['patient']['birthTime']['value'];
     $this->ccd_data_array['field_name_value_array']['patient_data'][1]['sex'] = $xml['recordTarget']['patientRole']['patient']['administrativeGenderCode']['displayName'];
     $this->ccd_data_array['field_name_value_array']['patient_data'][1]['street'] = $xml['recordTarget']['patientRole']['addr']['streetAddressLine'];
     $this->ccd_data_array['field_name_value_array']['patient_data'][1]['city'] = $xml['recordTarget']['patientRole']['addr']['city'];
     $this->ccd_data_array['field_name_value_array']['patient_data'][1]['state'] = $xml['recordTarget']['patientRole']['addr']['state'];
     $this->ccd_data_array['field_name_value_array']['patient_data'][1]['postal_code'] = $xml['recordTarget']['patientRole']['addr']['postalCode'];
     $this->ccd_data_array['field_name_value_array']['patient_data'][1]['phone_home'] = preg_replace('/[^0-9]+/i', '', $xml['recordTarget']['patientRole']['telecom']['value']);
     $this->ccd_data_array['field_name_value_array']['patient_data'][1]['extension'] = $xml['recordTarget']['patientRole']['id']['extension'];
     $audit_master_id = \Application\Plugin\CommonPlugin::insert_ccr_into_audit_data($this->ccd_data_array);
     $this->update_document_table($document_id, $audit_master_id, $audit_master_approval_status);
 }
コード例 #3
0
 function fetch_result($fromDate, $toDate, $code_selected, $provider_selected, $start, $end, $get_count = null)
 {
     $records = array();
     $query_string = array();
     $query = "SELECT   c.code_text,l.pid AS patientid,p.language,l.diagnosis,CONCAT(p.fname, ' ', p.mname, ' ', p.lname) AS patientname,l.date AS issuedate, l.id AS issueid,l.title AS issuetitle \n\t\t\tFROM\n\t\t\t  lists l, patient_data p, codes c, form_encounter AS fe \n\t\t\tWHERE c.reportable = 1 ";
     if ($provider_selected) {
         $query .= " AND provider_id = ? ";
         $query_string[] = $provider_selected;
     }
     $query .= " AND l.id NOT IN \n\t\t\t(SELECT \n\t\t\t\tlists_id \n\t\t\tFROM\n\t\t\t\tsyndromic_surveillance) \n\t\t\tAND l.date >= ? AND l.date <= ? AND l.pid = p.pid ";
     $query_string[] = $fromDate;
     $query_string[] = $toDate;
     if ($code_selected) {
         $query .= " AND c.id IN (?) ";
         $query_string[] = implode(',', $code_selected);
     }
     $query .= " AND l.diagnosis LIKE 'ICD9:%' \n\t\t\t\t\tAND ( SUBSTRING(l.diagnosis, 6) = c.code || SUBSTRING(l.diagnosis, 6) = CONCAT_WS('', c.code, ';') ) \n\t\t\t\t\tAND fe.pid = l.pid \n\t\t\t\tUNION DISTINCT \n\t\t\t\tSELECT c.code_text, b.pid AS patientid, p.language, b.code, CONCAT(p.fname, ' ', p.mname, ' ', p.lname) AS patientname, b.date AS issuedate,  b.id AS issueid, '' AS issuetitle \n\t\t\t\tFROM\n\t\t\t\t\tbilling b, patient_data p, codes c, form_encounter fe \n\t\t\t\tWHERE c.reportable = 1 \n\t\t\t\t\tAND b.code_type = 'ICD9' AND b.activity = '1' AND b.pid = p.pid AND fe.encounter = b.encounter ";
     if ($code_selected) {
         $query .= " AND c.id IN (?) ";
         $query_string[] = implode(',', $code_selected);
     }
     $query .= " AND c.code = b.code \n\t\t\tAND fe.date IN \n\t\t\t(SELECT \n\t\t\t\tMAX(fenc.date) \n\t\t\tFROM\n\t\t\t\tform_encounter AS fenc \n\t\t\tWHERE fenc.pid = fe.pid) ";
     if ($provider_selected) {
         $query .= " AND provider_id = ? ";
         $query_string[] = $provider_selected;
     }
     $query .= " AND fe.date >= ? AND fe.date <= ?";
     $query_string[] = $fromDate;
     $query_string[] = $toDate;
     if ($get_count) {
         $appTable = new ApplicationTable();
         $result = $appTable->zQuery($query, $query_string);
         foreach ($result as $row) {
             $records[] = $row;
         }
         return count($records);
     }
     $query .= " LIMIT " . \Application\Plugin\CommonPlugin::escapeLimit($start) . "," . \Application\Plugin\CommonPlugin::escapeLimit($end);
     $appTable = new ApplicationTable();
     $result = $appTable->zQuery($query, $query_string);
     foreach ($result as $row) {
         $records[] = $row;
     }
     return $records;
 }
コード例 #4
0
 /**
  * Auto Suggest
  */
 public function listAutoSuggest($post, $limit)
 {
     $pages = 0;
     $limitEnd = \Application\Plugin\CommonPlugin::escapeLimit($limit);
     if (isset($GLOBALS['set_autosuggest_options'])) {
         if ($GLOBALS['set_autosuggest_options'] == 1) {
             $leading = '%';
         } else {
             $leading = $post->leading;
         }
         if ($GLOBALS['set_autosuggest_options'] == 2) {
             $trailing = '%';
         } else {
             $trailing = $post->trailing;
         }
         if ($GLOBALS['set_autosuggest_options'] == 3) {
             $leading = '%';
             $trailing = '%';
         }
     } else {
         $leading = $post->leading;
         $trailing = $post->trailing;
     }
     $queryString = $post->queryString;
     $page = $post->page;
     $searchType = $post->searchType;
     $searchEleNo = $post->searchEleNo;
     if ($page == '') {
         $limitStart = 0;
     } else {
         $limitStart = \Application\Plugin\CommonPlugin::escapeLimit($page);
     }
     $keyword = $leading . $queryString . $trailing;
     if (strtolower($searchType) == 'patient') {
         $sql = "SELECT fname, mname, lname, pid, DOB FROM patient_data \n                WHERE pid LIKE ? \n                OR  CONCAT(fname, ' ', lname) LIKE ?  \n                OR  CONCAT(lname, ' ', fname) LIKE ? \n                OR DATE_FORMAT(DOB,'%m-%d-%Y') LIKE ?  \n                OR DATE_FORMAT(DOB,'%d-%m-%Y') LIKE ?  \n                OR DATE_FORMAT(DOB,'%Y-%m-%d') LIKE ?  \n                ORDER BY fname ";
         $result = $this->zQuery($sql, array($keyword, $keyword, $keyword, $keyword, $keyword, $keyword));
         $rowCount = $result->count();
         $sql .= "LIMIT {$limitStart}, {$limitEnd}";
         $result = $this->zQuery($sql, array($keyword, $keyword, $keyword, $keyword, $keyword, $keyword));
     } elseif (strtolower($searchType) == 'emrdirect') {
         $sql = "SELECT fname, mname, lname,email,id FROM users \n                WHERE (CONCAT(fname, ' ', lname) LIKE ?  \n                OR  CONCAT(lname, ' ', fname) LIKE ? \n                OR email LIKE ?)   \n                AND abook_type = 'emr_direct' \n                AND active = 1\n                ORDER BY fname ";
         $result = $this->zQuery($sql, array($keyword, $keyword, $keyword));
         $rowCount = $result->count();
         $sql .= "LIMIT {$limitStart}, {$limitEnd}";
         $result = $this->zQuery($sql, array($keyword, $keyword, $keyword));
     }
     $arr = array();
     if ($result) {
         foreach ($result as $row) {
             $arr[] = $row;
         }
         $arr['rowCount'] = $rowCount;
     }
     return $arr;
 }
コード例 #5
0
 public function import($xml, $document_id)
 {
     $components = $xml['component']['structuredBody']['component'];
     $components_oids = array('2.16.840.1.113883.10.20.22.4.7' => 'allergy', '2.16.840.1.113883.10.20.22.2.6.1' => 'allergy', '2.16.840.1.113883.10.20.22.2.1' => 'medication', '2.16.840.1.113883.10.20.22.2.1.1' => 'medication', '2.16.840.1.113883.10.20.22.2.5.1' => 'medical_problem', '2.16.840.1.113883.10.20.22.2.5' => 'medical_problem', '2.16.840.1.113883.10.20.22.2.2' => 'immunization', '2.16.840.1.113883.10.20.22.2.2.1' => 'immunization', '2.16.840.1.113883.3.88.11.83.145' => 'procedure', '2.16.840.1.113883.10.20.22.2.7.1' => 'procedure', '2.16.840.1.113883.10.20.22.2.3.1' => 'lab_result', '2.16.840.1.113883.10.20.22.2.3' => 'lab_result', '2.16.840.1.113883.10.20.22.2.4.1' => 'vital_sign', '2.16.840.1.113883.10.20.22.2.17' => 'social_history', '2.16.840.1.113883.3.88.11.83.127' => 'encounter', '2.16.840.1.113883.10.20.22.2.22.1' => 'encounter', '2.16.840.1.113883.10.20.22.2.10' => 'care_plan', '2.16.840.1.113883.10.20.22.2.14' => 'functional_cognitive_status', '1.3.6.1.4.1.19376.1.5.3.1.3.1' => 'referral', '2.16.840.1.113883.10.20.22.2.11.1' => 'discharge_medications', '2.16.840.1.113883.10.20.22.2.41' => 'discharge_summary');
     for ($i = 0; $i <= count($components); $i++) {
         if (count($components[$i]['section']['templateId']) > 1) {
             foreach ($components[$i]['section']['templateId'] as $key_1 => $value_1) {
                 if ($components_oids[$components[$i]['section']['templateId'][$key_1]['root']] != '') {
                     $func_name = $components_oids[$components[$i]['section']['templateId'][$key_1]['root']];
                     $this->{$func_name}($components[$i]);
                     break;
                 }
             }
         } else {
             if ($components_oids[$components[$i]['section']['templateId']['root']] != '') {
                 $func_name = $components_oids[$components[$i]['section']['templateId']['root']];
                 $this->{$func_name}($components[$i]);
             }
         }
     }
     $audit_master_approval_status = $this->ccda_data_array['approval_status'] = 1;
     $this->ccda_data_array['ip_address'] = $_SERVER['REMOTE_ADDR'];
     $this->ccda_data_array['type'] = '12';
     //Patient Details
     $this->ccda_data_array['field_name_value_array']['patient_data'][1]['fname'] = is_array($xml['recordTarget']['patientRole']['patient']['name']['given']) ? $xml['recordTarget']['patientRole']['patient']['name']['given'][0] : $xml['recordTarget']['patientRole']['patient']['name']['given'];
     $this->ccda_data_array['field_name_value_array']['patient_data'][1]['lname'] = $xml['recordTarget']['patientRole']['patient']['name']['family'];
     $this->ccda_data_array['field_name_value_array']['patient_data'][1]['DOB'] = $xml['recordTarget']['patientRole']['patient']['birthTime']['value'];
     $this->ccda_data_array['field_name_value_array']['patient_data'][1]['sex'] = $xml['recordTarget']['patientRole']['patient']['administrativeGenderCode']['displayName'];
     $this->ccda_data_array['field_name_value_array']['patient_data'][1]['pubpid'] = $xml['recordTarget']['patientRole']['id'][0]['extension'];
     $this->ccda_data_array['field_name_value_array']['patient_data'][1]['ss'] = $xml['recordTarget']['patientRole']['id'][1]['extension'];
     $this->ccda_data_array['field_name_value_array']['patient_data'][1]['street'] = $xml['recordTarget']['patientRole']['addr']['streetAddressLine'];
     $this->ccda_data_array['field_name_value_array']['patient_data'][1]['city'] = $xml['recordTarget']['patientRole']['addr']['city'];
     $this->ccda_data_array['field_name_value_array']['patient_data'][1]['state'] = $xml['recordTarget']['patientRole']['addr']['state'];
     $this->ccda_data_array['field_name_value_array']['patient_data'][1]['postal_code'] = $xml['recordTarget']['patientRole']['addr']['postalCode'];
     $this->ccda_data_array['field_name_value_array']['patient_data'][1]['country_code'] = $xml['recordTarget']['patientRole']['addr']['country'];
     $this->ccda_data_array['field_name_value_array']['patient_data'][1]['phone_home'] = preg_replace('/[^0-9]+/i', '', $xml['recordTarget']['patientRole']['telecom']['value']);
     $this->ccda_data_array['field_name_value_array']['patient_data'][1]['status'] = $xml['recordTarget']['patientRole']['patient']['maritalStatusCode']['displayName'];
     $this->ccda_data_array['field_name_value_array']['patient_data'][1]['religion'] = $xml['recordTarget']['patientRole']['patient']['religiousAffiliationCode']['displayName'];
     $this->ccda_data_array['field_name_value_array']['patient_data'][1]['race'] = $xml['recordTarget']['patientRole']['patient']['raceCode']['displayName'];
     $this->ccda_data_array['field_name_value_array']['patient_data'][1]['ethnicity'] = $xml['recordTarget']['patientRole']['patient']['ethnicGroupCode']['displayName'];
     //Author details
     $this->ccda_data_array['field_name_value_array']['author'][1]['extension'] = $xml['author']['assignedAuthor']['id']['extension'];
     $this->ccda_data_array['field_name_value_array']['author'][1]['address'] = $xml['author']['assignedAuthor']['addr']['streetAddressLine'];
     $this->ccda_data_array['field_name_value_array']['author'][1]['city'] = $xml['author']['assignedAuthor']['addr']['city'];
     $this->ccda_data_array['field_name_value_array']['author'][1]['state'] = $xml['author']['assignedAuthor']['addr']['state'];
     $this->ccda_data_array['field_name_value_array']['author'][1]['zip'] = $xml['author']['assignedAuthor']['addr']['postalCode'];
     $this->ccda_data_array['field_name_value_array']['author'][1]['country'] = $xml['author']['assignedAuthor']['addr']['country'];
     $this->ccda_data_array['field_name_value_array']['author'][1]['phone'] = $xml['author']['assignedAuthor']['telecom']['value'];
     $this->ccda_data_array['field_name_value_array']['author'][1]['name'] = $xml['author']['assignedAuthor']['assignedPerson']['name']['given'];
     //Data Enterer
     $this->ccda_data_array['field_name_value_array']['dataEnterer'][1]['extension'] = $xml['dataEnterer']['assignedEntity']['id']['extension'];
     $this->ccda_data_array['field_name_value_array']['dataEnterer'][1]['address'] = $xml['dataEnterer']['assignedEntity']['addr']['streetAddressLine'];
     $this->ccda_data_array['field_name_value_array']['dataEnterer'][1]['city'] = $xml['dataEnterer']['assignedEntity']['addr']['city'];
     $this->ccda_data_array['field_name_value_array']['dataEnterer'][1]['state'] = $xml['dataEnterer']['assignedEntity']['addr']['state'];
     $this->ccda_data_array['field_name_value_array']['dataEnterer'][1]['zip'] = $xml['dataEnterer']['assignedEntity']['addr']['postalCode'];
     $this->ccda_data_array['field_name_value_array']['dataEnterer'][1]['country'] = $xml['dataEnterer']['assignedEntity']['addr']['country'];
     $this->ccda_data_array['field_name_value_array']['dataEnterer'][1]['phone'] = $xml['dataEnterer']['assignedEntity']['telecom']['value'];
     $this->ccda_data_array['field_name_value_array']['dataEnterer'][1]['name'] = $xml['dataEnterer']['assignedEntity']['assignedPerson']['name']['given'];
     //Informant
     $this->ccda_data_array['field_name_value_array']['informant'][1]['extension'] = $xml['informant'][0]['assignedEntity']['id']['extension'];
     $this->ccda_data_array['field_name_value_array']['informant'][1]['street'] = $xml['informant'][0]['assignedEntity']['addr']['streetAddressLine'];
     $this->ccda_data_array['field_name_value_array']['informant'][1]['city'] = $xml['informant'][0]['assignedEntity']['addr']['city'];
     $this->ccda_data_array['field_name_value_array']['informant'][1]['state'] = $xml['informant'][0]['assignedEntity']['addr']['state'];
     $this->ccda_data_array['field_name_value_array']['informant'][1]['postalCode'] = $xml['informant'][0]['assignedEntity']['addr']['postalCode'];
     $this->ccda_data_array['field_name_value_array']['informant'][1]['country'] = $xml['informant'][0]['assignedEntity']['addr']['country'];
     $this->ccda_data_array['field_name_value_array']['informant'][1]['phone'] = $xml['informant'][0]['assignedEntity']['telecom']['value'];
     $this->ccda_data_array['field_name_value_array']['informant'][1]['name'] = $xml['informant'][0]['assignedEntity']['assignedPerson']['name']['given'];
     //Personal Informant
     $this->ccda_data_array['field_name_value_array']['custodian'][1]['extension'] = $xml['custodian']['assignedCustodian']['representedCustodianOrganization']['id']['extension'];
     $this->ccda_data_array['field_name_value_array']['custodian'][1]['organisation'] = $xml['custodian']['assignedCustodian']['representedCustodianOrganization']['name'];
     //documentationOf
     $doc_of_str = '';
     if (!is_array($xml['documentationOf']['serviceEvent']['performer'][0]['assignedEntity']['assignedPerson']['name']['prefix'])) {
         $doc_of_str .= $xml['documentationOf']['serviceEvent']['performer'][0]['assignedEntity']['assignedPerson']['name']['prefix'] . " ";
     }
     if (!is_array($xml['documentationOf']['serviceEvent']['performer'][0]['assignedEntity']['assignedPerson']['name']['given'])) {
         $doc_of_str .= $xml['documentationOf']['serviceEvent']['performer'][0]['assignedEntity']['assignedPerson']['name']['given'] . " ";
     }
     if (!is_array($xml['documentationOf']['serviceEvent']['performer'][0]['assignedEntity']['assignedPerson']['name']['family'])) {
         $doc_of_str .= $xml['documentationOf']['serviceEvent']['performer'][0]['assignedEntity']['assignedPerson']['name']['family'] . " ";
     }
     if (!is_array($xml['documentationOf']['serviceEvent']['performer'][0]['assignedEntity']['representedOrganization']['name'])) {
         $doc_of_str .= $xml['documentationOf']['serviceEvent']['performer'][0]['assignedEntity']['representedOrganization']['name'] . " ";
     }
     $this->ccda_data_array['field_name_value_array']['documentationOf'][1]['assignedPerson'] = $doc_of_str;
     $documentationOf = $this->ccda_data_array['field_name_value_array']['documentationOf'][1]['assignedPerson'];
     $audit_master_id = \Application\Plugin\CommonPlugin::insert_ccr_into_audit_data($this->ccda_data_array);
     $this->update_document_table($document_id, $audit_master_id, $audit_master_approval_status, $documentationOf);
 }
コード例 #6
0
 /**
  * function immunized patient details
  * @param type $form_data
  * @return type
  */
 public function immunizedPatientDetails($form_data, $getCount = null)
 {
     $query_data = array();
     $query_codes = $form_data['query_codes'];
     $from_date = $form_data['form_from_date'];
     $to_date = $form_data['form_to_date'];
     $form_get_hl7 = $form_data['form_get_hl7'];
     $fdate = '';
     $todate = '';
     $query = "SELECT " . "i.patient_id AS patientid, " . "p.language, " . "i.cvx_code , ";
     if ($form_get_hl7 === 'true') {
         $query .= "DATE_FORMAT(p.DOB,'%Y%m%d') AS DOB, " . "concat(p.street, '^^', p.city, '^', p.state, '^', p.postal_code) AS address, " . "p.country_code, " . "p.phone_home, " . "p.phone_biz, " . "p.status, " . "p.sex, " . "p.ethnoracial, " . "p.race, " . "p.ethnicity, " . "c.code_text, " . "c.code, " . "c.code_type, " . "DATE_FORMAT(i.vis_date,'%Y%m%d') AS immunizationdate, " . "DATE_FORMAT(i.administered_date,'%Y%m%d') AS administered_date, " . "i.lot_number AS lot_number, " . "i.manufacturer AS manufacturer, " . "concat(p.fname, '^', p.lname) AS patientname, " . "f.facility_code," . "i.administered_by_id,i.note,";
     } else {
         $query .= "concat(p.fname, ' ',p.mname,' ', p.lname) AS patientname, " . "i.vis_date AS immunizationdate, ";
     }
     $query .= "i.id AS immunizationid, c.code_text_short AS immunizationtitle " . "FROM (immunizations AS i, patient_data AS p, codes AS c) " . "LEFT JOIN code_types ct ON c.code_type = ct.ct_id " . "LEFT JOIN users AS u ON i.administered_by_id = u.id " . "LEFT JOIN facility AS f ON f.id = u.facility_id " . "WHERE " . "ct.ct_key='CVX' and ";
     if ($from_date != 0) {
         $query .= "i.vis_date >= ? ";
         $query_data[] = $from_date;
     }
     if ($from_date != 0 and $to_date != 0) {
         $query .= " and ";
     }
     if ($to_date != 0) {
         $query .= "i.vis_date <= ? ";
         $query_data[] = $to_date;
     }
     if ($from_date != 0 or $to_date != 0) {
         $query .= " and ";
     }
     $query .= "i.patient_id=p.pid and " . add_escape_custom($query_codes) . "i.cvx_code = c.code ";
     if ($getCount) {
         $result = $this->applicationTable->zQuery($query, $query_data);
         $resCount = $result->count();
         return $resCount;
     }
     $query .= " LIMIT " . \Application\Plugin\CommonPlugin::escapeLimit($form_data['limit_start']) . "," . \Application\Plugin\CommonPlugin::escapeLimit($form_data['results']);
     $result = $this->applicationTable->zQuery($query, $query_data);
     return $result;
 }
コード例 #7
0
 public function getEachCCDAComponentDetailsAction()
 {
     $request = $this->getRequest();
     $id = $request->getQuery('id');
     $component = $request->getQuery('component');
     $amid = $request->getQuery('amid');
     $temp = '';
     switch ($component) {
         case 'allergies':
             $allergies_audit = $this->getCarecoordinationTable()->createAuditArray($amid, 'lists2');
             if (count($allergies_audit) > 0) {
                 $temp .= '<div><table class="narr_table" border="1" width="100%!important;">
                                      <thead><tr class="narr_tr">
                                             <th class="narr_th">' . \Application\Listener\Listener::z_xlt('Substance') . '</th>
                                             <th class="narr_th">' . \Application\Listener\Listener::z_xlt('Reaction') . '</th>
                                             <th class="narr_th">' . \Application\Listener\Listener::z_xlt('Severity') . '</th>
                                             <th class="narr_th">' . \Application\Listener\Listener::z_xlt('Status') . '</th>
                                         </tr></thead>
                                      <tbody>';
                 foreach ($allergies_audit['lists2'] as $key => $val) {
                     $severity_option_id = $this->getCarecoordinationTable()->getOptionId('severity_ccda', '', 'SNOMED-CT:' . $val['severity_al']);
                     $severity_text = $this->getCarecoordinationTable()->getListTitle($severity_option_id, 'severity_ccda', 'SNOMED-CT:' . $val['severity_al']);
                     if ($val['enddate'] != 0 && $val['enddate'] != '') {
                         $status = 'completed';
                     } else {
                         $status = 'active';
                     }
                     $temp .= '<tr class="narr_tr">
                                                 <td>' . \Application\Plugin\CommonPlugin::escape($val['list_code_text']) . '</td>
                                                 <td>' . \Application\Listener\Listener::z_xlt($val['reaction_text']) . '</td>
                                                 <td>' . \Application\Listener\Listener::z_xlt($severity_text) . '</td>
                                                 <td>' . \Application\Listener\Listener::z_xlt($status) . '</td>
                                                </tr>';
                 }
                 $temp .= '</tbody></table></div>';
             } else {
                 $temp .= \Application\Listener\Listener::z_xlt('No Known Allergies');
             }
             break;
         case 'medications':
             $medications_audit = $this->getCarecoordinationTable()->createAuditArray($amid, 'lists3');
             if (count($medications_audit) > 0) {
                 $temp .= '<div><table class="narr_table" border="1" width="100%">
                                         <thead><tr class="narr_tr">
                                                 <th class="narr_th">' . \Application\Listener\Listener::z_xlt('Medication') . '</th>
                                                 <th class="narr_th">' . \Application\Listener\Listener::z_xlt('Directions') . '</th>
                                                 <th class="narr_th">' . \Application\Listener\Listener::z_xlt('Start Date') . '</th>
                                                 <th class="narr_th">' . \Application\Listener\Listener::z_xlt('Status') . '</th>
                                                 <th class="narr_th">' . \Application\Listener\Listener::z_xlt('Indications') . '</th>
                                                 <th class="narr_th">' . \Application\Listener\Listener::z_xlt('Fill Instructions') . '</th>
                                             </tr></thead>
                                         <tbody>';
                 foreach ($medications_audit['lists3'] as $key => $val) {
                     if ($val['enddate'] && $val['enddate'] != 0) {
                         $active = 'completed';
                     } else {
                         $active = 'active';
                     }
                     $temp .= '<tr class="narr_tr">
                                                     <td>' . \Application\Plugin\CommonPlugin::escape($val['drug_text']) . '</td>
                                                     <td>' . \Application\Plugin\CommonPlugin::escape($val['rate'] . " " . $val['rate_unit'] . " " . $val['route_display'] . " " . $val['dose'] . " " . $val['dose_unit']) . '</td>
                                                     <td>' . \Application\Model\ApplicationTable::fixDate(substr($val['begdate'], 0, 4) . "-" . substr($val['begdate'], 4, 2) . "-" . substr($val['begdate'], 6, 2), $this->date_format, 'yyyy-mm-dd') . '</td>
                                                     <td>' . \Application\Listener\Listener::z_xlt($active) . '</td>
                                                     <td>' . \Application\Plugin\CommonPlugin::escape($val['indication']) . '</td>
                                                     <td>' . \Application\Plugin\CommonPlugin::escape($val['note']) . '</td>
                                                 </tr>';
                 }
                 $temp .= '</tbody></table></div>';
             } else {
                 $temp .= \Application\Listener\Listener::z_xlt('No Known Medications');
             }
             break;
         case 'problems':
             $problems_audit = $this->getCarecoordinationTable()->createAuditArray($amid, 'lists1');
             if (count($problems_audit) > 0) {
                 $temp .= '<div><ul>';
                 $i = 1;
                 foreach ($problems_audit['lists1'] as $key => $val) {
                     if ($val['enddate'] != 0 && $val['enddate'] != '') {
                         $status = 'Resolved';
                     } else {
                         $status = 'Active';
                     }
                     $temp .= '<li>' . $i . '. ' . \Application\Plugin\CommonPlugin::escape($val['list_code_text']) . ',' . substr($val['begdate'], 0, 4) . "-" . substr($val['begdate'], 4, 2) . "-" . substr($val['begdate'], 6, 2) . ', ' . \Application\Listener\Listener::z_xlt('Status') . ' :' . \Application\Listener\Listener::z_xlt($status) . '</li>';
                     $i++;
                 }
                 $temp .= '</ul></div>';
             } else {
                 $temp .= \Application\Listener\Listener::z_xlt('No Known Problems');
             }
             break;
         case 'immunizations':
             $immunizations_audit = $this->getCarecoordinationTable()->createAuditArray($amid, 'immunization');
             if (count($immunizations_audit) > 0) {
                 $temp .= '<div><table class="narr_table" border="1" width="100%">
                                         <thead><tr class="narr_tr">
                                                 <th class="narr_th">' . \Application\Listener\Listener::z_xlt('Vaccine') . '</th>
                                                 <th class="narr_th">' . \Application\Listener\Listener::z_xlt('Date') . '</th>
                                                 <th class="narr_th">' . \Application\Listener\Listener::z_xlt('Status') . '</th>
                                             </tr></thead>
                                         <tbody>';
                 foreach ($immunizations_audit['immunization'] as $key => $val) {
                     $temp .= '<tr class="narr_tr">
                                             <td>' . \Application\Plugin\CommonPlugin::escape($val['cvx_code_text']) . '</td>
                                             <td>' . $this->getCarecoordinationTable()->getMonthString(substr($val['administered_date'], 4, 2)) . ' ' . substr($val['administered_date'], 0, 4) . '</td>
                                             <td>' . \Application\Listener\Listener::z_xlt('Completed') . '</td>
                                         </tr>';
                 }
                 $temp .= '</tbody></table></div>';
             } else {
                 $temp .= \Application\Listener\Listener::z_xlt('No Known Immunizations');
             }
             break;
         case 'procedures':
             $procedure_audit = $this->getCarecoordinationTable()->createAuditArray($amid, 'procedure');
             if (count($procedure_audit) > 0) {
                 $temp .= '<div><table class="narr_table" border="1" width="100%">
                                         <thead><tr class="narr_tr">
                                                 <th class="narr_th">' . \Application\Listener\Listener::z_xlt('Procedure') . '</th>
                                                 <th class="narr_th">' . \Application\Listener\Listener::z_xlt('Date') . '</th>
                                             </tr></thead>
                                         <tbody>';
                 foreach ($procedure_audit['procedure'] as $key => $val) {
                     $temp .= '<tr class="narr_tr">
                                             <td>' . \Application\Plugin\CommonPlugin::escape($val['code_text']) . '</td>
                                             <td>' . \Application\Model\ApplicationTable::fixDate(substr($val['date'], 0, 4) . "-" . substr($val['date'], 4, 2) . "-" . substr($val['date'], 6, 2), $this->date_format, 'yyyy-mm-dd') . '</td>
                                         </tr>';
                 }
                 $temp .= '</tbody></table></div>';
             } else {
                 $temp .= \Application\Listener\Listener::z_xlt('No Known Procedures');
             }
             break;
         case 'results':
             $lab_results_audit = $this->getCarecoordinationTable()->createAuditArray($amid, 'procedure_result');
             if (count($lab_results_audit) > 0) {
                 $temp .= '<div>
                                         <table class="narr_table" border="1">
                                             <thead><tr class="narr_tr">
                                                     <th class="narr_th">' . \Application\Listener\Listener::z_xlt('Laboratory Information') . '</th>
                                                     <th class="narr_th">' . \Application\Listener\Listener::z_xlt('Result') . '</th>
                                                     <th class="narr_th">' . \Application\Listener\Listener::z_xlt('Date') . '</th>
                                                 </tr></thead>
                                             <tbody>';
                 foreach ($lab_results_audit['procedure_result'] as $key => $val) {
                     if ($val['results_text']) {
                         $temp .= '<tr class="narr_tr">
                                             <td>' . \Application\Plugin\CommonPlugin::escape($val['results_text']) . ($val['results_range'] != "-" ? "(" . \Application\Plugin\CommonPlugin::escape($val['results_range']) . ")" : "") . '</td>
                                             <td>' . \Application\Plugin\CommonPlugin::escape($val['results_value']) . " " . \Application\Plugin\CommonPlugin::escape($val['results_unit']) . '</td>
                                             <td>' . \Application\Model\ApplicationTable::fixDate(substr($val['date'], 0, 4) . "-" . substr($val['date'], 4, 2) . "-" . substr($val['date'], 6, 2), $this->date_format, 'yyyy-mm-dd') . '</td>
                                          </tr>';
                     }
                 }
                 $temp .= '</tbody></table></div>';
             } else {
                 $temp .= \Application\Listener\Listener::z_xlt('No Known Lab Results');
             }
             break;
         case 'plan_of_care':
             $care_plan_audit = $this->getCarecoordinationTable()->createAuditArray($amid, 'care_plan');
             if (count($care_plan_audit) > 0) {
                 $temp .= '<div><table class="narr_table" border="1" width="100%">
                                         <head><tr class="narr_tr">
                                         <th class="narr_th">' . \Application\Listener\Listener::z_xlt('Planned Activity') . '</th>
                                         <th class="narr_th">' . \Application\Listener\Listener::z_xlt('Planned Date') . '</th>
                                         </tr></thead>
                                         <tbody>';
                 foreach ($care_plan_audit['care_plan'] as $key => $val) {
                     $temp .= '<tr class="narr_tr">
                                         <td>' . \Application\Plugin\CommonPlugin::escape($val['code_text']) . '</td>
                                         <td>' . \Application\Model\ApplicationTable::fixDate(substr($val['date'], 0, 4) . "-" . substr($val['date'], 4, 2) . "-" . substr($val['date'], 6, 2), $this->date_format, 'yyyy-mm-dd') . '</td>
                                         </tr>';
                 }
                 $temp .= '</tbody></table></div>';
             } else {
                 $temp .= \Application\Listener\Listener::z_xlt('No Known Plan of Care');
             }
             break;
         case 'vitals':
             $vitals_audit = $this->getCarecoordinationTable()->createAuditArray($amid, 'vital_sign');
             if (count($vitals_audit) > 0) {
                 $temp .= '<div><table class="narr_table" border="1" width="100%">
                                      <thead><tr class="narr_tr">
                                      <th class="narr_th" align="right">' . \Application\Listener\Listener::z_xlt('Date / Time') . ': </th>';
                 foreach ($vitals_audit['vital_sign'] as $key => $val) {
                     $temp .= '<th class="narr_th">' . \Application\Model\ApplicationTable::fixDate(substr($val['date'], 0, 4) . "-" . substr($val['date'], 4, 2) . "-" . substr($val['date'], 6, 2), $this->date_format, 'yyyy-mm-dd') . '</th>';
                 }
                 $temp .= '</tr></thead><tbody>
                                      <tr class="narr_tr">
                                         <th class="narr_th" align="left">' . \Application\Listener\Listener::z_xlt('Temperature') . '</th>';
                 foreach ($vitals_audit['vital_sign'] as $key => $val) {
                     $temp .= '<td>' . \Application\Plugin\CommonPlugin::escape($val['temperature']) . '</td>';
                 }
                 $temp .= '</tr>
                                      <tr class="narr_tr">
                                         <th class="narr_th" align="left">' . \Application\Listener\Listener::z_xlt('Diastolic') . '</th>';
                 foreach ($vitals_audit['vital_sign'] as $key => $val) {
                     $temp .= '<td>' . \Application\Plugin\CommonPlugin::escape($val['bpd']) . '</td>';
                 }
                 $temp .= '</tr>
                                      <tr class="narr_tr">
                                         <th class="narr_th" align="left">' . \Application\Listener\Listener::z_xlt('Systolic') . '</th>';
                 foreach ($vitals_audit['vital_sign'] as $key => $val) {
                     $temp .= '<td>' . \Application\Plugin\CommonPlugin::escape($val['bps']) . '</td>';
                 }
                 $temp .= '</tr>
                                      <tr class="narr_tr">
                                         <th class="narr_th" align="left">' . \Application\Listener\Listener::z_xlt('Head Circumference') . '</th>';
                 foreach ($vitals_audit['vital_sign'] as $key => $val) {
                     $temp .= '<td>' . \Application\Plugin\CommonPlugin::escape($val['head_circ']) . '</td>';
                 }
                 $temp .= '</tr>
                                      <tr class="narr_tr">
                                         <th class="narr_th" align="left">' . \Application\Listener\Listener::z_xlt('Pulse') . '</th>';
                 foreach ($vitals_audit['vital_sign'] as $key => $val) {
                     $temp .= '<td>' . \Application\Plugin\CommonPlugin::escape($val['pulse']) . '</td>';
                 }
                 $temp .= '</tr>
                                      <tr class="narr_tr">
                                         <th class="narr_th" align="left">' . \Application\Listener\Listener::z_xlt('Height') . '</th>';
                 foreach ($vitals_audit['vital_sign'] as $key => $val) {
                     $temp .= '<td>' . \Application\Plugin\CommonPlugin::escape($val['height']) . '</td>';
                 }
                 $temp .= '</tr>
                                      <tr class="narr_tr">
                                         <th class="narr_th" align="left">' . \Application\Listener\Listener::z_xlt('Oxygen Saturation') . '</th>';
                 foreach ($vitals_audit['vital_sign'] as $key => $val) {
                     $temp .= '<td>' . \Application\Plugin\CommonPlugin::escape($val['oxygen_saturation']) . '</td>';
                 }
                 $temp .= '</tr>
                                      <tr class="narr_tr">
                                         <th class="narr_th" align="left">' . \Application\Listener\Listener::z_xlt('Breath') . '</th>';
                 foreach ($vitals_audit['vital_sign'] as $key => $val) {
                     $temp .= '<td>' . \Application\Plugin\CommonPlugin::escape($val['breath']) . '</td>';
                 }
                 $temp .= '</tr>
                                      <tr class="narr_tr">
                                         <th class="narr_th" align="left">' . \Application\Listener\Listener::z_xlt('Weight') . '</th>';
                 foreach ($vitals_audit['vital_sign'] as $key => $val) {
                     $temp .= '<td>' . \Application\Plugin\CommonPlugin::escape($val['weight']) . '</td>';
                 }
                 $temp .= '</tr>
                                      <tr class="narr_tr">
                                         <th class="narr_th" align="left">' . \Application\Listener\Listener::z_xlt('BMI') . '</th>';
                 foreach ($vitals_audit['vital_sign'] as $key => $val) {
                     $temp .= '<td>' . \Application\Plugin\CommonPlugin::escape($val['BMI']) . '</td>';
                 }
                 $temp .= '</tr></tbody></table></div>';
             } else {
                 $temp .= \Application\Listener\Listener::z_xlt('No Known Vitals');
             }
             break;
         case 'social_history':
             $social_history_audit = $this->getCarecoordinationTable()->createAuditArray($amid, 'social_history');
             if (count($social_history_audit) > 0) {
                 $temp .= '<div><table class="narr_table" border="1" width="100%">
                                         <thead><tr class="narr_tr">
                                                 <th class="narr_th">' . \Application\Listener\Listener::z_xlt('Social History Element') . '</th>
                                                 <th class="narr_th">' . \Application\Listener\Listener::z_xlt('Description') . '</th>
                                                 <th class="narr_th">' . \Application\Listener\Listener::z_xlt('Effective Dates') . '</th>
                                             </tr></thead>
                                         <tbody>';
                 foreach ($social_history_audit['social_history'] as $key => $val) {
                     $array_his_tobacco = explode("|", $val['smoking']);
                     if ($array_his_tobacco[2] != 0 && $array_his_tobacco[2] != '') {
                         $his_tob_date = substr($array_his_tobacco[2], 0, 4) . "-" . substr($array_his_tobacco[2], 4, 2) . "-" . substr($array_his_tobacco[2], 6, 2);
                     }
                     $temp .= '<tr class="narr_tr">
                                             <td>' . \Application\Listener\Listener::z_xlt('Smoking') . '</td>
                                             <td>' . \Application\Plugin\CommonPlugin::escape($array_his_tobacco[0]) . '</td>
                                             <td>' . \Application\Model\ApplicationTable::fixDate($his_tob_date, $this->date_format, 'yyyy-mm-dd') . '</td>
                                         </tr>';
                 }
                 $temp .= '</tbody></table></div>';
             } else {
                 $temp .= \Application\Listener\Listener::z_xlt('No Known Social History');
             }
             break;
         case 'encounters':
             $encounter_audit = $this->getCarecoordinationTable()->createAuditArray($amid, 'encounter');
             if (count($encounter_audit) > 0) {
                 $temp .= '<div><table class="narr_table" border="1" width="100%">
                                         <thead><tr class="narr_tr">
                                                 <th class="narr_th">' . \Application\Listener\Listener::z_xlt('Encounter') . '</th>
                                                 <th class="narr_th">' . \Application\Listener\Listener::z_xlt('Performer') . '</th>
                                                 <th class="narr_th">' . \Application\Listener\Listener::z_xlt('Location') . '</th>
                                                 <th class="narr_th">' . \Application\Listener\Listener::z_xlt('Date') . '</th>
                                                 <th class="narr_th">' . \Application\Listener\Listener::z_xlt('Encounter Diagnosis') . '</th>
                                                 <th class="narr_th">' . \Application\Listener\Listener::z_xlt('Status') . '</th>
                                                 <th class="narr_th">' . \Application\Listener\Listener::z_xlt('Reason for Visit') . '</th>
                                             </tr></thead>
                                         <tbody>';
                 foreach ($encounter_audit['encounter'] as $key => $val) {
                     if ($val['code_text'] != 'NULL') {
                         $encounter_activity = 'Active';
                     } else {
                         $encounter_activity = '';
                     }
                     $enc_date = substr($val['date'], 0, 4) . "-" . substr($val['date'], 4, 2) . "-" . substr($val['date'], 6, 2);
                     $temp .= '<tr class="narr_tr">                                    
                                             <td>' . \Application\Plugin\CommonPlugin::escape($val['pc_catname']) . '</td>
                                             <td>' . \Application\Plugin\CommonPlugin::escape($val['provider_name']) . '</td>
                                             <td>' . \Application\Plugin\CommonPlugin::escape($val['represented_organization_name']) . '</td>
                                             <td>' . \Application\Model\ApplicationTable::fixDate($enc_date, $this->date_format, 'yyyy-mm-dd') . '</td>
                                             <td>' . ($val['code_text'] != 'NULL' ? \Application\Plugin\CommonPlugin::escape($val['code_text']) : '') . '</td>
                                             <td>' . \Application\Listener\Listener::z_xlt($encounter_activity) . '</td>
                                             <td></td>
                                         </tr>';
                 }
                 $temp .= '</tbody></table></div>';
             } else {
                 $temp .= \Application\Listener\Listener::z_xlt('No Known Encounters');
             }
             break;
         case 'functional_status':
             $functional_cognitive_status_audit = $this->getCarecoordinationTable()->createAuditArray($amid, 'functional_cognitive_status');
             if (count($functional_cognitive_status_audit) > 0) {
                 $temp .= '<div><table class="narr_table" border="1" width="100%">
                                         <thead><tr class="narr_tr">
                                                 <th class="narr_th">' . \Application\Listener\Listener::z_xlt('Functional Condition') . '</th>
                                                 <th class="narr_th">' . \Application\Listener\Listener::z_xlt('Effective Dates') . '</th>
                                                 <th class="narr_th">' . \Application\Listener\Listener::z_xlt('Condition Status') . '</th>
                                             </tr></thead>
                                         <tbody>';
                 foreach ($functional_cognitive_status_audit['functional_cognitive_status'] as $key => $val) {
                     $temp .= '<tr class="narr_tr">
                                             <td>' . \Application\Plugin\CommonPlugin::escape($val['description']) . '</td>
                                             <td>' . \Application\Model\ApplicationTable::fixDate(substr($val['date'], 0, 4) . "-" . substr($val['date'], 4, 2) . "-" . substr($val['date'], 6, 2), $this->date_format, 'yyyy-mm-dd') . '</td>
                                             <td>' . \Application\Listener\Listener::z_xlt('Active') . '</td>
                                         </tr>';
                 }
                 $temp .= '</tbody></table></div>';
             } else {
                 $temp .= \Application\Listener\Listener::z_xlt('No Known Social Functional Status');
             }
             break;
         case 'referral':
             $referral_audit = $this->getCarecoordinationTable()->createAuditArray($amid, 'referral');
             if (count($referral_audit) > 0) {
                 $temp .= '<div>';
                 foreach ($referral_audit['referral'] as $key => $val) {
                     $referal_data = explode("#\$%^&*", $val['body']);
                     foreach ($referal_data as $k => $v) {
                         $temp .= '<p>' . \Application\Plugin\CommonPlugin::escape($v) . '</p>';
                     }
                 }
                 $temp .= '</div>';
             } else {
                 $temp .= \Application\Listener\Listener::z_xlt('No Known Referrals');
             }
             break;
         case 'instructions':
             $temp .= \Application\Listener\Listener::z_xlt('No Known Clinical Instructions');
             break;
         case 'discharge_medication':
             $discharge_medication_audit = $this->getCarecoordinationTable()->createAuditArray($amid, 'discharge_medication');
             $temp .= '<div><table class="narr_table" border="1" width="100%">
                                         <thead><tr class="narr_tr">
                                                 <th class="narr_th">' . \Application\Listener\Listener::z_xlt('Medication') . '</th>
                                                 <th class="narr_th">' . \Application\Listener\Listener::z_xlt('Directions') . '</th>
                                                 <th class="narr_th">' . \Application\Listener\Listener::z_xlt('Start Date') . '</th>
                                                 <th class="narr_th">' . \Application\Listener\Listener::z_xlt('Status') . '</th>
                                                 <th class="narr_th">' . \Application\Listener\Listener::z_xlt('Indications') . '</th>
                                                 <th class="narr_th">' . \Application\Listener\Listener::z_xlt('Fill Instructions') . '</th>
                                             </tr></thead>
                                         <tbody>';
             foreach ($discharge_medication_audit['discharge_medication'] as $key => $val) {
                 if ($val['enddate'] && $val['enddate'] != 0) {
                     $active = 'completed';
                 } else {
                     $active = 'active';
                 }
                 $temp .= '<tr class="narr_tr">
                                                     <td>' . \Application\Plugin\CommonPlugin::escape($val['drug_text']) . '</td>
                                                     <td>' . \Application\Plugin\CommonPlugin::escape($val['rate'] . " " . $val['rate_unit'] . " " . $val['route_display'] . " " . $val['dose'] . " " . $val['dose_unit']) . '</td>
                                                     <td>' . \Application\Model\ApplicationTable::fixDate(substr($val['begdate'], 0, 4) . "-" . substr($val['begdate'], 4, 2) . "-" . substr($val['begdate'], 6, 2), $this->date_format, 'yyyy-mm-dd') . '</td>
                                                     <td>' . \Application\Listener\Listener::z_xlt($active) . '</td>
                                                     <td>' . \Application\Plugin\CommonPlugin::escape($val['indication']) . '</td>
                                                     <td>' . \Application\Plugin\CommonPlugin::escape($val['note']) . '</td>
                                                 </tr>';
             }
             $temp .= '</tbody></table></div>';
             break;
         case 'discharge_summary':
             $discharge_summary_audit = $this->getCarecoordinationTable()->createAuditArray($amid, 'discharge_summary');
             $temp .= '<div>';
             foreach ($discharge_summary_audit['discharge_summary'] as $key => $val) {
                 $text = str_replace("#\$%", "<br>", \Application\Plugin\CommonPlugin::escape($val['text']));
                 $temp .= $text;
             }
             $temp .= '</div>';
             break;
     }
     echo $temp;
     exit;
 }
コード例 #8
0
 /**
  * function immunized patient details
  * @param type $form_data
  * @return type
  */
 public function immunizedPatientDetails($form_data, $getCount = null)
 {
     $query_data = array();
     $query_codes = $form_data['query_codes'];
     $from_date = $form_data['form_from_date'];
     $to_date = $form_data['form_to_date'];
     $form_get_hl7 = $form_data['form_get_hl7'];
     $query_pids = $form_data['query_pids'];
     $fdate = '';
     $todate = '';
     $query = "SELECT " . "i.patient_id AS patientid, " . "p.language, " . "i.cvx_code , ";
     if ($form_get_hl7 === 'true') {
         $query .= "DATE_FORMAT(p.DOB,'%Y%m%d') AS DOB, " . "p.pubpid, " . "CONCAT(IF(p.street IS NULL,'',p.street), '^^', IF(p.city IS NULL,'',p.city), '^', IF(p.state IS NULL,'',p.state), '^', IF(p.postal_code IS NULL,'',p.postal_code) ,'^', IF(l.option_id IS NULL,'',l.notes)) AS address, " . "p.country_code, " . "p.phone_home, " . "p.phone_biz, " . "p.status, " . "p.sex, " . "p.ethnoracial, " . "p.race, " . "p.ethnicity, " . "p.guardiansname, " . "p.guardianrelationship, " . "p.guardiansex, " . "p.guardianphone, " . "p.guardianworkphone, " . "p.email, " . "p.publicity_code, " . "p.imm_reg_status, " . "p.protect_indicator, " . "DATE_FORMAT(p.prot_indi_effdate,'%Y%m%d') AS protection_effective_date, " . "DATE_FORMAT(p.publ_code_eff_date,'%Y%m%d') AS publicity_code_effective_date, " . "DATE_FORMAT(p.imm_reg_stat_effdate,'%Y%m%d') AS immunization_registry_status_effective_date, " . "CONCAT(IF(p.guardianaddress IS NULL,'',p.guardianaddress), '^', '','^',IF(p.guardiancity IS NULL,'',p.guardiancity), '^', IF(p.guardianstate IS NULL,'',p.guardianstate), '^', IF(p.guardianpostalcode IS NULL,'',p.guardianpostalcode) ,'^', IF(l.option_id IS NULL,'',l.notes),'^','L', '^', '', '^', '', '^', '') AS guardian_address, " . "p.ss, " . "c.code_text, " . "c.code, " . "c.code_type, " . "DATE_FORMAT(i.vis_date,'%Y%m%d') AS immunizationdate, " . "DATE_FORMAT(i.administered_date,'%Y%m%d') AS administered_date, " . "i.lot_number AS lot_number, " . "i.manufacturer AS manufacturer, " . "i.administration_site, " . "CONCAT(IF(p.lname IS NULL,'',p.lname), '^', p.fname , '^', IF(p.mname IS NULL,'',p.mname)) AS patientname, " . "f.id," . "f.name AS fac_name, " . "f.facility_code," . "i.administered_by_id," . "i.note," . "CONCAT (IF(u.npi IS NULL,'',u.npi),'^',u.lname,'^',u.fname,'^',IF(u.mname IS NULL,'',u.mname)) as primary_care_provider_details, " . "l.notes AS country_code, " . "l1.notes AS route_code, " . "i.route, " . "CONCAT(u.lname,'^',u.fname,'^',IF(u.mname IS NULL,'',u.mname),'^','','^',IF(u.title IS NULL,'',u.title),'^','','^','','^','TX','^','L','^','','^','','^','','^','','^','') AS providername, " . "CONCAT(f.id,'^',IF(f.street IS NULL,'',SUBSTRING(f.`street`,1,20)),'^',IF(f.`city` IS NULL,'',f.`city`),'^',IF(f.`state` IS NULL,'',f.`state`),'^',IF(f.`postal_code` IS NULL,'',f.`postal_code`),'^',IF(f.`country_code` IS NULL,'',f.`country_code`)) AS facility_address, " . "u.id AS users_id, " . "i.created_by, " . "i.ordering_provider, " . "CONCAT(u1.lname,'^',u1.fname,'^',IF(u1.mname IS NULL,'',u1.mname)) AS entered_by_name, " . "CONCAT(u2.lname,'^',u2.fname,'^',IF(u2.mname IS NULL,'',u2.mname)) AS ordering_provider_name, " . "i.administered_by_id,i.note,i.information_source,DATE_FORMAT(i.expiration_date,'%Y%m%d') AS expiration_date,i.refusal_reason,i.completion_status,";
     } else {
         $query .= "CONCAT(IF(p.fname IS NULL,'',p.fname),' ',IF(p.mname IS NULL,'',p.mname),' ',IF(p.lname IS NULL,'',p.lname)) AS  patientname, " . "i.vis_date AS immunizationdate, ";
     }
     $query .= "i.id AS immunizationid, c.code_text_short AS immunizationtitle, c.code_text,i.amount_administered AS administered_amount, i.amount_administered_unit AS administered_unit " . "FROM (immunizations AS i, patient_data AS p, codes AS c) " . "LEFT JOIN code_types ct ON c.code_type = ct.ct_id " . "LEFT JOIN users AS u ON i.administered_by_id = u.id " . "LEFT JOIN facility AS f ON f.id = u.facility_id " . "LEFT JOIN list_options l ON l.option_id = p.country_code AND l.list_id='country' " . "LEFT JOIN list_options l1 ON l1.option_id = i.route AND l1.list_id='drug_route' " . "LEFT JOIN list_options l2 ON l2.option_id = p.guardiancountry AND l2.list_id='country' " . "LEFT JOIN users AS u1 ON i.created_by = u1.id " . "LEFT JOIN users AS u2 ON i.ordering_provider = u2.id " . "WHERE " . "ct.ct_key='CVX' and ";
     if ($from_date != 0) {
         $query .= "i.vis_date >= ? ";
         $query_data[] = $from_date;
     }
     if ($from_date != 0 and $to_date != 0) {
         $query .= " and ";
     }
     if ($to_date != 0) {
         $query .= "i.vis_date <= ? ";
         $query_data[] = $to_date;
     }
     if ($from_date != 0 or $to_date != 0) {
         $query .= " and ";
     }
     $query .= "i.patient_id=p.pid and " . add_escape_custom($query_codes) . $query_pids . "i.cvx_code = c.code ORDER BY i.patient_id, i.id";
     if ($getCount) {
         $result = $this->applicationTable->zQuery($query, $query_data);
         $resCount = $result->count();
         return $resCount;
     }
     $query .= " LIMIT " . \Application\Plugin\CommonPlugin::escapeLimit($form_data['limit_start']) . "," . \Application\Plugin\CommonPlugin::escapeLimit($form_data['results']);
     $result = $this->applicationTable->zQuery($query, $query_data);
     return $result;
 }