Skip to content

Commit

Permalink
Merge pull request #58 from mcode/325-RxStatus
Browse files Browse the repository at this point in the history
325  RxStatus
  • Loading branch information
zacharyrobin authored Jan 9, 2024
2 parents be412e6 + 0052e98 commit 0145f1e
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 1 deletion.
1 change: 1 addition & 0 deletions backend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
"body-parser-xml": "^2.0.3",
"cors": "^2.8.5",
"express": "^4.18.2",
"fast-xml-parser": "^4.3.2",
"mongoose": "^6.11.4",
"var": "^0.4.0",
"web-vitals": "^2.1.4",
Expand Down
48 changes: 48 additions & 0 deletions backend/src/ncpdpScriptBuilder/buildScript.v2017071.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
/* NCPDP SCRIPT v2017071 Support */
import { XMLBuilder } from 'fast-xml-parser';

export default function buildRxStatus(caseNumber, doctorName, drugNames) {
var time = new Date();
var rxStatus = {
RxStatus: [
{
Message: [
{
Header: [
{
To: doctorName
},
{
From: 'Pharmacy' // Placeholder: This is dependant on individual pharmacy
},
{
Message: 'NewRx Request Recieved For: ' + drugNames
},
{
RelatesToMessageID: caseNumber // Placeholder: This is dependant on individual pharmacy, using Case Number
},
{
Time: time
}
]
},
{
Body: [
{
Status: [
{
Code: '200' // Placeholder: This is dependant on individual pharmacy
}
]
}
]
}
]
}
]
};
const builder = new XMLBuilder({ oneListGroup: 'true' });
var RxStatus = builder.build(rxStatus);

return RxStatus;
}
9 changes: 8 additions & 1 deletion backend/src/routes/doctorOrders.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ import axios from 'axios';
import bodyParser from 'body-parser';
import bpx from 'body-parser-xml';
import env from 'var';
import buildRxStatus from '../ncpdpScriptBuilder/buildScript.v2017071.js';

bpx(bodyParser);
router.use(
bodyParser.xml({
Expand Down Expand Up @@ -47,7 +49,12 @@ router.post('/api/addRx', async (req, res) => {

console.log('POST DoctorOrder: ');
console.log(newOrder);
res.send(newOrder);

var RxStatus = buildRxStatus(newOrder.caseNumber, newOrder.doctorName, newOrder.drugNames);
console.log('RxStatus:');
console.log(RxStatus);

res.send(RxStatus);
});

/**
Expand Down

0 comments on commit 0145f1e

Please sign in to comment.