insurance allocation report clean up
[openemr.git] / library / immunization_helper.php
bloba66370fdd371f37cfd43ad9726b58730160d62a5
1 <?php
2 /**
3 * library/immunization_helper.php Upgrading and patching functions of database.
5 * Copyright (C) 2013 Jan Jajalla <jansta23@gmail.com>
7 * LICENSE: This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation; either version 3
10 * of the License, or (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://opensource.org/licenses/gpl-license.php>;.
18 * @package OpenEMR
19 * @author Jan Jajalla <jansta23@gmail.com>
20 * @link http://www.open-emr.org
23 /**
24 * Return listing of immunizations for a patient.
26 * @param string $pid person id
27 * @param string $sortby sorting field ('vacc' sorts by name, otherwise will sort by date)
28 * @param boolean $showError indicator whether to retrieve the records that were added erroneously
29 * @return recordset listing of immunizations for a patient
31 function getImmunizationList($pid, $sortby, $showError)
33 $sql = "select i1.id ,i1.immunization_id, i1.cvx_code, i1.administered_date, c.code_text_short, c.code".
34 ",i1.manufacturer ,i1.lot_number, i1.completion_status ".
35 ",ifnull(concat(u.lname,', ',u.fname),'Other') as administered_by ".
36 ",i1.education_date ,i1.note ". ",i1.expiration_date " .
37 ",i1.amount_administered, i1.amount_administered_unit, i1.route, i1.administration_site, i1.added_erroneously".
38 " from immunizations i1 ".
39 " left join users u on i1.administered_by_id = u.id ".
40 " left join code_types ct on ct.ct_key = 'CVX' ".
41 " left join codes c on c.code_type = ct.ct_id AND i1.cvx_code = c.code ".
42 " where i1.patient_id = ? ";
43 if (!$showError) {
44 $sql .= "and i1.added_erroneously = 0 ";
47 $sql .= " order by ";
49 if ($sortby == "vacc") {
50 $sql .= " c.code_text_short, i1.immunization_id, i1.administered_date DESC";
51 } else {
52 $sql .= " administered_date desc";
55 $results = sqlStatement($sql, array($pid));
56 return $results;