Skip to content
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

openmrs add fhir.get() function #765

Merged
merged 8 commits into from
Oct 9, 2024
Merged

openmrs add fhir.get() function #765

merged 8 commits into from
Oct 9, 2024

Conversation

mtuchi
Copy link
Collaborator

@mtuchi mtuchi commented Oct 1, 2024

Summary

Add fhir.get() function

Details

Using OpenMRS FHIR Module I have added another function (fhir.get()) which can be used to fetch data from OpenMRS FHIR endpoints. This implementation does not interfere with the current implementation of OpenMRS adaptor which uses OpenMRS Rest API.

Since OpenMRS FHIR Module is the implementation of FHIR, I have tried to compile a list of query params that are most relevant when making a get request with search params and include links to the original documentation.

Important Consideration

  • I could not find the documentation for paging in OpenMRS FHIR Module. But i have tried two endpoints Encounter and Practitioner and both work as expected in auto-paging.

fhir.get('Encounter', { count: 100, lastUpdated: ge${$.cursor})
fhir.get('Practitioner', { count: 2, lastUpdated: ge${$.cursor})

AI Usage

Please disclose how you've used AI in this work (it's cool, we just want to know!):

  • Code generation (copilot but not intellisense)
  • Learning or fact checking
  • Strategy / design
  • Optimisation / refactoring
  • Translation / spellchecking / doc gen
  • Other
  • I have not used AI

You can read more details in our Responsible AI Policy

Review Checklist

Before merging, the reviewer should check the following items:

  • Does the PR do what it claims to do?
  • If this is a new adaptor, added the adaptor on marketing website ?
  • Are there any unit tests?
  • Is there a changeset associated with this PR? Should there be? Note that
    dev only changes don't need a changeset.
  • Have you ticked a box under AI Usage?

@mtuchi
Copy link
Collaborator Author

mtuchi commented Oct 1, 2024

Probably there is a better way of handling auto pagination when fetching encounters from /ws/fhir2/R4/Encounter endpoint but currently i have design this function to validate my workflow design OpenFn/openfn-lime-pilot#42

@mtuchi
Copy link
Collaborator Author

mtuchi commented Oct 2, 2024

Notes for Joe

why fhirGet

  • Currently the adaptor append /ws/rest/v1/ in each operation so i can't make a get request to an endpoint like /ws/fhir2/R4/Encounter because the request url will be {instanceUrl}/ws/rest/v1/ws/fhir2/R4/Encounterwhich is invalid url. Because i didn't to do a major change i created afhirget()` to validate my requirement.

why fhirRequest ?

  • The response for fetching encounters from /ws/fhir2/R4/Encounter is different from /ws/rest/v1/encounter. So auto paging doesn't work with the current implementation of util.request(). I created a copy of util.request() and add auto paging

Query param mapping. Eg 🫱 fhirGet('/ws/fhir2/R4/Encounter', { _count: 100, _lastUpdated: ge${$.cursor}});

  • It's hard finding API documentation for /ws/fhir2/R4/Encounter. Currently i am using chatgpt to figure out what query params are supported and also looking at the response to see other possible query params

@josephjclark
Copy link
Collaborator

Ah this is weird 😬

First, a quick note, your "notes for joe" should really be part of the main PR body. That's important and explains why you're doing this work. When I bug you about doing your github admin or adding detail to PRs, this comment is exactly the kind of thing I'm looking for.

Do we have time to think about this more? I'd much rather do a major version bump and add a fhir "mode" to the existing get functions (or maybe, for now, just to get)

It's a bummer about the documentation. Does this help? https://openmrs.atlassian.net/wiki/spaces/projects/pages/26935963/FHIR+Swagger+Documentation You should find JSON there which describes the supported query parameters.

@mtuchi
Copy link
Collaborator Author

mtuchi commented Oct 5, 2024

Well noted @josephjclark on notes for joe i will keep em coming
Let me read the FHIR Swagger Docs, I will share feedback. This is the OpenMRS Rest API Docs that we used to implement the adaptor

@mtuchi
Copy link
Collaborator Author

mtuchi commented Oct 7, 2024

Hiya @josephjclark unfortunately the documentation was not help full because it only show 3 parameters for /Encounter and currently i am using _count and _lastUpdate in the query parameter. Eg fhirGet('/ws/fhir2/R4/Encounter', { _count: 100, _lastUpdated: ge${$.cursor}}). I tried to see if i can find the documentation from the current OpenMRS instance that i am using but i was getting 404 when trying to access http://{serverHost}:{serverPort}/openmrs/module/fhir/rest/swagger.json.
There is a sense of urgency on this function because it's needed in one of the msf workflow

@mtuchi mtuchi changed the title openmrs add fhirGet function openmrs add fhir.get() function Oct 8, 2024
@mtuchi mtuchi marked this pull request as ready for review October 8, 2024 13:41
@mtuchi
Copy link
Collaborator Author

mtuchi commented Oct 8, 2024

@josephjclark i have cleaned up the implementation a bit and add unit test. I am happy to start with this implementation and modify later when we have a better design. For the time being this will unblock our implementation in msf - OpenFn/openfn-lime-pilot#34

@josephjclark
Copy link
Collaborator

I'm really not happy about this 😐️

Since you say it's urgent, and I can't do anything about it until next week, I'll do a quick review and release now.

What we're doing here is adding more tech debt to an incredibly long (and serious) list. It's making tomorrow harder, which is really the opposite of why we work. It's also been expensive because there's a lot of documentation, and a test, which is going to end up being wasted effort. Actually I don't think we should be duplicating FHIR documentation like this either.

It's a really unsustainable way of developing and we should not be adding short term functions like this.

@josephjclark josephjclark merged commit de0a8fa into main Oct 9, 2024
2 checks passed
@josephjclark josephjclark deleted the openmrs-fhir-get branch October 9, 2024 10:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

2 participants