Skip to content

Commit

Permalink
fix: add missing use statement in facility admin script (#7428)
Browse files Browse the repository at this point in the history
* fix: add missing use statement in facility admin script

* add missing use statement in facility add script

* fix use statement in create ccr

* better placement of use statements per review plus warns fixed

* use text() instead
  • Loading branch information
stephenwaite committed May 13, 2024
1 parent 6cef758 commit 6d8bddc
Show file tree
Hide file tree
Showing 11 changed files with 62 additions and 51 deletions.
23 changes: 16 additions & 7 deletions ccr/createCCR.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,31 +12,30 @@
* @license https://github.com/openemr/openemr/blob/master/LICENSE GNU General Public License 3
*/

use OpenEMR\Common\Session\SessionUtil;

// check if using the patient portal
//(if so, then use the portal authorization)
$notPatientPortal = false;
if (isset($_GET['portal_auth'])) {
$landingpage = "../portal/index.php";

// Will start the (patient) portal OpenEMR session/cookie.
require_once(dirname(__FILE__) . "/../src/Common/Session/SessionUtil.php");
OpenEMR\Common\Session\SessionUtil::portalSessionStart();
SessionUtil::portalSessionStart();

if (isset($_SESSION['pid']) && isset($_SESSION['patient_portal_onsite_two'])) {
$pid = $_SESSION['pid'];
$ignoreAuth = true;
global $ignoreAuth;
} else {
OpenEMR\Common\Session\SessionUtil::portalSessionCookieDestroy();
SessionUtil::portalSessionCookieDestroy();
header('Location: ' . $landingpage . '?w');
exit;
}
} else {
// Check authorization.
$thisauth = AclMain::aclCheckCore('patients', 'pat_rep');
if (!$thisauth) {
echo (new TwigContainer(null, $GLOBALS['kernel']))->getTwig()->render('core/unauthorized.html.twig', ['pageTitle' => xl("Create CCR")]);
exit;
}
$notPatientPortal = true;
}

require_once(dirname(__FILE__) . "/../interface/globals.php");
Expand All @@ -45,8 +44,18 @@
require_once(dirname(__FILE__) . "/transmitCCD.php");
require_once(dirname(__FILE__) . "/../custom/code_types.inc.php");

use OpenEMR\Common\Acl\AclMain;
use OpenEMR\Common\Twig\TwigContainer;
use PHPMailer\PHPMailer\PHPMailer;

if ($notPatientPortal) {
$thisauth = AclMain::aclCheckCore('patients', 'pat_rep');
if (!$thisauth) {
echo (new TwigContainer(null, $GLOBALS['kernel']))->getTwig()->render('core/unauthorized.html.twig', ['pageTitle' => xl("Create CCR")]);
exit;
}
}

function createCCR($action, $raw = "no", $requested_by = "")
{

Expand Down
2 changes: 1 addition & 1 deletion ccr/createCCRActor.php
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@
$e_InformationSystem = $ccr->createElement('InformationSystem');
$e_Actor->appendChild($e_InformationSystem);

$e_Name = $ccr->createElement('Name', $row1['facility']);
$e_Name = $ccr->createElement('Name', text($row1['facility'] ?? ''));
$e_InformationSystem->appendChild($e_Name);

$e_Type = $ccr->createElement('Type', 'Facility');
Expand Down
18 changes: 9 additions & 9 deletions ccr/createCCRAlerts.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,35 +36,35 @@
$e_DateTime = $ccr->createElement('DateTime');
$e_Alert->appendChild($e_DateTime);

$date = date_create($row['date']);
$date = date_create($row['date'] ?? '');

$e_ExactDateTime = $ccr->createElement('ExactDateTime', $date->format('Y-m-d\TH:i:s\Z'));
$e_DateTime->appendChild($e_ExactDateTime);

$e_IDs = $ccr->createElement('IDs');
$e_Alert->appendChild($e_IDs);

$e_ID = $ccr->createElement('ID', $row['pid']);
$e_ID = $ccr->createElement('ID', $row['pid'] ?? '');
$e_IDs->appendChild($e_ID);

$e_IDs->appendChild(sourceType($ccr, $sourceID));

$e_Type = $ccr->createElement('Type');
$e_Alert->appendChild($e_Type);

$e_Text = $ccr->createElement('Text', $row['type'] . '-' . $row['alert_title']);
$e_Text = $ccr->createElement('Text', ($row['type'] ?? '') . '-' . ($row['alert_title'] ?? ''));
$e_Type->appendChild($e_Text);

$e_Description = $ccr->createElement('Description');
$e_Alert->appendChild($e_Description);

$e_Text = $ccr->createElement('Text', $row['code_text']);
$e_Text = $ccr->createElement('Text', $row['code_text'] ?? '');
$e_Description->appendChild($e_Text);

$e_Code = $ccr->createElement('Code');
$e_Description->appendChild($e_Code);

$e_Value = $ccr->createElement('Value', $row['diagnosis']);
$e_Value = $ccr->createElement('Value', $row['diagnosis'] ?? '');
$e_Code->appendChild($e_Value);

$e_Alert->appendChild(sourceType($ccr, $sourceID));
Expand All @@ -84,13 +84,13 @@
$e_DateTime = $ccr->createElement('DateTime');
$e_EnvironmentalAgent->appendChild($e_DateTime);

$e_ExactDateTime = $ccr->createElement('ExactDateTime', $row['date']);
$e_ExactDateTime = $ccr->createElement('ExactDateTime', $row['date'] ?? '');
$e_DateTime->appendChild($e_ExactDateTime);

$e_Description = $ccr->createElement('Description');
$e_EnvironmentalAgent->appendChild($e_Description);

$e_Text = $ccr->createElement('Text', $row['alert_title']);
$e_Text = $ccr->createElement('Text', $row['alert_title'] ?? '');
$e_Description->appendChild($e_Text);

$e_Code = $ccr->createElement('Code');
Expand All @@ -102,7 +102,7 @@
$e_Status = $ccr->createElement('Status');
$e_EnvironmentalAgent->appendChild($e_Status);

$e_Text = $ccr->createElement('Text', $row['outcome']);
$e_Text = $ccr->createElement('Text', $row['outcome'] ?? '');
$e_Status->appendChild($e_Text);

$e_EnvironmentalAgent->appendChild(sourceType($ccr, $sourceID));
Expand All @@ -113,7 +113,7 @@
$e_Description = $ccr->createElement('Description');
$e_Reaction->appendChild($e_Description);

$e_Text = $ccr->createElement('Text', $row['reaction']);
$e_Text = $ccr->createElement('Text', $row['reaction'] ?? '');
$e_Description->appendChild($e_Text);

$e_Status = $ccr->createElement('Status');
Expand Down
6 changes: 3 additions & 3 deletions ccr/createCCRImmunization.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
$e_DateTime = $ccr->createElement('DateTime');
$e_Immunization->appendChild($e_DateTime);

$date = date_create($row['administered_date']);
$date = date_create($row['administered_date'] ?? '');

$e_ExactDateTime = $ccr->createElement('ExactDateTime', $date->format('Y-m-d\TH:i:s\Z'));
$e_DateTime->appendChild($e_ExactDateTime);
Expand All @@ -59,7 +59,7 @@
$e_ProductName = $ccr->createElement('ProductName');
$e_Product->appendChild($e_ProductName);

$e_Text = $ccr->createElement('Text', $row['title']);
$e_Text = $ccr->createElement('Text', $row['title'] ?? '');
$e_ProductName->appendChild($e_Text);

$e_Directions = $ccr->createElement('Directions');
Expand All @@ -71,7 +71,7 @@
$e_Description = $ccr->createElement('Description');
$e_Direction->appendChild($e_Description);

$e_Text = $ccr->createElement('Text', $row['note']);
$e_Text = $ccr->createElement('Text', $row['note'] ?? '');
$e_Description->appendChild($e_Text);

$e_Code = $ccr->createElement('Code');
Expand Down
20 changes: 10 additions & 10 deletions ccr/createCCRMedication.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
$e_DateTime = $ccr->createElement('DateTime');
$e_Medication->appendChild($e_DateTime);

$date = date_create($value['date_added']);
$date = date_create($value['date_added'] ?? '');

$e_ExactDateTime = $ccr->createElement('ExactDateTime', $date->format('Y-m-d\TH:i:s\Z'));
$e_DateTime->appendChild($e_ExactDateTime);
Expand All @@ -48,7 +48,7 @@
$e_Status = $ccr->createElement('Status');
$e_Medication->appendChild($e_Status);

$e_Text = $ccr->createElement('Text', $value['active']);
$e_Text = $ccr->createElement('Text', $value['active'] ?? '');
$e_Status->appendChild($e_Text);

$e_Medication->appendChild(sourceType($ccr, $sourceID));
Expand All @@ -59,13 +59,13 @@
$e_ProductName = $ccr->createElement('ProductName');
$e_Product->appendChild($e_ProductName);

$e_Text = $ccr->createElement('Text', $value['drug']);
$e_Text = $ccr->createElement('Text', $value['drug'] ?? '');
$e_ProductName->appendChild(clone $e_Text);

$e_Code = $ccr->createElement('Code');
$e_ProductName->appendChild($e_Code);

$e_Value = $ccr->createElement('Value', $value['rxnorm_drugcode']);
$e_Value = $ccr->createElement('Value', $value['rxnorm_drugcode'] ?? '');
$e_Code->appendChild($e_Value);

$e_Value = $ccr->createElement('CodingSystem', 'RxNorm');
Expand All @@ -74,25 +74,25 @@
$e_Strength = $ccr->createElement('Strength');
$e_Product->appendChild($e_Strength);

$e_Value = $ccr->createElement('Value', $value['size']);
$e_Value = $ccr->createElement('Value', $value['size'] ?? '');
$e_Strength->appendChild($e_Value);

$e_Units = $ccr->createElement('Units');
$e_Strength->appendChild($e_Units);

$e_Unit = $ccr->createElement('Unit', $value['title']);
$e_Unit = $ccr->createElement('Unit', $value['title'] ?? '');
$e_Units->appendChild($e_Unit);

$e_Form = $ccr->createElement('Form');
$e_Product->appendChild($e_Form);

$e_Text = $ccr->createElement('Text', $value['form']);
$e_Text = $ccr->createElement('Text', $value['form'] ?? '');
$e_Form->appendChild($e_Text);

$e_Quantity = $ccr->createElement('Quantity');
$e_Medication->appendChild($e_Quantity);

$e_Value = $ccr->createElement('Value', $value['quantity']);
$e_Value = $ccr->createElement('Value', $value['quantity'] ?? '');
$e_Quantity->appendChild($e_Value);

$e_Units = $ccr->createElement('Units');
Expand Down Expand Up @@ -131,7 +131,7 @@
$e_Instruction = $ccr->createElement('Instruction');
$e_PatientInstructions->appendChild($e_Instruction);

$e_Text = $ccr->createElement('Text', $value['note']);
$e_Text = $ccr->createElement('Text', $value['note'] ?? '');
$e_Instruction->appendChild($e_Text);

$e_Refills = $ccr->createElement('Refills');
Expand All @@ -140,6 +140,6 @@
$e_Refill = $ccr->createElement('Refill');
$e_Refills->appendChild($e_Refill);

$e_Number = $ccr->createElement('Number', $value['refills']);
$e_Number = $ccr->createElement('Number', $value['refills'] ?? '');
$e_Refill->appendChild($e_Number);
} while ($value = sqlFetchArray($result));
14 changes: 7 additions & 7 deletions ccr/createCCRProblem.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,15 +38,15 @@
$e_DateTime = $ccr->createElement('DateTime');
$e_Problem->appendChild($e_DateTime);

$date = date_create($row['date']);
$date = date_create($row['date'] ?? '');

$e_ExactDateTime = $ccr->createElement('ExactDateTime', $date->format('Y-m-d\TH:i:s\Z'));
$e_DateTime->appendChild($e_ExactDateTime);

$e_IDs = $ccr->createElement('IDs');
$e_Problem->appendChild($e_IDs);

$e_ID = $ccr->createElement('ID', $row['pid']);
$e_ID = $ccr->createElement('ID', $row['pid'] ?? '');
$e_IDs->appendChild($e_ID);

$e_IDs->appendChild(sourceType($ccr, $sourceID));
Expand All @@ -61,13 +61,13 @@
$e_Description = $ccr->createElement('Description');
$e_Problem->appendChild($e_Description);

$e_Text = $ccr->createElement('Text', lookup_code_descriptions($row['diagnosis']));
$e_Text = $ccr->createElement('Text', lookup_code_descriptions($row['diagnosis'] ?? ''));
$e_Description->appendChild($e_Text);

$e_Code = $ccr->createElement('Code');
$e_Description->appendChild($e_Code);

$e_Value = $ccr->createElement('Value', $row['diagnosis']);
$e_Value = $ccr->createElement('Value', $row['diagnosis'] ?? '');
$e_Code->appendChild($e_Value);

$e_Value = $ccr->createElement('CodingSystem', 'ICD9-CM');
Expand All @@ -88,12 +88,12 @@
$e_Actor = $ccr->createElement('Actor');
$e_Source->appendChild($e_Actor);

$e_ActorID = $ccr->createElement('ActorID', $uuid);
$e_ActorID = $ccr->createElement('ActorID', $uuid ?? '');
$e_Actor->appendChild($e_ActorID);

$e_Problem->appendChild($e_Source);

$e_CommentID = $ccr->createElement('CommentID', $row['comments']);
$e_CommentID = $ccr->createElement('CommentID', $row['comments'] ?? '');
$e_Problem->appendChild($e_CommentID);

$e_Episodes = $ccr->createElement('Episodes');
Expand Down Expand Up @@ -124,7 +124,7 @@
$e_Description = $ccr->createElement('Description');
$e_HealthStatus->appendChild($e_Description);

$e_Text = $ccr->createElement('Text', $row['reason']);
$e_Text = $ccr->createElement('Text', $row['reason'] ?? '');
$e_Description->appendChild($e_Text);

$e_HealthStatus->appendChild(sourceType($ccr, $sourceID));
Expand Down
18 changes: 9 additions & 9 deletions ccr/createCCRResult.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
$e_DateTime = $ccr->createElement('DateTime');
$e_Result->appendChild($e_DateTime);

$date = date_create($row['date']);
$date = date_create($row['date'] ?? '');

$e_ExactDateTime = $ccr->createElement('ExactDateTime', $date->format('Y-m-d\TH:i:s\Z'));
$e_DateTime->appendChild($e_ExactDateTime);
Expand All @@ -53,7 +53,7 @@
$e_Actor = $ccr->createElement('Actor');
$e_Source->appendChild($e_Actor);

$e_ActorID = $ccr->createElement('ActorID', $uuid);
$e_ActorID = $ccr->createElement('ActorID', $uuid ?? '');
//$e_ActorID = $ccr->createElement('ActorID',${"labID{$row['lab']}"});
$e_Actor->appendChild($e_ActorID);

Expand All @@ -78,7 +78,7 @@
$e_Description = $ccr->createElement('Description');
$e_Test->appendChild($e_Description);

$e_Text = $ccr->createElement('Text', $row['name']);
$e_Text = $ccr->createElement('Text', $row['name'] ?? '');
$e_Description->appendChild($e_Text);

$e_Code = $ccr->createElement('Code');
Expand All @@ -93,13 +93,13 @@
$e_Actor = $ccr->createElement('Actor');
$e_Source->appendChild($e_Actor);

$e_ActorID = $ccr->createElement('ActorID', $uuid);
$e_ActorID = $ccr->createElement('ActorID', $uuid ?? '');
$e_Actor->appendChild($e_ActorID);

$e_TestResult = $ccr->createElement('TestResult');
$e_Test->appendChild($e_TestResult);

$e_Value = $ccr->createElement('Value', $row['result']);
$e_Value = $ccr->createElement('Value', $row['result'] ?? '');
$e_TestResult->appendChild($e_Value);

$e_Code = $ccr->createElement('Code');
Expand All @@ -111,7 +111,7 @@
$e_Description = $ccr->createElement('Description');
$e_TestResult->appendChild($e_Description);

$e_Text = $ccr->createElement('Text', $row['result']);
$e_Text = $ccr->createElement('Text', $row['result'] ?? '');
$e_Description->appendChild($e_Text);

//if($row['abnormal'] == '' ) {
Expand All @@ -121,7 +121,7 @@
$e_Normal = $ccr->createElement('Normal');
$e_NormalResult->appendChild($e_Normal);

$e_Value = $ccr->createElement('Value', $row['range']);
$e_Value = $ccr->createElement('Value', $row['range'] ?? '');
$e_Normal->appendChild($e_Value);

$e_Units = $ccr->createElement('Units');
Expand All @@ -136,14 +136,14 @@
$e_Actor = $ccr->createElement('Actor');
$e_Source->appendChild($e_Actor);

$e_ActorID = $ccr->createElement('ActorID', $uuid);
$e_ActorID = $ccr->createElement('ActorID', $uuid ?? '');
$e_Actor->appendChild($e_ActorID);

//} else {
$e_Flag = $ccr->createElement('Flag');
$e_Test->appendChild($e_Flag);

$e_Text = $ccr->createElement('Text', $row['abnormal']);
$e_Text = $ccr->createElement('Text', $row['abnormal'] ?? '');
$e_Flag->appendChild($e_Text);
//}

Expand Down
2 changes: 1 addition & 1 deletion ccr/display.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
if (!$d->can_access()) {
echo $twig->getTwig()->render("templates/error/400.html.twig", ['statusCode' => 401, 'errorMessage' => 'Access Denied']);
exit;
} else if ($d->is_deleted()) {
} elseif ($d->is_deleted()) {
echo $twig->getTwig()->render("templates/error/404.html.twig");
exit;
}
Expand Down
Loading

0 comments on commit 6d8bddc

Please sign in to comment.