Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Immuniazation Resource #3729

Merged
merged 8 commits into from
Jul 12, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Added UUID to Edit Immu. with isValidUUID()
Signed-off-by: Yash Bothra <yashrajbothra786@gmail.com>
  • Loading branch information
yashrajbothra committed Jul 8, 2020
commit c8aff8e3bf48d0a3888299960f648aad66f6b61c
8 changes: 8 additions & 0 deletions interface/patient_file/summary/immunizations.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
use OpenEMR\Common\Csrf\CsrfUtils;
use OpenEMR\Common\Logging\EventAuditLogger;
use OpenEMR\Core\Header;
use OpenEMR\Common\Uuid\UuidRegistry;
yashrajbothra marked this conversation as resolved.
Show resolved Hide resolved

if (isset($_GET['mode'])) {
if (!CsrfUtils::verifyCsrfToken($_GET["csrf_token_form"])) {
Expand All @@ -31,6 +32,7 @@
if ($_GET['mode'] == "add") {
$sql = "REPLACE INTO immunizations set
id = ?,
uuid = ?,
administered_date = if(?,?,NULL),
immunization_id = ?,
cvx_code = ?,
Expand All @@ -56,6 +58,7 @@
ordering_provider = ?";
$sqlBindArray = array(
trim($_GET['id']),
UuidRegistry::isValidUUID($_GET['uuid']) ? UuidRegistry::uuidToBytes($_GET['uuid']) : null,
yashrajbothra marked this conversation as resolved.
Show resolved Hide resolved
trim($_GET['administered_date']), trim($_GET['administered_date']),
trim($_GET['form_immunization_id']),
trim($_GET['cvx_code']),
Expand Down Expand Up @@ -108,6 +111,10 @@
$result = sqlQuery($sql, array($_GET['id']));

$administered_date = new DateTime($result['administered_date']);
$uuid = null;
if (isset($result['uuid']) && UuidRegistry::isValidUUID($result['uuid'])) {
yashrajbothra marked this conversation as resolved.
Show resolved Hide resolved
$uuid = UuidRegistry::uuidToString($result['uuid']);
}
yashrajbothra marked this conversation as resolved.
Show resolved Hide resolved
$administered_date = $administered_date->format('Y-m-d H:i');

$immuniz_amt_adminstrd = $result['amount_administered'];
Expand Down Expand Up @@ -346,6 +353,7 @@ function saveImmunizationObservationResults($id, $immunizationdata)
<input type="hidden" name="mode" id="mode" value="add">
<input type="hidden" name="id" id="id" value="<?php echo attr($id); ?>">
<input type="hidden" name="pid" id="pid" value="<?php echo attr($pid); ?>">
<input type="hidden" name="uuid" id="uuid" value="<?php echo attr($uuid); ?>">
<br />
<table border=0 cellpadding=1 cellspacing=1>
<?php
Expand Down
14 changes: 13 additions & 1 deletion src/Common/Uuid/UuidRegistry.php
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ public function createUuid()
$test_uuid = (\Ramsey\Uuid\Uuid::fromBytes($uuid))->toString(); // convert byte uuid to string and log below
error_log($test_uuid);
error_log(bin2hex((\Ramsey\Uuid\Uuid::fromString($test_uuid))->getBytes())); // convert string uuid to byte and log hex
*/
*/

// Check to ensure uuid is unique in uuid_registry (unless $this->disable_tracker is set to true)
if (!$this->disable_tracker) {
Expand Down Expand Up @@ -183,4 +183,16 @@ public static function uuidToBytes($uuidString)
{
return Uuid::fromString($uuidString)->getBytes();
}

/**
* Check if UUID string is Valid
* @return boolean
*/
public static function isValidUUID($uuidString)
{
return (!empty($uuidString) &&
$uuidString != null &&
$uuidString != '' &&
$uuidString != '\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0');
}
}