if (sqlNumRows($qint) <= 0) { $rint = sqlQuery("SELECT option_id AS option_id FROM list_options WHERE list_id='drug_interval' ORDER BY ABS(option_id) DESC LIMIT 1"); sqlQuery("INSERT INTO list_options (list_id,option_id,title,seq) VALUES ('drug_interval',?,?,?)", array($rint['option_id'] + 1, $medArray[$i]['DosageFrequencyDescription'], $rint['option_id'] + 1)); $rint['option_id'] = $rint['option_id'] + 1; } } $check = sqlStatement("select * from prescriptions where prescriptionguid=? and patient_id=? and prescriptionguid is not null", array($medArray[$i]['PrescriptionGuid'], $medArray[$i]['ExternalPatientID'])); $prescription_id = ''; if (sqlNumRows($check) == 0) { $prescription_id = sqlInsert("insert into prescriptions \n (\n patient_id,provider_id,encounter,date_added,drug,drug_id,drug_info_erx,form,dosage,size,unit,route,`INTERVAL`,refills,note,`DATETIME`,\n `USER`,site,prescriptionguid,erx_source,rxnorm_drugcode\n )\n values\n (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,NOW(),?,?,?,'1',?)", array($medArray[$i]['ExternalPatientID'], $provider['id'], $encounter, substr($medArray[$i]['PrescriptionDate'], 0, 10), $medArray[$i]['DrugName'], $medArray[$i]['DrugID'], $medArray[$i]['DrugInfo'], $rin['option_id'], $medArray[$i]['DosageNumberDescription'], number($medArray[$i]['Strength']), $runit['option_id'], $rroute['option_id'], $rint['option_id'], $medArray[$i]['Refills'], $medArray[$i]['PrescriptionNotes'], $_SESSION['authUserID'], $medArray[$i]['SiteID'], $medArray[$i]['PrescriptionGuid'], $medArray[$i]['rxcui'])); $j++; } else { sqlQuery("update prescriptions set \n provider_id=?, drug=?, drug_id=?, drug_info_erx=?, form=?, dosage=?, size=? ,unit=?, route=?, `INTERVAL`=?, refills=?, note=?, \n `DATETIME`=NOW(),`USER`=?, site=? ,erx_source='1', rxnorm_drugcode=?, active='1'\n WHERE prescriptionguid=? AND patient_id=?\n ", array($provider['id'], $medArray[$i]['DrugName'], $medArray[$i]['DrugID'], $medArray[$i]['DrugInfo'], $rin['option_id'], $medArray[$i]['DosageNumberDescription'], number($medArray[$i]['Strength']), $runit['option_id'], $rroute['option_id'], $rint['option_id'], $medArray[$i]['Refills'], $medArray[$i]['PrescriptionNotes'], $_SESSION['authUserID'], $medArray[$i]['SiteID'], $medArray[$i]['rxcui'], $medArray[$i]['PrescriptionGuid'], $medArray[$i]['ExternalPatientID'])); } $result = sqlFetchArray($check); if ($result['id']) { $prescription_id = $result['id']; } processAmcCall('e_prescribe_amc', true, 'add', $medArray[$i]['ExternalPatientID'], 'prescriptions', $prescription_id); } if ($j != 0) { sqlQuery("update patient_data set soap_import_status=? where pid=?", array('2', $pid)); } if ($xml_response_count == 0) { echo htmlspecialchars(xl("Nothing to import for Prescription"), ENT_NOQUOTES); } elseif ($xml_response_count > 0) { echo htmlspecialchars(xl("Prescription History import successfully completed"), ENT_NOQUOTES); } ?>
function edit_action_process() { if ($_POST['process'] != "true") { return; } //print_r($_POST); // Stupid Smarty code treats empty values as not specified values. // Since active is a checkbox, represent the unchecked state as -1. if (empty($_POST['active'])) { $_POST['active'] = '-1'; } $this->prescriptions[0] = new Prescription($_POST['id']); parent::populate_object($this->prescriptions[0]); //echo $this->prescriptions[0]->toString(true); $this->prescriptions[0]->persist(); $_POST['process'] = ""; // If the "Prescribe and Dispense" button was clicked, then // redisplay as in edit_action() but also replicate the fee and // include a piece of javascript to call dispense(). // if ($_POST['disp_button']) { $this->assign("DISP_QUANTITY", $_POST['disp_quantity']); $this->assign("DISP_FEE", $_POST['disp_fee']); $this->assign("ENDING_JAVASCRIPT", "dispense();"); $this->_state = false; return $this->edit_action($this->prescriptions[0]->id); } // Set the AMC reporting flag (to record percentage of prescriptions that // are set as e-prescriptions) if (!empty($_POST['escribe_flag'])) { // add the e-prescribe flag processAmcCall('e_prescribe_amc', true, 'add', $this->prescriptions[0]->get_patient_id(), 'prescriptions', $this->prescriptions[0]->id); } else { // remove the e-prescribe flag processAmcCall('e_prescribe_amc', true, 'remove', $this->prescriptions[0]->get_patient_id(), 'prescriptions', $this->prescriptions[0]->id); } // TajEmo Work by CB 2012/05/29 02:58:29 PM to stop from going to send screen. Improves Work Flow // if ($this->prescriptions[0]->get_active() > 0) { // return $this->send_action($this->prescriptions[0]->id); // } $this->list_action($this->prescriptions[0]->get_patient_id()); exit; }
/** * Insert or update medications for current patient * @return integer Count of newly cached records */ public function insertUpdateMedications() { $store = $this->getStore(); $insertedRows = 0; $medArray = self::htmlFixXmlToArray($this->getPatientFullMedicationHistory6()->GetPatientFullMedicationHistory6Result->XmlResponse); $store->updatePrescriptionsActiveByPatientId($this->getPatientId()); if (is_array($medArray)) { foreach ($medArray as $med) { if ($med['DosageForm']) { $optionIdDosageForm = $this->insertMissingListOptions('drug_form', $med['DosageForm']); } else { $optionIdDosageForm = null; } if ($med['Route']) { $optionIdRoute = $this->insertMissingListOptions('drug_route', $med['Route']); } else { $optionIdRoute = null; } if ($med['StrengthUOM']) { $optionIdStrengthUOM = $this->insertMissingListOptions('drug_units', $med['StrengthUOM']); } else { $optionIdStrengthUOM = null; } if ($med['DosageFrequencyDescription']) { $optionIdFrequencyDescription = $this->insertMissingListOptions('drug_interval', $med['DosageFrequencyDescription']); } else { $optionIdFrequencyDescription = null; } $providerId = $store->selectUserIdByUserName($med['ExternalPhysicianID']); $check = $store->selectPrescriptionIdByGuidPatientId($med['PrescriptionGuid'], $med['ExternalPatientID']); $prescriptionId = ''; if (0 == sqlNumRows($check)) { $prescriptionId = $store->insertPrescriptions($med, $encounter, $providerId, $this->getAuthUserId(), $optionIdDosageForm, $optionIdRoute, $optionIdStrengthUOM, $optionIdFrequencyDescription); ++$insertedRows; setListTouch($this->getPatientId(), 'prescription_erx'); } else { $store->updatePrescriptions($med, $providerId, $this->getAuthUserId(), $optionIdDosageForm, $optionIdRoute, $optionIdStrengthUOM, $optionIdFrequencyDescription); } $result = sqlFetchArray($check); if ($result['id']) { $prescriptionId = $result['id']; } // Making sure only transmitted prescriptions entry added into amc_misc_data for eRx Numerator if (!empty($med['PharmacyNCPDP'])) { processAmcCall('e_prescribe_amc', true, 'add', $med['ExternalPatientID'], 'prescriptions', $prescriptionId); } if ($med['FormularyChecked'] === 'true') { processAmcCall('e_prescribe_chk_formulary_amc', true, 'add', $med['ExternalPatientID'], 'prescriptions', $prescriptionId); } } } return $insertedRows; }
<?php // Copyright (C) 2011 Brady Miller <*****@*****.**> // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License // as published by the Free Software Foundation; either version 2 // of the License, or (at your option) any later version. // // // This file contains functions to manage some AMC items. // //SANITIZE ALL ESCAPES $sanitize_all_escapes = true; // //STOP FAKE REGISTER GLOBALS $fake_register_globals = false; // require_once dirname(__FILE__) . "/../../interface/globals.php"; require_once dirname(__FILE__) . "/../amc.php"; // If all items are valid(ie. not empty) (note object_category and object_id and date_created can be empty), then proceed. if (!empty($_POST['amc_id']) && !empty($_POST['complete']) && !empty($_POST['mode']) && !empty($_POST['patient_id'])) { processAmcCall($_POST['amc_id'], $_POST['complete'], $_POST['mode'], $_POST['patient_id'], $_POST['object_category'], $_POST['object_id'], $_POST['date_created']); }
// new form if ($value !== '') { sqlStatement("INSERT INTO lbt_data " . "( form_id, field_id, field_value ) VALUES ( ?, ?, ? )", array($newid, $field_id, $value)); } } } if (!$transid) { $transid = $newid; } // Set the AMC sent records flag if (!empty($_POST['send_sum_flag'])) { // add the sent records flag processAmcCall('send_sum_amc', true, 'add', $pid, 'transactions', $transid); } else { // remove the sent records flag processAmcCall('send_sum_amc', true, 'remove', $pid, 'transactions', $transid); } if ($GLOBALS['concurrent_layout']) { $body_onload_code = "javascript:location.href='transactions.php';"; } else { $body_onload_code = "javascript:parent.Transactions.location.href='transactions.php';"; } } $CPR = 4; // cells per row function end_cell() { global $item_count, $cell_count; if ($item_count > 0) { echo "</td>"; $item_count = 0;