diff --git a/src/components/RemsInterface/RemsInterface.jsx b/src/components/RemsInterface/RemsInterface.jsx index 7a58f75a..4f2129b0 100644 --- a/src/components/RemsInterface/RemsInterface.jsx +++ b/src/components/RemsInterface/RemsInterface.jsx @@ -57,38 +57,71 @@ export default class RemsInterface extends Component { return (
-
{metReq.requirement.name}
+
{metReq.requirementName}
{metReq.completed ? "✅" : "❌"}
-
{metReq.requirement.description}
+
{metReq.requirementDescription}
- { - metReq.childMetRequirements.map(subMetReq => -
-
{subMetReq.requirement.name}
-
{subMetReq.completed ? "✅" : "❌"}
-
{subMetReq.requirement.description}
-
- ) - }
) }); } + getResource(bundle, resourceReference) { + let temp = resourceReference.split("/"); + let _resourceType = temp[0]; + let _id = temp[1]; + + for (let i = 0; i < bundle.entry.length; i++) { + if ((bundle.entry[i].resource.resourceType === _resourceType) + && (bundle.entry[i].resource.id === _id)) { + return bundle.entry[i].resource; + } + } + return null; + } + async sendRemsMessage() { - const remsAdminResponse = await axios.post("http://localhost:8090/rems", this.props.specialtyRxBundle, this.getAxiosOptions()); + const remsAdminResponse = await axios.post("http://localhost:8090/etasu/met", this.props.specialtyRxBundle, this.getAxiosOptions()); + console.log(remsAdminResponse) this.setState({ remsAdminResponse }); - console.log(remsAdminResponse) - - // Will not send post request to PIS if only for prescriber enrollment + + // Will not send post request to PIS if only for patient enrollment if(this.state.remsAdminResponse?.data?.case_number){ - axios.post("http://localhost:3010/api/doctorOrder/$process-message", remsAdminResponse.data, this.getAxiosOptions()).then((response) => { + + // extract params and questionnaire response identifier + let params = this.getResource(this.props.specialtyRxBundle, this.props.specialtyRxBundle.entry[0].resource.focus.parameters.reference); + + // stakeholder and medication references + let prescriptionReference = ""; + let patientReference = ""; + for (let param of params.parameter) { + if (param.name === "prescription") { + prescriptionReference = param.reference; + } + else if (param.name === "source-patient") { + patientReference = param.reference; + } + } + + // obtain drug information from database + let presciption = this.getResource(this.props.specialtyRxBundle, prescriptionReference); + let prescriptionDisplay = presciption.medicationCodeableConcept.coding[0].display.split(" ")[0]; + let patient = this.getResource(this.props.specialtyRxBundle, patientReference); + let patientName = patient.name[0].given[0] + ' ' + patient.name[0].family; + + // console.log(`http://localhost:5051/api/getRx/paitent/${patientName}/drug/${prescriptionDisplay}`); + + axios.get(`http://localhost:5051/doctorOrders/api/getRx/patient/${patientName}/drug/${prescriptionDisplay}`, remsAdminResponse.data, this.getAxiosOptions()).then((response) => { this.setState({ response }); console.log(response); console.log(response.data); }); } + + // const remsAdminResponse = await axios.post("http://localhost:8090/etasu/met", this.props.specialtyRxBundle, this.getAxiosOptions()); + // this.setState({ remsAdminResponse }); + // console.log(remsAdminResponse) } toggleBundle() { @@ -124,14 +157,36 @@ export default class RemsInterface extends Component { refreshPisBundle() { this.setState({ spinPis: true }); - axios.get(`http://localhost:3010/api/doctorOrder/${this.state.response.data.doctorOrder._id}`).then((response) => { + + let params = this.getResource(this.props.specialtyRxBundle, this.props.specialtyRxBundle.entry[0].resource.focus.parameters.reference); + + // stakeholder and medication references + let prescriptionReference = ""; + let patientReference = ""; + for (let param of params.parameter) { + if (param.name === "prescription") { + prescriptionReference = param.reference; + } + else if (param.name === "source-patient") { + patientReference = param.reference; + } + } + + // obtain drug information from database + let presciption = this.getResource(this.props.specialtyRxBundle, prescriptionReference); + let prescriptionDisplay = presciption.medicationCodeableConcept.coding[0].display.split(" ")[0]; + let patient = this.getResource(this.props.specialtyRxBundle, patientReference); + let patientName = patient.name[0].given[0] + ' ' + patient.name[0].family; + + axios.get(`http://localhost:5051/doctorOrders/api/getRx/patient/${patientName}/drug/${prescriptionDisplay}`) + .then((response) => { this.setState({ response: response }); }) } refreshBundle() { this.setState({ spin: true }); - axios.get(`http://localhost:8090/rems/${this.state.remsAdminResponse.data.case_number}`).then((response) => { + axios.get(`http://localhost:8090/etasu/met/${this.state.remsAdminResponse.data.case_number}`).then((response) => { this.setState({ remsAdminResponse: response }); }) } @@ -146,7 +201,7 @@ export default class RemsInterface extends Component { } let colorPis = "#f7f7f7" - const statusPis = this.state.response?.data?.doctorOrder?.dispenseStatus; + const statusPis = this.state.response?.data?.dispenseStatus; if (statusPis === "Approved") { colorPis = "#5cb85c" @@ -157,116 +212,127 @@ export default class RemsInterface extends Component { } // Checking if REMS Request (pt enrollment) || Met Requirments (prescriber Form) + let hasRemsResponse = this.state.remsAdminResponse?.data ? true : false let hasRemsCase = this.state.remsAdminResponse?.data?.case_number ? true : false; return (
- {hasRemsCase ? + { + hasRemsResponse ?
-
-

REMS Admin Status

- -
-
- Case Number : {this.state.remsAdminResponse?.data?.case_number || "N/A"} -
-
- Status: {this.state.remsAdminResponse?.data?.status} -
-
- - - - {this.state.remsAdminResponse?.data?.case_number ? - this.setState({ spin: false })} - /> - : "" - } - -
- -
- {this.state.viewResponse ? -
+ {hasRemsCase ? +
+
+

REMS Admin Status

+ +
+
+ Case Number : {this.state.remsAdminResponse?.data?.case_number || "N/A"} +
+
+ Status: {this.state.remsAdminResponse?.data?.status} +
+
+ + + + {this.state.remsAdminResponse?.data?.case_number ? + this.setState({ spin: false })} + /> + : "" + } + +
+ +
+ {this.state.viewResponse ? +
+

+

ETASU

+ {this.unfurlJson(this.state.remsAdminResponse?.data, 0)} +
+ : + ""} + {this.state.viewBundle ?


-

ETASU

- {this.unfurlJson(this.state.remsAdminResponse?.data, 0)} -
- : - ""} - {this.state.viewBundle ?
-

-

Bundle

- {this.renderBundle(this.props.specialtyRxBundle)} -
: ""} - +

Bundle

+ {this.renderBundle(this.props.specialtyRxBundle)} +
: ""} + +
+ +
+

Pharmacy Status

+ +
+
+ ID : {this.state.response?.data?._id || "N/A"} +
+
+ Status: {this.state.response?.data?.dispenseStatus} +
+
+ {/* */} + {this.state.response?.data?._id ? + this.setState({ spinPis: false })} + /> + : "" + } +
+ +
+ {this.state.viewPisBundle ?
+

+

Bundle

+ {this.renderBundle(this.props.specialtyRxBundle)} +
: ""} +
- -
-

Pharmacy Status

- -
-
- ID : {this.state.response?.data?.doctorOrder?._id || "N/A"} -
-
- Status: {this.state.response?.data?.doctorOrder?.dispenseStatus} -
-
- - {this.state.response?.data?.doctorOrder?._id ? - this.setState({ spinPis: false })} - /> - : "" - } -
- -
- {this.state.viewPisBundle ?
-

-

Bundle

- {this.renderBundle(this.props.specialtyRxBundle)} -
: ""} + : +
+
+

Prescriber Document Status

+ +
+
+ Status: Documents successfully submitted +
+
+ + + {this.state.remsAdminResponse?.data?.case_number ? + this.setState({ spin: false })} + /> + : "" + } +
+ +
+ {this.state.viewBundle ?
+

+

Bundle

+ {this.renderBundle(this.props.specialtyRxBundle)} +
: ""} + +
+ }
:
-
-

Prescriber Document Status

- -
-
- Status: Documents successfully submitted -
-
- - - {this.state.remsAdminResponse?.data?.case_number ? - this.setState({ spin: false })} - /> - : "" - } -
- -
- {this.state.viewBundle ?
-

-

Bundle

- {this.renderBundle(this.props.specialtyRxBundle)} -
: ""} - -
+ No response - form has already been submitted previously....
} +
) }