Skip to content

Commit 143c8e7

Browse files
committed
single denial reason
1 parent 0f97196 commit 143c8e7

1 file changed

Lines changed: 19 additions & 20 deletions

File tree

src/ncpdp/script.ts

Lines changed: 19 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ const handleRemsRequest = async (message: any, res: Response) => {
152152
}
153153

154154
// Requirements not met - denial with reason code
155-
const reasonCode = determineReasonCodes(outstandingRequirements);
155+
const reasonCode = determineReasonCode(outstandingRequirements);
156156
const reasonText = buildReasonText(reasonCode);
157157

158158
const denialDetails = {
@@ -253,7 +253,7 @@ const handleRemsInitiation = async (message: any, res: Response) => {
253253
}
254254

255255
if (outstandingRequirements.length > 0) {
256-
const reasonCode = determineReasonCodes(outstandingRequirements);
256+
const reasonCode = determineReasonCode(outstandingRequirements);
257257
const reasonText = buildReasonText(reasonCode);
258258

259259
logger.info(`Requirements not met - closing with: ${reasonCode}`);
@@ -341,7 +341,7 @@ const handleRxFill = async (message: any, res: Response) => {
341341
};
342342

343343

344-
const determineReasonCodes = (outstandingRequirements: any[]): string => {
344+
const determineReasonCode = (outstandingRequirements: any[]): string => {
345345
let hasPatientReq = false;
346346
let hasPrescriberReq = false;
347347
let hasPharmacyReq = false;
@@ -397,10 +397,9 @@ const buildApprovedResponse = (
397397
): string => {
398398
const builder = new Builder({ headless: false });
399399

400-
// Handle both capitalized and lowercased keys from parsed XML
401400
const patient = request.patient;
402-
const pharmacy = request.pharmacy;
403-
const prescriber = request.prescriber;
401+
const pharmacy = request.pharmacy;
402+
const prescriber = request.prescriber;
404403
const medicationPrescribed = request.medicationprescribed;
405404
const remsReferenceID = request.remsreferenceid;
406405

@@ -452,12 +451,12 @@ const buildDeniedResponse = (
452451
): string => {
453452
const builder = new Builder({ headless: false });
454453

455-
const patient = request.patient;
456-
const pharmacy = request.pharmacy;
457-
const prescriber = request.prescriber;
458-
const medicationPrescribed = request.medicationprescribed;
454+
const patient = request.patient;
455+
const pharmacy = request.pharmacy;
456+
const prescriber = request.prescriber;
457+
const medicationPrescribed = request.medicationprescribed;
459458
const remsReferenceID = request.remsreferenceid;
460-
const solicitedModel = request.request?.solicitedmodel;
459+
const solicitedModel = request.request?.solicitedmodel;
461460
const caseId = solicitedModel?.remscaseid;
462461

463462
const response = {
@@ -505,11 +504,11 @@ const buildInitiationClosedResponse = (
505504
): string => {
506505
const builder = new Builder({ headless: false });
507506

508-
const patient = request.patient;
509-
const pharmacy = request.pharmacy;
507+
const patient = request.patient;
508+
const pharmacy = request.pharmacy;
510509
const prescriber = request.prescriber;
511-
const medicationPrescribed = request.medicationprescribed;
512-
const remsReferenceID = request.remsreferenceid;
510+
const medicationPrescribed = request.medicationprescribed;
511+
const remsReferenceID = request.remsreferenceid;
513512

514513
const response = {
515514
Message: {
@@ -550,7 +549,7 @@ const buildInitiationClosedResponse = (
550549
const buildInitiationSuccessResponse = (header: any, request: any, remsCase: any): string => {
551550
const builder = new Builder({ headless: false });
552551

553-
const patient = request.patient;
552+
const patient = request.patient;
554553
const humanPatient = patient?.humanpatient;
555554
const pharmacy = request.pharmacy;
556555
const prescriber = request.prescriber;
@@ -580,14 +579,14 @@ const buildInitiationSuccessResponse = (header: any, request: any, remsCase: any
580579
Identification: {
581580
REMSPatientID: remsCase.remsPatientId || remsCase.case_number
582581
},
583-
Names: humanPatient?.Names || humanPatient?.names,
584-
GenderAndSex: humanPatient?.GenderAndSex || humanPatient?.genderandsex,
585-
DateOfBirth: humanPatient?.DateOfBirth || humanPatient?.dateofbirth,
582+
Names: humanPatient?.names,
583+
GenderAndSex: humanPatient?.genderandsex,
584+
DateOfBirth: humanPatient?.dateofbirth,
586585
Address: {
587586
$: {
588587
'xsi:type': 'MandatoryAddressType'
589588
},
590-
...(humanPatient?.Address || humanPatient?.address)
589+
...humanPatient?.address
591590
}
592591
}
593592
},

0 commit comments

Comments
 (0)