Skip to content

Commit

Permalink
Fix prettier
Browse files Browse the repository at this point in the history
  • Loading branch information
Ariel Virgulto committed Feb 12, 2024
1 parent 4d117eb commit e5146e8
Show file tree
Hide file tree
Showing 4 changed files with 84 additions and 51 deletions.
25 changes: 17 additions & 8 deletions src/views/Patient/MedReqDropDown/MedReqDropDown.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,21 @@ import RefreshIcon from '@mui/icons-material/Refresh';
import Box from '@mui/material/Box';
import ListIcon from '@mui/icons-material/List';
import LocalPharmacyIcon from '@mui/icons-material/LocalPharmacy';
import { BundleEntry, Patient, MedicationRequest, Practitioner, Resource, MedicationDispense } from 'fhir/r4';
import {
BundleEntry,
Patient,
MedicationRequest,
Practitioner,
Resource,
MedicationDispense
} from 'fhir/r4';
import Client from 'fhirclient/lib/Client';
import { ReactElement, useEffect, useState } from 'react';
import example from '../../../cds-hooks/prefetch/exampleHookService.json'; // TODO: Replace with request to CDS service
import { hydrate } from '../../../cds-hooks/prefetch/PrefetchHydrator';
import { Hook, Card as HooksCard, OrderSelectHook } from '../../../cds-hooks/resources/HookTypes';
import OrderSelect from '../../../cds-hooks/resources/OrderSelect';
import {
getDrugCodeFromMedicationRequest
} from '../../Questionnaire/questionnaireUtil';
import { getDrugCodeFromMedicationRequest } from '../../Questionnaire/questionnaireUtil';
import './MedReqDropDown.css';
import * as env from 'env-var';
import { MedicationBundle, submitToREMS } from '../PatientView';
Expand Down Expand Up @@ -82,7 +87,9 @@ function MedReqDropDown({
const [checkedEtasuTime, setCheckedEtasuTime] = useState(0);
// Pharmacy
const [showPharmacy, setShowPharmacy] = useState<boolean>(false);
const [testEhrResponse, setTestEhrResponse] = useState<BundleEntry<MedicationDispense> | null>(null);
const [testEhrResponse, setTestEhrResponse] = useState<BundleEntry<MedicationDispense> | null>(
null
);
const [checkedPharmacyTime, setCheckedPharmacyTime] = useState(0);
const [sendRxEnabled, setSendRxEnabled] = useState<boolean>(false);

Expand Down Expand Up @@ -209,7 +216,9 @@ function MedReqDropDown({
setCheckedPharmacyTime(Date.now());
const rxId = selectedMedicationCard?.id;

const url = `${env.get('REACT_APP_DEFAULT_ISS').asString()}/MedicationDispense?prescription=${rxId}`;
const url = `${env
.get('REACT_APP_DEFAULT_ISS')
.asString()}/MedicationDispense?prescription=${rxId}`;
axios({
method: 'get',
url: url
Expand Down Expand Up @@ -310,7 +319,7 @@ function MedReqDropDown({
} else if (remsAdminResponse?.status === 'Pending') {
color = '#f0ad4e'; // orange
}

const pStatus = testEhrResponse?.resource?.status;
let pColor = '#0c0c0c'; // black
if (pStatus === 'completed') {
Expand Down Expand Up @@ -426,7 +435,7 @@ function MedReqDropDown({
<div>
<LocalPharmacyIcon fontSize="large" />
<p className="etasuButtonText">Pharmacy: </p>
<p>{testEhrResponse?.resource?.status || 'Not Started'}</p>
<p>{testEhrResponse?.resource?.status || 'Not Started'}</p>
</div>
</Button>
{renderTimestamp(checkedPharmacyTime)}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,14 @@ const PharmacyStatus = (props: PharmacyStatusProps) => {
<div className="status-icon" style={{ backgroundColor: color }}></div>
<Grid container columns={12}>
<Grid item xs={10}>
<div className="bundle-entry">ID: {props.testEhrResponse?.resource?.id|| 'N/A'}</div>
<div className="bundle-entry">Status: {props.testEhrResponse?.resource?.status ? props.testEhrResponse?.resource?.status?.charAt(0).toUpperCase() + props.testEhrResponse?.resource?.status?.slice(1) : 'N/A'}</div>
<div className="bundle-entry">ID: {props.testEhrResponse?.resource?.id || 'N/A'}</div>
<div className="bundle-entry">
Status:{' '}
{props.testEhrResponse?.resource?.status
? props.testEhrResponse?.resource?.status?.charAt(0).toUpperCase() +
props.testEhrResponse?.resource?.status?.slice(1)
: 'N/A'}
</div>
</Grid>
<Grid item xs={2}>
<div className="bundle-entry">
Expand Down
Original file line number Diff line number Diff line change
@@ -1,40 +1,40 @@
import { fireEvent, render, screen } from '@testing-library/react';
import '@testing-library/jest-dom';
import { MedicationDispense, BundleEntry } from 'fhir/r4';
import { MedicationDispense, BundleEntry } from 'fhir/r4';

import PharmacyStatus from '../PharmacyStatus';

const testMedicationDispense: BundleEntry<MedicationDispense> = {
'resource': {
'resourceType': 'MedicationDispense',
'id': 'pat017-mr-turalio-dispense',
'meta': {
'versionId': '4',
'lastUpdated': '2024-02-08T16:02:57.850+00:00',
'source': '#pat017-mr-turali'
resource: {
resourceType: 'MedicationDispense',
id: 'pat017-mr-turalio-dispense',
meta: {
versionId: '4',
lastUpdated: '2024-02-08T16:02:57.850+00:00',
source: '#pat017-mr-turali'
},
'status': 'completed',
'medicationCodeableConcept': {
'coding': [
{
'system': 'http://www.nlm.nih.gov/research/umls/rxnorm',
'code': '2183126',
'display': 'Turalio 200 MG Oral Capsule'
},
{
'system': 'http://hl7.org/fhir/sid/ndc',
'code': '65597-402-20'
}
]
},
'subject': {
'reference': 'Patient/pat017',
'display': 'Jon Snow'
},
'authorizingPrescription': [
status: 'completed',
medicationCodeableConcept: {
coding: [
{
system: 'http://www.nlm.nih.gov/research/umls/rxnorm',
code: '2183126',
display: 'Turalio 200 MG Oral Capsule'
},
{
'reference': 'MedicationRequest/pat017-mr-turalio'
system: 'http://hl7.org/fhir/sid/ndc',
code: '65597-402-20'
}
]
},
subject: {
reference: 'Patient/pat017',
display: 'Jon Snow'
},
authorizingPrescription: [
{
reference: 'MedicationRequest/pat017-mr-turalio'
}
]
}
};
Expand All @@ -61,10 +61,15 @@ describe('Test the PharmacyStatus Component', () => {
expect(refreshButton).toBeInTheDocument();
});
test('Renders order', async () => {
render(<PharmacyStatus update={false} callback={() => {}} testEhrResponse={testMedicationDispense} />);
expect(await screen.findByText(`ID: ${testMedicationDispense.resource?.id}`)).toBeInTheDocument();
expect(await screen.findByText(`Status: ${testMedicationDispense.resource?.status}`)).toBeInTheDocument();

render(
<PharmacyStatus update={false} callback={() => {}} testEhrResponse={testMedicationDispense} />
);
expect(
await screen.findByText(`ID: ${testMedicationDispense.resource?.id}`)
).toBeInTheDocument();
expect(
await screen.findByText(`Status: ${testMedicationDispense.resource?.status}`)
).toBeInTheDocument();
});

test('Loads data on start', () => {
Expand Down
31 changes: 22 additions & 9 deletions src/views/Questionnaire/components/RemsInterface/RemsInterface.tsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,20 @@
import React, { useEffect, useState } from 'react';
import ResourceEntry from './ResourceEntry';
import './RemsInterface.css';
import axios from 'axios';
import axios from 'axios';
import Paper from '@mui/material/Paper';
import Button from '@mui/material/Button';
import AutorenewIcon from '@mui/icons-material/Autorenew';
import { Bundle, MedicationDispense, BundleEntry, MessageHeader, Parameters, Patient } from 'fhir/r4';
import {
Bundle,
MedicationDispense,
BundleEntry,
MessageHeader,
Parameters,
Patient
} from 'fhir/r4';
import * as env from 'env-var';


interface RemsInterfaceProps {
remsAdminResponse: RemsAdminResponse;
specialtyRxBundle: Bundle;
Expand All @@ -31,7 +37,7 @@ interface JsonData {

export default function RemsInterface(props: RemsInterfaceProps) {
const [remsAdminResponse, setRemsAdminResponse] = useState<RemsAdminResponse | null>(null);
const [response, setResponse] = useState<BundleEntry<MedicationDispense> | null>(null);
const [response, setResponse] = useState<BundleEntry<MedicationDispense> | null>(null);

const [spin, setSpin] = useState<boolean>(false);
const [spinPis, setSpinPis] = useState<boolean>(false);
Expand All @@ -42,7 +48,6 @@ export default function RemsInterface(props: RemsInterfaceProps) {
sendRemsMessage();
}, []);


const unfurlJson = (jsonData: JsonData) => {
return jsonData.metRequirements
.sort((first: MetRequirements, second: MetRequirements) => {
Expand Down Expand Up @@ -111,7 +116,9 @@ export default function RemsInterface(props: RemsInterfaceProps) {
}
const potentialPrescription = getResource(props.specialtyRxBundle, prescriptionReference);
const rxId = potentialPrescription?.id;
const url = `${env.get('REACT_APP_DEFAULT_ISS').asString()}/MedicationDispense?prescription=${rxId}`;
const url = `${env
.get('REACT_APP_DEFAULT_ISS')
.asString()}/MedicationDispense?prescription=${rxId}`;
axios({
method: 'get',
url: url
Expand Down Expand Up @@ -245,11 +252,17 @@ export default function RemsInterface(props: RemsInterfaceProps) {
<h1>Pharmacy Status</h1>
<Paper style={{ paddingBottom: '5px' }}>
<div className="status-icon" style={{ backgroundColor: colorPis }}></div>
<div className="bundle-entry">ID : {response?.resource?.id || 'N/A'}</div>
<div className="bundle-entry">Status: {response?.resource?.status ? response?.resource?.status?.charAt(0).toUpperCase() + response?.resource?.status?.slice(1) : 'N/A'}</div>
<div className="bundle-entry">ID : {response?.resource?.id || 'N/A'}</div>
<div className="bundle-entry">
Status:{' '}
{response?.resource?.status
? response?.resource?.status?.charAt(0).toUpperCase() +
response?.resource?.status?.slice(1)
: 'N/A'}
</div>
<div className="bundle-entry">
{/* <Button variant="contained" onClick={this.togglePisBundle}>View Bundle</Button> */}
{response?.resource?.id ? (
{response?.resource?.id ? (
<AutorenewIcon
className={spinPis === true ? 'refresh' : 'renew-icon'}
onClick={refreshPisBundle}
Expand Down

0 comments on commit e5146e8

Please sign in to comment.