// Copyright © 2010 by Andrew Moore // Copyright © 2010 by "Boyd Stephen Smith Jr." // Copyright (c) 2017 - 2021 Jerry Padgett // Copyright (c) 2021 Robert Down // Copyright (c) 2022 David Eschelbacher // // 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. // Functions for managing the lists and layouts // // Note: there are translation wrappers for the lists and layout labels // at library/translation.inc.php. The functions are titled // xl_list_label() and xl_layout_label() and are controlled by the // $GLOBALS['translate_lists'] and $GLOBALS['translate_layout'] // flags in globals.php // Documentation for layout_options.edit_options: // // A = Age as years or "xx month(s)" // B = Gestational age as "xx week(s) y day(s)" // C = Capitalize first letter of each word (text fields) // D = Check for duplicates in New Patient form // G = Graphable (for numeric fields in forms supporting historical data) // H = Read-only field copied from static history (this is obsolete) // J = Jump to Next Row // K = Prepend Blank Row // L = Lab Order ("ord_lab") types only (address book) // M = Radio Group Master (currently for radio buttons only) // m = Radio Group Member (currently for radio buttons only) // N = Show in New Patient form // O = Procedure Order ("ord_*") types only (address book) // P = Default to previous value when current value is not yet set // R = Distributor types only (address book) // T = Use description as default Text // DAP = Use description as placeholder // U = Capitalize all letters (text fields) // V = Vendor types only (address book) // 0 = Read Only - the input element's "disabled" property is set // 1 = Write Once (not editable when not empty) (text fields) // 2 = Show descriptions instead of codes for billing code input // note: isOption() returns true/false // NOTE: All of the magic constants for the data types here are found in library/layout.inc.php require_once("user.inc"); require_once("patient.inc"); require_once("lists.inc"); require_once(dirname(dirname(__FILE__)) . "/custom/code_types.inc.php"); use OpenEMR\Common\Acl\AclExtended; use OpenEMR\Common\Acl\AclMain; use OpenEMR\Services\EncounterService; use OpenEMR\Services\FacilityService; use OpenEMR\Services\PatientService; $facilityService = new FacilityService(); $date_init = ""; $membership_group_number = 0; // Our base Bootstrap column class, referenced here and in some other modules. // Using col-lg allow us to have additional breakpoint at col-md.(992px, 768px) // col-md-auto will let BS decide with col-12 always for sm devices. $BS_COL_CLASS = 'col-12 col-md-auto col-lg'; function get_pharmacies() { return sqlStatement("SELECT d.id, d.name, a.line1, a.city, " . "p.area_code, p.prefix, p.number FROM pharmacies AS d " . "LEFT OUTER JOIN addresses AS a ON a.foreign_id = d.id " . "LEFT OUTER JOIN phone_numbers AS p ON p.foreign_id = d.id " . "AND p.type = 2 " . "ORDER BY a.state, a.city, d.name, p.area_code, p.prefix, p.number"); } function optionalAge($frow, $date, &$asof, $description = '') { $asof = ''; if (empty($date)) { return ''; } $edit_options = $frow['edit_options'] ?? null; $date = substr($date, 0, 10); if (isOption($edit_options, 'A') !== false) { $format = 0; } elseif (isOption($edit_options, 'B') !== false) { $format = 3; } else { return ''; } if (isOption($frow['form_id'], 'LBF') === false) { $tmp = sqlQuery( "SELECT date FROM form_encounter WHERE " . "pid = ? AND encounter = ? ORDER BY id DESC LIMIT 1", array($GLOBALS['pid'], $GLOBALS['encounter']) ); if (!empty($tmp['date'])) { $asof = substr($tmp['date'], 0, 10); } } if ($description === '') { $prefix = ($format ? xl('Gest age') : xl('Age')) . ' '; } else { $prefix = $description . ' '; } return $prefix . oeFormatAge($date, $asof, $format); } // Function to generate a drop-list. // function generate_select_list( $tag_name, $list_id, $currvalue, $title, $empty_name = ' ', $class = '', $onchange = '', $tag_id = '', $custom_attributes = null, $multiple = false, // new #10 $backup_list = '', // new #11 $ignore_default = false, $include_inactive = false, $tabIndex = false ) { $s = ''; $tag_name_esc = attr($tag_name); if ($multiple) { $tag_name_esc = $tag_name_esc . "[]"; } $s .= ""; } else { $s .= ""; $s .= ""; $fontTitle = xlt('Please choose a valid selection from the list.'); $fontText = xlt('Fix this'); $s .= " $fontText!"; } } elseif (!$got_selected && strlen($currvalue ?? '') > 0 && $multiple) { //if not found in main list, display all selected values that exist in backup list $list_id = $backup_list; $got_selected_backup = false; if (!empty($backup_list)) { $lres_backup = sqlStatement("SELECT * FROM list_options WHERE list_id = ? AND activity = 1 ORDER BY seq, title", array($list_id)); while ($lrow_backup = sqlFetchArray($lres_backup)) { $selectedValues = explode("|", $currvalue); $optionValue = attr($lrow_backup['option_id']); if (in_array($lrow_backup ['option_id'], $selectedValues)) { $s .= "