Skip to content
This repository was archived by the owner on Jul 31, 2023. It is now read-only.
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
23 changes: 23 additions & 0 deletions src/components/RemsInterface/RemsInterface.css
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,29 @@ body {
animation-timing-function: ease-in-out;
}

.requestBody{
overflow-y: scroll;
height:500px;
}
.jsonData{
line-height:16px;
font-family: 'Courier New', Courier, monospace;
font-size: 14px;

border-left: 2px solid #dddddd;
border-top:0px;
padding-left:6px;

display:block;
}

.elementBody{
color:#adadad;
}
.elementKey{
color:#343434
}

@keyframes spin {
from {
transform:rotate(0deg);
Expand Down
127 changes: 81 additions & 46 deletions src/components/RemsInterface/RemsInterface.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ export default class RemsInterface extends Component {
response: null,
spin: false,
spinPis: false,
viewResponse: false,
viewBundle: false,
viewPisBundle: false,
};
Expand All @@ -31,6 +32,8 @@ export default class RemsInterface extends Component {
this.refreshBundle = this.refreshBundle.bind(this);
this.refreshPisBundle = this.refreshPisBundle.bind(this);
this.toggleBundle = this.toggleBundle.bind(this);
this.toggleResponse = this.toggleResponse.bind(this);

this.togglePisBundle = this.togglePisBundle.bind(this);
}

Expand All @@ -47,8 +50,25 @@ export default class RemsInterface extends Component {
return options;
}

unfurlJson(jsonData, level) {
var divStyle = {
marginLeft: 20
};
if (jsonData) {
return Object.keys(jsonData).map(element => {
var elementKey = `${element}-${level}`;
return (
<div id={elementKey} className="jsonData" key={element} style={divStyle}>
<span className="elementKey">{element}</span>: <span className="elementBody">{jsonData[element] === null ? "null" : typeof jsonData[element] === "object" ? this.unfurlJson(jsonData[element], level + 1) : jsonData[element]}</span>
</div>
)
});
}

}

async sendRemsMessage() {
const remsAdminResponse = await axios.post("http://localhost:8090/api/rems", this.props.specialtyRxBundle, this.getAxiosOptions());
const remsAdminResponse = await axios.post("http://localhost:8090/rems", this.props.specialtyRxBundle, this.getAxiosOptions());
this.setState({ remsAdminResponse });
console.log(remsAdminResponse)
axios.post("http://localhost:3010/api/doctorOrder/fhir/rems", remsAdminResponse.data, this.getAxiosOptions()).then((response) => {
Expand All @@ -61,14 +81,21 @@ export default class RemsInterface extends Component {
}

toggleBundle() {
this.setState((prevState)=>{
return {...prevState, viewBundle: !prevState.viewBundle}
this.setState((prevState) => {
return { ...prevState, viewBundle: !prevState.viewBundle }
})
}

toggleResponse() {
console.log(this.state.viewResponse);
this.setState((prevState) => {
return { ...prevState, viewResponse: !prevState.viewResponse }
})
}

togglePisBundle() {
this.setState((prevState)=>{
return {...prevState, viewPisBundle: !prevState.viewPisBundle}
this.setState((prevState) => {
return { ...prevState, viewPisBundle: !prevState.viewPisBundle }
})
}

Expand All @@ -85,15 +112,15 @@ 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)=>{
this.setState({response: response});
this.setState({ spinPis: true });
axios.get(`http://localhost:3010/api/doctorOrder/${this.state.response.data.doctorOrder._id}`).then((response) => {
this.setState({ response: response });
})
}
refreshBundle() {
this.setState({spin: true});
axios.get(`http://localhost:8090/api/rems/${this.state.remsAdminResponse.data.case_number}`).then((response)=>{
this.setState({remsAdminResponse: response});
this.setState({ spin: true });
axios.get(`http://localhost:8090/rems/${this.state.remsAdminResponse.data.case_number}`).then((response) => {
this.setState({ remsAdminResponse: response });
})
}
render() {
Expand All @@ -105,7 +132,7 @@ export default class RemsInterface extends Component {
color = "#f0ad4e"
}

let colorPis = "#f7f7f7"
let colorPis = "#f7f7f7"
const statusPis = this.state.response?.data?.doctorOrder?.dispenseStatus;

if (statusPis === "Approved") {
Expand All @@ -120,7 +147,7 @@ export default class RemsInterface extends Component {
<div>
<div className="container left-form">
<h1>REMS Admin Status</h1>
<Paper style={{paddingBottom: "5px"}}>
<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"}
Expand All @@ -130,53 +157,61 @@ export default class RemsInterface extends Component {
</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})}
/>
:""
}
<Button variant="contained" onClick={this.toggleResponse}>View Response</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="requestBody">
{this.unfurlJson(this.state.remsAdminResponse?.data, 0)}
</div>
:
""}
{this.state.viewBundle ? <div className="bundle-view">
{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">
<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">
{this.renderBundle(this.props.specialtyRxBundle)}
</div>: ""}
</div> : ""}
</div>
{/* <button className="submit-btn" onClick={() => { this.sendRemsMessage() }}>Submit</button> */}

Expand Down