Showing posts with label HL7. Show all posts
Showing posts with label HL7. Show all posts

Sunday, January 5, 2025

HL7 FHIR APIs can fundamentally transform the rapid development of frontend web application

 Just imagine if all your backend APIs is based on HL7 FHIR API, how it will fundamentally transform your frontend web application development

One immediate benefit is that your frontend developer will not be pressing you to come up the running APIs, because he/she can just pick any publicly available HL7 FHIR Server to test and integrate. 

Another greater benefit is that we can fundamentally re-design the web application to take full advantage of the consistent APIs that are based on HL7 FHIR. 

Let me walk through the 2nd benefits here

I am going to walk through a simple ReactJS Single Page Application (SPA) I have created in the past, the actual source code is hosted on code sandbox - https://muqhwj.csb.app/patients. This demo SPA is integrated with the live APIs hosted in HealthX Sandbox - https://api.healthx.sg/.../2807f247634c4f3c941568d460835a71. (Note the last part of the URL is the tenant ID)

For the demo ReactJS SPA, pls take note that the intent of the demo app is NOT to demonstrate the coding best practice for ReactJS SPA, eg I did not use TypeScript in the demo yet, the configuration is not maintained in external configuration settings etc. I only spent 1 or 2 days to put up the demoReactJS SPA.

The demo application shows whatever health records available in the backend system with a simple UI design - summary view and detail view. There is only one API component and oneUI component regardless of how many resources you like to show on the UI
  1. All the backend API integration is coded in this API slice - https://codesandbox.io/p/sandbox/muqhwj...
    1. I use the method - getResourcesEntries for getting ALL kinds of resources (other than Patient record) and also do transformation from backend process API to experience API for the Summary View (I moved the included patient resources into respective patient data resource eg Condition under the element "_includedPatient", so that it is easier for UI to render the data). 
    2. The second method is getResourceDetail which is to get the detail payload of the specific record for any given type of resource for the Detail View
  2. The UI layout is implemented in these two files
If you want to try out yourself, you can fork to a new project, and then try to modify these two files to add additional record type to be shown in UI, or update the data elements to be shown for each record type

  1. Add new record type and corresponding menu item name in this file - https://codesandbox.io/p/sandbox/muqhwj...
  2. Add/update data elements to be shown for the corresponding record type - update function resourceSummaryElements in this file - https://codesandbox.io/p/sandbox/muqhwj...

Tuesday, July 2, 2024

HL7 FHIR DevDays 2024 - Sharing of Singapore's Healthier SG implementation

 Below is the some of the slides from the recent sharing at FHIR DevDays 2024 (https://www.devdays.com/) on Singapore's National Healthier SG implementation.









I am also glad that the implementation got the inaugural FHIR implementers award, below is the finalist pitch I shared during DevDays







For more details, please go to the following Firely site on the highlights of FHIR DevDays 2024



Friday, August 11, 2023

How to model Patient flowsheet in HL7 FHIR

1. Overview

Recently I am working on the HL7 FHIR information model to represent patient flowsheet for the purpose of integration with one EMR vendor product, the EMR vendor also does not have information and model to represent patient flowsheet, though the reading is represented using Observation resource.

I searched FHIR chat group, there is also no specific implementation guideline on patient flowsheet, thus I have proposed the following design, I welcome comment and discussion on this topic.

1) Use PlanDefinition resource to represent the flowsheet

2) Use CarePlan resource to represent the association of the selected flowsheet to the patient

3) For the Observation resource, use "basedOn" attribute to specify the specific patient flowsheet for the reading submission


Below diagram illustrates the model and relationship between the three resources




2. CarePlan resource

CarePlan resource to represent the specific flowsheet selected for the patient, the "category" attribute will be used to specify this care plan is patient flowsheet.



3. PlanDefinition resource for the flowsheet which can be selected and assigned to the patient





4. Observation resource for the patient flowsheet reading, use "basedOn" to associate wth the patient flowsheet



5. Revised Design after consultation within FHIR community

After discussion within FHIR community, the consensus is that we should use Questionnaire to represent the Flowsheet template.

Below please find the overview of the revised model (Click on the image to Zoom In)




Thursday, May 18, 2023

Leverage HL7 FHIR Operation to achieve the purpose of "Small Functional APIs"

Overview

During the course of design and implementation for API for modern API driven development, various engineers have been asking the gradually of API, how much responsibility each API shall have, and how to balance the initial implementation and ongoing maintenance of the APIs from both API provider and API consumer perspectives. In this post, I will be sharing my recommendations from my personal professional perspective, do let me know your view.

Technology has been evolving, eg from SOAP to RESTful, from monolithic application design to SOA and now MSA, however the underlying design principles remains unchanged, and we can still go back to the decades old design principles to guide modern application design, and API design specifically in this post.

One of the design principles I would like to reference here is the following para from "Basics of the Unix Philosophy"

"Make each program do one thing well. To do a new job, build afresh rather than complicate old programs by adding new features."

As this quote conveys, the Unix culture centers around small and simple tools that can be combined. This advice still rings true even after more than 45 years later when we deal with API design and development. To adapt this principle to API design, we may say,  "Make each API do one thing well".

Benefits of making small functional APIs

So what's the benefits of adopting this API design principle, there are three benefits according to this books - Building Secure and Reliable Systems

  1. Design for Understandability. 
  2. Design for Least Privilege 
  3. Design for Resilience 


Design for Understandability

It is much easier for API consumer to understand the API as it is small functional API, it has very specific functional responsibility, it has very specific input parameters and expected response. It is also easier to API provider to rollout new API faster and safer since it does not involve the changing of existing gigantic API

Design for Least Privilege

Each API can be enforced specifically to allow certain API consumers to call, this can be easily enforced at the typical API Gateway products. In contrast to very coarse grained API, this can not done, as API gateway will not be able to go into the API payload to check whether a certain API consumer is allowed to call or not, also if the API gateway starting to go down to this level of detail, then it also embeds the business specific logics, it will complicate the API gateway management and maintenance

Design for Resilience

Wth each API only serve for specific functional responsibility, we can also control the blast radius. When things go wrong, only the specific APIs are affected, thus only specific functional areas are affected.


How to design small functional APIs


However "great power comes with great responsibility", to reap the benefits, we need to take extra care to have good design in place, to ensure the API design is consistent and scalable across many different small functional APIs.

Luckily we do not need to start from scratch, HL7 FHIR also defined capability for standardised, consistent and scalable way of designing small functional APIs, this is the Extended Operations on RESTful APIs.


I will cover the use of HL7 FHIR Operations capability in next post, stay tuned!

Tuesday, April 8, 2014

HL7 FHIR Partial Update

Below I summarized what I have tried so far for handling partial update in HL7 FHIR.

1) Syntax

URL: http://[server]/[resource]/[logical id]/_delta
method: POST

I did not use PATCH method since some of older browser does not support this method, also not sure whether PATCH method has been supported in all javascript library

2) Extension element to specify update mode

For each element to be added/replaced/deleted, added the following extension

       <extension url="http://hl7.org/fhir/Profile/iso-21090#updateMode" >
            <valueCode value="A or R or D" />
        </extension>

As an example, below is the XML snippet for updating birthDate

 <birthDate value="1970-03-13">
      <extension url="http://hl7.org/fhir/Profile/iso-21090#updateMode" >
            <valueCode value="R" />
        </extension
>

  </birthDate>


3) Handling collection

For collection data elements such as name, address and contact in Patient resource, server needs to know which element within the collection is to be replaced/deleted. So I decided to pull collection element's internal id as part of the query response, and then use the same id when submitting the payload to server

- Added collection element internal id in query response as part of element extension

    <telecom>
        <extension url="http://hl7.org/fhir/metadata#id">
            <valueString value="1308"/>
        </extension>

        <system value="phone"/>
        <value value="68181256"/>
        <use value="home"/>
    </telecom>

- Payload for partial update
      <telecom>
            <extension url="http://hl7.org/fhir/metadata#id">
                <valueString value="1308"/>
            </extension>

            <extension url="http://hl7.org/fhir/Profile/iso-21090#updateMode" >
                <valueCode value="R" />
             </extension>

           <system value="phone"/>
           <value value="68181256"/>
           <use value="office"/>
    </telecom>


4) Suggestion

The above approach works okay so far, however I'd like to make one suggestion here. As we can see from the above XML snippet, the content is very verbose after adding extension elements.Can we add the two attributes (id and updateMode) in FHIR resource as part of Element built-in attributes? In this way, the content will be very compact as the following snippet shows,

     <telecom  id="1308" updateMode="R">             
           <system value="phone"/>
           <value value="68181256"/>
           <use value="office"/>
    </telecom>


Tuesday, November 12, 2013

Open source implementation of HL7 FHIR persistence

After I presented the journey from HL7v2 to HL7 FHIR during HIMSS DHW 2013 few weeks ago, the slide is here Use of FHIR in next generation healthcare product for reference, I started to think about how easy it is to implement native FHIR based RDMBS storage, so that the FHIR resource can be natively stored in RDMBS and users are also able to directly query the data using SQL. There are some existing open source implementation, but as far as I can tell those implementations are using document based storage such as MongoDB, data reuse and extraction for reporting and other usage might be problem.

It is not as straightforward as I have initially thought, I need to explore different ways of persisting FHIR resource into RDMBS such as

1) Whether it is possible to just generate O/R mapping without changing the existing FHIR resource java classes. For this issue, the initial assessment is not 100 percent possible, I intend to compile a list and feed back to Grahame for consideration.
2) Whether to store patient name as JPA embeddable or entity
3) How to handle nested collection, such as List<CodeableConcept> since CodeableConcept object itself contains list of Coding object. or List<HumanName> where each attribute such as 'family' attribute is again a collection of String object
4) With nested collection, is it possible to query such attributes at API level. For example I already encountered some problems when I tried to query collection attributes within embedded table as even the latest JPA 2.1 spec does not support such implementation yet, as a result I have to go back to change the O/R mapping approach



Though it is still in early stage of exploring and trying out, I think it might be useful experience to share with other like-minded developers who might be keen to explore the same to create FHIR based persistence similar to HL7 RIMBAA concept, so I decided to make it as open source project, the project is hosted at sourceforge http://sourceforge.net/projects/hl7-fhir/

The scope of the project is illustrated below,  the reference implementation uses eclipselink 2.5 which is based on the latest JPA 2.1 spec,  database tier is using hsqldb as reference.




Once I have finalized the O/R mapping approach, the next step is to come up a XSLT to auto generate all the JPA O/R mapping based on FHIR XSD

So do stay tuned, and let me know if you have any feedback or have the intention to contribute to this project!

HL7 FHIR APIs can fundamentally transform the rapid development of frontend web application

 Just imagine if all your backend APIs is based on HL7 FHIR API, how it will fundamentally transform your frontend web application developme...