function getLabsGraphValues() { $oDD = new \raptor\DashboardData($this->m_oContext); $aDD = $oDD->getDashboardDetails(); $selectedPatient = array('ethnicity' => $aDD['PatientEthnicity'], 'gender' => $aDD['PatientGender'], 'age' => $aDD['PatientAge']); $labsResult = MdwsUtils::getChemHemLabs($this->m_oContext->getMdwsClient()); //Pass in selected patient and egfr formula if one is defined $result = MdwsUtils::convertSoapLabsToGraph($selectedPatient, NULL, $labsResult, 3); error_log('getLabsGraphValues patient>>>' . print_r($selectedPatient, TRUE)); error_log('getLabsGraphValues labs>>>' . print_r($labsResult, TRUE)); error_log('getLabsGraphValues filtered>>>' . print_r($result, TRUE)); if (!is_array($result)) { $result = array(); } return $result; }
/** * Get all the form contents for rendering * @return type renderable array */ public function getForm($form, &$form_state, $disabled, $myvalues) { $form['data_entry_area1'] = array('#prefix' => "\n<section class='user-profile-dataentry'>\n", '#suffix' => "\n</section>\n", '#disabled' => $disabled); //TODO real form fields $form['hiddenthings']['tid'] = array('#type' => 'hidden', '#value' => $myvalues['tid']); $form['hiddenthings']['procName'] = array('#type' => 'hidden', '#value' => $myvalues['procName']); $mdwsDao = $this->m_oContext->getMdwsClient(); $aCancelOptions = MdwsUtils::getRadiologyCancellationReasons($mdwsDao); $form['data_entry_area1']['toppart']['reason'] = array("#type" => "select", "#title" => t("Reason"), "#options" => $aCancelOptions, "#description" => t("Select reason for cancelling this order."), "#required" => TRUE); $showcustomcomment = FALSE; if (!$showcustomcomment) { $form['hiddenthings']['notes_tx'] = ''; $form['hiddenthings']['esig'] = ''; } else { $form['data_entry_area1']['toppart']['notes_tx'] = array('#type' => 'textarea', '#title' => t('Comments'), '#disabled' => $disabled, '#default_value' => ''); $form['data_entry_area1']['toppart']['esig'] = array('#type' => 'textfield', '#title' => t('Electronic Signature'), '#disabled' => $disabled, '#size' => 60, '#maxlength' => 128, '#default_value' => '', '#required' => TRUE); } $form['data_entry_area1']['action_buttons'] = array('#prefix' => "\n<section class='raptor-action-buttons'>\n", '#suffix' => "\n</section>\n", '#disabled' => $disabled); $form['data_entry_area1']['action_buttons']['remove'] = array('#type' => 'submit', '#attributes' => array('class' => array('admin-action-button')), '#value' => t('Cancel this Imaging Order'), '#disabled' => $disabled); $form['data_entry_area1']['action_buttons']['cancel'] = array('#type' => 'item', '#markup' => '<input class="raptor-dialog-cancel" type="button" value="Exit with No Changes">'); return $form; }
/** * Get all the form contents for rendering * @return type renderable array */ function getForm($form, &$form_state, $disabled, $myvalues) { $form["data_entry_area1"] = array('#prefix' => "\n<section class='raptor-dialog'>\n", '#suffix' => "\n</section>\n"); $oContext = \raptor\Context::getInstance(); $oWL = new \raptor\WorklistData($oContext); $raptor_worklist_rows = $oWL->getWorklistRows(); //$oContext); $data_rows = $raptor_worklist_rows["DataRows"]; $mdwsDao = $oContext->getMdwsClient(); $aCancelOptions = MdwsUtils::getRadiologyCancellationReasons($mdwsDao); $form["data_entry_area1"]['metadata']['cancelreason'] = array('#type' => 'select', '#required' => TRUE, '#empty_value' => '', '#title' => t('Reason for Canceling Selected Orders'), '#options' => $aCancelOptions, '#default_value' => $myvalues['cancelreason'], '#description' => t('Select the reason for canceling the selected orders.')); $form["data_entry_area1"]['metadata']['cancelcomment'] = array('#type' => 'textarea', '#required' => FALSE, '#title' => t('Additional Cancellation Reason Comment'), '#default_value' => $myvalues['cancelcomment'], '#description' => t('Additional reason for the cancellation.')); $form["data_entry_area1"]['table_container'] = array('#type' => 'item', '#prefix' => '<div class="raptor-dialog-table-container"><p>Each of the rows with a checkmark in the table below is an order that is selected for cancellation. Only place a checkmark on the orders you intend to cancel.</p>', '#suffix' => '</div>', '#tree' => TRUE); $rows = "\n"; $rowcount = 0; foreach ($data_rows as $data_row) { $rowcount++; if ($rowcount > 100) { break; } if (!is_array($data_row) || count($data_row) == 0) { continue; } $aRankScoreDetails = $data_row[18]; $score = $aRankScoreDetails[0]; $aRSComment = $aRankScoreDetails[1]; $rscomment = ''; foreach ($aRSComment as $key => $value) { $rscomment .= "<br>{$key}={$value}"; } //$rsurl = getRankScoreIcon($score); // Change row background color if it is assigned to the current user $extra_row_class = is_array($data_row[12]) && $data_row[12]['uid'] == $m_oContext->getUID() ? "special-row" : ""; $assignmentinfo = is_array($data_row[12]) ? '<span title="' . $data_row[12]['requester_notes_tx'] . '">' . $data_row[12]['fullname'] . '</span>' : $data_row[12]; $ticketid = $data_row[0]; $options[$data_row[0]] = array('ticketid' => $ticketid, 'patientname' => $data_row[WorklistData::WLIDX_PATIENTNAME], 'targetdate' => $data_row[3], 'ordereddate' => $data_row[4], 'modality' => $data_row[WorklistData::WLIDX_MODALITY], 'imagetype' => $data_row[17], 'study' => $data_row[WorklistData::WLIDX_STUDY], 'urgency' => $data_row[7], 'transport' => $data_row[WorklistData::WLIDX_TRANSPORT], 'patientlocation' => $data_row[WorklistData::WLIDX_PATIENTCATEGORYLOCATION], 'workflowstatus' => $data_row[WorklistData::WLIDX_WORKFLOWSTATUS], 'assignment' => $assignmentinfo, 'numpending' => $data_row[WorklistData::WLIDX_PENDINGORDERSSAMEPATIENT], 'scheduled' => $data_row[WorklistData::WLIDX_SCHEDINFO]['ShowTx'], 'seemore' => '<a href="#" title="click to see more info" onclick="alert(\'todo show data for ' . $ticketid . '\');return false;">see more</a>'); } $header = array('ticketid' => t('Ticket'), 'patientname' => t('Patient'), 'targetdate' => t('Date Desired'), 'ordereddate' => t('Date Order'), 'modality' => t('Modality'), 'imagetype' => t('Image Type'), 'study' => t('Study'), 'urgency' => t('Urgency'), 'transport' => t('Transport'), 'patientlocation' => t('Patient Category / Location'), 'workflowstatus' => t('Workflow Status'), 'assignment' => t('Assignment'), 'numpending' => t('#P'), 'scheduled' => t('Scheduled'), 'seemore' => t('More Info')); $form["data_entry_area1"]['table_container']['orders'] = array('#title' => 'Select Orders to Cancel', '#type' => 'tableselect', '#header' => $header, '#options' => $options, '#empty' => t('No content available.')); $form["data_entry_area1"]['table_container']['orders']['#attributes']['class']['dataTable'] = 'dataTable'; $form['data_entry_area1']['action_buttons'] = array('#type' => 'item', '#prefix' => '<div class="raptor-action-buttons">', '#suffix' => '</div>', '#tree' => TRUE); $form['data_entry_area1']['action_buttons']['cancelorder'] = array('#type' => 'submit', '#value' => t('Cancel the Selected Orders')); $form['data_entry_area1']['action_buttons']['cancel'] = array('#type' => 'item', '#markup' => '<input class="raptor-dialog-cancel" type="button" value="Exit without Canceling any Orders" />'); return $form; }
/** * Context needs simple way of getting patient ID. * @return the patientid associated with an order */ public function getPatientIDFromTrackingID($sTrackingID) { $debugmsg = 'LOOK getPatientIDFromTrackingID for [' . $sTrackingID . ']'; error_log($debugmsg); //Get the IEN from the tracking ID $aParts = explode('-', $sTrackingID); if (count($aParts) == 2) { $nIEN = $aParts[1]; //siteid-IEN } else { if (count($aParts) == 1) { $nIEN = $aParts[0]; //Just IEN } else { $sMsg = 'Did NOT recognize format of tracking id [' . $sTrackingID . '] expected SiteID-IEN format!'; error_log($sMsg); throw new \Exception($sMsg); } } $debugmsg = 'LOOK getPatientIDFromTrackingID for IEN=[' . $nIEN . ']'; error_log($debugmsg); //Now lookup the patient ID $pid = NULL; $serviceResponse = MdwsUtils::parseDdrGetsEntry($this->makeQuery("ddrGetsEntry", array('file' => '75.1', 'iens' => $nIEN . ',', 'flds' => '*', 'flags' => 'IEN'))); foreach ($serviceResponse as $key => $value) { $pid = $value; break; //First one is the one we want. } if ($pid == NULL) { $msg = 'Expected to find a PID but did not find one for ticket [' . $sTrackingID . '] ' . '<br>Details...' . print_r($aParts, TRUE) . '<br>Soapresult>>>' . print_r($serviceResponse, TRUE); die($msg); } $debugmsg = 'LOOK Found PID as [' . $pid . ']'; error_log($debugmsg); return $pid; }
private function getWorklistItemFromMDWS($sTrackingID) { //error_log('DEBUG called getWorklistItemFromMDWS start with ['.$sTrackingID.']'); //Get the IEN from the tracking ID $aParts = explode('-', $sTrackingID); if (count($aParts) == 2) { $nIEN = $aParts[1]; //siteid-IEN } else { if (count($aParts) == 1) { $nIEN = $aParts[0]; //Just IEN } else { $sMsg = 'Did NOT recognize format of tracking id [' . $sTrackingID . '] expected SiteID-IEN format!'; error_log($sMsg); throw new \Exception($sMsg); } } $aResult = MdwsUtils::parseDdrGetsEntry($this->m_oContext->getMdwsClient()->makeQuery("ddrGetsEntry", array('file' => '75.1', 'iens' => $nIEN . ',', 'flds' => '*', 'flags' => 'IEN'))); //error_log('DEBUG called getWorklistItemFromMDWS done with result >>>'.print_r($aResult,TRUE)); return $aResult; }
/** * Write all the RAPTOR data of curent ticket into VISTA. * - Safety Checklist information * - General notes * @return boolean TRUE if success, else FALSE */ function commitDataToVista($nSiteID, $nIEN, $nUID, $sCWFS, $myvalues, $encounterString = NULL) { $bSuccess = TRUE; $errormsg = NULL; error_log('Starting commitDataToVista(' . $nSiteID . ',' . $nIEN . ') at ' . microtime()); $commit_dt = date("Y-m-d H:i:s", time()); $prev_commit_dt = $this->getDateMostRecentVistaCommitDate($nSiteID, $nIEN); //Verify the electronic sigature $eSig = $myvalues['commit_esig']; $oMdwsDao = $this->m_oContext->getMdwsClient(); //$bValidESig = MdwsUtils::validateEsig($oMdwsDao, $eSig); $bValidESig = $this->isValidEsig($eSig, $oMdwsDao); if (!$bValidESig) { $errormsg = 'Trouble committing ticket ' . $nSiteID . '-' . $nIEN . ' Safety Checklist note to Vista because invalid electronic signature'; $bSuccess = FALSE; } if ($bSuccess) { module_load_include('php', 'raptor_datalayer', 'core/AllUsers'); $oAllUsers = new \raptor\AllUsers(); try { $oMdwsDao = $this->m_oContext->getMdwsClient(); if ($encounterString == NULL) { $aVisits = \raptor\MdwsUtils::getVisits($oMdwsDao); if (is_array($aVisits) && count($aVisits) > 0) { if (isset($myvalues['selected_vid']) && $myvalues['selected_vid'] != '') { $selected_vid = $myvalues['selected_vid']; //vid_<LOCATIONID>_<TIMESTAMP> $vidparts = explode('_', $selected_vid); $locationId = $vidparts[1]; $visitTimestamp = $vidparts[2]; foreach ($aVisits as $aVisit) { if ($aVisit['locationId'] == $locationId && $aVisit['visitTimestamp'] == $visitTimestamp) { $encounterString = \raptor\MdwsUtils::getEncounterStringFromVisit($aVisit['visitTO']); //TODO ask the user to pick one!!! } } if ($encounterString == NULL) { die('Did NOT find an encounter string for $selected_vid=[' . $selected_vid . '] in ' . print_r($aVisits, TRUE)); } } else { throw new \Exception('Did not find any selected visit for the VISTA writeback!'); //drupal_set_message('TODO remove automatic selection of first visit for writeback. Used for writing this record!','warning'); //error_log('commitChecklistToVista got visits='.print_r($aVisits,TRUE).''); //$encounterString = \raptor\MdwsUtils::getEncounterStringFromVisit($aVisits[0]['visitTO']); //TODO ask the user to pick one!!! //error_log('commitChecklistToVista got most recent visit on ticket '.$nSiteID.'-'.$nIEN.' as encounterString=['.$encounterString.']'); } } else { drupal_set_message('Did NOT find any visits to which we can commit a note!', 'error'); $bSuccess = FALSE; } } //Write the note(s). $newNoteIen = NULL; try { $userDuz = $oMdwsDao->getDUZ(); //Pull values from database that have not yet been committed to VISTA $aChecklistData = array(); $this->addUncommittedChecklistDetailsToNotesArray($nSiteID, $nIEN, $oAllUsers, $prev_commit_dt, $aChecklistData); if (count($aChecklistData) > 0) { //Write the checklist note $newNoteIen = \raptor\MdwsUtils::writeRaptorSafetyChecklist($oMdwsDao, $aChecklistData, $encounterString, NULL); MdwsUtils::signNote($oMdwsDao, $newNoteIen, $userDuz, $eSig); } //Pull values from database that have not yet been committed to VISTA $noteTextArray = array(); $this->addUncommittedDetailsToNotesArray($nSiteID, $nIEN, $oAllUsers, $prev_commit_dt, $noteTextArray); if (count($noteTextArray) > 0) { //Yes, write the general note. $newGeneralNoteIen = \raptor\MdwsUtils::writeRaptorGeneralNote($oMdwsDao, $noteTextArray, $encounterString, NULL); MdwsUtils::signNote($oMdwsDao, $newGeneralNoteIen, $userDuz, $eSig); } } catch (\Exception $ex) { drupal_set_message('Trouble in commit because ' . $ex->getMessage(), 'error'); throw $ex; } if ($newNoteIen != NULL) { error_log('commitDataToVista got newNoteIen=[' . $newNoteIen . '] for encounter string=' . $encounterString); } } catch (\Exception $ex) { $errormsg = 'Trouble committing ticket ' . $nSiteID . '-' . $nIEN . ' Safety Checklist note to Vista because ' . $ex->getMessage(); throw $ex; } } if ($bSuccess) { //Okay, record that we successfully committed. try { db_insert('raptor_ticket_commit_tracking')->fields(array('siteid' => $nSiteID, 'IEN' => $nIEN, 'workflow_state' => $sCWFS, 'author_uid' => $nUID, 'commit_dt' => $commit_dt))->execute(); } catch (\Exception $ex) { $errormsg = 'Trouble committing ticket ' . $nSiteID . '-' . $nIEN . ' to raptor_ticket_commit_tracking because ' . $ex->getMessage(); throw $ex; } } if ($bSuccess) { drupal_set_message('Committed patient data to Vista'); } else { if ($errormsg != NULL) { error_log('failed commit to vista>>> ' . $errormsg); drupal_set_message($errormsg, 'error'); } else { drupal_set_message('Trouble committing patient data to Vista', 'error'); } } error_log('Finished commitDataToVista on ticket ' . $nSiteID . '-' . $nIEN . ' at ' . microtime()); return $bSuccess; }
private function logoutMdwsSubsystem() { try { $this->serializeNow('Logging out of MDWS', FALSE); $this->getMdwsClient()->disconnect(); return ""; } catch (\Exception $ex) { return array("ERRNUM" => MdwsUtils::getErrorNumberForException($ex), "ERRSUMMARY" => "Error on disconnect", "ERRDETAIL" => $ex); } }
public static function getVisits($mdwsDao, $fromDate = '', $toDate = '') { try { if (!isset($fromDate) || trim($fromDate) == '') { $oneMonthAgo = MdwsUtils::getVistaDate(-1 * DEFAULT_GET_VISIT_DAYS); $fromDate = MdwsUtils::covertVistaDateToYYYYMMDD($oneMonthAgo); // TODO - get today-30 date in this format } if (!isset($toDate) || trim($toDate) == '') { $today = MdwsUtils::getVistaDate(0); $toDate = MdwsUtils::covertVistaDateToYYYYMMDD($today); //$toDate = '20140718'; // TODO - get today's date in this format } $soapResult = $mdwsDao->makeQuery('getVisits', array('fromDate' => $fromDate, 'toDate' => $toDate)); //$soapResult = $mdwsDao->makeQuery('getAllMeds', NULL); //$soapResult = $mdwsDao->makeQuery('getAllMeds', null); // TODO - remove this line and uncomment line above $result = array(); //return $result; // TODO - remove this line if (!isset($soapResult) || !isset($soapResult->getVisitsResult) || isset($soapResult->getVisitsResult->fault)) { throw new \Exception('Invalid getVisits result -> ' . print_r($soapResult, true)); // . "\n<br>MdwsDao=". $mdwsDao // . "\n<br>Which of these is TRUE? 1=[".!isset($soapResult->getVisitsResult).'] or 2=['.isset($soapResult->getVisitsResult->fault).']' // . "\n<br>". 'RAW SOAP RESULT='.print_r($soapResult,TRUE)); } // check for zero results if (!isset($soapResult->getVisitsResult->count) || $soapResult->getVisitsResult->count == 0) { return $result; // TBD - return null or empty array? } // homogenize result of 1 to array $visitAry = is_array($soapResult->getVisitsResult->visits->VisitTO) ? $soapResult->getVisitsResult->visits->VisitTO : array($soapResult->getVisitsResult->visits->VisitTO); foreach ($visitAry as $visit) { $aryItem = array('locationName' => $visit->location->name, 'locationId' => $visit->location->id, 'visitTimestamp' => $visit->timestamp, 'visitTO' => $visit); $result[] = $aryItem; //Already acending //array_push($result, $aryItem); } $aSorted = array_reverse($result); //Now this is descrnding. return $aSorted; } catch (\Exception $ex) { throw new \Exception('Trouble in getVisits because ' . $ex); } }