-
Notifications
You must be signed in to change notification settings - Fork 39
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
OHRI-2295 Update OHRI endpoints to use SWR #1902
base: dev
Are you sure you want to change the base?
Conversation
73e4092
to
673fcc2
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @CynthiaKamau just a few comments
@@ -145,7 +137,7 @@ export async function getPatientListsForPatient(patientUuid: string) { | |||
|
|||
export function fetchPatientsFinalHIVStatus(patientUUID: string) { | |||
return openmrsFetch( | |||
`/ws/fhir2/R4/Observation?code=${finalHIVCodeConcept}&value-concept=${finalPositiveHIVValueConcept}&patient=${patientUUID}&_sort=-date&_count=1`, | |||
`/ws/fhir2/R4/Observation?code=${configSchema.obsConcepts._default.finalHIVCodeConcept}&value-concept=${configSchema.obsConcepts._default.finalPositiveHIVValueConcept}&patient=${patientUUID}&_sort=-date&_count=1`, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Getting configs like this seems stressful, since we are using SWR, you can make this a hook and then you will be able to use the useConfig
and that way it will be easy getting the configs.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For some reason, if i
useConfig
none of the endpoints load, i guess its because im not using a hook as the endpoint is called in aPromise.all
export const FirstName_UUID = '166102AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA'; | ||
export const Relationship_UUID = '85d3b4fe-c1a9-4e27-a86b-dcc1e30c8a93'; | ||
export const BASE_WS_API_URL = '/ws/rest/v1/'; | ||
export const BASE_FHIR_API_URL = '/ws/fhir2/R4/'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
new line please, also these baseUrls might be available in the framework we don't need to redefine them
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let me switch to using the openmrs ones
@@ -191,7 +183,9 @@ export function fetchPatientLastEncounter(patientUuid: string, encounterType) { | |||
} | |||
|
|||
export function fetchPatientCovidOutcome() { | |||
return openmrsFetch(`/ws/rest/v1/reportingrest/cohort/${covidOutcomesCohortUUID}`).then(({ data }) => { | |||
return openmrsFetch( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it possible to also turn this into a hook
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually, this endpoint is not in use anymore
6249d39
to
8f37be0
Compare
@@ -177,7 +167,7 @@ export function fetchPatientComputedConcept_HIV_Status(patientUUID: string) { | |||
|
|||
export function fetchPatientLastEncounter(patientUuid: string, encounterType) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@CynthiaKamau I still see fetch functions, I think most of them can be transformed to use SWR
and make them hooks. The ones I think my be hard might be the ones that are using promise.all but we can get a work around on them.
export function fetchConceptNameByUuid(conceptUuid: string) { | ||
return openmrsFetch(`/ws/rest/v1/concept/${conceptUuid}/name?limit=1`).then(({ data }) => { | ||
return openmrsFetch(`${restBaseUrl}/concept/${conceptUuid}/name?limit=1`).then(({ data }) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All these should use SWR and can be hooks since they are GET requests
8f37be0
to
48b32d6
Compare
Requirements
OHRI-123 My PR title
.Summary
Update OHRI endpoints to use SWR
Screenshots
Related Issue
Other