public function getCCDAComponents($type) { $components = array(); $query = "select * from ccda_components where ccda_type = ?"; $appTable = new ApplicationTable(); $result = $appTable->zQuery($query, array($type)); foreach ($result as $row) { $components[$row['ccda_components_field']] = $row['ccda_components_name']; } return $components; }
/** * @param array $parameters * @return array */ public function getPatients(array $parameters) { //You can use this function to write whatever rules that you need from the DB //$sql="SELECT * FROM patient_data WHERE fname like ".$parameters['fname']." OR lname like ".$parameters['lname'] ." OR DOB like ".$parameters['DOB']; $obj = new ApplicationTable(); $sql = " SELECT * FROM patient_data WHERE fname like ? OR lname like ? OR DOB like ? OR pubpid = ?"; $params = array($parameters['fname'], $parameters['lname'], $parameters['DOB'], isset($parameters['pubpid']) ? $parameters['pubpid'] : ''); $rowset = $obj->zQuery($sql, $params); $results = array(); foreach ($rowset as $row) { $results[] = $row; } return $results; }
/** * function getHL7 * generating HL7 format */ public function reportAction() { $request = $this->getRequest(); $data = $request->getPost(); if (isset($data['hl7button'])) { $form_code = isset($data['codes']) ? $data['codes'] : array(); $from_date = $request->getPost('from_date', null) ? $this->CommonPlugin()->date_format($request->getPost('from_date', null), 'yyyy-mm-dd', $GLOBALS['date_display_format']) : date('Y-m-d', strtotime(date('Ymd')) - 86400 * 7); $to_date = $request->getPost('to_date', null) ? $this->CommonPlugin()->date_format($request->getPost('to_date', null), 'yyyy-mm-dd', $GLOBALS['date_display_format']) : date('Y-m-d'); $form_get_hl7 = 'true'; $patient_id = $request->getPost('patient_id', null); //pagination $results = $request->getPost('form_results', 100); $results = $results > 0 ? $results : 100; $current_page = $request->getPost('form_current_page', 1); $end = $current_page * $results; $start = $end - $results; $new_search = $request->getPost('form_new_search', null); //endpagination if (empty($form_code)) { $query_codes = ''; } else { $query_codes = 'c.id in ( '; foreach ($form_code as $code) { $query_codes .= $code . ","; } $query_codes = substr($query_codes, 0, -1); $query_codes .= ') and '; } if (empty($patient_id)) { $query_pids = ''; } else { $pid_arr = explode(',', $patient_id); $query_pids = '('; foreach ($pid_arr as $pid_val) { $query_pids .= "p.pid = ( '"; $query_pids .= \Application\Model\ApplicationTable::quoteValue($pid_val) . "' ) or "; $query_pids .= "p.fname like ( '%"; $query_pids .= \Application\Model\ApplicationTable::quoteValue($pid_val) . "%' ) or "; $query_pids .= "p.mname like ( '%"; $query_pids .= \Application\Model\ApplicationTable::quoteValue($pid_val) . "%' ) or "; $query_pids .= "p.lname like ( '%"; $query_pids .= \Application\Model\ApplicationTable::quoteValue($pid_val) . "%' ) or "; } $query_pids = trim($query_pids); $query_pids = rtrim($query_pids, 'or'); $query_pids .= ') and '; } $params = array('form_from_date' => $from_date, 'form_to_date' => $to_date, 'form_get_hl7' => $form_get_hl7, 'query_codes' => $query_codes, 'results' => $results, 'current_page' => $current_page, 'limit_start' => $start, 'limit_end' => $end, 'query_pids' => $query_pids); if ($new_search) { $count = $this->getImmunizationTable()->immunizedPatientDetails($params, 1); } else { $count = $request->getPost('form_count'); if ($count == '') { $count = $this->getImmunizationTable()->immunizedPatientDetails($params, 1); } } $totalpages = ceil($count / $results); $details = $this->getImmunizationTable()->immunizedPatientDetails($params); $rows = array(); foreach ($details as $row) { $rows[] = $row; } $D = "\r"; $nowdate = date('YmdHis'); $now = date('YmdGi'); $now1 = date('Y-m-d G:i'); $filename = "imm_reg_" . $now . ".hl7"; // GENERATE HL7 FILE if ($form_get_hl7 === 'true') { $content = ''; $patient_id = ''; foreach ($rows as $r) { $race_code = $administered_unit_title = $administered_route_title = ''; $race_title = $ethnicity = $ethnicity_code = $ethnicity_title = ''; $administered_site_code = $guardian_relationship_code = $manufacturer_code = ''; $immunization_info_source_code = $email = $race = $units = $manufacturer = ''; $information_source = $completion_status = $refusal_reason_code = ''; $immunization_refusal = $ordering_provider = $entered_by = $publicity_code_val = ''; $publicity_code = $imm_registry_status_code = $protection_indicator = ''; $guardiansname = ''; if ($r['patientid'] != $patient_id) { $content .= "MSH|^~\\&|OPENEMR|" . $r['facility_code'] . "||NIST Test Iz Reg|{$nowdate}||" . "VXU^V04^VXU_V04|OPENEMR-110316102457117|P|2.5.1|||AL|ER" . "{$D}"; $race_code = $this->getImmunizationTable()->getNotes($r['race'], 'race'); $race_title = $this->CommonPlugin()->getListtitle('race', $r['race']); $ethnicity_code = $this->getImmunizationTable()->getNotes($r['ethnicity'], 'ethnicity'); $ethnicity_title = $this->CommonPlugin()->getListtitle('ethnicity', $r['ethnicity']); $guardianarray = explode(' ', $r['guardiansname']); $guardianname = $guardianarray[1] . '^' . $guardianarray[0]; if ($r['sex'] === 'Male') { $r['sex'] = 'M'; } if ($r['sex'] === 'Female') { $r['sex'] = 'F'; } if ($r['status'] === 'married') { $r['status'] = 'M'; } if ($r['status'] === 'single') { $r['status'] = 'S'; } if ($r['status'] === 'divorced') { $r['status'] = 'D'; } if ($r['status'] === 'widowed') { $r['status'] = 'W'; } if ($r['status'] === 'separated') { $r['status'] = 'A'; } if ($r['status'] === 'domestic partner') { $r['status'] = 'P'; } if ($r['email']) { $email = '~^NET^Internet^' . $r['email']; } if ($r['race']) { $race = $race_code . '^' . $race_title . '^HL70005'; } if ($r['ethnicity']) { $ethnicity = $ethnicity_code . '^' . $ethnicity_title . '^CDCREC'; } $r['ss'] = $r['ss'] ? "~" . $r['ss'] . "^^^MAA^SS" : ""; $content .= "PID|" . "1|" . "|" . $r['pubpid'] . "^^^MPI&2.16.840.1.113883.19.3.2.1&ISO^MR" . $r['ss'] . "|" . "|" . $r['patientname'] . "^^^^L|" . $guardianname . "|" . $r['DOB'] . "|" . $r['sex'] . "|" . "|" . $race . "|" . $r['address'] . "^L" . "|" . "|" . "^PRN^PH^^^" . $this->format_phone($r['phone_home']) . "^^" . $email . "|" . "^WPN^PH^^^" . $this->format_phone($r['phone_biz']) . "^^|" . $r['language'] . "|" . $r['status'] . "|" . "|" . "|" . "|" . "|" . "|" . $ethnicity . "|" . "|" . "|" . "|" . "|" . "|" . "|" . "|" . "|" . "|" . "|" . "|" . "|" . "|" . "|" . "|" . "|" . "" . "{$D}"; if ($r['publicity_code']) { $publicity_code_val = $this->getImmunizationTable()->getNotes($r['publicity_code'], 'publicity_code'); $publicity_code = $publicity_code_val . "^" . $r['publicity_code'] . "^HL70215"; } $imm_registry_status_code = $this->getImmunizationTable()->getNotes($r['imm_reg_status'], 'immunization_registry_status'); $protection_indicator = $this->getImmunizationTable()->getNotes($r['protect_indicator'], 'yesno'); if ($publicity_code || $protection_indicator || $imm_registry_status_code) { $content .= "PD1|" . "|" . "|" . $r['fac_name'] . "|" . $r['primary_care_provider_details'] . "|" . "|" . "|" . "|" . "|" . "|" . "|" . $publicity_code . "|" . $protection_indicator . "|" . $r['protection_effective_date'] . "|" . "|" . "|" . $imm_registry_status_code . "|" . $r['immunization_registry_status_effective_date'] . "|" . $r['publicity_code_effective_date'] . "|" . "|" . "|" . "" . "{$D}"; } if ($r['guardiansex'] === 'male') { $r['guardiansex'] = 'M'; } if ($r['guardiansex'] === 'female') { $r['guardiansex'] = 'F'; } $guardian_relationship_code = $this->getImmunizationTable()->getNotes($r['guardianrelationship'], 'next_of_kin_relationship'); if ($r['guardiansname'] && $r['guardianrelationship']) { $content .= "NK1|" . "1|" . $guardianname . "^^^^^L|" . $guardian_relationship_code . "^" . $r['guardianrelationship'] . "^HL70063|" . $r['guardian_address'] . "|" . "^PRN^PH^^^" . $this->format_phone($r['guardianphone']) . "|" . "^WPN^PH^^^" . $this->format_phone($r['guardianworkphone']) . "|" . "|" . "|" . "|" . "|" . "|" . "|" . "|" . $r['guardiansex'] . "|" . "|" . "|" . "|" . "|" . "|" . "|" . "|" . "|" . "|" . "|" . "|" . "|" . "|" . "" . "{$D}"; } } if ($r['completion_status'] == 'Refused') { $r['immunizationid'] = '9999'; } if ($r['administered_by_id'] == 0 && $r['information_source'] == 'hist_inf_src_unspecified') { $ordering_provider = ""; } else { if ($r['ordering_provider']) { $ordering_provider = $r['ordering_provider'] . "^" . $r['ordering_provider_name'] . "^^^^^NIST-AA-1^L"; } } if ($r['created_by']) { $entered_by = $r['created_by'] . "^" . $r['entered_by_name'] . "^^^^^NIST-AA-1"; } $content .= "ORC" . "|" . "RE|" . "|" . $r['immunizationid'] . "^NDA|" . "|" . "|" . "|" . "|" . "|" . "|" . $entered_by . "|" . "|" . $ordering_provider . "|" . "|" . "|" . "|" . "|" . "|" . "|" . "|" . "|" . "|" . "|" . "|" . "|" . "|" . "|" . "|" . "|" . "|" . "|" . "" . "{$D}"; $administered_unit_title = $this->CommonPlugin()->getListtitle('drug_units', $r['administered_unit']); $manufacturer_code = $this->getImmunizationTable()->getNotes($r['manufacturer'], 'Immunization_Manufacturer'); $immunization_info_source_code = $this->getImmunizationTable()->getNotes($r['information_source'], 'immunization_informationsource'); if ($administered_unit_title) { $units = $administered_unit_title . '^' . $administered_unit_title . '^UCUM^^^'; } if ($r['manufacturer']) { $manufacturer = $manufacturer_code . "^" . $r['manufacturer'] . "^" . "MVX"; } if ($r['information_source']) { $information_source = $immunization_info_source_code . "^" . $r['information_source'] . "^NIP001"; } if ($r['providername'] != NULL && $r['information_source'] == 'new_immunization_record') { $r['providername'] = $r['users_id'] . "^" . $r['providername']; } $refusal_reason_code = $this->getImmunizationTable()->getNotes($r['refusal_reason'], 'immunization_refusal_reason'); $completion_status = $this->getImmunizationTable()->getNotes($r['completion_status'], 'Immunization_Completion_Status'); if ($r['refusal_reason']) { $completion_status = 'RE'; $immunization_refusal = $refusal_reason_code . "^" . $r['refusal_reason'] . "^NIP002"; } if ($r['code'] == '998') { $completion_status = 'NA'; } $content .= "RXA|" . "0|" . "1|" . $r['administered_date'] . "|" . "|" . $r['code'] . "^" . $r['immunizationtitle'] . "^" . "CVX" . "|" . $r['administered_amount'] . "|" . $units . "|" . "|" . $information_source . "|" . $r['providername'] . "|" . $r['facility_address'] . "|" . "|" . "|" . "|" . $r['lot_number'] . "|" . $r['expiration_date'] . "|" . $manufacturer . "|" . $immunization_refusal . "|" . "|" . $completion_status . "|" . "A" . "{$D}"; $administered_route_title = $this->CommonPlugin()->getListtitle('drug_route', $r['route']); $administered_site_code = $this->getImmunizationTable()->getNotes($r['administration_site'], 'immunization_administered_site'); if ($r['route_code'] || $r['administration_site']) { $content .= "RXR|" . $r['route_code'] . "^" . $administered_route_title . "^HL70162|" . $administered_site_code . "^" . $r['administration_site'] . "^HL70163" . "|" . "|" . "|" . "" . "{$D}"; } $imm_obs_res = $this->getImmunizationTable()->getImmunizationObservationResultsData($r['patientid'], $r['immunizationid']); if (count($imm_obs_res > 0)) { $last_key = 1; foreach ($imm_obs_res as $key_obs => $val_obs) { $criteria_code = $criteria_notes = $obs_value_notes = $obs_value = $obs_method = $date_obs = $value_type = $criteria_value = ''; $criteria_code = $this->getImmunizationTable()->getCodes($val_obs['imo_criteria'], 'immunization_observation'); $criteria_notes = $this->getImmunizationTable()->getNotes($val_obs['imo_criteria'], 'immunization_observation'); $obs_value_notes = $this->getImmunizationTable()->getNotes($val_obs['imo_criteria_value'], 'imm_vac_eligibility_results'); $criteria_value = $criteria_code . "^" . $val_obs['imo_criteria'] . "^" . $criteria_notes; $date_obs = preg_replace('/-/', '', substr($val_obs['imo_date_observation'], 0, 10)); if ($val_obs['imo_criteria'] == 'funding_program_eligibility') { $obs_value = $obs_value_notes . "^" . $val_obs['imo_criteria_value'] . "^HL70064"; $obs_method = "VXC40^per immunization^CDCPHINVS"; $value_type = "CE"; } else { if ($val_obs['imo_criteria'] == 'vaccine_type') { $obs_value = $val_obs['imo_code'] . "^" . $val_obs['imo_codetext'] . "^" . $val_obs['imo_codetype']; $value_type = "CE"; } else { if ($val_obs['imo_criteria'] == 'disease_with_presumed_immunity') { $value_type = "CE"; $obs_value = $val_obs['imo_code'] . "^" . $val_obs['imo_codetext'] . "^SCT"; } } } if ($key_obs > 1) { if ($last_key > 4) { $key_val = $last_key + 1; } else { $key_val = $key_val + 1; } } else { $key_val = $key_obs + 1; } $content .= "OBX|" . $key_val . "|" . $value_type . "|" . $criteria_value . "|" . $key_val . "|" . $obs_value . "|" . "|" . "|" . "|" . "|" . "|" . "F|" . "|" . "|" . $date_obs . "|" . "|" . "|" . $obs_method . "{$D}"; $last_key = $key_val; if ($val_obs['imo_vis_date_published'] != 0) { $value_type = "TS"; $criteria_value = "29768-9^Date vaccine information statement published^LN"; $obs_value = preg_replace('/-/', '', $val_obs['imo_vis_date_published']); if ($key_obs > 1) { if ($last_key == 4) { $key_val = $last_key + 1; } else { $key_val = $key_val + 1; } } else { $key_val = $last_key + 1; } $content .= "OBX|" . $key_val . "|" . $value_type . "|" . $criteria_value . "|" . $last_key . "|" . $obs_value . "|" . "|" . "|" . "|" . "|" . "|" . "F|" . "|" . "|" . $date_obs . "|" . "|" . "|" . "" . "{$D}"; } $last_key = $key_val; if ($val_obs['imo_vis_date_presented'] != 0) { $value_type = "TS"; $criteria_value = "29769-7^Date vaccine information statement presented^LN"; $obs_value = preg_replace('/-/', '', $val_obs['imo_vis_date_presented']); if ($key_obs > 1) { if ($last_key == 5) { $key_val = $last_key + 1; } else { $key_val = $key_val + 1; } } else { $key_val = $last_key + 1; } $content .= "OBX|" . $key_val . "|" . $value_type . "|" . $criteria_value . "|" . ($last_key - 1) . "|" . $obs_value . "|" . "|" . "|" . "|" . "|" . "|" . "F|" . "|" . "|" . $date_obs . "|" . "|" . "|" . "" . "{$D}"; } $last_key = $key_val; } } $patient_id = $r['patientid']; } header('Content-type: text/plain'); header('Content-Disposition: attachment; filename=' . $filename); // put the content in the file echo $content; exit; } } }
public function update_document_table($document_id, $audit_master_id, $audit_master_approval_status) { $appTable = new ApplicationTable(); $query = "UPDATE documents \n SET audit_master_id = ?,\n imported = ?,\n audit_master_approval_status=? \n WHERE id = ?"; $appTable->zQuery($query, array($audit_master_id, 1, $audit_master_approval_status, $document_id)); }
public function update_imported($document_id) { $appTable = new ApplicationTable(); $appTable->zQuery("UPDATE documents SET imported = 1 WHERE id = ?", array($document_id)); }
/** * fixDate - Date Conversion Between Different Formats * @param String $input_date Date to be converted * @param String $date_format Target Date Format */ public function fixDate($input_date, $output_format = null, $input_format = null) { if (!$input_date) { return; } $input_date = preg_replace('/T|Z/', ' ', $input_date); $temp = explode(' ', $input_date); //split using space and consider the first portion, in case of date with time $input_date = $temp[0]; $output_format = \Application\Model\ApplicationTable::dateFormat($output_format); $input_format = \Application\Model\ApplicationTable::dateFormat($input_format); preg_match("/[^ymd]/", $output_format, $date_seperator_output); $seperator_output = $date_seperator_output[0]; $output_date_arr = explode($seperator_output, $output_format); preg_match("/[^ymd]/", $input_format, $date_seperator_input); $seperator_input = $date_seperator_input[0]; $input_date_array = explode($seperator_input, $input_format); preg_match("/[^1234567890]/", $input_date, $date_seperator_input); $seperator_input = $date_seperator_input[0]; $input_date_arr = explode($seperator_input, $input_date); foreach ($output_date_arr as $key => $format) { $index = array_search($format, $input_date_array); $output_date_arr[$key] = $input_date_arr[$index]; } $output_date = implode($seperator_output, $output_date_arr); $output_date = $temp[1] ? $output_date . " " . $temp[1] : $output_date; //append the time, if exists, with the new formatted date return $output_date; }
public function fetchXmlDocuments() { $obj = new ApplicationTable(); $query = "SELECT doc.id \n\t FROM categories_to_documents AS cat_doc\n\t JOIN documents AS doc ON doc.imported = 0 AND doc.id = cat_doc.document_id AND doc.mimetype = 'text/xml'\n\t WHERE cat_doc.category_id = 1"; $result = $obj->zQuery($query); $count = 0; $module = array(); foreach ($result as $row) { $content = \Documents\Plugin\Documents::getDocument($row['id']); $module[$count]['doc_id'] = $row['id']; if (preg_match("/<ClinicalDocument/", $content)) { if (preg_match("/2.16.840.1.113883.3.88.11.32.1/", $content)) { $module[$count]['doc_type'] = 'CCD'; } else { $module[$count]['doc_type'] = 'CCDA'; } } elseif (preg_match("/<ccr:ContinuityOfCareRecord/", $content)) { $module[$count]['doc_type'] = 'CCR'; } $count++; } return $module; }
/** * deleteDocument - remove document from list * @param Int $docid */ public function deleteDocument($docid) { $obj = new ApplicationTable(); $sql = "UPDATE \n `documents` \n SET\n `activity` = ? \n WHERE `id` = ?"; $obj->zQuery($sql, array(0, $docid)); }
public function getModuleSections($module_id) { $sql = "SELECT * FROM module_acl_sections WHERE module_id = ?"; $obj = new ApplicationTable(); $result = $obj->sqlQuery($sql, array($module_id)); return $result; }
public function getListtitle($listId, $listOptionId) { $appTable = new ApplicationTable(); $sql = "SELECT title FROM list_options WHERE list_id = ? AND option_id = ? "; $result = $appTable->zQuery($sql, array($listId, $listOptionId)); $row = $result->current(); $return = xl_list_label($row['title']); return $return; }
public function updateExistingMappedFields($values) { $appTable = new ApplicationTable(); $res = $appTable->zQuery("update ccda_table_mapping set deleted = 1 where id <= ? and user_id = ?", $values); }
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; }
/** *Update document category using category name *@param $category_name - Name of the category to which the document has to be moved *@param $document_id - Documents whose category has to be updated with $category_name */ public function updateDocumentCategoryUsingCatname($category_name, $document_id) { $obj = new ApplicationTable(); $sql = "UPDATE categories_to_documents \n JOIN categories ON `name` = ?\n SET category_id=id\n WHERE document_id = ?"; $result = $obj->zQuery($sql, array($category_name, $document_id)); }
public function getList($list) { $appTable = new ApplicationTable(); $query = "SELECT title,option_id,notes,codes FROM list_options WHERE list_id = ?"; $result = $appTable->zQuery($query, array($list)); $records = array(); foreach ($result as $row) { $records[] = $row; } return $records; }
public function deleteACLSections($module_id) { $obj = new ApplicationTable(); $sql = "DELETE FROM module_acl_sections WHERE module_id =? AND parent_section <> 0"; $obj->sqlQuery($sql, array($module_id)); $sqsl = "DELETE FROM modules_settings WHERE mod_id =? AND fld_type = 1"; $obj->sqlQuery($sql, array($module_id)); }
public function getRefferals($pid, $encounter) { $appTable = new ApplicationTable(); $referrals = ''; $query = "SELECT field_value FROM transactions JOIN lbt_data ON form_id=id AND field_id = 'body' WHERE pid = ?"; $result = $appTable->zQuery($query, array($pid)); $referrals = '<referral_reason>'; foreach ($result as $row) { $referrals .= '<text>' . htmlspecialchars($row['field_value']) . '</text>'; } $referrals .= '</referral_reason>'; return $referrals; }
public function getLatestEncounter($pid) { $encounter = ''; $appTable = new ApplicationTable(); $query = "SELECT encounter FROM form_encounter WHERE pid = ? ORDER BY id DESC LIMIT 1"; $result = $appTable->zQuery($query, array($pid)); foreach ($result as $row) { $encounter = $row['encounter']; } return $encounter; }
public function getCareTeamProviderId($pid) { $appTable = new ApplicationTable(); $query = "SELECT care_team FROM patient_data WHERE `pid` = ?"; $result = $appTable->zQuery($query, array($pid)); $row = $result->current(); return $row['care_team']; }
public function AddNewUSer($data = array()) { $fname = $data['fname']; $lname = $data['lname']; $direct_address = $data['direct_address']; $appTable = new ApplicationTable(); $query = "INSERT INTO users SET username = ? ,password = ? ,authorized = ?,fname = ?,lname = ?,email = ?,active = ?,abook_type = ?"; $appTable->zQuery($query, array('', '', 0, $fname, $lname, $direct_address, 1, 'emr_direct')); }
public function getList($list_id, $selected = '', $opt = '') { $appTable = new ApplicationTable(); $this->listenerObject = new Listener(); $res = $appTable->zQuery("SELECT * FROM list_options WHERE list_id=? ORDER BY seq, title", array($list_id)); $i = 0; if ($opt == 'search') { $rows[$i] = array('value' => 'all', 'label' => $this->listenerObject->z_xlt('All'), 'selected' => TRUE); $i++; } elseif ($opt == '') { $rows[$i] = array('value' => '', 'label' => $this->listenerObject->z_xlt('Unassigned'), 'disabled' => FALSE); $i++; } foreach ($res as $row) { $sel = $row['option_id'] == $selected ? TRUE : FALSE; $rows[$i] = array('value' => htmlspecialchars($row['option_id'], ENT_QUOTES), 'label' => $this->listenerObject->z_xlt($row['title']), 'selected' => $sel); $i++; } return $rows; }
public function getCodes($option_id, $list_id) { $appTable = new ApplicationTable(); if ($option_id) { $query = "SELECT notes \n FROM list_options \n WHERE list_id=? AND option_id=?"; $result = $appTable->zQuery($query, array($list_id, $option_id)); $res_cur = $result->current(); } return $res_cur['notes']; }
public function getRefferals($pid, $encounter) { $appTable = new ApplicationTable(); $referrals = ''; $query = "SELECT body FROM transactions WHERE pid = ?"; $result = $appTable->zQuery($query, array($pid)); $referrals = '<referral_reason>'; foreach ($result as $row) { $referrals .= '<text>' . htmlspecialchars($row['body']) . '</text>'; } $referrals .= '</referral_reason>'; return $referrals; }