Skip to content

Commit

Permalink
Update location of file and api url
Browse files Browse the repository at this point in the history
  • Loading branch information
Ariel Virgulto committed Sep 6, 2024
1 parent 3ba4809 commit 95f7720
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 1 deletion.
40 changes: 40 additions & 0 deletions src/ncpdp/script.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import { Router, Request } from 'express';
import { remsCaseCollection } from '../fhir/models';
const router = Router();

router.post('/ncpdp/script', async (req: Request) => {
try {
const requestBody = req.body;
if (requestBody.message?.body?.rxfill) {
// call to handle rxfill
handleRxFill(requestBody);
} else {
// do nothing for now
}
} catch (error) {
console.log(error);
throw error;
}
});

const handleRxFill = async (bundle: any) => {
const rxfill = bundle.message?.body?.rxfill;

const fillStatus = rxfill?.fillstatus?.dispensed?.note;
const patient = rxfill?.patient;
const code = rxfill?.medicationprescribed?.drugcoded?.drugdbcode?.code;

await remsCaseCollection.findOneAndUpdate(
{
patientFirstName: patient?.humanpatient?.name?.firstname,
patientLastName: patient?.humanpatient?.name?.lastname,
patientDOB: patient?.humanpatient?.dateofbirth?.date,
drugCode: code
},
{ dispenseStatus: fillStatus },
{ new: true }
);
return fillStatus;
};

export default router;
2 changes: 1 addition & 1 deletion src/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import patientViewService from './hooks/rems.patientview';
import encounterStartService from './hooks/rems.encounterstart';
import { Server } from '@projecttacoma/node-fhir-server-core';
import Etasu from './lib/etasu';
import Ncpdp from './lib/rxfill';
import Ncpdp from './ncpdp/script';
import env from 'env-var';
import https from 'https';
import fs from 'fs';
Expand Down

0 comments on commit 95f7720

Please sign in to comment.