Skip to content

Commit

Permalink
run prettier
Browse files Browse the repository at this point in the history
  • Loading branch information
plarocque4 committed Sep 9, 2024
1 parent 016f0c8 commit f2ffa3d
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 41 deletions.
42 changes: 20 additions & 22 deletions backend/src/ncpdpScriptBuilder/buildScript.v2017071.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,34 +50,32 @@ function buildMessage(inputMessage, body) {
}

export function buildRxStatus(newRxMessageConvertedToJSON) {
const body =
[
{
Status: [
{
Code: '000' // Placeholder: This is dependent on individual pharmacy
}
]
}
];
const body = [
{
Status: [
{
Code: '000' // Placeholder: This is dependent on individual pharmacy
}
]
}
];
const rxStatus = buildMessage(newRxMessageConvertedToJSON, body);
const builder = new XMLBuilder(XML_BUILDER_OPTIONS);
return builder.build(rxStatus);
}

export function buildRxError(newRxMessageConvertedToJSON, errorMessage) {
const body =
[
{
Error: [
{
Code: 900, // Transaction was rejected
DescriptionCode: 1000, // Unable to identify based on information submitted
Description: errorMessage
}
]
}
];
const body = [
{
Error: [
{
Code: 900, // Transaction was rejected
DescriptionCode: 1000, // Unable to identify based on information submitted
Description: errorMessage
}
]
}
];
const rxStatus = buildMessage(newRxMessageConvertedToJSON, body);
const builder = new XMLBuilder(XML_BUILDER_OPTIONS);
return builder.build(rxStatus);
Expand Down
6 changes: 5 additions & 1 deletion backend/src/routes/doctorOrders.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,11 @@ import axios from 'axios';
import bodyParser from 'body-parser';
import bpx from 'body-parser-xml';
import env from 'var';
import { buildRxStatus, buildRxFill, buildRxError } from '../ncpdpScriptBuilder/buildScript.v2017071.js';
import {
buildRxStatus,
buildRxFill,
buildRxError
} from '../ncpdpScriptBuilder/buildScript.v2017071.js';
import { NewRx } from '../database/schemas/newRx.js';
import { medicationRequestToRemsAdmins } from '../database/data.js';

Expand Down
35 changes: 17 additions & 18 deletions backend/src/routes/ncpdp.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,24 +23,23 @@ router.use(bodyParser.urlencoded({ extended: false }));
* Description : 'Supports NCPDP SCRIPT messages, currntly only NewRx'
*/
router.post('/script', async (req, res) => {
// Parsing incoming NCPDP SCRIPT XML to JSON
console.log('received /ncpdp/script message');
const newRxMessageConvertedToJSON = req.body;
let message = newRxMessageConvertedToJSON?.Message;
let body = message?.Body;
let status = null;
if (body?.NewRx) {
// process NewRx message
status = await processNewRx(newRxMessageConvertedToJSON);
// Parsing incoming NCPDP SCRIPT XML to JSON
console.log('received /ncpdp/script message');
const newRxMessageConvertedToJSON = req.body;
let message = newRxMessageConvertedToJSON?.Message;
let body = message?.Body;
let status = null;
if (body?.NewRx) {
// process NewRx message
status = await processNewRx(newRxMessageConvertedToJSON);
} else {
let errorStr = 'unknown message type';
console.log('/ncpdp/script ' + errorStr);
status = buildRxError(newRxMessageConvertedToJSON, errorStr);
}

} else {
let errorStr = 'unknown message type';
console.log('/ncpdp/script ' + errorStr);
status = buildRxError(newRxMessageConvertedToJSON, errorStr);
}

res.send(status);
console.log('Sent Status/Error');
res.send(status);
console.log('Sent Status/Error');
});

export default router;
export default router;

0 comments on commit f2ffa3d

Please sign in to comment.