Skip to content

Commit b086b5b

Browse files
authored
Merge pull request #128 from mcode/dev
Dev
2 parents f3c4e5f + 7480650 commit b086b5b

19 files changed

Lines changed: 550 additions & 424 deletions

File tree

.env

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,5 +24,6 @@ VITE_RESPONSE_EXPIRATION_DAYS = 30
2424
VITE_SERVER = http://localhost:8090
2525
VITE_SMART_LAUNCH_URL = http://localhost:4040/
2626
VITE_URL = http://localhost:3000
27-
VITE_URL_FILTER = http://localhost:3000/*
2827
VITE_USER = alice
28+
VITE_HOOK_TO_SEND = patient-view
29+
VITE_URL_FILTER = http://localhost:3000/*

package-lock.json

Lines changed: 0 additions & 156 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/components/Dashboard/Dashboard.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ const Dashboard = props => {
8181
case Section.MEDICATIONS:
8282
return <MedicationsSection client={props.client} />;
8383
case Section.NOTIFICATIONS:
84-
return <NotificationsSection />
84+
return <NotificationsSection />;
8585
default:
8686
return <EmptySection />;
8787
}

src/components/Dashboard/ListSelections/NotificationsSection.jsx

Lines changed: 70 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -7,76 +7,85 @@ import { createMedicationFromMedicationRequest } from '../../../util/fhir';
77
import { standardsBasedGetEtasu } from '../../../util/util';
88

99
const NotificationsSection = () => {
10-
const [globalState, _] = useContext(SettingsContext);
11-
const classes = useStyles();
12-
const [etasu, setEtasu] = useState([]);
13-
const [medications, setMedications] = useState([]);
14-
useEffect(() => {
15-
setEtasu([]);
16-
getMedicationRequest();
17-
}, []);
10+
const [globalState, _] = useContext(SettingsContext);
11+
const classes = useStyles();
12+
const [etasu, setEtasu] = useState([]);
13+
const [medications, setMedications] = useState([]);
14+
useEffect(() => {
15+
setEtasu([]);
16+
getMedicationRequest();
17+
}, []);
1818

19-
useEffect(() => {
20-
getAllEtasu();
21-
}, [medications]);
19+
useEffect(() => {
20+
getAllEtasu();
21+
}, [medications]);
2222

23-
const getMedicationRequest = () => {
24-
const patientsMedications = [];
25-
axios({
26-
method: 'get',
27-
url: `${globalState.baseUrl}/MedicationRequest?subject=Patient/${globalState.patient.id}`
28-
}).then((result) => {
29-
result?.data.entry.forEach((m) => {
30-
const medication = createMedicationFromMedicationRequest(m.resource);
31-
patientsMedications.push(medication);
32-
})
33-
setMedications(patientsMedications);
34-
}, (error) =>{
35-
console.error(error);
23+
const getMedicationRequest = () => {
24+
const patientsMedications = [];
25+
axios({
26+
method: 'get',
27+
url: `${globalState.baseUrl}/MedicationRequest?subject=Patient/${globalState.patient.id}`
28+
}).then(
29+
result => {
30+
result?.data.entry.forEach(m => {
31+
const medication = createMedicationFromMedicationRequest(m.resource);
32+
patientsMedications.push(medication);
3633
});
37-
};
34+
setMedications(patientsMedications);
35+
},
36+
error => {
37+
console.error(error);
38+
}
39+
);
40+
};
3841

39-
const compileResponses = (newRequest, body) => {
40-
if (newRequest.contained) {
41-
newRequest.body = body;
42-
setEtasu(prevState => [ ...prevState, newRequest]);
43-
}
42+
const compileResponses = (newRequest, body) => {
43+
if (newRequest.contained) {
44+
newRequest.body = body;
45+
setEtasu(prevState => [...prevState, newRequest]);
4446
}
47+
};
4548

46-
const getAllEtasu = () => {
47-
medications.forEach((medication) => {
48-
const body = makeBody(medication);
49-
const standardEtasuUrl = `${globalState.remsAdminServer}/4_0_0/GuidanceResponse/$rems-etasu`;
50-
standardsBasedGetEtasu(standardEtasuUrl, body, compileResponses);
51-
});
52-
53-
}
49+
const getAllEtasu = () => {
50+
medications.forEach(medication => {
51+
const body = makeBody(medication);
52+
const standardEtasuUrl = `${globalState.remsAdminServer}/4_0_0/GuidanceResponse/$rems-etasu`;
53+
standardsBasedGetEtasu(standardEtasuUrl, body, compileResponses);
54+
});
55+
};
5456

55-
const makeBody = (medication) => {
56-
return {
57-
resourceType: "Parameters",
58-
parameter: [
59-
{
60-
name: 'patient',
61-
resource: globalState.patient
62-
},
63-
{
64-
name: 'medication',
65-
resource: medication
66-
}
67-
]
57+
const makeBody = medication => {
58+
return {
59+
resourceType: 'Parameters',
60+
parameter: [
61+
{
62+
name: 'patient',
63+
resource: globalState.patient
64+
},
65+
{
66+
name: 'medication',
67+
resource: medication
6868
}
69-
}
69+
]
70+
};
71+
};
7072

71-
return (
72-
<div className={classes.dashboardArea}>
73-
<h2 className={classes.elementHeader}>Notifications</h2>
74-
{etasu.map((remsCase) => {
75-
const display = remsCase.body.parameter[1]?.resource.code.coding[0].display;
76-
return <EtasuStatusComponent key={display} display={display} remsAdminResponseInit={remsCase} data={remsCase.body} />
77-
})}
78-
</div>
79-
);
73+
return (
74+
<div className={classes.dashboardArea}>
75+
<h2 className={classes.elementHeader}>Notifications</h2>
76+
{etasu.map(remsCase => {
77+
const display = remsCase.body.parameter[1]?.resource.code.coding[0].display;
78+
return (
79+
<EtasuStatusComponent
80+
key={display}
81+
display={display}
82+
remsAdminResponseInit={remsCase}
83+
data={remsCase.body}
84+
/>
85+
);
86+
})}
87+
</div>
88+
);
8089
};
8190

8291
export default memo(NotificationsSection);

0 commit comments

Comments
 (0)