Author: ClearHealth Inc. (www.clear-health.com) 2009 ClearHealth(TM), HealthCloud(TM), WebVista(TM) and their respective logos, icons, and terms are registered trademarks of ClearHealth Inc. Though this software is open source you MAY NOT use our trademarks, graphics, logos and icons without explicit permission. Derivitive works MUST NOT be primarily identified using our trademarks, though statements such as "Based on ClearHealth(TM) Technology" or "incoporating ClearHealth(TM) source code" are permissible. This file is licensed under the GPL V3, you can find a copy of that license by visiting: http://www.fsf.org/licensing/licenses/gpl.html ***************************************************************************
Пример #1
0
 public function printPres($id)
 {
     $pres = Prescription::where('id', $id)->first();
     $pres->detail;
     foreach ($pres->detail as $key => $value) {
         $pres->detail[$key]->getDrug;
         $pres->detail[$key]->get_drug->getUnit;
     }
     $pres->getPatient;
     $pres->get_patient->add;
     $pres->disease = implode(", ", Disease::whereIn('id', explode(',', $pres->disease))->lists('name'));
     $bill = $pres->is_free == 0 ? Config::get('constants.bill', 50000) : 0;
     $objPdf = new SellPDF();
     $objPdf->create($pres);
     $objPdf->Output();
     flush();
 }
Пример #2
0
 public function print_pres()
 {
     $id = Input::get('id');
     $prescription = Prescription::findOrFail($id);
     $date = date('j F, Y', strtotime($prescription->appointment->date));
     $time = date('H:i:s', strtotime($prescription->appointment->time));
     $doctor_name = $prescription->appointment->employee->name;
     $patient = $prescription->appointment->patient;
     $medicines = [];
     foreach (explode(',', $prescription->medicines) as $id) {
         array_push($medicines, Medicine::find($id));
     }
     $html = "<html><body>" . " <img src='./images/logo_new1.jpg'/>\n                <center>\n                    <h1><u> Prescription </u></h1>\n                </center>\n                <table style='border-collapse: collapse; margin-left:auto; margin-right:auto' cellpadding='7' border='1'>\n\n                    <tr>\n                        <td height='20'><label>Patient Name:</label></td>\n                        <td><label> {$patient->name} </label></td>\n                    </tr>\n                    <tr>\n                        <td height='20'><label>Patient ID:</label></td>\n                        <td><label> {$patient->patient_id} </label></td>\n                    </tr>\n                    <tr>\n                        <td height='20'><label>Visit Date:</label></td>\n                        <td><label> {$date} </label></td>\n                    </tr>\n                    <tr>\n                        <td height='20'><label>Visit Time:</label></td>\n                        <td><label> {$time} </label></td>\n                    </tr>\n                    <tr>\n                        <td height='20'><label>Doctor Name:</label></td>\n                        <td><label> {$doctor_name} </label></td>\n                    </tr>\n                    <tr>\n                        <td height='20'><label>Prescription Code:</label></td>\n                        <td><label> {$prescription->code} </label></td>\n                    </tr>\n                    <tr>\n                        <td height='20'> <label>Medicines:</label></td>\n                        <td><label>";
     foreach ($medicines as $index => $medicine) {
         $html .= $index + 1 . ' - ' . $medicine->name . "<br />";
     }
     $html .= "</label></td>\n                    </tr>\n                    <tr>\n                        <td height='20'><label>Note:</label></td>\n                        <td><label> {$prescription->note} </label></td>\n                    </tr>\n                    <tr>\n                        <td height='20'><label>Dignostic Procedure:</label></td>\n                        <td><label> {$prescription->procedure} </label></td>\n                    </tr>\n                </table>" . "</body></html>";
     return PDF::load($html, 'A4', 'portrait')->show($patient->name . ' Prescription');
 }
 function StoreLaboratoryItemToBill($pid, $labtest_nr, $batch_nr, $bill_number, $insurance, $pricelist_no)
 {
     global $db, $root_path;
     global $user_id, $sid, $local_user;
     $this->debug = false;
     if ($this->debug) {
         echo "<b>class_tz_billing::StoreLaboratoryItemToBill(pid: {$pid}, batch_nr: {$batch_nr}, bill_number: {$bill_number})</b><br>";
     }
     $this->debug ? $db->debug = TRUE : ($db->debug = FALSE);
     require_once $root_path . 'include/care_api_classes/class_tz_insurance.php';
     $insurance_tz = new Insurance_tz();
     $contract = $insurance_tz->CheckForValidContract($pid);
     // do we have pending issues of prescriptions?
     // read all items out of the prescription table
     if (empty($contract['id']) or $contract['id'] = '') {
         $contract['id'] = 0;
     }
     $user_id = $_SESSION['sess_user_name'];
     // old code
     //    $this->sql = "select
     //                          encounter_nr,
     //                          parameters
     //                  FROM $this->tbl_lab_requests
     //                  WHERE batch_nr=".$batch_nr;
     $this->sql = "select care_test_request_chemlabor.*, care_test_request_chemlabor_sub.sub_id AS prescrip_nr,\r\n\t\tcare_test_request_chemlabor_sub.item_id AS p_item_id,\r\n\t\tcare_tz_drugsandservices.item_description\r\n\r\n\t\tFROM care_test_request_chemlabor_sub\r\n\t\tINNER JOIN care_test_request_chemlabor\r\n\t\tON care_test_request_chemlabor.batch_nr=care_test_request_chemlabor_sub.batch_nr\r\n\t\tINNER JOIN care_tz_drugsandservices\r\n\t\tON care_test_request_chemlabor_sub.item_id = care_tz_drugsandservices.item_id\r\n\t\tWHERE care_test_request_chemlabor_sub.sub_id=" . $labtest_nr;
     if ($this->debug) {
         echo $this->sql;
     }
     $result = $db->Execute($this->sql);
     //echo $result;
     //echo $batch_nr;
     require_once $root_path . 'include/care_api_classes/class_prescription.php';
     $drg_obj = new Prescription();
     while ($row = $result->FetchRow()) {
         //echo $this->records['paramater_name'];
         //$this->chemlab_testname = $this->GetNameOfLAboratoryFromID($this->records['item_number']);
         //$this->price = $this->GetPriceOfLAboratoryItemFromID($this->records['id']);
         $price = $this->getPrice($row['p_item_id'], $pricelist_no);
         $name = $drg_obj->GetNameOfItem($row['p_item_id']);
         if ($this->debug) {
             echo 'Testname: ' . $row['item_description'] . '<br>';
         }
         if ($this->debug) {
             echo 'Encounter_nr:    ' . $row['encounter_nr'] . '<br>';
         }
         if ($this->debug) {
             echo 'Prescription_nr:    ' . $row['prescrip_nr'] . '<br>';
         }
         if ($this->debug) {
             echo 'labtest_nr:    ' . $row['sub_id'] . '=' . $batch_nr . '<br>';
         }
         if ($this->debug) {
             echo 'contract id : ' . $contract['id'] . '<br>';
         }
         $this->chemlab_amount = 1;
         $this->sql = "\r\n\t\t\tINSERT INTO {$this->tbl_bill_elements}  " . "\t(" . "\t\tnr, " . "\t\tdate_change, " . "\t\tis_labtest, " . "\t\tis_medicine, " . "\t\tis_radio_test, " . "\t\tis_comment, " . "\t\tis_paid, " . "\t\tamount, " . "\t\tamount_doc, " . "\t\ttimes_per_day, " . "\t\tdays, " . "\t\tprice, " . "\t\tdescription, " . "\t\tnotes, " . "\t\titem_number, " . "\t\tbalanced_insurance, " . "\t\tinsurance_id, " . "               prescriptions_nr, " . "\t\tUser_Id)" . "\r\n\t\t\tVALUES (" . $bill_number . ", '" . time() . "', 1, 0, 0, 0, 1, 1, 1, 0, 0, " . $price . ", '" . $row['item_description'] . "', 0, " . $row['p_item_id'] . ", '" . $insurance . "', '" . $contract['id'] . "', '" . $row['prescrip_nr'] . "','" . $user_id . "')";
         if ($this->debug) {
             echo $this->sql;
         }
         $db->Execute($this->sql);
         $this->sql = "UPDATE {$this->tbl_lab_requests_sub} SET bill_number=" . $bill_number . "\r\n\t\t \tWHERE batch_nr= {$batch_nr}\r\n\t\t \tAND item_id=" . $row[p_item_id];
         if ($this->debug) {
             echo $this->sql;
         }
         $db->Execute($this->sql);
         // Mark these lines in the table prescription as "still billed". We can do this
         // in that way: Insert the billing number where we can find this article again...
         //herausfinden, was geändert wird, damit Rechnung als billed gekennzeichnet wird
         //$this->sql="UPDATE $this->tbl_lab_requests SET bill_number='".$bill_number."', bill_status='pending' WHERE batch_nr=".$pid;
         //if ($this->debug) echo $this->sql;
         //$db->Execute($this->sql);
     }
     // end while
     //    $this->parameters = $db->Execute($this->sql);
     //    while ($this->records=$this->parameters->FetchRow()) {
     //      if ($this->debug) echo $this->records['parameters']."<br>";
     //      parse_str($this->records['parameters'],$this->parameter_array);
     //      while(list($this->index,$this->chemlab_amount) = each($this->parameter_array)) {
     //  				//Strip the string baggage off to get the task id
     //  				$this->chemlab_testindex = substr($this->index,5,strlen($this->index)-6);
     //
     //          $this->chemlab_testname = $this->GetNameOfLAboratoryFromID($this->chemlab_testindex);
     //
     //          $this->price = $this->GetPriceOfLAboratoryItemFromID($this->chemlab_testindex);
     //          if ($this->debug) echo "the name of chemlab is:".$this->chemlab_testname." with a amount of ".$this->chemlab_amount." and a price of ".$this->price."<br>";
     //          require_once($root_path.'include/care_api_classes/class_tz_insurance.php');
     //		  $insurance_tz = New Insurance_tz();
     //		  $contract = $insurance_tz->CheckForValidContract($pid);
     //          // we have it all... now we store it into the billing-elements-table
     //          $this->sql ="INSERT INTO $this->tbl_bill_elements (nr, date_change, is_labtest, is_medicine, amount, price, balanced_insurance, insurance_id, description)
     //								 			VALUES (".$bill_number.",".time().",1,0,".$this->chemlab_amount.",'".$this->price."','".$insurance."','".$contract['id']."','".$this->chemlab_testname."')";
     //				  if ($this->debug) echo $this->sql;
     //				  $db->Execute($this->sql);
     //				  $insurance=0;
     //			  }
     //    }
     //    // Mark these lines in the table prescription as "still billed". We can do this
     //    // in that way: Insert the billing number where we can find this article again...
     //    $this->sql="UPDATE $this->tbl_lab_requests SET bill_number='".$bill_number."' , bill_status='pending' WHERE batch_nr=".$batch_nr;
     //    $db->Execute($this->sql);
 }
Пример #4
0
 public function save(&$bill, &$prod, $main_provid = NULL, $main_supid = NULL, $default_warehouse = NULL, $mark_as_closed = false)
 {
     global $code_types;
     if (isset($main_provid) && $main_supid == $main_provid) {
         $main_supid = 0;
     }
     $copay_update = FALSE;
     $update_session_id = '';
     $ct0 = '';
     // takes the code type of the first fee type code type entry from the fee sheet, against which the copay is posted
     $cod0 = '';
     // takes the code of the first fee type code type entry from the fee sheet, against which the copay is posted
     $mod0 = '';
     // takes the modifier of the first fee type code type entry from the fee sheet, against which the copay is posted
     if (is_array($bill)) {
         foreach ($bill as $iter) {
             // Skip disabled (billed) line items.
             if (!empty($iter['billed'])) {
                 continue;
             }
             $id = $iter['id'];
             $code_type = $iter['code_type'];
             $code = $iter['code'];
             $del = !empty($iter['del']);
             $units = empty($iter['units']) ? 1 : intval($iter['units']);
             $price = empty($iter['price']) ? 0 : 0 + trim($iter['price']);
             $pricelevel = empty($iter['pricelevel']) ? '' : $iter['pricelevel'];
             $modifier = empty($iter['mod']) ? '' : trim($iter['mod']);
             $justify = empty($iter['justify']) ? '' : trim($iter['justify']);
             $notecodes = empty($iter['notecodes']) ? '' : trim($iter['notecodes']);
             $provid = empty($iter['provid']) ? 0 : intval($iter['provid']);
             $fee = sprintf('%01.2f', $price * $units);
             if (!$cod0 && $code_types[$code_type]['fee'] == 1) {
                 $mod0 = $modifier;
                 $cod0 = $code;
                 $ct0 = $code_type;
             }
             if ($code_type == 'COPAY') {
                 if ($fee < 0) {
                     $fee = $fee * -1;
                 }
                 if (!$id) {
                     // adding new copay from fee sheet into ar_session and ar_activity tables
                     $session_id = idSqlStatement("INSERT INTO ar_session " . "(payer_id, user_id, pay_total, payment_type, description, patient_id, payment_method, " . "adjustment_code, post_to_date) " . "VALUES ('0',?,?,'patient','COPAY',?,'','patient_payment',now())", array($_SESSION['authId'], $fee, $this->pid));
                     sqlBeginTrans();
                     $sequence_no = sqlQuery("SELECT IFNULL(MAX(sequence_no),0) + 1 AS increment FROM ar_activity WHERE " . "pid = ? AND encounter = ?", array($this->pid, $this->encounter));
                     SqlStatement("INSERT INTO ar_activity (pid, encounter, sequence_no, code_type, code, modifier, " . "payer_type, post_time, post_user, session_id, " . "pay_amount, account_code) VALUES (?,?,?,?,?,?,0,now(),?,?,?,'PCP')", array($this->pid, $this->encounter, $sequence_no['increment'], $ct0, $cod0, $mod0, $_SESSION['authId'], $session_id, $fee));
                     sqlCommitTrans();
                 } else {
                     // editing copay saved to ar_session and ar_activity
                     $session_id = $id;
                     $res_amount = sqlQuery("SELECT pay_amount FROM ar_activity WHERE pid=? AND encounter=? AND session_id=?", array($this->pid, $this->encounter, $session_id));
                     if ($fee != $res_amount['pay_amount']) {
                         sqlStatement("UPDATE ar_session SET user_id=?,pay_total=?,modified_time=now(),post_to_date=now() WHERE session_id=?", array($_SESSION['authId'], $fee, $session_id));
                         sqlStatement("UPDATE ar_activity SET code_type=?, code=?, modifier=?, post_user=?, post_time=now()," . "pay_amount=?, modified_time=now() WHERE pid=? AND encounter=? AND account_code='PCP' AND session_id=?", array($ct0, $cod0, $mod0, $_SESSION['authId'], $fee, $this->pid, $this->encounter, $session_id));
                     }
                 }
                 if (!$cod0) {
                     $copay_update = TRUE;
                     $update_session_id = $session_id;
                 }
                 continue;
             }
             # Code to create justification for all codes based on first justification
             if ($GLOBALS['replicate_justification'] == '1') {
                 if ($justify != '') {
                     $autojustify = $justify;
                 }
             }
             if ($GLOBALS['replicate_justification'] == '1' && $justify == '' && check_is_code_type_justify($code_type)) {
                 $justify = $autojustify;
             }
             if ($justify) {
                 $justify = str_replace(',', ':', $justify) . ':';
             }
             $auth = "1";
             $ndc_info = '';
             if (!empty($iter['ndcnum'])) {
                 $ndc_info = 'N4' . trim($iter['ndcnum']) . '   ' . $iter['ndcuom'] . trim($iter['ndcqty']);
             }
             // If the item is already in the database...
             if ($id) {
                 if ($del) {
                     $this->logFSMessage(xl('Service deleted'));
                     deleteBilling($id);
                 } else {
                     $tmp = sqlQuery("SELECT * FROM billing WHERE id = ? AND (billed = 0 or billed is NULL) AND activity = 1", array($id));
                     if (!empty($tmp)) {
                         $tmparr = array('code' => $code, 'authorized' => $auth);
                         if (isset($iter['units'])) {
                             $tmparr['units'] = $units;
                         }
                         if (isset($iter['price'])) {
                             $tmparr['fee'] = $fee;
                         }
                         if (isset($iter['pricelevel'])) {
                             $tmparr['pricelevel'] = $pricelevel;
                         }
                         if (isset($iter['mod'])) {
                             $tmparr['modifier'] = $modifier;
                         }
                         if (isset($iter['provid'])) {
                             $tmparr['provider_id'] = $provid;
                         }
                         if (isset($iter['ndcnum'])) {
                             $tmparr['ndc_info'] = $ndc_info;
                         }
                         if (isset($iter['justify'])) {
                             $tmparr['justify'] = $justify;
                         }
                         if (isset($iter['notecodes'])) {
                             $tmparr['notecodes'] = $notecodes;
                         }
                         foreach ($tmparr as $key => $value) {
                             if ($tmp[$key] != $value) {
                                 if ('fee' == $key) {
                                     $this->logFSMessage(xl('Price changed'));
                                 }
                                 if ('units' == $key) {
                                     $this->logFSMessage(xl('Quantity changed'));
                                 }
                                 if ('provider_id' == $key) {
                                     $this->logFSMessage(xl('Service provider changed'));
                                 }
                                 sqlStatement("UPDATE billing SET `{$key}` = ? WHERE id = ?", array($value, $id));
                             }
                         }
                     }
                 }
             } else {
                 if (!$del) {
                     $this->logFSMessage(xl('Service added'));
                     $code_text = lookup_code_descriptions($code_type . ":" . $code);
                     addBilling($this->encounter, $code_type, $code, $code_text, $this->pid, $auth, $provid, $modifier, $units, $fee, $ndc_info, $justify, 0, $notecodes, $pricelevel);
                 }
             }
         }
     }
     // end for
     // if modifier is not inserted during loop update the record using the first
     // non-empty modifier and code
     if ($copay_update == TRUE && $update_session_id != '' && $mod0 != '') {
         sqlStatement("UPDATE ar_activity SET code_type = ?, code = ?, modifier = ?" . " WHERE pid = ? AND encounter = ? AND account_code = 'PCP' AND session_id = ?", array($ct0, $cod0, $mod0, $this->pid, $this->encounter, $update_session_id));
     }
     // Doing similarly to the above but for products.
     if (is_array($prod)) {
         foreach ($prod as $iter) {
             // Skip disabled (billed) line items.
             if (!empty($iter['billed'])) {
                 continue;
             }
             $drug_id = $iter['drug_id'];
             $selector = empty($iter['selector']) ? '' : $iter['selector'];
             $sale_id = $iter['sale_id'];
             // present only if already saved
             $units = max(1, intval(trim($iter['units'])));
             $price = empty($iter['price']) ? 0 : 0 + trim($iter['price']);
             $pricelevel = empty($iter['pricelevel']) ? '' : $iter['pricelevel'];
             $fee = sprintf('%01.2f', $price * $units);
             $del = !empty($iter['del']);
             $rxid = 0;
             $warehouse_id = empty($iter['warehouse']) ? '' : $iter['warehouse'];
             $somechange = false;
             // If the item is already in the database...
             if ($sale_id) {
                 $tmprow = sqlQuery("SELECT ds.prescription_id, ds.quantity, ds.inventory_id, ds.fee, " . "ds.sale_date, di.warehouse_id " . "FROM drug_sales AS ds " . "LEFT JOIN drug_inventory AS di ON di.inventory_id = ds.inventory_id " . "WHERE ds.sale_id = ?", array($sale_id));
                 $rxid = 0 + $tmprow['prescription_id'];
                 if ($del) {
                     if (!empty($tmprow)) {
                         // Delete this sale and reverse its inventory update.
                         $this->logFSMessage(xl('Product deleted'));
                         sqlStatement("DELETE FROM drug_sales WHERE sale_id = ?", array($sale_id));
                         if (!empty($tmprow['inventory_id'])) {
                             sqlStatement("UPDATE drug_inventory SET on_hand = on_hand + ? WHERE inventory_id = ?", array($tmprow['quantity'], $tmprow['inventory_id']));
                         }
                     }
                     if ($rxid) {
                         sqlStatement("DELETE FROM prescriptions WHERE id = ?", array($rxid));
                     }
                 } else {
                     // Modify the sale and adjust inventory accordingly.
                     if (!empty($tmprow)) {
                         foreach (array('quantity' => $units, 'fee' => $fee, 'pricelevel' => $pricelevel, 'selector' => $selector, 'sale_date' => $this->visit_date) as $key => $value) {
                             if ($tmprow[$key] != $value) {
                                 $somechange = true;
                                 if ('fee' == $key) {
                                     $this->logFSMessage(xl('Price changed'));
                                 }
                                 if ('pricelevel' == $key) {
                                     $this->logFSMessage(xl('Price level changed'));
                                 }
                                 if ('selector' == $key) {
                                     $this->logFSMessage(xl('Template selector changed'));
                                 }
                                 if ('quantity' == $key) {
                                     $this->logFSMessage(xl('Quantity changed'));
                                 }
                                 sqlStatement("UPDATE drug_sales SET `{$key}` = ? WHERE sale_id = ?", array($value, $sale_id));
                                 if ($key == 'quantity' && $tmprow['inventory_id']) {
                                     sqlStatement("UPDATE drug_inventory SET on_hand = on_hand - ? WHERE inventory_id = ?", array($units - $tmprow['quantity'], $tmprow['inventory_id']));
                                 }
                             }
                         }
                         if ($tmprow['inventory_id'] && $warehouse_id && $warehouse_id != $tmprow['warehouse_id']) {
                             // Changing warehouse.  Requires deleting and re-adding the sale.
                             // Not setting $somechange because this alone does not affect a prescription.
                             $this->logFSMessage(xl('Warehouse changed'));
                             sqlStatement("DELETE FROM drug_sales WHERE sale_id = ?", array($sale_id));
                             sqlStatement("UPDATE drug_inventory SET on_hand = on_hand + ? WHERE inventory_id = ?", array($units, $tmprow['inventory_id']));
                             $tmpnull = null;
                             $sale_id = sellDrug($drug_id, $units, $fee, $this->pid, $this->encounter, empty($iter['rx']) ? 0 : $rxid, $this->visit_date, '', $warehouse_id, false, $tmpnull, $pricelevel, $selector);
                         }
                     }
                     // Delete Rx if $rxid and flag not set.
                     if ($GLOBALS['gbl_auto_create_rx'] && $rxid && empty($iter['rx'])) {
                         sqlStatement("UPDATE drug_sales SET prescription_id = 0 WHERE sale_id = ?", array($sale_id));
                         sqlStatement("DELETE FROM prescriptions WHERE id = ?", array($rxid));
                     }
                 }
             } else {
                 if (!$del) {
                     $somechange = true;
                     $this->logFSMessage(xl('Product added'));
                     $tmpnull = null;
                     $sale_id = sellDrug($drug_id, $units, $fee, $this->pid, $this->encounter, 0, $this->visit_date, '', $warehouse_id, false, $tmpnull, $pricelevel, $selector);
                     if (!$sale_id) {
                         die(xlt("Insufficient inventory for product ID") . " \"" . text($drug_id) . "\".");
                     }
                 }
             }
             // If a prescription applies, create or update it.
             if (!empty($iter['rx']) && !$del && ($somechange || empty($rxid))) {
                 // If an active rx already exists for this drug and date we will
                 // replace it, otherwise we'll make a new one.
                 if (empty($rxid)) {
                     $rxid = '';
                 }
                 // Get default drug attributes; prefer the template with the matching selector.
                 $drow = sqlQuery("SELECT dt.*, " . "d.name, d.form, d.size, d.unit, d.route, d.substitute " . "FROM drugs AS d, drug_templates AS dt WHERE " . "d.drug_id = ? AND dt.drug_id = d.drug_id " . "ORDER BY (dt.selector = ?) DESC, dt.quantity, dt.dosage, dt.selector LIMIT 1", array($drug_id, $selector));
                 if (!empty($drow)) {
                     $rxobj = new Prescription($rxid);
                     $rxobj->set_patient_id($this->pid);
                     $rxobj->set_provider_id(isset($main_provid) ? $main_provid : $this->provider_id);
                     $rxobj->set_drug_id($drug_id);
                     $rxobj->set_quantity($units);
                     $rxobj->set_per_refill($units);
                     $rxobj->set_start_date_y(substr($this->visit_date, 0, 4));
                     $rxobj->set_start_date_m(substr($this->visit_date, 5, 2));
                     $rxobj->set_start_date_d(substr($this->visit_date, 8, 2));
                     $rxobj->set_date_added($this->visit_date);
                     // Remaining attributes are the drug and template defaults.
                     $rxobj->set_drug($drow['name']);
                     $rxobj->set_unit($drow['unit']);
                     $rxobj->set_dosage($drow['dosage']);
                     $rxobj->set_form($drow['form']);
                     $rxobj->set_refills($drow['refills']);
                     $rxobj->set_size($drow['size']);
                     $rxobj->set_route($drow['route']);
                     $rxobj->set_interval($drow['period']);
                     $rxobj->set_substitute($drow['substitute']);
                     //
                     $rxobj->persist();
                     // Set drug_sales.prescription_id to $rxobj->get_id().
                     $oldrxid = $rxid;
                     $rxid = 0 + $rxobj->get_id();
                     if ($rxid != $oldrxid) {
                         sqlStatement("UPDATE drug_sales SET prescription_id = ? WHERE sale_id = ?", array($rxid, $sale_id));
                     }
                 }
             }
         }
     }
     // end for
     // Set default and/or supervising provider for the encounter.
     if (isset($main_provid) && $main_provid != $this->provider_id) {
         $this->logFSMessage(xl('Default provider changed'));
         sqlStatement("UPDATE form_encounter SET provider_id = ? WHERE pid = ? AND encounter = ?", array($main_provid, $this->pid, $this->encounter));
         $this->provider_id = $main_provid;
     }
     if (isset($main_supid) && $main_supid != $this->supervisor_id) {
         sqlStatement("UPDATE form_encounter SET supervisor_id = ? WHERE pid = ? AND encounter = ?", array($main_supid, $this->pid, $this->encounter));
         $this->supervisor_id = $main_supid;
     }
     // Save-and-Close is currently specific to Family Planning but might be more
     // generally useful.  It provides the ability to mark an encounter as billed
     // directly from the Fee Sheet, if there are no charges.
     if ($mark_as_closed) {
         $tmp1 = sqlQuery("SELECT SUM(ABS(fee)) AS sum FROM drug_sales WHERE " . "pid = ? AND encounter = ? AND billed = 0", array($this->pid, $this->encounter));
         $tmp2 = sqlQuery("SELECT SUM(ABS(fee)) AS sum FROM billing WHERE " . "pid = ? AND encounter = ? AND billed = 0 AND activity = 1", array($this->pid, $this->encounter));
         if ($tmp1['sum'] + $tmp2['sum'] == 0) {
             sqlStatement("update drug_sales SET billed = 1 WHERE " . "pid = ? AND encounter = ? AND billed = 0", array($this->pid, $this->encounter));
             sqlStatement("UPDATE billing SET billed = 1, bill_date = NOW() WHERE " . "pid = ? AND encounter = ? AND billed = 0 AND activity = 1", array($this->pid, $this->encounter));
         } else {
             // Would be good to display an error message here... they clicked
             // Save and Close but the close could not be done.  However the
             // framework does not provide an easy way to do that.
         }
     }
 }
<?php

require_once $root_path . 'include/inc_environment_global.php';
include_once $root_path . 'include/care_api_classes/class_prescription.php';
if (!isset($pres_obj)) {
    $pres_obj = new Prescription();
}
$app_types = $pres_obj->getAppTypes();
$pres_types = $pres_obj->getPrescriptionTypes();
require_once $root_path . 'include/care_api_classes/class_person.php';
$person_obj = new Person();
if (empty($encounter_nr) and !empty($pid)) {
    $encounter_nr = $person_obj->CurrentEncounter($pid);
}
$debug = FALSE;
if ($debug) {
    if (!empty($back_path)) {
        $backpath = $back_path;
    }
    echo "file: show_prescription<br>";
    if (!isset($externalcall)) {
        echo "internal call<br>";
    } else {
        echo "external call<br>";
    }
    echo "mode=" . $mode . "<br>";
    echo "show=" . $show . "<br>";
    echo "nr=" . $nr . "<br>";
    echo "breakfile: " . $breakfile . "<br>";
    echo "backpath: " . $backpath . "<br>";
    echo "pid:" . $pid . "<br>";
Пример #6
0
 public function newPrescription()
 {
     $input = Input::all();
     $pres = Prescription::where(DB::raw('DATE(created_at)'), '=', date('Y-m-d'))->where('patient', '=', $input['patient'])->first();
     $flagDetail = true;
     if (!Until::isNull($pres)) {
         if (Input::has('listDelete')) {
             PrescriptionDetail::whereIn('id', explode(",", $input['listDelete']))->delete();
         } else {
             if ($input['presSelect'] != $pres->id) {
                 PrescriptionDetail::where('prescription', '=', $pres->id)->delete();
                 $flagDetail = false;
             }
         }
     } else {
         $pres = new Prescription();
         $pres->is_no_drug = false;
         $flagDetail = false;
     }
     $pres->patient = $input['patient'];
     $pres->disease = $input['disease'];
     $pres->note = $input['note'];
     $pres->day = $input['dosage'];
     $pres->is_repres = $input['isRe'] == "false" ? 0 : 1;
     $pres->save();
     $inputDrug = json_decode($input['drugs']);
     foreach ($inputDrug as $drug) {
         $detail = new PrescriptionDetail();
         if (!Until::isNull($drug->idDetail) && $flagDetail) {
             $detail = PrescriptionDetail::where('id', '=', $drug->idDetail)->first();
         }
         $detail->prescription = $pres->id;
         $detail->drug = $drug->drugId;
         $detail->price = Drug::where('id', '=', $drug->drugId)->first()->price;
         switch ($drug->type) {
             case 1:
                 $detail->morning = $drug->morning;
                 $detail->lunch = $drug->lunch;
                 $detail->afternoon = $drug->afternoon;
                 $detail->night = $drug->night;
                 $detail->total = $drug->total;
                 break;
             case 2:
                 $detail->special = $drug->dosage;
             case 3:
             case 4:
                 $detail->total = $drug->fixed;
                 break;
         }
         $detail->save();
     }
     $pres = $this->createDataPrint($pres);
     return Response::json(array('pres' => $pres));
 }
 /**
  * Remove the specified prescription from storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function destroy($id)
 {
     Prescription::destroy($id);
     return Redirect::route('prescriptions.index');
 }
 function fragment_action($id, $sort = "")
 {
     if (empty($id)) {
         $this->function_argument_error();
         exit;
     }
     if (!empty($sort)) {
         $this->assign("prescriptions", Prescription::prescriptions_factory($id, $sort));
     } else {
         $this->assign("prescriptions", Prescription::prescriptions_factory($id));
     }
     //print_r(Prescription::prescriptions_factory($id));
     $this->display($GLOBALS['template_dir'] . "prescription/" . $this->template_mod . "_fragment.html");
 }
Пример #9
0
<?php

/*------begin------ This protection code was suggested by Luki R. luki@karet.org ---- */
if (preg_match('/save_immunization.inc.php/i', $_SERVER['PHP_SELF'])) {
    die('<meta http-equiv="refresh" content="0; url=../">');
}
require_once $root_path . 'include/care_api_classes/class_prescription.php';
if (!isset($obj)) {
    $obj = new Prescription();
}
require_once $root_path . 'include/inc_date_format_functions.php';
if (!isset($db) || !$db) {
    include_once $root_path . 'include/inc_db_makelink.php';
}
if ($dblink_ok) {
    switch ($mode) {
        case 'create':
            $_POST['prescribe_date'] = @formatDate2STD($_POST['prescribe_date'], $date_format);
            $obj->setDataArray($_POST);
            if ($obj->insertDataFromInternalArray()) {
                header("location:" . $thisfile . URL_REDIRECT_APPEND . "&target={$target}&pid=" . $_SESSION['sess_pid']);
                exit;
            } else {
                echo "<br>{$LDDbNoSave}";
            }
            break;
        case 'update':
            $_POST['date'] = @formatDate2STD($_POST['date'], $date_format);
            $obj->setDataArray($_POST);
            $obj->where = ' nr=' . $imm_nr;
            if ($obj->updateDataFromInternalArray($dept_nr)) {
<?php

require_once $root_path . 'include/care_api_classes/class_prescription.php';
if (!isset($pres_obj)) {
    $pres_obj = new Prescription();
}
require_once $root_path . 'include/care_api_classes/class_person.php';
$person_obj = new Person();
require_once $root_path . 'include/care_api_classes/class_encounter.php';
require_once $root_path . 'include/care_api_classes/class_tz_billing.php';
require_once $root_path . 'include/care_api_classes/class_tz_insurance.php';
$bill = new Bill();
$thisfile = basename($_SERVER['PHP_SELF']);
echo '<script type="text/javascript">';
echo 'function reCalculate(tl,s,t,d){';
echo '	tl.value= s.value*t.value*d.value;';
echo '}';
echo '</script>';
if (empty($encounter_nr) and !empty($pid)) {
    $encounter_nr = $person_obj->CurrentEncounter($pid);
}
$debug = FALSE;
if ($debug) {
    if (!empty($back_path)) {
        $backpath = $back_path;
    }
    echo "file: show_prescription<br>";
    if (!isset($externalcall)) {
        echo "internal call<br>";
    } else {
        echo "external call<br>";
     //$item_id = $drg_obj->GetItemIDByNumber('LAB'.$value);
     // TODO: Set here the function to store it as bill - element -> drug_class='lab'
     //$prescription_obj->insert_prescription($pn,$item_id);
     //new code:
     $sqlInner1 = "SELECT * from care_tz_laboratory_param WHERE id='" . $parsedParamList['paramater_name'] . "'";
     $resultInner1 = $db->Execute($sqlInner1);
     $row1 = $resultInner1->FetchRow();
     //echo 'id='.$row1['id'];
     $testname = str_replace("'", "\\'", $row1['name']);
     $sqlInner2 = "SELECT * from care_tz_laboratory_tests WHERE name='" . $testname . "'";
     $resultInner2 = $db->Execute($sqlInner2);
     //echo $resultInner;
     $row2 = $resultInner2->FetchRow();
     $pre_item_id = $row2['id'];
     $item_id = 'LAB' . $pre_item_id;
     $pres_obj = new Prescription();
     $pres_obj->insert_prescription($pn, $item_id, 1);
     //				 echo 'x'.$item_id.'x';
     while (list($u, $v) = each($param_array)) {
         // Get for each lab-request-id the item_id of this lab-test out of drugsandservices-table
         $item_id = $prescription_obj->GetItemIDByNumber('LAB' . $v);
         // TODO: Set here the function to store it as bill - element -> drug_class='lab'
         $prescription_obj->insert_prescription($pn, $item_id);
     }
 }
 // end of while (list($u,$v) = each ($param_array))
 // Load the visual signalling functions
 include_once $root_path . 'include/inc_visual_signalling_fx.php';
 // Set the visual signal
 setEventSignalColor($pn, SIGNAL_COLOR_DIAGNOSTICS_REQUEST);
 //print_r($data);
     $ct = 0;
 }
 if (empty($sono)) {
     $sono = 0;
 }
 if (empty($mammograph)) {
     $mammograph = 0;
 }
 if (empty($mrt)) {
     $mrt = 0;
 }
 if (empty($nuclear)) {
     $nuclear = 0;
 }
 $sql = "INSERT INTO care_test_request_" . $db_request_table . "\n\t\t\t(batch_nr, encounter_nr, dept_nr,\n\t\t\txray, ct, sono, mammograph, mrt, nuclear,\n\t\t\t if_patmobile, if_allergy, if_hyperten, if_pregnant,\n\t\t\tclinical_info, test_request, number_of_tests, send_date,\n\t\t\tsend_doctor, status,\n\t\t\thistory,\n\t\t\tcreate_id,\n\t\t\tcreate_time,\n\t\t\tresults)\n\t\t\tVALUES\n\t\t\t(\n\t\t\t'" . $batch_nr . "','" . $pn . "','" . $dept_nr . "',\n\t\t\t'" . $xray . "','" . $ct . "','" . $sono . "','" . $mammograph . "','" . $mrt . "','" . $nuclear . "',\n\t\t\t'" . $if_patmobile . "','" . $if_allergy . "','" . $if_hyperten . "','" . $if_pregnant . "',\n\t\t\t'" . htmlspecialchars($clinical_info) . "','" . htmlspecialchars($test_request) . "','" . $number_of_tests . "','" . date('Y-m-d') . "',\n\t\t\t'" . htmlspecialchars($send_doctor) . "', 'pending',\n\t\t\t'Create: " . date('Y-m-d H:i:s') . " = " . $_SESSION['sess_user_name'] . "\n',\n\t\t\t'" . $_SESSION['sess_user_name'] . "',\n\t\t\t'" . date('YmdHis') . "',\n\t\t\t''\n\t\t\t)";
 $presc_obj = new Prescription();
 //$drug_list_id = $presc_obj-> GetItemIDByName($_POST['test_request']);
 $presc_obj->insert_prescription_Radio($pn, $_POST['test_request'], $_POST['number_of_tests']);
 if ($ergebnis = $core->Transact($sql)) {
     //echo $sql;
     // Load the visual signalling functions
     include_once $root_path . 'include/inc_visual_signalling_fx.php';
     // Set the visual signal
     setEventSignalColor($pn, SIGNAL_COLOR_RADIOLOGY_REQUEST);
     header("location:" . $root_path . "modules/laboratory/labor_test_request_aftersave.php?sid={$sid}&lang={$lang}&edit={$edit}&saved=insert&pn={$pn}&station={$station}&user_origin={$user_origin}&status={$status}&target={$target}&noresize={$noresize}&batch_nr={$batch_nr}");
     exit;
 } else {
     echo "<p>{$sql}<p>{$LDDbNoSave}";
     $mode = "";
 }
 break;
<?php

require_once $root_path . 'include/inc_environment_global.php';
include_once $root_path . 'include/care_api_classes/class_prescription.php';
if (!isset($pres_obj)) {
    $pres_obj = new Prescription();
}
$app_types = $pres_obj->getAppTypes();
$pres_types = $pres_obj->getPrescriptionTypes();
$debug = FALSE;
if ($debug) {
    echo "External_call:" . $externalcall;
}
$mode = 'edit';
echo '<br><br><br>
      <table width="70%" border="0" bgcolor=#ffffdd align="center">
      <tr> 
        <td width="20%">date</td>
        <td width="40%">item description</td>
        <td width="10%">dosage</td>
        <td width="10%">&nbsp;</td>
        <td width="10%">edit</td>
        <td width="10%">delete</td>
      </tr>
      <tr> 
        <td>&nbsp;</td>
        <td>&nbsp;</td>
        <td>&nbsp;</td>
        <td>&nbsp;</td>
        <td>&nbsp;</td>
        <td>&nbsp;</td>
Пример #14
0
 public static function handlereFaxSourceData(Audit $audit)
 {
     $data = array();
     if ($audit->objectClass != 'ESignature') {
         return $data;
     }
     $eSignature = new ESignature();
     $eSignature->eSignatureId = $audit->objectId;
     $eSignature->populate();
     if ($eSignature->objectClass != 'Medication') {
         return $data;
     }
     $data['_audit'] = $audit;
     $medication = new Medication();
     $medication->medicationId = $eSignature->objectId;
     $medication->populate();
     $data['transmissionId'] = (int) $medication->medicationId;
     $data['recipients'] = array();
     $patient = new Patient();
     $patient->personId = $medication->personId;
     $patient->populate();
     $pharmacyId = $patient->defaultPharmacyId;
     $provider = new Provider();
     $provider->personId = $medication->prescriberPersonId;
     $provider->populate();
     // recipients MUST be a pharmacy?
     $pharmacy = new Pharmacy();
     $pharmacy->pharmacyId = $pharmacyId;
     $pharmacy->populate();
     //$data['recipients'][] = array('fax'=>$pharmacy->Fax,'name'=>$pharmacy->StoreName,'company'=>$pharmacy->StoreName);
     // temporarily comment out the above recipient and use the hardcoded recipient
     $data['recipients'][] = array('fax' => '6022976632', 'name' => 'Jay Walker', 'company' => 'ClearHealth Inc.');
     $prescription = new Prescription();
     $prescription->prescriberName = $provider->firstName . ' ' . $provider->lastName . ' ' . $provider->title;
     $prescription->prescriberStateLicenseNumber = $provider->stateLicenseNumber;
     $prescription->prescriberDeaNumber = $provider->deaNumber;
     // Practice Info
     $primaryPracticeId = $provider->primaryPracticeId;
     $practice = new Practice();
     $practice->id = $primaryPracticeId;
     $practice->populate();
     $address = $practice->primaryAddress;
     $prescription->practiceName = $practice->name;
     $prescription->practiceAddress = $address->line1 . ' ' . $address->line2;
     $prescription->practiceCity = $address->city;
     $prescription->practiceState = $address->state;
     $prescription->practicePostalCode = $address->postalCode;
     $attachment = new Attachment();
     $attachment->attachmentReferenceId = $provider->personId;
     $attachment->populateWithAttachmentReferenceId();
     if ($attachment->attachmentId > 0) {
         $db = Zend_Registry::get('dbAdapter');
         $sqlSelect = $db->select()->from('attachmentBlobs')->where('attachmentId = ?', (int) $attachment->attachmentId);
         if ($row = $db->fetchRow($sqlSelect)) {
             $tmpFile = tempnam('/tmp', 'ch30_sig_');
             file_put_contents($tmpFile, $row['data']);
             $signatureFile = $tmpFile;
             $prescription->prescriberSignature = $signatureFile;
         }
     }
     $prescription->patientName = $patient->lastName . ', ' . $patient->firstName;
     $address = $patient->homeAddress;
     $prescription->patientAddress = $address->line1 . ' ' . $address->line2;
     $prescription->patientCity = $address->city;
     $prescription->patientState = $address->state;
     $prescription->patientPostalCode = $address->postalCode;
     $prescription->patientDateOfBirth = date('m/d/Y', strtotime($patient->dateOfBirth));
     $prescription->medicationDatePrescribed = date('m/d/Y', strtotime($medication->datePrescribed));
     $prescription->medicationDescription = $medication->description;
     $prescription->medicationComment = $medication->comment;
     $prescription->medicationQuantity = $medication->quantity;
     $prescription->medicationRefills = $medication->refills;
     $prescription->medicationDirections = $medication->directions;
     $prescription->medicationSubstitution = $medication->substitution;
     $prescription->create();
     $filename = $prescription->imageFile;
     $fileType = pathinfo($filename, PATHINFO_EXTENSION);
     $data['files'] = array();
     $contents = file_get_contents($filename);
     unlink($filename);
     $data['files'][] = array('contents' => base64_encode($contents), 'type' => $fileType);
     return $data;
 }
     $ct = 0;
 }
 if (empty($sono)) {
     $sono = 0;
 }
 if (empty($mammograph)) {
     $mammograph = 0;
 }
 if (empty($mrt)) {
     $mrt = 0;
 }
 if (empty($nuclear)) {
     $nuclear = 0;
 }
 $sql = "INSERT INTO care_test_request_" . $db_request_table . "\r\n\t\t\t(batch_nr, encounter_nr, dept_nr,\r\n\t\t\txray, ct, sono, mammograph, mrt, nuclear,\r\n\t\t\t if_patmobile, if_allergy, if_hyperten, if_pregnant,\r\n\t\t\tclinical_info, test_request, number_of_tests, send_date,\r\n\t\t\tsend_doctor, status,\r\n\t\t\thistory,\r\n\t\t\tcreate_id,\r\n\t\t\tcreate_time,\r\n\t\t\tresults)\r\n\t\t\tVALUES\r\n\t\t\t(\r\n\t\t\t'" . $batch_nr . "','" . $pn . "','" . $dept_nr . "',\r\n\t\t\t'" . $xray . "','" . $ct . "','" . $sono . "','" . $mammograph . "','" . $mrt . "','" . $nuclear . "',\r\n\t\t\t'" . $if_patmobile . "','" . $if_allergy . "','" . $if_hyperten . "','" . $if_pregnant . "',\r\n\t\t\t'" . htmlspecialchars($clinical_info) . "','" . htmlspecialchars($test_request) . "','" . $number_of_tests . "','" . date('Y-m-d') . "',\r\n\t\t\t'" . htmlspecialchars($send_doctor) . "', 'pending',\r\n\t\t\t'Create: " . date('Y-m-d H:i:s') . " = " . $_SESSION['sess_user_name'] . "\n',\r\n\t\t\t'" . $_SESSION['sess_user_name'] . "',\r\n\t\t\t'" . date('YmdHis') . "',\r\n\t\t\t''\r\n\t\t\t)";
 $presc_obj = new Prescription();
 $drug_list_id = $presc_obj->GetItemIDByName($_POST['test_request']);
 $presc_obj->insert_prescription_Radio($pn, $drug_list_id, $_POST['number_of_tests']);
 if ($ergebnis = $core->Transact($sql)) {
     //echo $sql;
     // Load the visual signalling functions
     include_once $root_path . 'include/inc_visual_signalling_fx.php';
     // Set the visual signal
     setEventSignalColor($pn, SIGNAL_COLOR_RADIOLOGY_REQUEST);
     header("location:" . $root_path . "modules/laboratory/labor_test_request_aftersave.php?sid={$sid}&lang={$lang}&edit={$edit}&saved=insert&pn={$pn}&station={$station}&user_origin={$user_origin}&status={$status}&target={$target}&noresize={$noresize}&batch_nr={$batch_nr}");
     exit;
 } else {
     echo "<p>{$sql}<p>{$LDDbNoSave}";
     $mode = "";
 }
 break;
Пример #16
0
        $checked = '';
        if ($result['category'] == 'prescriptions' && $count < 4) {
            $count++;
            $checked = 'checked';
        }
        echo "<div>\n";
        echo "<input type=checkbox name='ch_" . $result['id'] . "' {$checked}><span>" . $result['category'] . '</span>:' . $result['subcategory'] . ':' . $result['item'] . "<br/>\n";
        echo "</div>\n";
    }
    echo "</div>\n";
    echo "<div id='log'>\n";
    //temp for debugging
    echo "</div>\n";
    //create Prescription object for the purpose of drawing data from the Prescription
    //table for those who wish to do so
    $rxarray = Prescription::prescriptions_factory($_SESSION['pid']);
    //now give a choice of drugs from the Prescription table
    foreach ($rxarray as $val) {
        echo "<input type=checkbox name='chrx_" . $val->id . "'>" . $val->drug . ':' . $val->start_date . "<br/>\n";
    }
    ?>
	
<?php 
    if ($_GET['letterhead']) {
        ?>
<input type=submit name='print_pdf' value='<?php 
        xl('Print (PDF)', 'e');
        ?>
'>
<?php 
    }
<?php

require_once $root_path . 'include/inc_environment_global.php';
include_once $root_path . 'include/care_api_classes/class_prescription.php';
if (!isset($pres_obj)) {
    $pres_obj = new Prescription();
}
$app_types = $pres_obj->getAppTypes();
$pres_types = $pres_obj->getPrescriptionTypes();
if (empty($externalcall)) {
    $externalcall = "FALSE";
}
$debug = FALSE;
if ($debug) {
    echo "External_call:" . $externalcall;
}
$mode = 'edit';
require_once $root_path . "/include/inc_js_edit_prescription.php";
if (empty($change)) {
    echo '<br><br><br>
        <table width="70%" border="0" bgcolor=#ffffdd align="center">
        <tr> 
          <td width="20%">date</td>
          <td width="40%">item description</td>
          <td width="10%">dosage</td>
          <td width="10%">&nbsp;</td>
          <td width="10%">edit</td>
        </tr>
        <tr> 
          <td>&nbsp;</td>
          <td>&nbsp;</td>
<?php

require_once $root_path . 'include/care_api_classes/class_prescription.php';
$presc_obj = new Prescription();
/*------begin------ This protection code was suggested by Luki R. luki@karet.org ---- */
if (preg_match('/save_admission_data.inc.php/i', $PHP_SELF)) {
    die('<meta http-equiv="refresh" content="0; url=../">');
}
$debug = false;
$debug ? $db->debug = TRUE : ($db->debug = FALSE);
if ($debug) {
    if (!isset($externalcall)) {
        echo "internal call<br>";
    } else {
        echo "external call<br>";
    }
    echo "mode=" . $mode . "<br>";
    echo "show=" . $show . "<br>";
    echo "nr=" . $nr . "<br>";
    echo "breakfile: " . $breakfile . "<br>";
    echo "backpath: " . $backpath . "<br>";
    echo "pid:" . $pid . "<br>";
    echo "encounter_nr:" . $encounter_nr;
    echo "prescrServ: " . $_GET['prescrServ'];
}
$i = 0;
if ($mode == 'delete') {
    $arr_item_number[0] = $nr;
}
foreach ($arr_item_number as $item_number) {
    $dosage = $arr_dosage[$i];
Пример #19
0
* Copyright 2002,2003,2004,2005,2006 Elpidio Latorilla
* elpidio@care2x.org,
*
* See the file "copy_notice.txt" for the licence notice
*/
define('LANG_FILE', 'lab.php');
$local_user = '******';
require_once $root_path . 'include/inc_front_chain_lang.php';
$thisfile = basename($_SERVER['PHP_SELF']);
//$db->debug=true;
# Create lab object
require_once $root_path . 'include/care_api_classes/class_lab.php';
$lab_obj = new Lab();
# Create presc object
require_once $root_path . 'include/care_api_classes/class_prescription.php';
$pres_obj = new Prescription();
//create a new drugs and services object
require_once $root_path . 'include/care_api_classes/class_tz_drugsandservices.php';
$das_obj = new DrugsAndServices();
# Load the date formatter */
function cleanString($wild)
{
    return preg_replace("/[^[:alnum:]+]/", "_", $wild);
}
if (isset($mode) && !empty($mode)) {
    if ($mode == 'save') {
        # Save the nr
        if (empty($_POST['status'])) {
            $_POST['status'] = ' ';
        }
        $_POST['modify_id'] = $_SESSION['sess_user_name'];
Пример #20
0
 public function newPrescription()
 {
     $input = Input::all();
     $pres = Prescription::where(DB::raw('DATE(created_at)'), '=', date('Y-m-d'))->where('patient', '=', $input['patient'])->first();
     $isSell = 0;
     if (!Until::isNull($pres)) {
         if (Input::has('listDelete')) {
             PrescriptionDetail::whereIn('id', $input['listDelete'])->delete();
         } else {
             if ($input['presSelect'] != $pres->id) {
                 PrescriptionDetail::where('prescription', '=', $pres->id)->delete();
             }
         }
         $isSell = $pres->is_sell;
     } else {
         $pres = new Prescription();
         $pres->is_no_drug = false;
     }
     $pres->patient = $input['patient'];
     $pres->disease = $input['disease'];
     $pres->note = $input['note'];
     $pres->day = $input['dosage'];
     $pres->is_free = Until::isNull($input['isFree']) ? 0 : 1;
     $pres->is_repres = Until::isNull($input['isRe']) ? 1 : 0;
     $pres->is_sell = $isSell;
     $pres->save();
     foreach ($input['drugs'] as $drug) {
         $detail = new PrescriptionDetail();
         if (!Until::isNull($drug['idDetail'])) {
             $detail = PrescriptionDetail::where('id', '=', $drug['idDetail'])->first();
         }
         $detail->prescription = $pres->id;
         $detail->drug = $drug['drugId'];
         $detail->price = Drug::where('id', '=', $drug['drugId'])->first()->price;
         switch ($drug['type']) {
             case 1:
                 $detail->morning = $drug['morning'];
                 $detail->lunch = $drug['lunch'];
                 $detail->afternoon = $drug['afternoon'];
                 $detail->night = $drug['night'];
                 $detail->total = $drug['total'];
                 break;
             case 3:
                 $detail->special = $drug['dosage'];
                 $detail->total = $drug['fixed'];
             case 2:
             case 4:
                 $detail->total = $drug['fixed'];
                 break;
         }
         $detail->save();
     }
     return Response::json('true');
 }
Пример #21
0
 Route::resource('checkupfees', 'CheckupfeesController');
 Route::resource('testfees', 'TestfeesController');
 // PDF Reports
 Route::any('print_pres', ['uses' => 'HomeController@print_pres']);
 // Prescription PDF
 Route::any('print_test', ['uses' => 'HomeController@print_test']);
 // Test Report PDF
 // Prints
 Route::get('app_pres_print', function () {
     $appointments = Appointment::has('prescription')->get();
     $flag = "pres_print";
     return View::make('appointment_based_data.appointments', compact('appointments', 'flag'));
 });
 Route::get('pres_print', function () {
     $id = Input::get('id');
     $prescription = Prescription::findOrFail($id);
     $date = date('j F, Y', strtotime($prescription->appointment->date));
     $time = date('H:i:s', strtotime($prescription->appointment->time));
     $doctor_name = $prescription->appointment->employee->name;
     $patient = $prescription->appointment->patient;
     $medicines = [];
     foreach (explode(',', $prescription->medicines) as $id) {
         array_push($medicines, Medicine::find($id));
     }
     return View::make('printables.prescription_print', compact('prescription', 'date', 'time', 'doctor_name', 'patient', 'medicines'));
 });
 Route::get('app_test_print', function () {
     $appointments = Appointment::has('labtests')->get();
     $flag = "test_print";
     return View::make('appointment_based_data.appointments', compact('appointments', 'flag'));
 });