6 * @link http://www.open-emr.org
7 * @author Stephen Nielson <stephen@nielson.org>
8 * @copyright Copyright (c) 2021 Stephen Nielson <stephen@nielson.org>
9 * @license https://github.com/openemr/openemr/blob/master/LICENSE GNU General Public License 3
12 use OpenEMR\Common\Csrf\CsrfUtils
;
13 use OpenEMR\Common\Session\SessionUtil
;
14 use OpenEMR\Core\Header
;
16 if ($oauthLogin !== true) {
17 $message = xlt("Error. Not authorized");
18 SessionUtil
::oauthSessionCookieDestroy();
23 // make sure we have our patients set
24 $errorMessage = $errorMessage ??
"";
25 $patients = $patients ??
[];
26 $redirect = $redirect ??
"";
27 $searchAction = $searchAction ??
"";
28 $fname = $searchParams['fname'] ??
"";
29 $mname = $searchParams['mname'] ??
"";
30 $lname = $searchParams['lname'] ??
"";
31 $hasMore = $hasMore ??
false;
36 <title
><?php
echo xlt("OpenEMR Authorization"); ?
></title
>
37 <?php Header
::setupHeader(); ?
>
39 <body
class="container-fluid bg-dark">
40 <div
class="row h-100 w-100 justify-content-center align-items-center">
41 <div
class="col-sm-6 bg-light text-dark">
42 <div
class="text-md-center">
43 <h4
class="mb-4 mt-1"><?php
echo xlt("Patient Selection"); ?
></h4
>
45 <div
class="row w-100">
47 <?php
if (!empty($errorMessage)) : ?
>
48 <p
class="alert alert-warning"><?php
echo xlt($errorMessage); ?
></p
>
51 <?php
if (count($patients) < 0) : ?
>
52 <p
class="alert alert-info"><?php
echo xlt("No patients to select"); ?
></p
>
54 <form action
="<?php echo $searchAction; ?>" method
="GET">
55 <input
class="w-25" name
="search[fname]" type
="text" class="form-control form-input" placeholder
="<?php echo xla("First Name
"); ?>"
56 value
="<?php echo attr($fname); ?>" />
57 <input
class="w-25" name
="search[mname]" type
="text" class="form-control form-input" placeholder
="<?php echo xla("Middle Name
"); ?>"
58 value
="<?php echo attr($mname); ?>" />
59 <input
class="w-25" name
="search[lname]" type
="text" class="form-control form-input" placeholder
="<?php echo xla("Last Name
"); ?>"
60 value
="<?php echo attr($lname); ?>" />
61 <input type
="submit" value
="<?php echo xla("Search
"); ?>" />
63 <?php
if ($hasMore) : ?
>
64 <p
class="alert alert-info"><?php
echo xlt("Too many search results found. Displaying a limited set of patients. Narrow your search results through the filters above."); ?
></p
>
68 <div
class="row w-100">
71 <table
class="table table-striped">
74 <th
><?php
echo xlt("Name"); ?
></th
>
75 <th
><?php
echo xlt("DOB"); ?
></th
>
76 <th
><?php
echo xlt("Sex"); ?
></th
>
77 <th
><?php
echo xlt("Email"); ?
></th
>
82 <?php
foreach ($patients as $patient) : ?
>
85 <?php
if ($patient['mname']) : ?
>
86 <?php
echo text(sprintf("%s %s %s", $patient['fname'], $patient['mname'], $patient['lname'])); ?
>
88 <?php
echo text(sprintf("%s %s", $patient['fname'], $patient['lname'])); ?
>
92 <?php
echo text($patient['DOB']); ?
>
95 <?php
echo text($patient['sex']); ?
>
98 <?php
echo text($patient['email']); ?
>
101 <button data
-patient
-id
="<?php echo attr($patient['uuid']); ?>" class="btn btn-primary patient-btn"><?php
echo xlt("Select patient"); ?
></button
>
111 <form method
="post" name
="patientForm" id
="patientForm" action
="<?php echo $redirect ?>">
112 <input type
="hidden" name
="csrf_token" value
="<?php echo attr(CsrfUtils::collectCsrfToken('oauth2')); ?>" />
113 <input id
="patient_id" type
="hidden" name
="patient_id" value
="" />
120 function choosePatient(evt
) {
121 var target
= evt
.target
;
122 var patientId
= target
.dataset
.patientId || undefined
;
124 console
.error(<?php
echo xlj("Developer error. Patient id is missing from dataset");?
>);
127 var patientInput
= document
.getElementById('patient_id');
129 console
.error(<?php
echo xlj("Developer error missing hidden form element 'selectedPatient'");?
>);
132 patientInput
.value
= patientId
;
134 // now submit our form.
135 let form
= document
.getElementById('patientForm');
137 console
.error(<?php
echo xlj("Developer error missing form 'patientForm'");?
>);
145 var btns
= document
.querySelectorAll(".patient-btn");
146 // eventually browsers will support the foreach.. otherwise let's loop
147 for (i
= 0; i
< btns
.length
; i++
) {
148 btns
[i
].addEventListener('click', choosePatient
);
151 window
.addEventListener('load', setup
);