* @author Jerry Padgett * @author Brady Miller * @copyright Copyright (c) 2012 Rod Roark * @copyright Copyright (c) 2018 Jerry Padgett * @copyright Copyright (c) 2019 Brady Miller * @license https://github.com/openemr/openemr/blob/master/LICENSE GNU General Public License 3 */ /** * Generate HTML for the QOE form suitable for insertion into a
. * This HTML may contain single quotes but not unescaped double quotes. * * @param integer $ptid Value matching a procedure_type_id in the procedure_types table. * @param integer $orderid Procedure order ID, if there is an existing order. * @param integer $dbseq Procedure order item sequence number, if there is an existing procedure. * @param string $formseq Zero-relative occurrence number in the form. * @return string The generated HTML. */ function generate_qoe_html($ptid = 0, $orderid = 0, $dbseq = 0, $formseq = 0) { global $rootdir, $qoe_init_javascript; $s = ""; $qoe_init_javascript = ''; $prefix = 'ans' . $formseq . '_'; if (empty($ptid)) { return $s; } // container is div in form. $s .= ""; // Get all the questions for the given procedure order type. $qres = sqlStatement("SELECT " . "q.question_code, q.question_text, q.options, q.required, q.maxsize, " . "q.fldtype, q.tips " . "FROM procedure_type AS t " . "JOIN procedure_questions AS q ON q.lab_id = t.lab_id " . "AND q.procedure_code = t.procedure_code AND q.activity = 1 " . "WHERE t.procedure_type_id = ? " . "ORDER BY q.seq, q.question_text", array($ptid)); while ($qrow = sqlFetchArray($qres)) { $options = trim($qrow['options']); $qfieldid = $prefix . trim($qrow['question_code']); $fldtype = $qrow['fldtype']; $maxsize = 0 + $qrow['maxsize']; $qrow['tips'] = str_ireplace("^", " ", $qrow['tips']); // in case of HL7 // Get answer value(s) to this question, if any. $answers = array(); if ($orderid && $dbseq > 0) { $ares = sqlStatement("SELECT answer FROM procedure_answers WHERE " . "procedure_order_id = ? AND procedure_order_seq = ? AND question_code = ? " . "ORDER BY answer_seq", array($orderid, $dbseq, $qrow['question_code'])); while ($arow = sqlFetchArray($ares)) { $answers[] = $arow['answer']; } } $s .= ""; $s .= "'; $s .= ''; } $s .= '
"; $s .= ""; if ($fldtype == 'T') { // Text Field. $s .= ""; } elseif ($fldtype == 'N') { // Numeric text Field. // TBD: Add some JavaScript validation for this. $s .= ""; } elseif ($fldtype == 'D') { // Date Field. $s .= ""; /* Legacy calendar removed to update to current calendar 07/20/2018 sjp */ } elseif ($fldtype == 'G') { // Gestational age in weeks and days. $currweeks = -1; $currdays = -1; if (!empty($answers)) { $currweeks = intval($answers[0] / 7); $currdays = $answers[0] % 7; } $s .= ""; $s .= " " . xlt('weeks') . "  "; $s .= ""; $s .= " " . xlt('days'); // Possible alternative code instead of radio buttons and checkboxes. // Might use this for cases where the list of choices is large. /***************************************************************** else { // Single- or multi-select list. $multiple = false; if (substr($options, 0, 2) == '+;') { $multiple = true; $options = substr($options, 2); } $s .= ""; } *****************************************************************/ } elseif ($fldtype == 'M') { // List of checkboxes. $a = explode(';', $qrow['options']); $i = 0; foreach ($a as $aval) { list($desc, $code) = explode(':', $aval); if (empty($code)) { $code = $desc; } if ($i) { $s .= "
"; } $s .= "
'; return $s; }