From c2671d3b0b3b41a8b2a03ef9985864b96d32d03b Mon Sep 17 00:00:00 2001 From: Sherwin Gaddis Date: Sat, 28 Oct 2023 11:59:17 -0400 Subject: [PATCH] Bug Fix - default pos code (#6953) * applying the default pos code * Moving to services * PSR @@!#$ * get fetch roll over --- interface/forms/newpatient/save.php | 4 ++-- src/Services/EncounterService.php | 13 +++++++++++++ 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/interface/forms/newpatient/save.php b/interface/forms/newpatient/save.php index 65b49bb09..2b247b8f2 100644 --- a/interface/forms/newpatient/save.php +++ b/interface/forms/newpatient/save.php @@ -40,7 +40,7 @@ if ($_POST['mode'] == 'new' && ($GLOBALS['enc_service_date'] == 'hide_both' || $ } else { $date = isset($_POST['form_date']) ? DateTimeToYYYYMMDDHHMMSS($_POST['form_date']) : null; } - +$defaultPosCode = $encounterService->getPosCode($_POST['facility_id']); $onset_date = isset($_POST['form_onset_date']) ? DateTimeToYYYYMMDDHHMMSS($_POST['form_onset_date']) : null; $sensitivity = $_POST['form_sensitivity'] ?? null; $pc_catid = $_POST['pc_catid'] ?? null; @@ -50,7 +50,7 @@ $reason = $_POST['reason'] ?? null; $mode = $_POST['mode'] ?? null; $referral_source = $_POST['form_referral_source'] ?? null; $class_code = $_POST['class_code'] ?? ''; -$pos_code = $_POST['pos_code'] ?? null; +$pos_code = (empty($_POST['pos_code'])) ? $defaultPosCode : $_POST['pos_code']; $in_collection = $_POST['in_collection'] ?? null; $parent_enc_id = $_POST['parent_enc_id'] ?? null; $encounter_provider = $_POST['provider_id'] ?? null; diff --git a/src/Services/EncounterService.php b/src/Services/EncounterService.php index ffc211cb3..9401d5281 100644 --- a/src/Services/EncounterService.php +++ b/src/Services/EncounterService.php @@ -725,4 +725,17 @@ class EncounterService extends BaseService } return []; } + + /** + * Returns the default POS code that is set in the facility table. + * + * @param $facility_id + * @return mixed + */ + public function getPosCode($facility_id) + { + $sql = "SELECT pos_code FROM facility WHERE id = ?"; + $result = sqlQuery($sql, [$facility_id]); + return $result['pos_code']; + } } -- 2.11.4.GIT