diff --git a/src/App.jsx b/src/App.jsx index add66b8c..1b6b464f 100644 --- a/src/App.jsx +++ b/src/App.jsx @@ -38,6 +38,7 @@ export default class App extends Component { response: null, priorAuthClaim: null, specialtyRxBundle: null, + remsAdminResponse: null, cqlPrepopulationResults: null, orderResource: null, bundle: null, @@ -392,6 +393,10 @@ export default class App extends Component { this.setState({ specialtyRxBundle: specialtyRxBundleParam }); } + setRemsAdminResponse(remsAdminResponse) { + this.setState({remsAdminResponse}) + } + getQuestionByName(question) { //question should be the HTML node const temp = question.getElementsByClassName("lf-item-code ng-hide")[0].innerText.trim(); @@ -637,8 +642,8 @@ export default class App extends Component { > - {this.state.specialtyRxBundle ? ( - + {this.state.specialtyRxBundle && this.state.remsAdminResponse ? ( + ) : ( { + setRxAlert({ open: false }); + }; + return ( +
+ + + {title} + + + + {rxAlert.description} + + + + + {rxAlert.callback ? + + : + null} + + +
+ ); +} \ No newline at end of file diff --git a/src/components/QuestionnaireForm/QuestionnaireForm.jsx b/src/components/QuestionnaireForm/QuestionnaireForm.jsx index 42d209bf..3b644353 100644 --- a/src/components/QuestionnaireForm/QuestionnaireForm.jsx +++ b/src/components/QuestionnaireForm/QuestionnaireForm.jsx @@ -8,6 +8,8 @@ import ConfigData from "../../config.json"; import ReactDOM from 'react-dom' import retrieveQuestions, { buildNextQuestionRequest } from "../../util/retrieveQuestions"; +import axios from "axios"; +import AlertDialog from "./AlertDialog"; // NOTE: need to append the right FHIR version to have valid profile URL var DTRQuestionnaireResponseURL = "http://hl7.org/fhir/us/davinci-dtr/StructureDefinition/dtr-questionnaireresponse-"; @@ -32,7 +34,8 @@ export default class QuestionnaireForm extends Component { popupOptions: [], popupFinalOption: "Cancel", formFilled: true, - formValidationErrors: [] + formValidationErrors: [], + showRxAlert: {open: false} }; this.outputResponse = this.outputResponse.bind(this); @@ -1362,7 +1365,25 @@ export default class QuestionnaireForm extends Component { this.props.setPriorAuthClaim(priorAuthBundle); - this.props.setSpecialtyRxBundle(specialtyRxBundle); + const options = { + headers: { + Accept: "application/json", + "Content-Type": "application/json" + } + } + axios.post("http://localhost:8090/etasu/met", specialtyRxBundle, options).then((response) => { + const proceedToRems = () => { + this.props.setSpecialtyRxBundle(specialtyRxBundle); + this.props.setRemsAdminResponse(response) + } + if(response.status == 201) { + proceedToRems() + } else if(response.status == 200) { + this.setState({showRxAlert: {response: response, rxBundle: specialtyRxBundle, description: "Form was already submitted previously. View current case?", open: true, callback: proceedToRems}}) + } + }).catch((e)=>{ + this.setState({showRxAlert: {description: "Encountered an error", open:true}}) + }) } else { alert("Prior Auth Bundle is not available or does not contain enough resources for Prior Auth. Can't submit to prior auth.") } @@ -1564,6 +1585,7 @@ export default class QuestionnaireForm extends Component { /> ) : null } + {this.setState({showRxAlert: e})}}> { isAdaptiveForm ? (
diff --git a/src/components/RemsInterface/RemsInterface.jsx b/src/components/RemsInterface/RemsInterface.jsx index 4f2129b0..90c3607a 100644 --- a/src/components/RemsInterface/RemsInterface.jsx +++ b/src/components/RemsInterface/RemsInterface.jsx @@ -58,7 +58,7 @@ export default class RemsInterface extends Component {
{metReq.requirementName}
-
{metReq.completed ? "✅" : "❌"}
+
{metReq.completed ? "✅" : "❌"}
{metReq.requirementDescription}
@@ -80,14 +80,13 @@ export default class RemsInterface extends Component { } return null; } - + async sendRemsMessage() { - const remsAdminResponse = await axios.post("http://localhost:8090/etasu/met", this.props.specialtyRxBundle, this.getAxiosOptions()); - console.log(remsAdminResponse) + const remsAdminResponse = this.props.remsAdminResponse this.setState({ remsAdminResponse }); - + // Will not send post request to PIS if only for patient enrollment - if(this.state.remsAdminResponse?.data?.case_number){ + if (this.state.remsAdminResponse?.data?.case_number) { // extract params and questionnaire response identifier let params = this.getResource(this.props.specialtyRxBundle, this.props.specialtyRxBundle.entry[0].resource.focus.parameters.reference); @@ -106,13 +105,16 @@ export default class RemsInterface extends Component { // obtain drug information from database let presciption = this.getResource(this.props.specialtyRxBundle, prescriptionReference); - let prescriptionDisplay = presciption.medicationCodeableConcept.coding[0].display.split(" ")[0]; + let simpleDrugName = presciption.medicationCodeableConcept.coding[0].display.split(" ")[0]; + let rxDate = presciption.authoredOn; let patient = this.getResource(this.props.specialtyRxBundle, patientReference); - let patientName = patient.name[0].given[0] + ' ' + patient.name[0].family; + let patientFirstName = patient.name[0].given[0]; + let patientLastName = patient.name[0].family; + let patientDOB = patient.birthDate; - // console.log(`http://localhost:5051/api/getRx/paitent/${patientName}/drug/${prescriptionDisplay}`); + // console.log(`http://localhost:5051/doctorOrders/api/getRx/${patientFirstName}/${patientLastName}/${patientDOB}?simpleDrugName=${simpleDrugName}&rxDate=${rxDate}`); - axios.get(`http://localhost:5051/doctorOrders/api/getRx/patient/${patientName}/drug/${prescriptionDisplay}`, remsAdminResponse.data, this.getAxiosOptions()).then((response) => { + axios.get(`http://localhost:5051/doctorOrders/api/getRx/${patientFirstName}/${patientLastName}/${patientDOB}?simpleDrugName=${simpleDrugName}&rxDate=${rxDate}`, remsAdminResponse.data, this.getAxiosOptions()).then((response) => { this.setState({ response }); console.log(response); console.log(response.data); @@ -157,28 +159,31 @@ export default class RemsInterface extends Component { refreshPisBundle() { this.setState({ spinPis: true }); - + 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; - } + // 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; + // obtain drug information from database + let presciption = this.getResource(this.props.specialtyRxBundle, prescriptionReference); + let simpleDrugName = presciption.medicationCodeableConcept.coding[0].display.split(" ")[0]; + let rxDate = presciption.authoredOn; + let patient = this.getResource(this.props.specialtyRxBundle, patientReference); + let patientFirstName = patient.name[0].given[0]; + let patientLastName = patient.name[0].family; + let patientDOB = patient.birthDate; - axios.get(`http://localhost:5051/doctorOrders/api/getRx/patient/${patientName}/drug/${prescriptionDisplay}`) + axios.get(`http://localhost:5051/doctorOrders/api/getRx/${patientFirstName}/${patientLastName}/${patientDOB}?simpleDrugName=${simpleDrugName}&rxDate=${rxDate}`) .then((response) => { this.setState({ response: response }); }) @@ -212,14 +217,11 @@ 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 (
- { - hasRemsResponse ? -
+
{hasRemsCase ?
@@ -235,7 +237,7 @@ export default class RemsInterface extends Component {
- + {this.state.remsAdminResponse?.data?.case_number ? : "" } - +
- + {this.state.viewResponse ?
@@ -261,9 +263,9 @@ export default class RemsInterface extends Component {

Bundle

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

Pharmacy Status

@@ -285,7 +287,7 @@ export default class RemsInterface extends Component { : "" }
- + {this.state.viewPisBundle ?


@@ -305,7 +307,7 @@ export default class RemsInterface extends Component {
- + {this.state.remsAdminResponse?.data?.case_number ? - + {this.state.viewBundle ?


Bundle

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