From 0f950fafb8a0f51d729e2d3d398e2c9b7e1b3ecc Mon Sep 17 00:00:00 2001 From: Rod Roark Date: Fri, 18 Jan 2013 15:11:16 -0800 Subject: [PATCH] Support browser downloads of orders and uploads of results. --- interface/orders/gen_hl7_order.inc.php | 11 ++++++++++ interface/orders/list_reports.php | 31 ++++++++++++++++++++++++---- interface/orders/load_compendium.php | 12 +++++++---- interface/orders/receive_hl7_results.inc.php | 4 ++-- 4 files changed, 48 insertions(+), 10 deletions(-) diff --git a/interface/orders/gen_hl7_order.inc.php b/interface/orders/gen_hl7_order.inc.php index 256325bce..ae87d2b09 100644 --- a/interface/orders/gen_hl7_order.inc.php +++ b/interface/orders/gen_hl7_order.inc.php @@ -442,6 +442,17 @@ function send_hl7_order($ppid, $out) { } } + else if ($protocol == 'DL') { + header("Pragma: public"); + header("Expires: 0"); + header("Cache-Control: must-revalidate, post-check=0, pre-check=0"); + header("Content-Type: application/force-download"); + header("Content-Disposition: attachment; filename=order_$msgid.hl7"); + header("Content-Description: File Transfer"); + echo $out; + exit; + } + // TBD: Insert "else if ($protocol == '???') {...}" to support other protocols. else { diff --git a/interface/orders/list_reports.php b/interface/orders/list_reports.php index a0dcf277f..b61e19fed 100644 --- a/interface/orders/list_reports.php +++ b/interface/orders/list_reports.php @@ -97,7 +97,7 @@ function openResults(orderid) { -
" . text($errmsg) . "
\n"; } +// Process uploaded file if there is one. +if (!empty($_FILES['userfile']['name'])) { // if upload was attempted + if (is_uploaded_file($_FILES['userfile']['tmp_name'])) { + $hl7 = file_get_contents($_FILES['userfile']['tmp_name']); + $msg = receive_hl7_results($hl7); + $message = xl('Upload processed successfully'); + if ($msg) { + $message = xl('Error processing upload') . ": " . $msg; + } + echo text($message) . "
\n"; + } + else { + echo "" . xlt('Upload failed!') . "
\n"; + } +} + $form_from_date = empty($_POST['form_from_date']) ? '' : trim($_POST['form_from_date']); $form_to_date = empty($_POST['form_to_date']) ? '' : trim($_POST['form_to_date']); // if (empty($form_to_date)) $form_to_date = $form_from_date; @@ -123,7 +139,7 @@ $form_patient = !empty($_POST['form_patient']);  : - ' onkeyup='datekeyup(this,mypcc)' onblur='dateblur(this,mypcc)' /> @@ -132,7 +148,7 @@ $form_patient = !empty($_POST['form_patient']); title='' />  : - ' onkeyup='datekeyup(this,mypcc)' onblur='dateblur(this,mypcc)' /> @@ -157,7 +173,14 @@ foreach (array('1' => xl('All'), '2' => xl('Reviewed'), '3' => xl('Unreviewed'), />Current Patient Only   - > + '> + : + + + + +   + > diff --git a/interface/orders/load_compendium.php b/interface/orders/load_compendium.php index 5132d1746..7b8bbefc3 100644 --- a/interface/orders/load_compendium.php +++ b/interface/orders/load_compendium.php @@ -357,6 +357,7 @@ if ($form_step == 1) { } } } + else if ($form_action == 2) { // load questions // Mark the vendor's current questions inactive. sqlStatement("UPDATE procedure_questions SET activity = 0 WHERE lab_id = ?", @@ -369,7 +370,9 @@ if ($form_step == 1) { // 1: Question Code // 2: Question // 3: Is Required (always "false") - // 4: Field Type ("Free Text", "Pre-Defined Text" or "Multiselect Pre-Defined Text") + // 4: Field Type ("Free Text", "Pre-Defined Text" or "Drop Down"; + // "Drop Down" was previously "Multiselect Pre-Defined Text" and + // indicates that more than one choice is allowed) // 5: Response (just one; the row is duplicated for each possible value) // while (!feof($fhcsv)) { @@ -385,11 +388,12 @@ if ($form_step == 1) { "lab_id = ? AND procedure_code = ? AND question_code = ?", array($lab_id, $pcode, $qcode)); - // If this is the first option value and it's Multiselect, then - // prepend '+;' to indicate start of a multi-select list. + // If this is the first option value and its type is Drop Down, then + // prepend '+;' to indicate the start of a multi-select list. if (!empty($options) && (empty($qrow['options']) || empty($qrow['activity'])) && - strpos($acsv[4], 'Multiselect') !== FALSE) + (strpos($acsv[4], 'Multiselect') !== FALSE) || + strpos($acsv[4], 'Drop') !== FALSE)) { $options = '+;' . $options; } diff --git a/interface/orders/receive_hl7_results.inc.php b/interface/orders/receive_hl7_results.inc.php index b45a80b6b..d8ef5be29 100644 --- a/interface/orders/receive_hl7_results.inc.php +++ b/interface/orders/receive_hl7_results.inc.php @@ -92,7 +92,7 @@ function rhl7ReportStatus($s) { * @param string &$hl7 The input HL7 text. * @return string Error text, or empty if no errors. */ -function receive_hl7_results(&$pprow, &$hl7) { +function receive_hl7_results(&$hl7) { if (substr($hl7, 0, 3) != 'MSH') { return xl('Input does not begin with a MSH segment'); } @@ -348,7 +348,7 @@ function poll_hl7_results(&$messages) { continue; } // Parse and process its contents. - $msg = receive_hl7_results($pprow, $hl7); + $msg = receive_hl7_results($hl7); if ($msg) { $messages[] = xl('Error processing file') . " '$file':" . $msg; ++$badcount; -- 2.11.4.GIT