Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions backend/env.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,10 @@
"default": "admin"
},

"REMS_ADMIN_BASE": {
"REMS_ADMIN_FHIR_URL": {
"type": "string",
"default": "http://localhost:8090"
"default": "http://localhost:8090/4_0_0"
},

"HTTPS_KEY_PATH": {
"type": "string",
"default": "server.key"
Expand Down
16 changes: 11 additions & 5 deletions backend/src/database/schemas/doctorOrderSchemas.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,23 @@ export const orderSchema = new mongoose.Schema({
rxDate: String,
drugPrice: Number,
drugNdcCode: String,
drugRxnormCode: String,
quantities: String,
total: Number,
pickupDate: String,
dispenseStatus: String,
metRequirements: [
{
stakeholderId: String,
completed: Boolean,
metRequirementId: String,
requirementName: String,
requirementDescription: String
name: String,
resource: {
status: String,
moduleUri: String,
resourceType: String,
note: [{ text: String }],
subject: {
reference: String
}
}
}
]
});
Expand Down
76 changes: 59 additions & 17 deletions backend/src/routes/doctorOrders.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,24 +75,65 @@ router.patch('/api/updateRx/:id', async (req, res) => {
const dontUpdateStatusBool = req.query.dontUpdateStatus;
// Finding by id
const order = await doctorOrder.findById(req.params.id).exec();
console.log('Found doctor order by id!');
console.log('Found doctor order by id! --- ', order);

const body = {
resourceType: 'Parameters',
parameter: [
{
name: 'patient',
resource: {
resourceType: 'Patient',
id: order.prescriberOrderNumber,
name: [
{
family: order.patientLastName,
given: order.patientName.split(' '),
use: 'official'
}
],
birthDate: order.patientDOB
}
},
{
name: 'medication',
resource: {
resourceType: 'Medication',
id: order.prescriberOrderNumber,
code: {
coding: [
{
system: 'http://www.nlm.nih.gov/research/umls/rxnorm',
code: order.drugRxnormCode,
display: order.drugNames
}
]
}
}
}
]
};

// Reaching out to REMS Admin finding by pt name and drug name
// '/etasu/met/patient/:patientFirstName/:patientLastName/:patientDOB/drug/:drugName',

const remsBase = env.REMS_ADMIN_BASE;
const url =
remsBase +
'/etasu/met/patient/' +
order.patientFirstName +
'/' +
order.patientLastName +
'/' +
order.patientDOB +
'/drug/' +
order.simpleDrugName;
const response = await axios.get(url);
const remsBase = env.REMS_ADMIN_FHIR_URL;

const newUrl = remsBase + '/GuidanceResponse/$rems-etasu';

const response = await axios.post(newUrl, body, {
headers: {
'content-type': 'application/json'
}
});
console.log('Retrieved order');
const responseResource = response.data.parameter[0].resource;
const params = [];
if (responseResource.contained && responseResource.contained[0]) {
for (const param of responseResource.contained[0]['parameter']) {
params.push(param);
}
}

const status = responseResource.status === 'success' ? 'Approved' : 'Pending';

// Saving and updating
const newOrder = await doctorOrder.findOneAndUpdate(
Expand All @@ -101,8 +142,8 @@ router.patch('/api/updateRx/:id', async (req, res) => {
dispenseStatus:
dontUpdateStatusBool || order.dispenseStatus === 'Picked Up'
? order.dispenseStatus
: response.data.status,
metRequirements: response.data.metRequirements
: status,
metRequirements: params
},
{
new: true
Expand Down Expand Up @@ -233,6 +274,7 @@ function parseNCPDPScript(newRx) {
drugNames: newRx.Message.Body.NewRx.MedicationPrescribed.DrugDescription,
simpleDrugName: newRx.Message.Body.NewRx.MedicationPrescribed.DrugDescription.split(' ')[0],
drugNdcCode: newRx.Message.Body.NewRx.MedicationPrescribed.DrugCoded.ProductCode.Code,
drugRxnormCode: newRx.Message.Body.NewRx.MedicationPrescribed.DrugCoded.DrugDBCode.Code,
rxDate: newRx.Message.Body.NewRx.MedicationPrescribed.WrittenDate.Date,
drugPrice: 200, // Add later?
quantities: newRx.Message.Body.NewRx.MedicationPrescribed.Quantity.Value,
Expand Down
29 changes: 18 additions & 11 deletions frontend/src/views/DoctorOrders/OrderCard/EtasuPopUp/EtasuPopUp.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,16 @@ import * as React from 'react';
import { useState } from 'react';

type MetRequirements = {
stakeholderId: string;
completed: boolean;
metRequirementId: string;
requirementName: string;
requirementDescription: string;
_id: string;
name: string;
resource: {
status: string;
moduleUri: string;
resourceType: string;
note: [{ text: string }];
subject: {
reference: string;
};
};
};

interface DoctorOrder {
Expand All @@ -30,6 +34,7 @@ interface DoctorOrder {
doctorEmail?: string;
drugNames?: string;
drugPrice?: number;
drugRxnormCode: number;
quanitities?: string;
total?: number;
pickupDate?: string;
Expand Down Expand Up @@ -88,16 +93,18 @@ const EtasuPopUp = (props: any) => {
{doctorOrder?.metRequirements
.sort((first: MetRequirements, second: MetRequirements) => {
// Keep the other forms unsorted.
if (second.requirementName.includes('Patient Status Update')) {
if (second.name.includes('Patient Status Update')) {
// Sort the Patient Status Update forms in descending order of timestamp.
return second.requirementName.localeCompare(first.requirementName);
return second.name.localeCompare(first.name);
}
return 0;
})
.map(etasuElement => (
<Box key={etasuElement._id}>
<Typography component="div">{etasuElement.requirementName}</Typography>
<Typography component="div">{etasuElement.completed ? '✅' : '❌'}</Typography>
<Box key={etasuElement.name}>
<Typography component="div">{etasuElement.name}</Typography>
<Typography component="div">
{etasuElement.resource.status === 'success' ? '✅' : '❌'}
</Typography>
</Box>
))}
</Box>
Expand Down
15 changes: 10 additions & 5 deletions frontend/src/views/DoctorOrders/OrderCard/OrderCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,16 @@ interface DoctorOrder {
pickupDate?: string;
dispenseStatus?: string;
metRequirements: {
stakeholderId: string;
completed: boolean;
metRequirementId: string;
requirementName: string;
requirementDescription: string;
name: string;
resource: {
status: string;
moduleUri: string;
resourceType: string;
note: [{ text: string }];
subject: {
reference: string;
};
};
}[];
}

Expand Down