Display fix: width in manila for demographics (#1909)
[openemr.git] / library / lab.inc
bloba6404454a72857188e3d469d6a159d8671976b75
1 <?php
3 /**
4  * patient.inc includes functions for manipulating patient information.
5  *
6  * @package OpenEMR
7  * @link    http://www.open-emr.org
8  * @author  Sherwin Gaddis <sherwingaddis@gmail.com>
9  * @copyright Copyright (c) 2016-2017 Sherwin Gaddis <sherwingaddis@gmail.com>
10  * @license https://github.com/openemr/openemr/blob/master/LICENSE GNU General Public License 3
11  */
14 /**
15  * @param $pid
16  * @param $encounter
17  * @return mixed
18  */
19 function fetchProcedureId($pid, $encounter)
21     $sql = "SELECT procedure_order_id FROM procedure_order WHERE patient_id = ? AND encounter_id = ?";
22     $res = sqlQuery($sql, array($pid,$encounter));
24     return $res['procedure_order_id'];
27 /**
28  * @param $oid
29  * @param $encounter
30  * @return array
31  */
32 function getProceduresInfo($oid, $encounter)
35     $sql = "SELECT pc.procedure_order_id, pc.procedure_order_seq, pc.procedure_code, pc.procedure_name, 
36          pc.diagnoses, po.provider_id, po.date_collected,po.lab_id, po.clinical_hx, po.date_ordered, po.patient_instructions, po.specimen_type, 
37          po.specimen_location, po.specimen_volume
38      FROM procedure_order_code AS pc  
39      JOIN procedure_order AS po ON pc.procedure_order_id 
40          AND po.procedure_order_id 
41      WHERE pc.procedure_order_id = ? 
42          AND po.encounter_id = ?
43          AND po.procedure_order_id = ?";
45     $listOrders = sqlStatement($sql, array($oid,$encounter,$oid));
46     $orders = array();
47     while ($rows = sqlFetchArray($listOrders)) {
48         $orders[] = $rows['procedure_order_id'];
49         $orders[] = $rows['procedure_order_seq'];
50         $orders[] = $rows['procedure_code'];
51         $orders[] = $rows['procedure_name'];
52         $orders[] = $rows['diagnoses'];
53         $orders[] = $rows['provider_id'];
54         $orders[] = $rows['date_collected'];
55         $orders[] = $rows['lab_id'];            //procedure_order.ppid
56         $orders[] = $rows['clinical_hx'];
57         $orders[] = $rows['date_ordered'];
58         $orders[] = $rows['patient_instructions'];
59         $orders[] = $rows['specimen_type'];
60         $orders[] = $rows['specimen_location'];
61         $orders[] = $rows['specimen_volume'];
62     }
64     return $orders;
67 /**
68  * @param $pid
69  * @return mixed
70  */
72 function getSelfPay($pid)
74     $sql = "SELECT subscriber_relationship FROM insurance_data WHERE pid = ?";
75     $res = sqlQuery($sql, array($pid));
77     return $res['subscriber_relationship'];
80 /**
81  * @param $prov_id
82  * @return array
83  */
84 function getNPI($prov_id)
86     $sql = "SELECT npi, upin FROM users WHERE id = ?";
87     $res = sqlQuery($sql, array($prov_id));
88     return array($res['npi'], $res['upin']);
91 /**
92  * @return array
93  */
94 function getProcedureProvider($prov_id)
96     $sql = "SELECT i.organization, i.street, i.city, i.state, i.zip, i.fax, i.phone, pi.lab_director ".
97            "FROM users AS i, procedure_providers AS pi WHERE pi.ppid = ? AND pi.lab_director = i.id ";
99     $res = sqlStatement($sql, array($prov_id));
100     $labs = sqlFetchArray($res);
102     return $labs;
106  * @param $prov_id
107  * @return array|null
108  */
109 function getLabProviders($prov_id)
112     $sql = "select fname, lname from users where authorized = 1 and active = 1 and username != '' and id = ?";
113     $rez = sqlQuery($sql, array($prov_id));
116     return $rez;
120 * This is going to be adjusted when there is more than one provider.
122 function getLabconfig()
124     $sql = "SELECT recv_app_id, recv_fac_id FROM procedure_providers ";
125     $res = sqlQuery($sql);
126     return $res;
129 function saveBarCode($bar, $pid, $order)
131     $sql = "INSERT INTO `requisition` (`id`, `req_id`, `pid`, `lab_id`) VALUES (NULL, ?, ?, ?)";
132     $inarr = array($bar,$pid,$order);
133     sqlStatement($sql, $inarr);
136 function getBarId($lab_id, $pid)
138     $sql = "SELECT req_id FROM requisition WHERE lab_id = ? AND pid = ?";
139     $bar = sqlQuery($sql, array($lab_id,$pid));
141     return $bar;