From bc233693916acae021d0273f93c6dfb64383ddb1 Mon Sep 17 00:00:00 2001 From: Patrick LaRocque Date: Fri, 24 May 2024 12:06:31 -0400 Subject: [PATCH 1/2] Add auth number to the list of parameters used to search for ETASU in the -etasu GuidanceResponse operation. --- src/services/guidanceresponse.service.ts | 50 ++++++++++++++++++------ 1 file changed, 38 insertions(+), 12 deletions(-) diff --git a/src/services/guidanceresponse.service.ts b/src/services/guidanceresponse.service.ts index c0b5ee7..62a5f5d 100644 --- a/src/services/guidanceresponse.service.ts +++ b/src/services/guidanceresponse.service.ts @@ -3,6 +3,7 @@ import { GuidanceResponseUtilities } from '../fhir/guidanceResponseUtilities'; import GuidanceResponseModel from '../lib/schemas/resources/GuidanceResponse'; import { Parameters, Medication, Patient, MedicationRequest } from 'fhir/r4'; import { getCaseInfo } from '../lib/etasu'; +import { RemsCase } from '../fhir/models'; module.exports.searchById = async (args: any) => { const { id } = args; @@ -57,6 +58,7 @@ module.exports.remsEtasu = async (args: any, context: any, logger: any) => { const parameters: Parameters = args?.resource; let patient: Patient | undefined; let medication: Medication | MedicationRequest | undefined; + let authNumber: string | undefined; parameters?.parameter?.forEach(param => { if (param?.name === 'patient' && param?.resource?.resourceType === 'Patient') { @@ -67,24 +69,48 @@ module.exports.remsEtasu = async (args: any, context: any, logger: any) => { param.resource?.resourceType === 'MedicationRequest') ) { medication = param.resource; + } else if (param?.name === 'authNumber') { + authNumber = param.valueString; } }); - const drugCode = getMedicationCode(medication); + let etasu: Pick< RemsCase, + | 'drugName' + | 'auth_number' + | 'status' + | 'drugCode' + | 'patientFirstName' + | 'patientLastName' + | 'patientDOB' + | 'metRequirements' + > | null; - // grab the patient demographics from the Patient resource in the parameters - const remsCaseSearchDict = { - patientFirstName: patient?.name?.[0]?.given, - patientLastName: patient?.name?.[0]?.family, - patientDOB: patient?.birthDate, - drugCode: drugCode - }; + if (authNumber) { + const remsCaseSearchDict = { + auth_number: authNumber + }; - const medicationSearchDict = { - code: drugCode - }; + const medicationSearchDict = {}; - const etasu = await getCaseInfo(remsCaseSearchDict, medicationSearchDict); + etasu = await getCaseInfo(remsCaseSearchDict, medicationSearchDict); + + } else { + const drugCode = getMedicationCode(medication); + + // grab the patient demographics from the Patient resource in the parameters + const remsCaseSearchDict = { + patientFirstName: patient?.name?.[0]?.given, + patientLastName: patient?.name?.[0]?.family, + patientDOB: patient?.birthDate, + drugCode: drugCode + }; + + const medicationSearchDict = { + code: drugCode + }; + + etasu = await getCaseInfo(remsCaseSearchDict, medicationSearchDict); + } return GuidanceResponseUtilities.createEtasuGuidanceResponse(etasu, patient); }; From 6bd9f38502c9fb6840834773aab83c05b02f53c6 Mon Sep 17 00:00:00 2001 From: Patrick LaRocque Date: Fri, 24 May 2024 12:16:54 -0400 Subject: [PATCH 2/2] run prettier --- src/services/guidanceresponse.service.ts | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/src/services/guidanceresponse.service.ts b/src/services/guidanceresponse.service.ts index 62a5f5d..de37ed9 100644 --- a/src/services/guidanceresponse.service.ts +++ b/src/services/guidanceresponse.service.ts @@ -74,16 +74,17 @@ module.exports.remsEtasu = async (args: any, context: any, logger: any) => { } }); - let etasu: Pick< RemsCase, - | 'drugName' - | 'auth_number' - | 'status' - | 'drugCode' - | 'patientFirstName' - | 'patientLastName' - | 'patientDOB' - | 'metRequirements' - > | null; + let etasu: Pick< + RemsCase, + | 'drugName' + | 'auth_number' + | 'status' + | 'drugCode' + | 'patientFirstName' + | 'patientLastName' + | 'patientDOB' + | 'metRequirements' + > | null; if (authNumber) { const remsCaseSearchDict = { @@ -93,7 +94,6 @@ module.exports.remsEtasu = async (args: any, context: any, logger: any) => { const medicationSearchDict = {}; etasu = await getCaseInfo(remsCaseSearchDict, medicationSearchDict); - } else { const drugCode = getMedicationCode(medication);