fix: ccda zip import and php warnings and deprecations (#7416)
[openemr.git] / library / specialty_forms.php
blobe7619ce0d5e25f02c27ce985c0baa05b4a5f44b0
1 <?php
3 /**
4 * For various specialty forms to call from dialog using the
5 * Ajax, iFrame, Alert, Confirm or HTML modes. Just follow
6 * the example patient previous names history form pattern shown below.
8 * @package OpenEMR
9 * @link https://www.open-emr.org
10 * @author Jerry Padgett <sjpadgett@gmail.com>
11 * @copyright Copyright (c) 2021 Jerry Padgett <sjpadgett@gmail.com>
12 * @license https://github.com/openemr/openemr/blob/master/LICENSE GNU General Public License 3
15 require_once(__DIR__ . "/../interface/globals.php");
17 use OpenEMR\Common\Csrf\CsrfUtils;
18 use OpenEMR\Core\Header;
20 if (!CsrfUtils::verifyCsrfToken($_GET["csrf_token_form"])) {
21 CsrfUtils::csrfNotVerified();
24 $form = trim($_GET['form_handler']);
25 echo "<script>var form=" . js_escape($form) . "</script>";
27 <!DOCTYPE html>
28 <html>
29 <head>
30 <title><?php echo xlt("Specialty Form"); ?></title>
31 <meta name="viewport" content="width=device-width, initial-scale=1.0">
32 <?php Header::setupHeader(['opener', 'datetime-picker']); ?>
33 <script>
34 $(function () {
35 $("#names_form").submit(function(event) {
36 event.preventDefault();
37 const url = top.webroot_url + '/library/ajax/specialty_form_ajax.php';
38 return fetch(
39 url,
41 method: 'POST',
42 body: new FormData(this)
44 ).then(data => data.json())
45 .then(data => {
46 let ele = opener.document.getElementById('form_name_history');
47 if (data !== false) {
48 let newOption = new Option(data.name, data.id, true, true);
49 ele.append(newOption);
50 } else {
51 let message = xl("Previous name history already exist. Try again or Cancel.");
52 dialog.alert(message);
54 }).then(() => {
55 dlgclose();
56 });
57 });
58 $("#form_cancel").click(function(){
59 dlgclose();
60 });
61 $('.datepicker').datetimepicker({
62 <?php $datetimepicker_timepicker = false; ?>
63 <?php $datetimepicker_showseconds = false; ?>
64 <?php $datetimepicker_formatInput = true; ?>
65 <?php require($GLOBALS['srcdir'] . '/js/xl/jquery-datetimepicker-2-5-4.js.php'); ?>
66 });
67 });
68 </script>
69 </head>
70 <body>
71 <?php if ($form === 'name_history') { ?>
72 <div class="container-fluid">
73 <form class="form" id="names_form">
74 <input type="hidden" name="csrf_token_form" value="<?php echo attr(CsrfUtils::collectCsrfToken()); ?>" />
75 <input type="hidden" name="pid" value="<?php echo attr($pid); ?>" />
76 <input type="hidden" name="task_name_history" value="save" />
77 <div class="col">
78 <p class="small text-center"><?php echo xlt("Patient previous names history. Ensure to add the date the name was last used if known."); ?></p>
79 <div class="col">
80 <div class="form-group">
81 <input type="text" name="previous_name_prefix" id="previous_name_prefix" class="form-control" />
82 <label class="form-label" for="previous_name_prefix"><?php echo xlt("Title"); ?></label>
83 </div>
84 </div>
85 <div class="col">
86 <div class="form-group">
87 <input type="text" name="previous_name_first" id="previous_name_first" class="form-control" />
88 <label class="form-label" for="previous_name_first"><?php echo xlt("First name"); ?></label>
89 </div>
90 </div>
91 <div class="col">
92 <div class="form-group">
93 <input type="text" name="previous_name_middle" id="previous_name_middle" class="form-control" />
94 <label class="form-label" for="previous_name_middle"><?php echo xlt("Middle name"); ?></label>
95 </div>
96 </div>
97 <div class="col">
98 <div class="form-group">
99 <input type="text" name="previous_name_last" id="previous_name_last" class="form-control" />
100 <label class="form-label" for="previous_name_last"><?php echo xlt("Last name"); ?></label>
101 </div>
102 </div>
103 <div class="col">
104 <div class="form-group">
105 <input type="text" name="previous_name_suffix" id="previous_name_suffix" class="form-control" />
106 <label class="form-label" for="previous_name_suffix"><?php echo xlt("Suffix"); ?></label>
107 </div>
108 </div>
109 <div class="col">
110 <div class="form-group">
111 <input type="text" name="previous_name_enddate" id="previous_name_enddate" class="form-control datepicker" />
112 <label class="form-label" for="previous_name_enddate"><?php echo xlt("End Date"); ?></label>
113 </div>
114 </div>
115 </div>
116 <div class="col-12 text-center">
117 <div class="form-group">
118 <button type='submit' class='btn btn-primary' name='form_save' id='form_save' value="save"><?php echo xlt('Save'); ?></button>
119 <button type='button' class='btn btn-secondary' name='form_cancel' id='form_cancel'><?php echo xlt('Cancel'); ?></button>
120 </div>
121 </div>
122 </form>
123 </div>
124 <?php } ?>
125 </body>
126 </html>