4 * Care plan form new.php
7 * @link http://www.open-emr.org
8 * @author Jacob T Paul <jacob@zhservices.com>
9 * @author Vinish K <vinish@zhservices.com>
10 * @author Brady Miller <brady.g.miller@gmail.com>
11 * @copyright Copyright (c) 2015 Z&H Consultancy Services Private Limited <sam@zhservices.com>
12 * @copyright Copyright (c) 2017-2019 Brady Miller <brady.g.miller@gmail.com>
13 * @license https://github.com/openemr/openemr/blob/master/LICENSE GNU General Public License 3
16 require_once("../../globals.php");
17 require_once("$srcdir/api.inc");
18 require_once("$srcdir/patient.inc");
19 require_once("$srcdir/options.inc.php");
20 require_once($GLOBALS['srcdir'] . '/csv_like_join.php');
21 require_once($GLOBALS['fileroot'] . '/custom/code_types.inc.php');
23 use OpenEMR\Common\Csrf\CsrfUtils
;
24 use OpenEMR\Core\Header
;
26 $returnurl = 'encounter_top.php';
27 $formid = 0 +
(isset($_GET['id']) ?
$_GET['id'] : 0);
29 $sql = "SELECT * FROM `form_care_plan` WHERE id=? AND pid = ? AND encounter = ?";
30 $res = sqlStatement($sql, array($formid,$_SESSION["pid"], $_SESSION["encounter"]));
31 for ($iter = 0; $row = sqlFetchArray($res); $iter++
) {
36 $check_res = $formid ?
$check_res : array();
37 $sql1 = "SELECT option_id AS `value`, title FROM `list_options` WHERE list_id = ?";
38 $result = sqlStatement($sql1, array('Plan_of_Care_Type'));
39 foreach ($result as $value) :
40 $care_plan_type[] = $value;
45 <title
><?php
echo xlt("Care Plan Form"); ?
></title
>
47 <?php Header
::setupHeader(['datetime-picker']);?
>
49 function duplicateRow(e
) {
50 var newRow
= e
.cloneNode(true);
51 e
.parentNode
.insertBefore(newRow
, e
.nextSibling
);
53 changeIds('description');
55 changeIds('codetext');
56 changeIds('code_date');
57 changeIds('displaytext');
58 changeIds('care_plan_type');
64 function removeVal(rowid
) {
65 rowid1
= rowid
.split('tb_row_');
66 document
.getElementById("description_" + rowid1
[1]).value
= '';
67 document
.getElementById("code_" + rowid1
[1]).value
= '';
68 document
.getElementById("codetext_" + rowid1
[1]).value
= '';
69 document
.getElementById("code_date_" + rowid1
[1]).value
= '';
70 document
.getElementById("displaytext_" + rowid1
[1]).innerHTML
= '';
71 document
.getElementById("care_plan_type_" + rowid1
[1]).value
= '';
72 document
.getElementById("user_" + rowid1
[1]).value
= '';
73 if (typeof doTemplateEditor
!== 'undefined') {
74 document
.getElementById("description_" + rowid1
[1]).addEventListener('dblclick', event
=> {
75 doTemplateEditor(this
, event
, event
.target
.dataset
.textcontext
);
80 function changeIds(class_val
) {
81 var elem
= document
.getElementsByClassName(class_val
);
82 for (let i
= 0; i
< elem
.length
; i++
) {
85 elem
[i
].id
= class_val +
"_" + index
;
87 if(class_val
== 'count') {
88 elem
[i
].value
= index
;
93 function deleteRow(rowId
) {
94 if (rowId
!= 'tb_row_1') {
95 var elem
= document
.getElementById(rowId
);
96 elem
.parentNode
.removeChild(elem
);
100 function sel_code(id
) {
101 id
= id
.split('tb_row_');
102 var checkId
= '_' + id
[1];
103 document
.getElementById('clickId').value
= checkId
;
104 dlgopen('<?php echo $GLOBALS['webroot
'] . "/interface/patient_file/encounter/" ?>find_code_popup.php?codetype=SNOMED-CT,LOINC,CPT4', '_blank', 700, 400);
107 function set_related(codetype
, code
, selector
, codedesc
) {
108 var checkId
= document
.getElementById('clickId').value
;
109 document
.getElementById("code" + checkId
).value
= (codetype +
":" + code
);
110 document
.getElementById("codetext" + checkId
).value
= codedesc
;
111 document
.getElementById("displaytext" + checkId
).innerHTML
= codedesc
;
115 // special case to deal with static and dynamic datepicker items
116 $
(document
).on('mouseover','.datepicker', function(){
117 $
(this
).datetimepicker({
118 <?php
$datetimepicker_timepicker = false; ?
>
119 <?php
$datetimepicker_showseconds = false; ?
>
120 <?php
$datetimepicker_formatInput = false; ?
>
121 <?php
require($GLOBALS['srcdir'] . '/js/xl/jquery-datetimepicker-2-5-4.js.php'); ?
>
122 <?php
// can add any additional javascript settings to datetimepicker here; need to prepend first setting with a comma ?>
129 <div
class="container mt-3">
132 <h2
><?php
echo xlt('Care Plan Form'); ?
></h2
>
133 <form method
='post' name
='my_form' action
='<?php echo $rootdir?>/forms/care_plan/save.php?id=<?php echo attr_url($formid) ?>'>
134 <input type
="hidden" name
="csrf_token_form" value
="<?php echo attr(CsrfUtils::collectCsrfToken()); ?>" />
136 <legend
><?php
echo xlt('Enter Details'); ?
></legend
>
137 <div
class="container">
139 if (!empty($check_res)) {
140 foreach ($check_res as $key => $obj) {
143 <div
class="tb_row" id
="tb_row_<?php echo attr($key) + 1; ?>">
144 <div
class="form-row">
145 <div
class="forms col-md-2">
146 <label
for="code_<?php echo attr($key) + 1; ?>" class="h5"><?php
echo xlt('Code'); ?
>:</label
>
147 <input type
="text" id
="code_<?php echo attr($key) + 1; ?>" name
="code[]" class="form-control code" value
="<?php echo attr($obj["code
"]); ?>" onclick
='sel_code(this.parentElement.parentElement.parentElement.id);' />
148 <span id
="displaytext_<?php echo attr($key) + 1; ?>" class="displaytext help-block"></span
>
149 <input type
="hidden" id
="codetext_<?php echo attr($key) + 1; ?>" name
="codetext[]" class="codetext" value
="<?php echo attr($obj["codetext
"]); ?>" />
150 <input type
="hidden" id
="user_<?php echo attr($key) + 1; ?>" name
="user[]" class="user" value
="<?php echo attr($obj["user
"]); ?>" />
152 <div
class="forms col-md-2">
153 <label
for="code_date_<?php echo attr($key) + 1; ?>" class="h5"><?php
echo xlt('Date'); ?
>:</label
>
154 <input type
='text' id
="code_date_<?php echo attr($key) + 1; ?>" name
='code_date[]' class="form-control code_date datepicker" value
='<?php echo attr($obj["date"]); ?>' title
='<?php echo xla('yyyy
-mm
-dd Date of service
'); ?>' />
156 <div
class="forms col-md-2">
157 <label
for="care_plan_type_<?php echo attr($key) + 1; ?>" class="h5"><?php
echo xlt('Type'); ?
>:</label
>
158 <select name
="care_plan_type[]" id
="care_plan_type_<?php echo attr($key) + 1; ?>" class="form-control care_plan_type">
159 <option value
=""></option
>
160 <?php
foreach ($care_plan_type as $value) :
161 $selected = ($value['value'] == $obj["care_plan_type"]) ?
'selected="selected"' : '';
162 if (!empty($selected)) {
163 $context = $value['title'];
166 <option value
="<?php echo attr($value['value']);?>" <?php
echo $selected;?
>><?php
echo text($value['title']);?
></option
>
170 <div
class="forms col-md-6">
171 <label
for="description_<?php echo attr($key) + 1; ?>" class="h5"><?php
echo xlt('Description'); ?
>:</label
>
172 <textarea name
="description[]" id
="description_<?php echo attr($key) + 1; ?>" data
-textcontext
="<?php echo attr($context); ?>" class="form-control description" rows
="6" ><?php
echo text($obj["description"]); ?
></textarea
>
174 <div
class="form-row w-100 mt-2 text-center">
175 <div
class="forms col-md-12">
176 <button type
="button" class="btn btn-primary btn-add btn-sm" onclick
="duplicateRow(this.parentElement.parentElement.parentElement.parentElement);" title
='<?php echo xla('Click here to duplicate the row
'); ?>'>
177 <?php
echo xlt('Add'); ?
>
179 <button
class="btn btn-danger btn-sm" onclick
="deleteRow(this.parentElement.parentElement.parentElement.parentElement.id);" title
='<?php echo xla('Click here to delete the row
'); ?>'>
180 <?php
echo xlt('Delete'); ?
>
183 <input type
="hidden" name
="count[]" id
="count_<?php echo attr($key) + 1; ?>" class="count" value
="<?php echo attr($key) + 1;?>" />
190 <div
class="tb_row" id
="tb_row_1">
191 <div
class="form-row">
192 <div
class="forms col-md-2">
193 <label
for="code_1" class="h5"><?php
echo xlt('Code'); ?
>:</label
>
194 <input type
="text" id
="code_1" name
="code[]" class="form-control code" value
="<?php echo attr($obj["code
"] ?? ''); ?>" onclick
='sel_code(this.parentElement.parentElement.parentElement.parentElement.id);'>
195 <input type
="hidden" id
="user_1" name
="user[]" class="user" value
="<?php echo attr($obj["user
"] ?? $_SESSION["authUser
"]); ?>" />
196 <span id
="displaytext_1" class="displaytext help-block"></span
>
197 <input type
="hidden" id
="codetext_1" name
="codetext[]" class="codetext" value
="<?php echo attr($obj["codetext
"] ?? ''); ?>">
199 <div
class="forms col-md-2">
200 <label
for="code_date_1" class="h5"><?php
echo xlt('Date'); ?
>:</label
>
201 <input type
='text' id
="code_date_1" name
='code_date[]' class="form-control code_date datepicker" value
='<?php echo attr($obj["date"] ?? ''); ?>' title
='<?php echo xla('yyyy
-mm
-dd Date of service
'); ?>' />
203 <div
class="forms col-md-2">
204 <label
for="care_plan_type_1" class="h5"><?php
echo xlt('Type'); ?
>:</label
>
205 <select name
="care_plan_type[]" id
="care_plan_type_1" class="form-control care_plan_type">
206 <option value
=""></option
>
207 <?php
foreach ($care_plan_type as $value) :
208 $selected = ($value['value'] == ($obj["care_plan_type"] ??
'')) ?
'selected="selected"' : '';
210 <option value
="<?php echo attr($value['value']);?>" <?php
echo $selected;?
>><?php
echo text($value['title']);?
></option
>
214 <div
class="forms col-md-6">
215 <label
for="description_1" class="h5"><?php
echo xlt('Description'); ?
>:</label
>
216 <textarea name
="description[]" id
="description_1" data
-textcontext
="" class="form-control description" rows
="6" ><?php
echo text($obj["description"] ??
''); ?
></textarea
>
218 <div
class="form-row w-100 mt-2 text-center">
219 <div
class="forms col-md-12">
220 <button type
="button" class="btn btn-primary btn-add btn-sm" onclick
="duplicateRow(this.parentElement.parentElement.parentElement.parentElement);" title
='<?php echo xla('Click here to duplicate the row
'); ?>'>
221 <?php
echo xlt('Add'); ?
>
223 <button type
="button" class="btn btn-danger btn-delete btn-sm" onclick
="deleteRow(this.parentElement.parentElement.parentElement.parentElement.id);" title
='<?php echo xla('Click here to delete the row
'); ?>'>
224 <?php
echo xlt('Delete'); ?
>
227 <input type
="hidden" name
="count[]" id
="count_1" class="count" value
="1" />
235 <div
class="form-group">
236 <div
class="col-sm-12 position-override">
237 <div
class="btn-group" role
="group">
238 <button type
="submit" onclick
="top.restoreSession()" class="btn btn-primary btn-save"><?php
echo xlt('Save'); ?
></button
>
239 <button type
="button" class="btn btn-secondary btn-cancel" onclick
="top.restoreSession(); parent.closeTab(window.name, false);"><?php
echo xlt('Cancel');?
></button
>
241 <input type
="hidden" id
="clickId" value
="" />