@@ -396,51 +396,53 @@ const getDispenseStatus = (order, guidanceResponse) => {
396396 */
397397async function parseNCPDPScript ( newRx ) {
398398 // Parsing XML NCPDP SCRIPT from EHR
399+ const patient = newRx . Message . Body . NewRx . Patient ;
400+ const prescriber = newRx . Message . Body . NewRx . Prescriber ;
401+ const medicationPrescribed = newRx . Message . Body . NewRx . MedicationPrescribed ;
402+
399403 const incompleteOrder = {
400404 orderId : newRx . Message . Header . MessageID . toString ( ) , // Will need to return to this and use actual pt identifier or uuid
401405 caseNumber : newRx . Message . Header . AuthorizationNumber ,
402406 prescriberOrderNumber : newRx . Message . Header . PrescriberOrderNumber ,
403- patientName :
404- newRx . Message . Body . NewRx . Patient . HumanPatient . Name . FirstName +
405- ' ' +
406- newRx . Message . Body . NewRx . Patient . HumanPatient . Name . LastName ,
407- patientFirstName : newRx . Message . Body . NewRx . Patient . HumanPatient . Name . FirstName ,
408- patientLastName : newRx . Message . Body . NewRx . Patient . HumanPatient . Name . LastName ,
409- patientDOB : newRx . Message . Body . NewRx . Patient . HumanPatient . DateOfBirth . Date ,
410- patientCity : newRx . Message . Body . NewRx . Patient . HumanPatient . Address . City ,
411- patientStateProvince : newRx . Message . Body . NewRx . Patient . HumanPatient . Address . StateProvince ,
412- patientPostalCode : newRx . Message . Body . NewRx . Patient . HumanPatient . Address . PostalCode ,
413- patientCountry : newRx . Message . Body . NewRx . Patient . HumanPatient . Address . Country ,
407+ patientName : patient . HumanPatient . Name . FirstName + ' ' + patient . HumanPatient . Name . LastName ,
408+ patientFirstName : patient . HumanPatient . Name . FirstName ,
409+ patientLastName : patient . HumanPatient . Name . LastName ,
410+ patientDOB : patient . HumanPatient . DateOfBirth . Date ,
411+ patientCity : patient . HumanPatient . Address . City ,
412+ patientStateProvince : patient . HumanPatient . Address . StateProvince ,
413+ patientPostalCode : patient . HumanPatient . Address . PostalCode ,
414+ patientCountry : patient . HumanPatient . Address . Country ,
414415 doctorName :
415416 'Dr. ' +
416- newRx . Message . Body . NewRx . Prescriber . NonVeterinarian . Name . FirstName +
417+ prescriber . NonVeterinarian . Name . FirstName +
417418 ' ' +
418- newRx . Message . Body . NewRx . Prescriber . NonVeterinarian . Name . LastName ,
419- doctorContact :
420- newRx . Message . Body . NewRx . Prescriber . NonVeterinarian . CommunicationNumbers . PrimaryTelephone
421- ?. Number ,
422- doctorID : newRx . Message . Body . NewRx . Prescriber . NonVeterinarian . Identification . NPI ,
423- doctorEmail :
424- newRx . Message . Body . NewRx . Prescriber . NonVeterinarian . CommunicationNumbers . ElectronicMail ,
425- drugNames : newRx . Message . Body . NewRx . MedicationPrescribed . DrugDescription ,
426- simpleDrugName : newRx . Message . Body . NewRx . MedicationPrescribed . DrugDescription . split ( ' ' ) [ 0 ] ,
419+ prescriber . NonVeterinarian . Name . LastName ,
420+ doctorContact : prescriber . NonVeterinarian . CommunicationNumbers . PrimaryTelephone ?. Number ,
421+ doctorID : prescriber . NonVeterinarian . Identification . NPI ,
422+ doctorEmail : prescriber . NonVeterinarian . CommunicationNumbers . ElectronicMail ,
423+ drugNames : medicationPrescribed . DrugDescription ,
424+ simpleDrugName : medicationPrescribed . DrugDescription ?. split ( ' ' ) [ 0 ] ,
427425
428426 drugNdcCode :
429- newRx . Message . Body . NewRx . MedicationPrescribed . DrugCoded . ProductCode ?. Code ||
430- newRx . Message . Body . NewRx . MedicationPrescribed . DrugCoded . NDC ||
427+ medicationPrescribed . DrugCoded . ProductCode ?. Code ||
428+ medicationPrescribed . DrugCoded . NDC ||
431429 null ,
432430
433- drugRxnormCode :
434- newRx . Message . Body . NewRx . MedicationPrescribed . DrugCoded . DrugDBCode ?. Code || null ,
431+ drugRxnormCode : medicationPrescribed . DrugCoded . DrugDBCode ?. Code || null ,
435432
436- rxDate : newRx . Message . Body . NewRx . MedicationPrescribed . WrittenDate . Date ,
433+ rxDate : medicationPrescribed . WrittenDate . Date ,
437434 drugPrice : 200 , // Add later?
438- quantities : newRx . Message . Body . NewRx . MedicationPrescribed . Quantity . Value ,
435+ quantities : medicationPrescribed . Quantity . Value ,
439436 total : 1800 ,
440437 pickupDate : 'Tue Dec 13 2022' , // Add later?
441438 dispenseStatus : 'Pending'
442439 } ;
443440
441+ if ( incompleteOrder . drugNames === undefined || incompleteOrder . drugNames === 'undefined' ) {
442+ incompleteOrder . drugNames = incompleteOrder . drugNdcCode ;
443+ incompleteOrder . simpleDrugName = incompleteOrder . drugNdcCode ;
444+ }
445+
444446 const metRequirements = isRemsDrug ( incompleteOrder ) ? [ ] : null ;
445447 const order = new doctorOrder ( { ...incompleteOrder , metRequirements } ) ;
446448 return order ;
0 commit comments