* @copyright Copyright (c) 2016 Raymond Magauran * @license https://github.com/openemr/openemr/blob/master/LICENSE GNU General Public License 3 */ require_once(__DIR__ . "/../../globals.php"); require_once(dirname(__FILE__) . "/../../../library/api.inc"); require_once(dirname(__FILE__) . "/../../../library/lists.inc"); require_once(dirname(__FILE__) . "/../../../library/forms.inc"); require_once(dirname(__FILE__) . "/../../../library/patient.inc"); require_once(dirname(__FILE__) . "/../../../controllers/C_Document.class.php"); use OpenEMR\Services\FacilityService; use OpenEMR\Core\Header; $form_name = "eye_mag"; $form_folder = "eye_mag"; $facilityService = new FacilityService(); require_once(__DIR__ . "/../../forms/" . $form_folder . "/php/" . $form_folder . "_functions.php"); if ($_REQUEST['CHOICE'] ?? '') { $choice = $_REQUEST['choice']; } if ($_REQUEST['ptid'] ?? '') { $pid = $_REQUEST['ptid']; } if ($_REQUEST['encid'] ?? '') { $encounter = $_REQUEST['encid']; } if ($_REQUEST['formid'] ?? '') { $form_id = $_REQUEST['formid']; } if ($_REQUEST['formname'] ?? '') { $form_name = $_REQUEST['formname']; } if (!($id ?? '')) { $id = $form_id ?? ''; } // Get users preferences, for this user // (and if not the default where a fresh install begins from, or someone else's) $query = "SELECT * FROM form_eye_mag_prefs where PEZONE='PREFS' AND id=? ORDER BY ZONE_ORDER,ordering"; $result = sqlStatement($query, array($_SESSION['authUserID'])); while ($prefs = sqlFetchArray($result)) { $LOCATION = $prefs['LOCATION']; $$LOCATION = text($prefs['GOVALUE']); } function eye_mag_report($pid, $encounter, $cols, $id, $formname = 'eye_mag') { global $form_folder; global $form_name; global $choice; /** * openEMR note: eye_mag Index is id, * linked to encounter in form_encounter * whose encounter is linked to id in forms. */ $query = " select *,form_encounter.date as encounter_date from forms,form_encounter,form_eye_base, form_eye_hpi,form_eye_ros,form_eye_vitals, form_eye_acuity,form_eye_refraction,form_eye_biometrics, form_eye_external, form_eye_antseg,form_eye_postseg, form_eye_neuro,form_eye_locking where forms.deleted != '1' and forms.formdir='eye_mag' and forms.encounter=form_encounter.encounter and forms.form_id=form_eye_base.id and forms.form_id=form_eye_hpi.id and forms.form_id=form_eye_ros.id and forms.form_id=form_eye_vitals.id and forms.form_id=form_eye_acuity.id and forms.form_id=form_eye_refraction.id and forms.form_id=form_eye_biometrics.id and forms.form_id=form_eye_external.id and forms.form_id=form_eye_antseg.id and forms.form_id=form_eye_postseg.id and forms.form_id=form_eye_neuro.id and forms.form_id=form_eye_locking.id and forms.encounter=? and forms.pid=? "; $objQuery = sqlQuery($query, array($encounter,$pid)); @extract($objQuery); $dated = new DateTime($encounter_date); $dated = $dated->format('Y/m/d'); global $visit_date; $visit_date = oeFormatShortDate($dated); /* * Patient/Client -> Visits -> Visit History, on mouse over this is called with variable "choice". * To use this feature, this "choice" variable must be added programmatically to * /interface/patient_file/history/encounters_ajax.php, currently line 20. * The variable $choice will tell us what to display. * If it is not present it will display everything == 'narrative'. * @param string $choice options NULL,TEXT,DRAW,NARRATIVE * @param string $encounter = encounter number * @param string $pid value = patient id * @return string => returns the HTML of the report selected */ if ($choice == 'DRAW') { /* $side="OU"; $zone = array("HPI","PMH","VISION","NEURO","EXT","ANTSEG","RETINA","IMPPLAN"); // for ($i = 0; $i < count($zone); ++$i) { // show only 2 for now in the encounter page ($choice =='drawing') ? ($count = count($zone)) : ($count ='2'); for ($i = 0; $i < $count; ++$i) { $file_location = $GLOBALS["OE_SITES_BASE"]."/".$_SESSION['site_id']."/documents/".$pid."/".$form_folder."/".$encounter."/".$side."_".$zone[$i]."_VIEW.png"; $sql = "SELECT * from documents where url='file://".$file_location."'"; $doc = sqlQuery($sql); if (file_exists($file_location) && ($doc['id'] > '0')) { $filetoshow = $GLOBALS['web_root']."/controller.php?document&retrieve&patient_id=$pid&document_id=$doc[id]&as_file=false"; ?>
$value) { $$key = $value; } } } /* * This is the core report, including Practice logo, patient ID/header. * It relies on the presence of the PMSFH,IMPPLAN arrays. * Rest of fields are pulled from the DB. */ function narrative($pid, $encounter, $cols, $form_id, $choice = 'full') { global $form_folder; global $PDF_OUTPUT; global $facilityService; //if $cols == 'Fax', we are here from taskman, making a fax and this a one page short form - leave out PMSFH, prescriptions //and any clinical area that is blank. $query = " select *,form_encounter.date as encounter_date from forms,form_encounter,form_eye_base, form_eye_hpi,form_eye_ros,form_eye_vitals, form_eye_acuity,form_eye_refraction,form_eye_biometrics, form_eye_external, form_eye_antseg,form_eye_postseg, form_eye_neuro,form_eye_locking where forms.deleted != '1' and forms.formdir='eye_mag' and forms.encounter=form_encounter.encounter and forms.form_id=form_eye_base.id and forms.form_id=form_eye_hpi.id and forms.form_id=form_eye_ros.id and forms.form_id=form_eye_vitals.id and forms.form_id=form_eye_acuity.id and forms.form_id=form_eye_refraction.id and forms.form_id=form_eye_biometrics.id and forms.form_id=form_eye_external.id and forms.form_id=form_eye_antseg.id and forms.form_id=form_eye_postseg.id and forms.form_id=form_eye_neuro.id and forms.form_id=form_eye_locking.id and forms.encounter=? and forms.pid=? "; $encounter_data = sqlQuery($query, array($encounter, $pid)); @extract($encounter_data); $providerID = getProviderIdOfEncounter($encounter); $providerNAME = getProviderName($providerID); $dated = new DateTime($encounter_date); $dated = $dated->format('Y/m/d'); $visit_date = oeFormatShortDate($dated); ?>
getById($_SESSION['pc_facility']); } else { $facility = $facilityService->getPrimaryBillingLocation(); } } ?>

:  

:  
" . xlt('Timing'); ?>:  "; } if ($CONTEXT1) { echo "" . xlt('Context'); ?>:  "; } if ($SEVERITY1) { echo "" . xlt('Severity'); ?>:  "; } if ($MODIFY1) { echo "" . xlt('Modifying'); ?>:  "; } if ($ASSOCIATED1) { echo "" . xlt('Associated'); ?>:  "; } if ($LOCATION1) { echo "" . xlt('Location'); ?>:  "; } if ($QUALITY1) { echo "" . xlt('Quality'); ?>:  "; } if ($DURATION1) { echo "" . xlt('Duration'); ?>:  "; } ?> " . xlt('Chief Complaint 2'); ?>:  
:  
" . xlt('Timing'); ?>:  "; } if ($CONTEXT2) { echo "" . xlt('Context'); ?>:  "; } if ($SEVERITY2) { echo "" . xlt('Severity'); ?>:  "; } if ($MODIFY2) { echo "" . xlt('Modifying'); ?>:  "; } if ($ASSOCIATED2) { echo "" . xlt('Associated'); ?>:  "; } if ($LOCATION2) { echo "" . xlt('Location'); ?>:  "; } if ($QUALITY2) { echo "" . xlt('Quality'); ?>:  "; } if ($DURATION2) { echo "" . xlt('Duration'); ?>:  "; } ?>
" . xlt('Chief Complaint 3'); ?>:  
 
" . xlt('Timing'); ?>:  "; } if ($CONTEXT3) { echo "" . xlt('Context'); ?>:  "; } if ($SEVERITY3) { echo "" . xlt('Severity'); ?>:  "; } if ($MODIFY3) { echo "" . xlt('Modifying'); ?>:  "; } if ($ASSOCIATED3) { echo "" . xlt('Associated'); ?>:  "; } if ($LOCATION3) { echo "" . xlt('Location'); ?>:  "; } if ($QUALITY3) { echo "" . xlt('Quality'); ?>:  "; } if ($DURATION3) { echo "" . xlt('Duration'); ?>:  "; } ?>

:
 "; if ($CHRONIC2) { echo " " . $CHRONIC2 . "
"; } if ($CHRONIC3) { echo " " . $CHRONIC3 . "
"; } } ?>
retrieve_action($pid, -1, false, true, true, true, 'patient_picture'); if (!empty($fileTemp)) { if ($PDF_OUTPUT) { // tmp file in ../documents/temp since need to be available via webroot $from_file_tmp_web_name = tempnam($GLOBALS['OE_SITE_DIR'] . '/documents/temp', "oer"); file_put_contents($from_file_tmp_web_name, $fileTemp); echo ""; $tmp_files_remove[] = $from_file_tmp_web_name; } else { $filetoshow = $GLOBALS['webroot'] . "/controller.php?document&retrieve&patient_id=" . attr_url($pid) . "&document_id=-1&as_file=false&original_file=true&disable_exit=false&show_original=true&context=patient_picture"; echo ""; } } ?>
X'; if ($PDF_OUTPUT) { $ODVF[$z] = 'X'; } $bad++; } else { $ODVF[$z] = ''; if ($PDF_OUTPUT) { $ODVF[$z] = 'O'; } } $OSzone = "OSVF" . $z; if ($$OSzone == "1") { $OSVF[$z] = 'X'; if ($PDF_OUTPUT) { $OSVF[$z] = 'X'; } $bad++; } else { $OSVF[$z] = ''; if ($PDF_OUTPUT) { $OSVF[$z] = 'O'; } } } ?>
"; } if ($ODIOPTPN || $OSIOPTPN) { echo ""; } if ($ODIOPFTN || $OSIOPFTN) { echo ""; } ?>
" . xlt('App{{Applanation abbreviation}}') . ":" . text($ODIOPAP) . "" . text($OSIOPAP) . "
" . xlt('Tpn{{Tonopen abbreviation}}') . ":" . text($ODIOPTPN) . "" . text($OSIOPTPN) . "
" . xlt('FTN{{Finger Tension abbreviation}}') . ":" . text($ODIOPFTN) . "" . text($OSIOPFTN) . "
@

Full to CF OU"; } else { ?>





 " . xlt('D&V Full OU{{Ductions and Versions full both eyes}}') . " 

"; } else { if ($PDF_OUTPUT) { $background = "url(" . $GLOBALS["fileroot"] . "/interface/forms/" . $form_folder . "/images/eom.jpg)"; } else { $background = "url(../../forms/" . $form_folder . "/images/eom.bmp)"; } $zone = array( "MOTILITY_RRSO", "MOTILITY_RS", "MOTILITY_RLSO", "MOTILITY_RR", "MOTILITY_R0", "MOTILITY_RL", "MOTILITY_RRIO", "MOTILITY_RI", "MOTILITY_RLIO", "MOTILITY_LRSO", "MOTILITY_LS", "MOTILITY_LLSO", "MOTILITY_LR", "MOTILITY_L0", "MOTILITY_LL", "MOTILITY_LRIO", "MOTILITY_LI", "MOTILITY_LLIO" ); for ($i = 0; $i < count($zone); ++$i) { ($$zone[$i] >= '1') ? ($$zone[$i] = "-" . $$zone[$i]) : ($$zone[$i] = ''); } ?>
   "; } if ($ODPUPILSIZE1 || $OSPUPILSIZE1) { ?>
  ()
-->
-->

:
()
-->
-->

/5

/5

:
-
  -
Comments:
-
-
-
  -
:
:

:
:
 
:
:
:
:
:
:
:

-- --
:
:
:
:
:
   
:
:
:
:
"; // echo '
    '; while ($ip_list = sqlFetchArray($result)) { $newdata = array( 'form_id' => $ip_list['form_id'], 'pid' => $ip_list['pid'], 'title' => $ip_list['title'], 'code' => $ip_list['code'], 'codetype' => $ip_list['codetype'], 'codetext' => $ip_list['codetext'], 'plan' => str_replace($order, $replace, $ip_list['plan']), 'IMPPLAN_order' => $ip_list['IMPPLAN_order'] ); $IMPPLAN_items[$i] = $newdata; $i++; } if (!empty($IMPPLAN_items)) { //for ($i=0; $i < count($IMPPLAN_item); $i++) { foreach ($IMPPLAN_items as $item) { echo ($item['IMPPLAN_order'] + 1) . '. ' . text($item['title']) . '
    '; echo '
    '; $pattern = '/Code/'; if (preg_match($pattern, $item['code'])) { $item['code'] = ''; } if ($item['codetext'] > '') { echo $item['codetext'] . "
    "; } else { if ($item['code'] > '') { if ($item['codetype'] > '') { $item['code'] = $item['codetype'] . ": " . $item['code']; } echo $item['plan'] . "

    "; } } } $query = "SELECT * FROM form_eye_mag_orders where form_id=? and pid=? ORDER BY id ASC"; $PLAN_results = sqlStatement($query, array($form_id, $pid)); if (!empty($PLAN_results)) { ?>
    :
    "; } echo $item['plan'] . "

    "; ?>

"; } else { echo "

"; } } else { $signature = $GLOBALS["webserver_root"] . "/interface/forms/" . $form_folder . "/images/sign_" . $providerID . ".jpg"; if (file_exists($signature)) { echo "
"; } else { echo "

"; } } echo "
" . xlt('electronically signed on') . " " . oeFormatShortDate() . ""; ?>
'1') && (is_numeric($document_id))) { $d = new Document($document_id); $fname = basename($d->get_url()); $extension = substr($fname, strrpos($fname, ".")); $notes = $d->get_notes(); if (!empty($notes)) { echo ""; } foreach ($notes as $note) { echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; } if (!empty($notes)) { echo "
' . xlt('Note') . ' #' . $note->get_id() . '
' . xlt('Date') . ': ' . text(oeFormatShortDate($note->get_date())) . '
' . $note->get_note() . '

"; } // if ($extension == ".png" || $extension == ".jpg" || $extension == ".jpeg" || $extension == ".gif") { if ($PDF_OUTPUT) { $tempDocC = new C_Document(); $fileTemp = $tempDocC->retrieve_action($pid, $doc['id'], false, true, true); // tmp file in ../documents/temp since need to be available via webroot $from_file_tmp_web_name = tempnam($GLOBALS['OE_SITE_DIR'] . '/documents/temp', "oer"); file_put_contents($from_file_tmp_web_name, $fileTemp); echo ""; $tmp_files_remove[] = $from_file_tmp_web_name; } else { $filetoshow = $GLOBALS['webroot'] . "/controller.php?document&retrieve&patient_id=" . attr_url($pid) . "&document_id=" . attr_url($doc['id']) . "&as_file=false&blahblah=" . attr_url(rand()); echo ""; } } else { //else show base_image $filetoshow = "../../forms/" . $form_folder . "/images/" . $side . "_" . $zone . "_BASE.jpg"; if ($PDF_OUTPUT) { $filetoshow = $GLOBALS["webroot"] . "/interface/forms/" . $form_folder . "/images/" . $side . "_" . $zone . "_BASE.jpg"; } // uncomment to show base image, no touch up by user. // echo ""; } return; } function report_ACT($term) { $term = nl2br(htmlspecialchars($term, ENT_NOQUOTES)); return $term . " "; } ?>