Skip to content
This repository was archived by the owner on Jul 31, 2023. It is now read-only.
Merged
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
298 changes: 182 additions & 116 deletions src/components/RemsInterface/RemsInterface.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -57,38 +57,71 @@ export default class RemsInterface extends Component {
return (
<div>
<div className={"resource-entry etasu-container"}>
<div className={"resource-entry-text"} >{metReq.requirement.name}</div>
<div className={"resource-entry-text"} >{metReq.requirementName}</div>
<div className={"resource-entry-icon"}>{metReq.completed ? "✅" : "❌"}</div>
<div className={"resource-entry-hover"}>{metReq.requirement.description}</div>
<div className={"resource-entry-hover"}>{metReq.requirementDescription}</div>
</div>
{
metReq.childMetRequirements.map(subMetReq =>
<div className={"resource-entry resource-child etasu-container"}>
<div className={"resource-entry-text"}>{subMetReq.requirement.name}</div>
<div className={"resource-entry-icon"}>{subMetReq.completed ? "✅" : "❌"}</div>
<div className={"resource-entry-hover"}>{subMetReq.requirement.description}</div>
</div>
)
}
</div>
)
});

}

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());

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should clean this up.

// this.setState({ remsAdminResponse });
// console.log(remsAdminResponse)
}

toggleBundle() {
Expand Down Expand Up @@ -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 });
})
}
Expand All @@ -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"
Expand All @@ -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 (
<div>
{hasRemsCase ?
{
hasRemsResponse ?
<div>
<div className="container left-form">
<h1>REMS Admin Status</h1>
<Paper style={{ paddingBottom: "5px" }}>
<div className="status-icon" style={{ backgroundColor: color }}></div>
<div className="bundle-entry">
Case Number : {this.state.remsAdminResponse?.data?.case_number || "N/A"}
</div>
<div className="bundle-entry">
Status: {this.state.remsAdminResponse?.data?.status}
</div>
<div className="bundle-entry">
<Button variant="contained" onClick={this.toggleBundle}>View Bundle</Button>
<Button variant="contained" onClick={this.toggleResponse}>View ETASU</Button>

{this.state.remsAdminResponse?.data?.case_number ?
<AutorenewIcon
className={this.state.spin === true ? "refresh" : "renew-icon"}
onClick={this.refreshBundle}
onAnimationEnd={() => this.setState({ spin: false })}
/>
: ""
}

</div>

</Paper>
{this.state.viewResponse ?
<div className="bundle-view">
{hasRemsCase ?
<div>
<div className="container left-form">
<h1>REMS Admin Status</h1>
<Paper style={{ paddingBottom: "5px" }}>
<div className="status-icon" style={{ backgroundColor: color }}></div>
<div className="bundle-entry">
Case Number : {this.state.remsAdminResponse?.data?.case_number || "N/A"}
</div>
<div className="bundle-entry">
Status: {this.state.remsAdminResponse?.data?.status}
</div>
<div className="bundle-entry">
<Button variant="contained" onClick={this.toggleBundle}>View Bundle</Button>
<Button variant="contained" onClick={this.toggleResponse}>View ETASU</Button>

{this.state.remsAdminResponse?.data?.case_number ?
<AutorenewIcon
className={this.state.spin === true ? "refresh" : "renew-icon"}
onClick={this.refreshBundle}
onAnimationEnd={() => this.setState({ spin: false })}
/>
: ""
}

</div>

</Paper>
{this.state.viewResponse ?
<div className="bundle-view">
<br></br>
<h3>ETASU</h3>
{this.unfurlJson(this.state.remsAdminResponse?.data, 0)}
</div>
:
""}
{this.state.viewBundle ? <div className="bundle-view">
<br></br>
<h3>ETASU</h3>
{this.unfurlJson(this.state.remsAdminResponse?.data, 0)}
</div>
:
""}
{this.state.viewBundle ? <div className="bundle-view">
<br></br>
<h3>Bundle</h3>
{this.renderBundle(this.props.specialtyRxBundle)}
</div> : ""}

<h3>Bundle</h3>
{this.renderBundle(this.props.specialtyRxBundle)}
</div> : ""}

</div>

<div className="right-form">
<h1>Pharmacy Status</h1>
<Paper style={{ paddingBottom: "5px" }}>
<div className="status-icon" style={{ backgroundColor: colorPis }}></div>
<div className="bundle-entry">
ID : {this.state.response?.data?._id || "N/A"}
</div>
<div className="bundle-entry">
Status: {this.state.response?.data?.dispenseStatus}
</div>
<div className="bundle-entry">
{/* <Button variant="contained" onClick={this.togglePisBundle}>View Bundle</Button> */}
{this.state.response?.data?._id ?
<AutorenewIcon
className={this.state.spinPis === true ? "refresh" : "renew-icon"}
onClick={this.refreshPisBundle}
onAnimationEnd={() => this.setState({ spinPis: false })}
/>
: ""
}
</div>

</Paper>
{this.state.viewPisBundle ? <div className="bundle-view">
<br></br>
<h3>Bundle</h3>
{this.renderBundle(this.props.specialtyRxBundle)}
</div> : ""}
</div>
</div>

<div className="right-form">
<h1>Pharmacy Status</h1>
<Paper style={{ paddingBottom: "5px" }}>
<div className="status-icon" style={{ backgroundColor: colorPis }}></div>
<div className="bundle-entry">
ID : {this.state.response?.data?.doctorOrder?._id || "N/A"}
</div>
<div className="bundle-entry">
Status: {this.state.response?.data?.doctorOrder?.dispenseStatus}
</div>
<div className="bundle-entry">
<Button variant="contained" onClick={this.togglePisBundle}>View Bundle</Button>
{this.state.response?.data?.doctorOrder?._id ?
<AutorenewIcon
className={this.state.spinPis === true ? "refresh" : "renew-icon"}
onClick={this.refreshPisBundle}
onAnimationEnd={() => this.setState({ spinPis: false })}
/>
: ""
}
</div>

</Paper>
{this.state.viewPisBundle ? <div className="bundle-view">
<br></br>
<h3>Bundle</h3>
{this.renderBundle(this.props.specialtyRxBundle)}
</div> : ""}
:
<div>
<div className="container left-form">
<h1>Prescriber Document Status</h1>
<Paper style={{ paddingBottom: "5px" }}>
<div className="status-icon" style={{ backgroundColor: "#5cb85c" }}></div>
<div className="bundle-entry">
Status: Documents successfully submitted
</div>
<div className="bundle-entry">
<Button variant="contained" onClick={this.toggleBundle}>View Bundle</Button>

{this.state.remsAdminResponse?.data?.case_number ?
<AutorenewIcon
className={this.state.spin === true ? "refresh" : "renew-icon"}
onClick={this.refreshBundle}
onAnimationEnd={() => this.setState({ spin: false })}
/>
: ""
}
</div>

</Paper>
{this.state.viewBundle ? <div className="bundle-view">
<br></br>
<h3>Bundle</h3>
{this.renderBundle(this.props.specialtyRxBundle)}
</div> : ""}

</div>
</div>
}
</div>
:
<div>
<div className="container left-form">
<h1>Prescriber Document Status</h1>
<Paper style={{ paddingBottom: "5px" }}>
<div className="status-icon" style={{ backgroundColor: "#5cb85c" }}></div>
<div className="bundle-entry">
Status: Documents successfully submitted
</div>
<div className="bundle-entry">
<Button variant="contained" onClick={this.toggleBundle}>View Bundle</Button>

{this.state.remsAdminResponse?.data?.case_number ?
<AutorenewIcon
className={this.state.spin === true ? "refresh" : "renew-icon"}
onClick={this.refreshBundle}
onAnimationEnd={() => this.setState({ spin: false })}
/>
: ""
}
</div>

</Paper>
{this.state.viewBundle ? <div className="bundle-view">
<br></br>
<h3>Bundle</h3>
{this.renderBundle(this.props.specialtyRxBundle)}
</div> : ""}

</div>
No response - form has already been submitted previously....
</div>
}

</div>
)
}
Expand Down