Add Support for FHIR PATCH operations
- Project Title: Add Support for FHIR PATCH operations
- Primary mentor: Ian Bacher @ibacher
- Backup mentor: Abert Namanya @abertnamanya
- Project Link: GSoC-2023: FHIR: Add Support for FHIR PATCH operations
- Project Report: GitHub - mherman22/GSOC-FinalReport
Overview
OpenMRS is using the FHIR API more and more in place of the REST API. However, the FHIR API is, by default, quite verbose. Supporting PATCH operations would allow us to support partial updates to FHIR resources without needing to send the whole resource from the client to the server.
The journey of enhancing OpenMRS through the addition of support for FHIR Patch Operations has been a remarkable experience. In light of the growing importance of the FHIR API as a replacement for the REST API, this project sought to introduce PATCH operations to enable more efficient partial updates to FHIR resources. This feature empowers users to modify specific elements within resources without the need to transmit entire resources between the client and the server.
In the context of the HAPI FHIR library, โpatchingโ refers to the process of making partial updates to a FHIR (Fast Healthcare Interoperability Resources) resource. FHIR resources are representations of healthcare-related data, such as patient, observations, medications, etc., designed to be easily shared and exchanged between different healthcare systems.
Patching allows you to modify specific parts of a FHIR resource without having to replace the entire resource. This can be particularly useful when you want to make minor updates or corrections to a resource without sending the entire payload over the network. The PATCH operation follows the HTTP PATCH method semantics and is designed to be more efficient than the PUT or POST methods for updating resources, especially when dealing with large resources or slow network connections.
- The Patch operations used within the above mentioned patch formats are
add, replace, move, copy, test, remove
.
Format for supporting a single patch
- Detect the incoming format(either json-merge patch, json-patch or xml-patch)
- Load the existing resource in the appropriate format
- Apply the patch
Objectives:
- Implement JSON PATCH operations on all OpenMRS FHIR R4 resources and ensure to have the tests working perfectly. - COMPLETED
- Implement JSON MERGE PATCH operations on all OpenMRS FHIR R4 resources and ensure to have the tests working perfectly. - COMPLETED
- Implement XML PATCH operations on all OpenMRS FHIR R4 resources and ensure to have the tests working perfectly. - COMPLETED
Contributions:
During the project, I worked on various code repositories and pull requests to bring the functionality of PATCH operations to the FHIR API:
Repositories:
- GitHub - openmrs/openmrs-module-fhir2: This is a module implementing a FHIR interface for OpenMRS
- GitHub - openmrs/openmrs-contrib-fhir2-ig: Implementation Guide for the FHIR2 module
Pull Requests:
- FM2-582: Add Support for Patching on Immunization Resource by mherman22 ยท Pull Request #513 ยท openmrs/openmrs-module-fhir2 ยท GitHub - Merged
- FM2-603: Add Support for UPDATE on the Observation Resource by mherman22 ยท Pull Request #509 ยท openmrs/openmrs-module-fhir2 ยท GitHub - Merged
- FM2-592: Add support for XML PATCH operation - Location Resource by mherman22 ยท Pull Request #507 ยท openmrs/openmrs-module-fhir2 ยท GitHub - Merged
- FM2-602: Add support for XML PATCHing operations - Encounter Resource by mherman22 ยท Pull Request #506 ยท openmrs/openmrs-module-fhir2 ยท GitHub - Merged
- FM2-597: Add support for XML PATCHing operations-MedicationDispense Resource by mherman22 ยท Pull Request #503 ยท openmrs/openmrs-module-fhir2 ยท GitHub - Merged
- FM2-598: Add support for XML PATCHing operations-Task Resource by mherman22 ยท Pull Request #502 ยท openmrs/openmrs-module-fhir2 ยท GitHub - Merged
- FM2-599: Add support for XML PATCHing operations - Medication Resource by mherman22 ยท Pull Request #501 ยท openmrs/openmrs-module-fhir2 ยท GitHub - Merged
- FM2-600: Add support for XML PATCHing operations - DiagnosticReport Resource by mherman22 ยท Pull Request #500 ยท openmrs/openmrs-module-fhir2 ยท GitHub - Merged
- Add support for XML PATCHing operations - MedicationRequest Resource by mherman22 ยท Pull Request #499 ยท openmrs/openmrs-module-fhir2 ยท GitHub - Merged
- FM2-593: Add support for XML patching operations - Condition Resource by mherman22 ยท Pull Request #498 ยท openmrs/openmrs-module-fhir2 ยท GitHub - Merged
- FM2-594: Add support for XML patching operations - Person Resource by mherman22 ยท Pull Request #497 ยท openmrs/openmrs-module-fhir2 ยท GitHub - Merged
- FM2-595: Add support for XML patching operations - AllergyIntolerance Resource by mherman22 ยท Pull Request #496 ยท openmrs/openmrs-module-fhir2 ยท GitHub - Merged
- FM2-596: Add support for XML patching operations - Practitioner Resource by mherman22 ยท Pull Request #495 ยท openmrs/openmrs-module-fhir2 ยท GitHub - Merged
- FM2-588: Add support for XML Patch operations - Patient Resource by mherman22 ยท Pull Request #493 ยท openmrs/openmrs-module-fhir2 ยท GitHub - Merged
- FM2-587: Add Support for JSON patching operations โ MedicationDispense Resource by mherman22 ยท Pull Request #492 ยท openmrs/openmrs-module-fhir2 ยท GitHub - Merged
- FM2-583: Add support for Json Merge Patch operations - Practitioner Resource by mherman22 ยท Pull Request #491 ยท openmrs/openmrs-module-fhir2 ยท GitHub - Merged
- FM2-586: Add support for Json Patching operations - DiagnosticReport Resource by mherman22 ยท Pull Request #490 ยท openmrs/openmrs-module-fhir2 ยท GitHub - Merged
- FM2-589: Add support for Json patching operations - Encounter Resource by mherman22 ยท Pull Request #489 ยท openmrs/openmrs-module-fhir2 ยท GitHub - Merged
- FM2-590: Add support for Json Merge Patch operations - Medication Resource by mherman22 ยท Pull Request #488 ยท openmrs/openmrs-module-fhir2 ยท GitHub - Merged
- Add support for Json Merge Patch operations - Patient Resource by mherman22 ยท Pull Request #487 ยท openmrs/openmrs-module-fhir2 ยท GitHub - Merged
- FM2-570: toOpenmrsType translators should set uuid to id part of id, not full id by mherman22 ยท Pull Request #485 ยท openmrs/openmrs-module-fhir2 ยท GitHub - Merged
- FM2-585: Add support for Json Merge Patch operations - Task Resource by mherman22 ยท Pull Request #484 ยท openmrs/openmrs-module-fhir2 ยท GitHub - Merged
- Fm2-579-impl: Add support for Json Patch operations - Patient Resource by mherman22 ยท Pull Request #483 ยท openmrs/openmrs-module-fhir2 ยท GitHub - Merged
- FM2-580: Add support for Json Merge Patch operations - Allergy Intolerance Resource by mherman22 ยท Pull Request #481 ยท openmrs/openmrs-module-fhir2 ยท GitHub - Merged
- FM2-577: Add support for Json patching operations - Person Resource by mherman22 ยท Pull Request #480 ยท openmrs/openmrs-module-fhir2 ยท GitHub - Merged
- FM2-576: Add support for Json patching operations - Condition Resource by mherman22 ยท Pull Request #479 ยท openmrs/openmrs-module-fhir2 ยท GitHub - Merged
- FM2-575: Add support for Json patching operations - Location Resource by mherman22 ยท Pull Request #478 ยท openmrs/openmrs-module-fhir2 ยท GitHub - Merged
Found Issues:
- Medication Dispense was not added to the landing page of the FhirIG
- Medication was not added to the landing page of the FhirIG
Fixed Issues:
- FM2-548: Add medication resource to the index page by mherman22 ยท Pull Request #59 ยท openmrs/openmrs-contrib-fhir2-ig ยท GitHub - Merged
- FM2-549: Adding MedicationDispense to index.md by mherman22 ยท Pull Request #60 ยท openmrs/openmrs-contrib-fhir2-ig ยท GitHub - Merged
Other related work:
During this GSoC jouney, i was able to do other work on the FHIR module as assigned by my mentor and below are the pull requests;-
- FM2-606: Mapping ContactPoints to OpenMRS - Merged
- FM2-605: Add Support for ETags in the FHIR API - Merged
- FM2-481: Clean up parameter passing for Condition Service Search by mherman22 ยท Pull Request #510 ยท openmrs/openmrs-module-fhir2 ยท GitHub - Merged
- FM2-481: Clean up parameter passing for AllergyIntolerance Service Search by mherman22 ยท Pull Request #518 ยท openmrs/openmrs-module-fhir2 ยท GitHub - Merged
- FM2-481: Clean up parameter passing for DiagnosticReport Service Search by mherman22 ยท Pull Request #511 ยท openmrs/openmrs-module-fhir2 ยท GitHub - Merged
- FM2-481: Clean up parameter passing for MedicationRequest Service Search by mherman22 ยท Pull Request #512 ยท openmrs/openmrs-module-fhir2 ยท GitHub - Merged
- FM2-481: Clean up parameter passing for Practitioner Service Search method by mherman22 ยท Pull Request #504 ยท openmrs/openmrs-module-fhir2 ยท GitHub - Merged
- FM2-481: Clean up parameter passing for Medication Service Search method by mherman22 ยท Pull Request #505 ยท openmrs/openmrs-module-fhir2 ยท GitHub - Merged
- FM2-481: Clean up parameter passing for Task Service class search method by mherman22 ยท Pull Request #442 ยท openmrs/openmrs-module-fhir2 ยท GitHub - Merged
- FM2-481: Clean up parameter passing in Person Service class search method by mherman22 ยท Pull Request #441 ยท openmrs/openmrs-module-fhir2 ยท GitHub - Merged
Talk Thread links:
- GSOC 2023: FHIR: Add support for FHIR PATCH operations - project updates
- toOpenmrsType translator for ServiceRequest should be implemented
- failed to validate with reason: uuid: This value exceeds the maximum length of 38 permitted for this field
- Add support for FHIR PATCH operations
Jira Epic
Weekly Blog Posts:
Throughout the development cycle, I chronicled my progress and insights through weekly blog posts:
- GSOC WEEK 12 - WRAPPING UP A FRUITFUL GSOC JOURNEY: ADDING CONTACT POINTS TO THE OPENMRS-MODULE-INITIALIZER
- GSOC WEEK 11: A JOURNEY OF REFINEMENT AND INNOVATION IN FHIR2 MODULE
- GSOC WEEK 10 - EMBRACING THE FINALE: REFLECTING ON MY GSOC JOURNEY
- GSOC 2023 AT OPENMRS | CODING PERIOD WEEK 09
- GSOC 2023 AT OPENMRS | CODING PERIOD WEEK 08
- GSOC 2023 AT OPENMRS | CODING PERIOD WEEK 07
- GSOC 2023 AT OPENMRS | CODING PERIOD WEEK 06
- GSOC 2023 AT OPENMRS | CODING PERIOD WEEK 05
- GSOC 2023 AT OPENMRS | CODING PERIOD WEEK 04
- GSOC 2023 AT OPENMRS | CODING PERIOD WEEK 03
- GSOC 2023 AT OPENMRS | CODING PERIOD WEEK 02
- GSOC 2023 AT OPENMRS | CODING PERIOD WEEK 01
- GSOC 2023 AT OPENMRS | COMMUNITY BONDING PERIOD
Video(Demo)
Resources:
- GSoC proposal
- Midterm evaluation video
- [FM2-573] Add support for FHIR PATCH operations - OpenMRS Issues
Future Works:
While significant strides have been made, certain aspects require further attention. Completing the integration of PATCH operations with complex FHIR resources(ServiceRequest) is a priority. Additionally, refining error handling and optimizing performance will ensure a robust implementation.
Part of the work to be worked on includes but not limited to the following;-
- Ensure Service Request resource is fully translated
- Ensure Service Request resource supports all the PATCHing formats implemented above.
- Write more tests in regard to the how the json documents and xml documents should be written in the attempt to give clearer error messages.(To Be Discussed)
- We could also implement the PATCH operations for the R3 resources(To Be Discussed).
Thoughts on GSoC:
Participating in GSoC 2023 on the OpenMRS platform has been an enlightening journey. Working with esteemed mentors like Ian Bacher and Abert Namanya has been instrumental in my growth. I have gained insights into the world of healthcare informatics, API optimization, and collaborative open-source development. Looking forward, GSoC has paved the way for a continued commitment to enhancing healthcare technology. My knowledge in FHIR standards and OpenMRS data model and how the two integrate to complement each other has greatly grown.
A special thanks to GSoC, OpenMRS, mentors, and the vibrant community for making this journey a resounding success!
cc: @kdaud @jayasanka @grace @jennifer @janflowers @erica @ibacher @dkayiwa @mozzy @samuel34 @jnsereko @jwnasambu @abertnamanya @pmanko @reagan