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