Skip to content

Commit

Permalink
Merge pull request #128 from mcode/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
smalho01 authored May 20, 2024
2 parents f3c4e5f + 7480650 commit b086b5b
Show file tree
Hide file tree
Showing 19 changed files with 550 additions and 424 deletions.
3 changes: 2 additions & 1 deletion .env
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,6 @@ VITE_RESPONSE_EXPIRATION_DAYS = 30
VITE_SERVER = http://localhost:8090
VITE_SMART_LAUNCH_URL = http://localhost:4040/
VITE_URL = http://localhost:3000
VITE_URL_FILTER = http://localhost:3000/*
VITE_USER = alice
VITE_HOOK_TO_SEND = patient-view
VITE_URL_FILTER = http://localhost:3000/*
156 changes: 0 additions & 156 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/components/Dashboard/Dashboard.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ const Dashboard = props => {
case Section.MEDICATIONS:
return <MedicationsSection client={props.client} />;
case Section.NOTIFICATIONS:
return <NotificationsSection />
return <NotificationsSection />;
default:
return <EmptySection />;
}
Expand Down
131 changes: 70 additions & 61 deletions src/components/Dashboard/ListSelections/NotificationsSection.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,76 +7,85 @@ import { createMedicationFromMedicationRequest } from '../../../util/fhir';
import { standardsBasedGetEtasu } from '../../../util/util';

const NotificationsSection = () => {
const [globalState, _] = useContext(SettingsContext);
const classes = useStyles();
const [etasu, setEtasu] = useState([]);
const [medications, setMedications] = useState([]);
useEffect(() => {
setEtasu([]);
getMedicationRequest();
}, []);
const [globalState, _] = useContext(SettingsContext);
const classes = useStyles();
const [etasu, setEtasu] = useState([]);
const [medications, setMedications] = useState([]);
useEffect(() => {
setEtasu([]);
getMedicationRequest();
}, []);

useEffect(() => {
getAllEtasu();
}, [medications]);
useEffect(() => {
getAllEtasu();
}, [medications]);

const getMedicationRequest = () => {
const patientsMedications = [];
axios({
method: 'get',
url: `${globalState.baseUrl}/MedicationRequest?subject=Patient/${globalState.patient.id}`
}).then((result) => {
result?.data.entry.forEach((m) => {
const medication = createMedicationFromMedicationRequest(m.resource);
patientsMedications.push(medication);
})
setMedications(patientsMedications);
}, (error) =>{
console.error(error);
const getMedicationRequest = () => {
const patientsMedications = [];
axios({
method: 'get',
url: `${globalState.baseUrl}/MedicationRequest?subject=Patient/${globalState.patient.id}`
}).then(
result => {
result?.data.entry.forEach(m => {
const medication = createMedicationFromMedicationRequest(m.resource);
patientsMedications.push(medication);
});
};
setMedications(patientsMedications);
},
error => {
console.error(error);
}
);
};

const compileResponses = (newRequest, body) => {
if (newRequest.contained) {
newRequest.body = body;
setEtasu(prevState => [ ...prevState, newRequest]);
}
const compileResponses = (newRequest, body) => {
if (newRequest.contained) {
newRequest.body = body;
setEtasu(prevState => [...prevState, newRequest]);
}
};

const getAllEtasu = () => {
medications.forEach((medication) => {
const body = makeBody(medication);
const standardEtasuUrl = `${globalState.remsAdminServer}/4_0_0/GuidanceResponse/$rems-etasu`;
standardsBasedGetEtasu(standardEtasuUrl, body, compileResponses);
});

}
const getAllEtasu = () => {
medications.forEach(medication => {
const body = makeBody(medication);
const standardEtasuUrl = `${globalState.remsAdminServer}/4_0_0/GuidanceResponse/$rems-etasu`;
standardsBasedGetEtasu(standardEtasuUrl, body, compileResponses);
});
};

const makeBody = (medication) => {
return {
resourceType: "Parameters",
parameter: [
{
name: 'patient',
resource: globalState.patient
},
{
name: 'medication',
resource: medication
}
]
const makeBody = medication => {
return {
resourceType: 'Parameters',
parameter: [
{
name: 'patient',
resource: globalState.patient
},
{
name: 'medication',
resource: medication
}
}
]
};
};

return (
<div className={classes.dashboardArea}>
<h2 className={classes.elementHeader}>Notifications</h2>
{etasu.map((remsCase) => {
const display = remsCase.body.parameter[1]?.resource.code.coding[0].display;
return <EtasuStatusComponent key={display} display={display} remsAdminResponseInit={remsCase} data={remsCase.body} />
})}
</div>
);
return (
<div className={classes.dashboardArea}>
<h2 className={classes.elementHeader}>Notifications</h2>
{etasu.map(remsCase => {
const display = remsCase.body.parameter[1]?.resource.code.coding[0].display;
return (
<EtasuStatusComponent
key={display}
display={display}
remsAdminResponseInit={remsCase}
data={remsCase.body}
/>
);
})}
</div>
);
};

export default memo(NotificationsSection);
Loading

0 comments on commit b086b5b

Please sign in to comment.