public function getMedications($pid, $encounter) { $medications = ''; $query = "select l.id, l.date_added, l.drug, l.dosage, l.quantity, l.size, l.substitute, l.drug_info_erx, l.active, SUBSTRING(l3.codes, LOCATE(':',l3.codes)+1, LENGTH(l3.codes)) AS route_code,\n l.rxnorm_drugcode, l1.title as unit, l1.codes as unit_code,l2.title as form,SUBSTRING(l2.codes, LOCATE(':',l2.codes)+1, LENGTH(l2.codes)) AS form_code, l3.title as route, l4.title as `interval`,\n u.title, u.fname, u.lname, u.mname, u.npi, u.street, u.streetb, u.city, u.state, u.zip, u.phonew1, l.note\n from prescriptions as l\n left join list_options as l1 on l1.option_id=unit AND l1.list_id = ?\n left join list_options as l2 on l2.option_id=form AND l2.list_id = ?\n left join list_options as l3 on l3.option_id=route AND l3.list_id = ?\n left join list_options as l4 on l4.option_id=`interval` AND l4.list_id = ?\n left join users as u on u.id = l.provider_id\n where l.patient_id = ? and l.active = 1"; $appTable = new ApplicationTable(); $res = $appTable->zQuery($query, array('drug_units', 'drug_form', 'drug_route', 'drug_interval', $pid)); $medications = "<medications>"; foreach ($res as $row) { if (!$row['rxnorm_drugcode']) { $row['rxnorm_drugcode'] = $this->generate_code($row['drug']); } $unit = $str = $active = ''; if ($row['size'] > 0) { $unit = $row['size'] . " " . \Application\Listener\Listener::z_xlt($row['unit']) . " "; } $str = $unit . " " . \Application\Listener\Listener::z_xlt($row['route']) . " " . $row['dosage'] . " " . \Application\Listener\Listener::z_xlt($row['form'] . " " . $row['interval']); if ($row['active'] > 0) { $active = 'active'; } else { $active = 'completed'; } if ($row['date_added']) { $start_date = str_replace('-', '', $row['date_added']); $start_date_formatted = \Application\Model\ApplicationTable::fixDate($row['date_added'], $GLOBALS['date_display_format'], 'yyyy-mm-dd'); } $medications .= "<medication>\n\t\t\t\t\t\t<id>" . htmlspecialchars($row['id'], ENT_QUOTES) . "</id>\n\t\t\t\t\t\t<extension>" . htmlspecialchars(base64_encode($_SESSION['site_id'] . $row['id']), ENT_QUOTES) . "</extension>\n\t\t\t\t\t\t<sha_extension>" . htmlspecialchars("cdbd33f0-6cde-11db-9fe1-0800200c9a66", ENT_QUOTES) . "</sha_extension>\n <performer_name>" . htmlspecialchars($row['fname'] . " " . $row['mname'] . " " . $row['lname'], ENT_QUOTES) . "</performer_name>\n\t\t\t\t\t\t<fname>" . htmlspecialchars($row['fname'], ENT_QUOTES) . "</fname>\n\t\t\t\t\t\t<mname>" . htmlspecialchars($row['mname'], ENT_QUOTES) . "</mname>\n\t\t\t\t\t\t<lname>" . htmlspecialchars($row['lname'], ENT_QUOTES) . "</lname>\n\t\t\t\t\t\t<title>" . htmlspecialchars($row['title'], ENT_QUOTES) . "</title>\n\t\t\t\t\t\t<npi>" . htmlspecialchars($row['npi'], ENT_QUOTES) . "</npi>\n\t\t\t\t\t\t<address>" . htmlspecialchars($row['street'], ENT_QUOTES) . "</address>\n\t\t\t\t\t\t<city>" . htmlspecialchars($row['city'], ENT_QUOTES) . "</city>\n\t\t\t\t\t\t<state>" . htmlspecialchars($row['state'], ENT_QUOTES) . "</state>\n\t\t\t\t\t\t<zip>" . htmlspecialchars($row['zip'], ENT_QUOTES) . "</zip>\n\t\t\t\t\t\t<work_phone>" . htmlspecialchars($row['phonew1'], ENT_QUOTES) . "</work_phone>\n\t\t\t\t\t\t<drug>" . htmlspecialchars($row['drug'], ENT_QUOTES) . "</drug>\n <direction>" . htmlspecialchars($str, ENT_QUOTES) . "</direction>\n\t\t\t\t\t\t<dosage>" . htmlspecialchars($row['dosage'], ENT_QUOTES) . "</dosage>\n\t\t\t\t\t\t<size>" . htmlspecialchars($row['size'] ? $row['size'] : 0, ENT_QUOTES) . "</size>\n\t\t\t\t\t\t<unit>" . htmlspecialchars($row['unit'] ? preg_replace('/\\s*/', '', \Application\Listener\Listener::z_xlt($row['unit'])) : 'Unit', ENT_QUOTES) . "</unit>\n\t\t\t\t\t\t<unit_code>" . htmlspecialchars($row['unit_code'] ? $row['unit_code'] : 0, ENT_QUOTES) . "</unit_code>\n\t\t\t\t\t\t<form>" . htmlspecialchars(\Application\Listener\Listener::z_xlt($row['form']), ENT_QUOTES) . "</form>\n\t\t\t\t\t\t<form_code>" . htmlspecialchars(\Application\Listener\Listener::z_xlt($row['form_code']), ENT_QUOTES) . "</form_code>\n\t\t\t\t\t\t<route_code>" . htmlspecialchars($row['route_code'], ENT_QUOTES) . "</route_code>\n\t\t\t\t\t\t<route>" . htmlspecialchars($row['route'], ENT_QUOTES) . "</route>\n\t\t\t\t\t\t<interval>" . htmlspecialchars(\Application\Listener\Listener::z_xlt($row['interval']), ENT_QUOTES) . "</interval>\n\t\t\t\t\t\t<start_date>" . htmlspecialchars($start_date, ENT_QUOTES) . "</start_date>\n\t\t\t\t\t\t<start_date_formatted>" . htmlspecialchars($row['date_added'], ENT_QUOTES) . "</start_date_formatted>\n\t\t\t\t\t\t<end_date>" . htmlspecialchars('00000000', ENT_QUOTES) . "</end_date>\n\t\t\t\t\t\t<status>" . $active . "</status>\n <indications>" . htmlspecialchars($row['pres_erx_diagnosis_name'] ? $row['pres_erx_diagnosis_name'] : 'NULL', ENT_QUOTES) . "</indications>\n <indications_code>" . htmlspecialchars($row['pres_erx_diagnosis'] ? $row['pres_erx_diagnosis'] : 0, ENT_QUOTES) . "</indications_code>\n\t\t\t\t\t\t<instructions>" . htmlspecialchars($row['note'], ENT_QUOTES) . "</instructions>\n\t\t\t\t\t\t<rxnorm>" . htmlspecialchars($row['rxnorm_drugcode'], ENT_QUOTES) . "</rxnorm>\n\t\t\t\t\t\t<provider_id></provider_id>\n\t\t\t\t\t\t<provider_name></provider_name>\n </medication>"; } $medications .= "</medications>"; return $medications; }
public function InsertMedicalProblem($med_pblm_array, $pid, $revapprove = 1) { $appTable = new ApplicationTable(); foreach ($med_pblm_array as $key => $value) { $activity = 1; if ($value['begdate'] != 0 && $revapprove == 0) { $med_pblm_begdate = $this->formatDate($value['begdate'], 1); $med_pblm_begdate_value = fixDate($med_pblm_begdate); } elseif ($value['begdate'] != 0 && $revapprove == 1) { $med_pblm_begdate_value = \Application\Model\ApplicationTable::fixDate($value['begdate'], 'yyyy-mm-dd', 'dd/mm/yyyy'); } elseif ($value['begdate'] == 0) { $med_pblm_begdate = $value['begdate']; $med_pblm_begdate_value = fixDate($med_pblm_begdate); $med_pblm_begdate_value = NULL; } if ($value['enddate'] != 0 && $revapprove == 0) { $med_pblm_enddate = $this->formatDate($value['enddate'], 1); $med_pblm_enddate_value = fixDate($med_pblm_enddate); } elseif ($value['enddate'] != 0 && $revapprove == 1) { $med_pblm_enddate_value = \Application\Model\ApplicationTable::fixDate($value['enddate'], 'yyyy-mm-dd', 'dd/mm/yyyy'); } elseif ($value['enddate'] == 0 || $value['enddate'] == '') { $med_pblm_enddate = $value['enddate']; $med_pblm_enddate_value = fixDate($med_pblm_enddate); $med_pblm_enddate_value = NULL; } if ($revapprove == 1) { if ($value['resolved'] == 1) { if (!$med_pblm_enddate_value) { $med_pblm_enddate_value = date('y-m-d'); } } else { $med_pblm_enddate_value = NULL; } } $query_select = "SELECT * FROM list_options WHERE list_id = ? AND title = ?"; $result = $appTable->zQuery($query_select, array('outcome', $value['observation_text'])); if ($result->count() > 0) { $q_update = "UPDATE list_options SET activity = 1 WHERE list_id = ? AND title = ? AND codes = ?"; $appTable->zQuery($q_update, array('outcome', $value['observation_text'], 'SNOMED-CT:' . $value['observation'])); foreach ($result as $value1) { $o_id = $value1['option_id']; } } else { $lres = $appTable->zQuery("SELECT IFNULL(MAX(CONVERT(SUBSTRING_INDEX(option_id,'-',-1),UNSIGNED INTEGER))+1,1) AS option_id FROM list_options WHERE list_id = ?", array('outcome')); foreach ($lres as $lrow) { $o_id = $lrow['option_id']; } $q_insert = "INSERT INTO list_options (list_id,option_id,title,codes,activity) VALUES (?,?,?,?,?)"; $appTable->zQuery($q_insert, array('outcome', $o_id, $value['observation_text'], 'SNOMED-CT:' . $value['observation'], 1)); } $q_sel_med_pblm = "SELECT * \n FROM lists\n WHERE external_id=? AND type='medical_problem' AND begdate=? AND diagnosis=? AND pid=?"; $res_q_sel_med_pblm = $appTable->zQuery($q_sel_med_pblm, array($value['extension'], $med_pblm_begdate_value, 'SNOMED-CT:' . $value['list_code'], $pid)); if ($res_q_sel_med_pblm->count() == 0) { $query = "INSERT INTO lists \n ( pid, \n date,\n diagnosis, \n activity, \n title, \n begdate, \n enddate,\n outcome,\n type,\n external_id\n ) \n VALUES \n ( ?,\n ?,\n ?,\n ?,\n ?,\n ?,\n ?,\n ?,\n ?,\n ?\n )"; $result = $appTable->zQuery($query, array($pid, date('y-m-d H:i:s'), 'SNOMED-CT:' . $value['list_code'], $activity, $value['list_code_text'], $med_pblm_begdate_value, $med_pblm_enddate_value, $o_id, 'medical_problem', $value['extension'])); $list_id = $result->getGeneratedValue(); } else { $q_upd_med_pblm = "UPDATE lists\n SET pid=?,\n date=?,\n diagnosis=?, \n title=?, \n begdate=?, \n enddate=?,\n outcome=?\n WHERE external_id=? AND type='medical_problem' AND begdate=? AND diagnosis=? AND pid=?"; $appTable->zQuery($q_upd_med_pblm, array($pid, date('y-m-d H:i:s'), 'SNOMED-CT:' . $value['list_code'], $value['list_code_text'], $med_pblm_begdate_value, $med_pblm_enddate_value, $o_id, $value['extension'], $value['begdate'], 'SNOMED-CT:' . $value['list_code'], $pid)); } } }
public function insertApprovedData($data) { $appTable = new ApplicationTable(); $patient_data_fields = ''; $patient_data_values = array(); foreach ($data as $key => $val) { if (substr($key, -4) == '-sel') { if (is_array($val)) { for ($i = 0; $i < count($val); $i++) { if ($val[$i] == 'insert') { if (substr($key, 0, -4) == 'lists1') { if ($data['lists1-activity'][$i] == 'Active') { $activity = 1; } elseif ($data['lists1-activity'][$i] == 'Inactive') { $activity = 0; } $query = "INSERT INTO lists (pid, diagnosis, activity, title, date, type) VALUES (?,?,?,?,?,?)"; $appTable->zQuery($query, array($data['pid'], $data['lists1-diagnosis'][$i], $activity, $data['lists1-title'][$i], \Application\Model\ApplicationTable::fixDate($data['lists1-date'][$i], 'yyyy-mm-dd', $GLOBALS['date_display_format']), 'medical_problem')); } elseif (substr($key, 0, -4) == 'lists2') { $query = "INSERT INTO lists (pid, date, type, title, diagnosis, reaction) VALUES (?,?,?,?,?,?)"; $appTable->zQuery($query, array($data['pid'], \Application\Model\ApplicationTable::fixDate($data['lists2-date'][$i], 'yyyy-mm-dd', $GLOBALS['date_display_format']), $data['lists2-type'][$i], $data['lists2-title'][$i], $data['lists2-diagnosis'][$i], $data['lists2-reaction'][$i])); } elseif (substr($key, 0, -4) == 'prescriptions') { if ($data['prescriptions-active'][$i] == 'Active') { $active = 1; } elseif ($data['prescriptions-active'][$i] == 'Inactive') { $active = 0; } $query = "INSERT INTO prescriptions (patient_id, date_added, active, drug, size, form, quantity) VALUES (?,?,?,?,?,?,?)"; $appTable->zQuery($query, array($data['pid'], \Application\Model\ApplicationTable::fixDate($data['prescriptions-date_added'][$i], 'yyyy-mm-dd', $GLOBALS['date_display_format']), $active, $data['prescriptions-drug'][$i], $data['prescriptions-size'][$i], $data['prescriptions-form'][$i], $data['prescriptions-quantity'][$i])); } elseif (substr($key, 0, -4) == 'immunizations') { $query = "INSERT INTO immunizations (patient_id, administered_date, note) VALUES (?,?,?)"; $appTable->zQuery($query, array($data['pid'], \Application\Model\ApplicationTable::fixDate($data['immunizations-administered_date'][$i], 'yyyy-mm-dd', $GLOBALS['date_display_format']), $data['immunizations-note'][$i])); } } elseif ($val[$i] == 'update') { if (substr($key, 0, -4) == 'lists1') { if ($data['lists1-activity'][$i] == 'Active') { $activity = 1; } elseif ($data['lists1-activity'][$i] == 'Inactive') { $activity = 0; } $query = "UPDATE lists SET diagnosis=?,activity=? WHERE pid=? AND diagnosis=?"; $appTable->zQuery($query, array($data['lists1-diagnosis'][$i], $activity, $data['pid'], $data['lists1-old-diagnosis'][$i])); } } } } else { if (substr($key, 0, 12) == 'patient_data') { if ($val == 'update') { $var_name = substr($key, 0, -4); $field_name = substr($var_name, 13); $patient_data_fields .= $field_name . '=?,'; array_push($patient_data_values, $data[$var_name]); } } } } } if (count($patient_data_values) > 0) { array_push($patient_data_values, $data['pid']); $patient_data_fields = substr($patient_data_fields, 0, -1); $query = "UPDATE patient_data SET {$patient_data_fields} WHERE pid=?"; $appTable->zQuery($query, $patient_data_values); } $appTable->zQuery("UPDATE documents SET foreign_id = ? WHERE id =? ", array($data['pid'], $data['document_id'])); $appTable->zQuery("UPDATE audit_master SET approval_status = '2' WHERE id=?", array($data['amid'])); $appTable->zQuery("UPDATE documents SET audit_master_approval_status=2 WHERE audit_master_id=?", array($data['amid'])); }
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; }