From 10bcaedf8634b555343c94cf267051e303aed9e2 Mon Sep 17 00:00:00 2001 From: stephen waite Date: Wed, 10 Apr 2024 22:53:45 -0400 Subject: [PATCH] fix: allow for saving insurance when country is empty (#7332) * fix: allow for saving insurance when country is empty * styling * revert FALSE array key --- _rest_routes.inc.php | 4 ++-- interface/patient_file/summary/insurance_edit.php | 2 +- src/Common/Http/HttpRestParsedRoute.php | 4 +++- src/RestControllers/RestControllerHelper.php | 8 ++++---- src/Validators/CoverageValidator.php | 4 ++-- templates/patient/insurance/insurance_edit.html.twig | 2 +- 6 files changed, 13 insertions(+), 11 deletions(-) diff --git a/_rest_routes.inc.php b/_rest_routes.inc.php index 0131b1dad17..b2792744a90 100644 --- a/_rest_routes.inc.php +++ b/_rest_routes.inc.php @@ -6533,7 +6533,7 @@ * description="The type or category of OpenEMR insurance policy, 'primary', 'secondary', or 'tertiary'. If this field is missing it will default to 'primary'.", * type="string" * ), - * required={"provider", "policy_number", "subscriber_fname", "subscriber_lname", "subscriber_relationship", "subscriber_ss", "subscriber_DOB", "subscriber_street", "subscriber_postal_code", "subscriber_city", "subscriber_state", "subscriber_country", "subscriber_sex", "accept_assignment"}, + * required={"provider", "policy_number", "subscriber_fname", "subscriber_lname", "subscriber_relationship", "subscriber_ss", "subscriber_DOB", "subscriber_street", "subscriber_postal_code", "subscriber_city", "subscriber_state", "subscriber_sex", "accept_assignment"}, * example={ * "provider": "33", * "plan_name": "Some Plan", @@ -12110,7 +12110,7 @@ // for the currently logged in user if ($request->getRequestUserUUIDString() == $uuid) { $return = (new FhirPersonRestController())->getOne($uuid); - } else if (!$request->isPatientRequest()) { + } elseif (!$request->isPatientRequest()) { // not a patient ,make sure we have access to the users ACL RestConfig::authorization_check("admin", "users"); $return = (new FhirPersonRestController())->getOne($uuid); diff --git a/interface/patient_file/summary/insurance_edit.php b/interface/patient_file/summary/insurance_edit.php index c13aa53e702..153c0d56f5d 100644 --- a/interface/patient_file/summary/insurance_edit.php +++ b/interface/patient_file/summary/insurance_edit.php @@ -107,7 +107,7 @@ // policy_types is defined in patient.inc.php ,'policy_types' => $GLOBALS['policy_types'] ,'uspsVerifyAddress' => $GLOBALS['usps_webtools_enable'] - ,'languageDirection' => $GLOBALS['language_direction'] + ,'languageDirection' => $GLOBALS['language_direction'] ?? '' ,'rightJustifyLabels' => $GLOBALS['right_justify_labels_demographics'] ] ); diff --git a/src/Common/Http/HttpRestParsedRoute.php b/src/Common/Http/HttpRestParsedRoute.php index cc51bb94af3..5e8e902ea9a 100644 --- a/src/Common/Http/HttpRestParsedRoute.php +++ b/src/Common/Http/HttpRestParsedRoute.php @@ -56,6 +56,8 @@ class HttpRestParsedRoute */ private $requestRoute; + private $requestMethod; + public function __construct($requestMethod, $requestRoute, $routeDefinition) { $this->routeDefinition = $routeDefinition; @@ -182,7 +184,7 @@ private function parseRouteParams($routeParams, $routeDefinition) // standard api allows for nesting of resources so we have to handle the other possibilities there. if ($apiType === 'fhir') { $this->resource = $parts[2] ?? null; - } else if (!empty($finalArg) && !\in_array($finalArg, ['portal', 'api'])) { + } elseif (!empty($finalArg) && !\in_array($finalArg, ['portal', 'api'])) { $this->resource = $finalArg; } diff --git a/src/RestControllers/RestControllerHelper.php b/src/RestControllers/RestControllerHelper.php index 2fdc32471a6..21cfb879844 100644 --- a/src/RestControllers/RestControllerHelper.php +++ b/src/RestControllers/RestControllerHelper.php @@ -136,7 +136,7 @@ public static function handleProcessingResult(ProcessingResult $processingResult $httpResponseBody["internalErrors"] = $processingResult->getInternalErrors(); (new SystemLogger())->debug("RestControllerHelper::handleProcessingResult() 500 error", ['internalErrors' => $processingResult->getValidationMessages()]); } else { - http_response_code($successStatusCode); + http_response_code($successStatusCode ?? 0); $dataResult = $processingResult->getData(); $recordsCount = count($dataResult); (new SystemLogger())->debug("RestControllerHelper::handleFhirProcessingResult() Records found", ['count' => $recordsCount]); @@ -290,18 +290,18 @@ public function addOperations($resource, $items, FHIRCapabilityStatementResource $fhirOperation->setName($operationName); $fhirOperation->setDefinition(new FHIRCanonical('http://hl7.org/fhir/uv/bulkdata/OperationDefinition/' . $definitionName)); $capResource->addOperation($fhirOperation); - } else if ($operation === '$bulkdata-status') { + } elseif ($operation === '$bulkdata-status') { $fhirOperation = new FHIRCapabilityStatementOperation(); $fhirOperation->setName($operation); $fhirOperation->setDefinition($this->restURL . '/OperationDefinition/$bulkdata-status'); $capResource->addOperation($fhirOperation); // TODO: @adunsulag we should document in our capability statement how to use the bulkdata-status operation - } else if ($operation === '$docref') { + } elseif ($operation === '$docref') { $fhirOperation = new FHIRCapabilityStatementOperation(); $fhirOperation->setName($operation); $fhirOperation->setDefinition(new FHIRCanonical('http://hl7.org/fhir/us/core/OperationDefinition/docref')); $capResource->addOperation($fhirOperation); - } else if (is_string($operation) && strpos($operation, '$') === 0) { + } elseif (is_string($operation) && strpos($operation, '$') === 0) { (new SystemLogger())->debug("Found operation that is not supported in system", ['resource' => $resource, 'operation' => $operation, 'items' => $items]); } } diff --git a/src/Validators/CoverageValidator.php b/src/Validators/CoverageValidator.php index 218262eac7f..d4aabde5d36 100644 --- a/src/Validators/CoverageValidator.php +++ b/src/Validators/CoverageValidator.php @@ -141,12 +141,12 @@ function (Validator $context) { $context->required('subscriber_postal_code')->lengthBetween(2, 255); $context->required('subscriber_city')->lengthBetween(2, 255); $context->required('subscriber_state')->listOption($GLOBALS['state_list']); - $context->required('subscriber_country')->listOption($GLOBALS['country_list']); + $context->optional('subscriber_country')->listOption($GLOBALS['country_list']); $context->optional('subscriber_phone')->lengthBetween(2, 255); $context->required('subscriber_sex')->listOption('sex'); $context->required('accept_assignment')->inArray(['TRUE', 'FALSE']); // policy type has a Not Applicable(NA) option which is an empty string so we allow empty here - $context->required('policy_type')->allowEmpty(true)->inArray(InsurancePolicyTypes::POLICY_TYPES); + $context->optional('policy_type')->allowEmpty(true)->inArray(InsurancePolicyTypes::POLICY_TYPES); $context->optional('subscriber_employer')->lengthBetween(2, 255); $context->optional('subscriber_employer_street')->lengthBetween(2, 255); $context->optional('subscriber_employer_postal_code')->lengthBetween(2, 255); diff --git a/templates/patient/insurance/insurance_edit.html.twig b/templates/patient/insurance/insurance_edit.html.twig index e818f0fd4a5..080e5b5b3c1 100644 --- a/templates/patient/insurance/insurance_edit.html.twig +++ b/templates/patient/insurance/insurance_edit.html.twig @@ -314,7 +314,7 @@ files for editing and adding new insurance policies for a patient. ,skip: not useStateTerminology }, { name: "Country"|xl - ,required: true + ,required: false ,data_type: country_data_type ,field_id: "subscriber_country" ,fld_length: 10