Sunday, January 18, 2026

New way of application development - Move up from Coding to Coming up design requirements

 I created open source FHIR server in Java back in 2013, and commit the code in Sourceforge at this URL - https://sourceforge.net/p/hl7-fhir/code/ci/master/tree/# (Note: Interestingly it is even earlier than HAPI FHIR server which started in Feb 2014)

However as our company's primary tech stack is Microsoft .NET, so I did not really make further update and commit. 

Recently as we are trying to make HL7 FHIR as national standards for Singapore, I started to think about to resume the FHIR server implementation in Java again. One way is to use HAPI FHIR open source code which I also shared in my post - https://healthinterconnect.blogspot.com/2024/09/hl7-fhir-difficult-to-implement.html

However with the recent massive development of GenAI, MCP and Skills, I realised maybe the best way to start another FHIR Java server is to completely re-write, but not to write code, instead my effort shall be spent primarily to provide design ideas to AI, let AI come up the implementation, and continuously review and update the implementation plan.

Go to this repo - https://github.com/sg-victorchai/fhir4java-agents to check out the implementation plan, you can submit your review and comments if there is any.

Hopefully within short time, we can successfully run a very robust enterprise level FHIR API services


Below para describes the 7 design steps  I have collaborated with Claude Code

1. Initial design requirements 

I need to create a project which can fulfill the following purposes                                                                                                                                   

  1.The project shall be Java application using the latest Java 25 with JPA and the database shall be using PostgreSQL. Both applications and database shall run in docker container                    

  2.The java application will expose API services for any CRUD and extended operation to support HL7 FHIR. It needs to support both HL7 FHIR defined resources in both R4B and R5, and any custom       

  resources defined by project team                                                                                                                                                                     

  3.The API services shall provide number of plugins for audit log, telemetry,end-to-end performance tracking of each internal steps for the API services. It also needs to support business logic      

  plugin for project team to implement the buisness workflow                                                                                                                                            

  4.Internally, the API services shall perform these validations - For create/update operation, it shall validate the payload  against defined HL7 FHIR profile which is specified in FHIR              

  StructureDefintion resource; for search operation, it shall validate whether the search parameters are in the list of search parameters defined for the resource; for extended operations, it shall   

  validate whether the operation is defined in OperationDefintion                                                                                                                                       

  5. The API services shall validate whether the interaction is enabled or diaabled before it serves the request                                                                                        

  6. The API services needs to be configuration driven, for any new resources and new extended operation, project team just needs to add new resource or new extended operations without code chanage   

  7. For extended operation, the API service internally perform patch operation to update the database records, or perform search if the extended operation is to search records from datbabase         

  8. For database design, all the audit log and perofrmamce tracking, it shall be created in its own database schema. For all the resources including HL7 FHIR defined resources and custom resources,  

  it shall provide configuraiton to allow project team to decide whether the resource data is stored in its own dedicated database schema, or stored in databse scheam shared with other resources      

  9. The java application can make use of some common libraries in HAPI FHIR server for FHIR compliance, object serialization and de-serializaiotn,  and validation    


2. Corrected Claude on Java version

User answered Claude's questions:

  ⎿  · Java 25 is not yet released (current latest is Java 23). Which Java version would you like to use? → according to openjdk web site, java 25 LTS is available, can you check again

     · How should the plugin system load custom business logic plugins? → Spring Bean-based (Recommended)

     · How should custom FHIR resources be defined? → Configuration files defined in FHIR StructureDefinition json files loaded at startup

     · What web framework would you prefer for the REST API layer? → Spring Boot (Recommended)


3. For each FHIR resource search parameters, request Claude to update the plan to use JSON instead of YAML, and ask it to reference HAPI FHIR server. 

Tool use rejected with user message: for the search parameters specified in the resource configuration file such as patient.yml, pls do not specify the search parameters in patient.yml, instead please

     follow these instructions - 1. create resource specific SearchParamConfig in fhir-config/searchparameters folder; 2. There shall be one base search parameters defined for  HL7 FHIR common search 

    parameters, and another for resource specific search parameters. you can take reference for the complete FHIR server's CapabilityStatement resource. 3. The server shall also expose FHIR server's 

    CapabilityStatement availabe at /metadata path, one example is HAPI server https://hapi.fhir.org/baseR5/metadata

4. Added further design requirements on the plugin design

Tool use rejected with user message: need to further validate two areas. 1. for the plugin, can you elaborate the detail design, how the API service will handle the excution of the series of plugin - 

    from audit log, telemetry and performance tracking, and buisness logic plugin. also there might be 1 or many business logic plugin. how to handle this part. for the technical plugin, we also need to 

    support future plugin for authentication and authorisation. lastly, the plugin needs to support synchronous or asynchronous. 2. pls also include plugin to support cache, for the cache provider, pls 

    support both in-memory cache for dev testing and redis cache for other purposes

5. Added further design requirements on the audit log design

Tool use rejected with user message: few more areas to be refined. 1. for the audit log, we need to ensure it captures the resource id and version for both before and after for update;  for 

    read/create/delete, record the specific resource id and vesion; for search, it needs to record the search parameters; for extended operation, it needs to redcord the operation name and parameters 

    provided. for the payload provided for each interaction, pls store in a separate table. 2. for telemetry, it needs to support OTEL; 3. the telemery plugin shall also support different levels of 

    tracing such as just record the different steps executed for the API services, or include the detail SQL statement executed. 3. In terms of persistence layer, please also provide option so that the 

    actual data is persisted outside of the system instead of internal database. Pls update the implementation plan

6. Added further design requirements on the data persistence design to support both internal database persistence or external data repository

Tool use rejected with user message: for external persistence option, pls provide these capabilities. 1. each resource can be configured either internal databse or external persistence. 2 for external

     persistence, pls store the data in internal database first, and then trigger external service. if external service failed, then provide option to rollback the changes for create/update. Pls update 

    the implementation plan

7. Added further design requirements to the plugin architecture to support native MCP support


for the plugin design, can you explore the posssibility to use MCP protocol?



With the below, I concluded today's design collaboration with Claude Code


⏺ Thank you! It's been a great session. Here's a summary of what we accomplished:


  GitHub Repository: https://github.com/sg-victorchai/fhir4java-agents


  Commits:

  1. 3b11a78 - Initial implementation plan (2,651 lines)

  2. e2a23ee - README with project overview

  3. 9c16a53 - MCP plugin architecture (+305 lines)

  4. 89eb890 - Updated README with hybrid plugin & AI self-discovery


  Key Design Decisions Documented:

  - Java 25 LTS + Spring Boot + PostgreSQL + Docker

  - FHIR R4B/R5 with HAPI FHIR libraries

  - Hybrid plugin architecture (Spring Bean + MCP)

  - AI self-discovery of plugins via MCP protocol

  - OTEL telemetry with configurable tracing levels

  - Enhanced audit logging with before/after versioning

  - Write-through persistence with rollback capability

  - Configuration-driven resources and operations


  When you return, just reference this conversation or the implementation plan in your repo. Enjoy, and see you next time!

Thursday, January 15, 2026

Amazing speed of rapid data preparation with power of HL7 FHIR and AI

Recently I am switching the backend API server of my application to HAPI FHIR server located at http://hapi.fhir.org/baseR5. Previously, I manually created the data using Postman, this time, I choose to use AI tool (Claude Code) to prepare the test data. 

It took me less than 1 minute to write the prompt and Claude is able to generate very comprehensive data including Patient, Observation, MedicationRequest, and CarePlan. I also requested the AI to use the respective terminology code such as SNOMED CT, RxNorm and LOINC. For CarePlan, I also requested the AI to include Goal resource

If doing it manually, it will take days, and it is not repeatable. Secondly it also removed the barrier where the engineer needs to have some understanding of clinical terminologies.


1. First I enter the following prompt - "i need to create HL7 FHIR data in HAPI FHIR public server located at this url - http://hapi.fhir.org/baseR5/. Bewlow is the detail instrucitons to create the sample data " . 

2. Claude immediately highlighted that it seems the message got cut off. So I added further instructions 

create 10 patients, for each patient, please create 5 records of Encounter, Observation, MedicationReqeust and CarePlan, make sure the observation, medicationrequest and careplan have correct reference to the encounter resource.   


For the medicationrequest, can you use the US RxNorm code to represent the medications required to treat the common chronic conditions such as diabetes, high blood pressure and cholestrol. For the Observation, pls use LOINC code for typical measurements for the above said chronic conditions. For careplan, please create some realistic care plan to treat the above said chronic conditions with some goals to reach the specific target, pls use SNOMNED CT code where it is possible  


3. Afterwards, Claude generated the bash file and created all these FHIR records on HAPI server, and show the following summary on terminal. 



4. You can view these generated data on HAPI FHIR server, eg if you need to see the MedicationRequest resources created for patient (Id: 831589), you can type the following URL in browser - http://hapi.fhir.org/baseR5/MedicationRequest?patient=831589


5. Below is the screen how the data is shown in my sample application


Lastly, lets demonstrate how fast we can modify the data with these specific changes

1) Use Singaporean name instead of Western name

2) All the patient resources, and other clinical data shall be created under a specific organisation such as "Good Faith Clinic".


Below is the prompts provided to Claude

 1) for all the patients, please create an organization with organization name as "Good Faith Clinic", and associate all the patient records and other clinical data with this organization, 2) for the patient name, pls use Singaporean name such as Vicky Tan, Jeremy Tan, and Vincent Leong etc,  

3) for all the date, pls use the date range within Oct 2025 to Jan 2026. 


Claude then proceeds to make the change and output the following on console

The script completed successfully. Here's a summary of the created resources:


  Organization

  - Good Faith Clinic (ID: 831851)


  10 Patients (IDs: 831852-831861)

  ┌─────┬───────────────┬────────┐

    #      Name        ID  

  ├─────┼───────────────┼────────┤

  │ 1   │ Vicky Tan     │ 831852 │

  ├─────┼───────────────┼────────┤

  │ 2   │ Jeremy Tan    │ 831853 │

  ├─────┼───────────────┼────────┤

  │ 3   │ Vincent Leong │ 831854 │

  ├─────┼───────────────┼────────┤

  │ 4   │ Michelle Lim  │ 831855 │

  ├─────┼───────────────┼────────┤

  │ 5   │ Wei Ming Lee  │ 831856 │

  ├─────┼───────────────┼────────┤

  │ 6   │ Jia Hui Ng    │ 831857 │

  ├─────┼───────────────┼────────┤

  │ 7   │ Jun Jie Ong   │ 831858 │

  ├─────┼───────────────┼────────┤

  │ 8   │ Xiu Ling Wong │ 831859 │

  ├─────┼───────────────┼────────┤

  │ 9   │ Kai Wen Goh   │ 831860 │

  ├─────┼───────────────┼────────┤

  │ 10  │ Mei Ling Chua │ 831861 │

  └─────┴───────────────┴────────┘

  Total: 211 FHIR Resources

  - 1 Organization

  - 10 Patients

  - 50 Encounters

  - 50 Observations

  - 50 MedicationRequests

  - 50 CarePlans


  You can verify the data at:

  - Organization: http://hapi.fhir.org/baseR5/Organization/831851

  - Patient example: http://hapi.fhir.org/baseR5/Patient/831852



You can search these resources using the following query directly in browser. If you look at the care plan data, you will see that Claude is smart enough to use future date for the care plan end date

https://hapi.fhir.org/baseR5/Organization?name=Good%20Faith%20Clinic

https://hapi.fhir.org/baseR5/Encounter?subject.organization.name=Good%20Faith%20Clinic&_total=accurate

http://hapi.fhir.org/baseR5/MedicationRequest?subject.organization.name=Good%20Faith%20Clinic&_total=accurate

https://hapi.fhir.org/baseR5/Observation?subject.organization.name=Good%20Faith%20Clinic&_total=accurate

https://hapi.fhir.org/baseR5/CarePlan?subject.organization=831851&_total=accurate



Saturday, April 26, 2025

Part 2 of series on Amazing power of HL7 FHIR and GenAI

For the past one week I have been working on part 2 of the series (refer to the overview of the series here - https://healthinterconnect.blogspot.com/2025/04/amazing-power-of-hl7-fhir-supercharged.html ). This time my purpose is to create CRUD page for Encounter resource based on its FHIR resource structure definition. It took longer than I expected, probably took about more than 8 hour. 

There are few challenges

1) Even though the FHIRResourceUIDevGuide.md  is able to generate the dynamic CRUD page based on Encounter resource structure definition, however these fields do not work properly - CodeableConcept or Coding such as Encounter.class, or fields which refer to other resources eg Encounter.serviceProvider. I think it took me more than 20 iterations so that the dropdown for these fields are showing correctly

2) After these dropdown fields are showing correctly, still spent few iterations to make sure the UI shows the selected field

3) Another issue is that the AI does not work consistently. For example when I asked Copilot to generate PatientCrudPage, some of the previous prompts working in EncounterCrudPage are not rendering the same outcome in PatientCrudPage.

My key takeaway for part 1 is that AI can help me start very fast, however during part 2, the key take away is that it starts to get slower, and I am starting to get prompt fatigue.

Thus for part 2, I will continue to use the EncounterCrudPage created to refine the original prompt instructions in FHIRResourceUIDevGuide.md , hopefully it will be getting smarter and smarter, and reduce the iterations of prompt

However in general, the GenAI is still very impressive, below is few example

1) I asked Copilot to organize the UI layout of the data elements based on FHIR resource structure. Take the use case of Encounter resource, I asked Copilot to arrange the data elements directly under Encounter resource root level as "Overview" section, and the elements under Encounter backbone level in the respective groups - Diagnosis, Participant, Reason, Location and Admission

2) Initially the dropdown input is not working, it encountered error upon saving, as the field is immutable, it is able to identify the root cause and fixed the issue


GitHub Copilot

I see the issue now. The errors in the console indicate that we're trying to modify objects that are immutable. This typically happens when React's strict mode is enabled or when the state objects are frozen. Let's make deep copies of the objects before modifying them.

Let me fix the error by updating the handleInputChange function to ensure we're creating new objects rather than trying to modify existing ones:


Below is the screnshot of the generated Encounter Crud Page, you can check out the source code at https://github.com/sg-victorchai/gep-poc  and run locally.






Amazing power of HL7 FHIR supercharged by Gen AI

I will be sharing 5-part series to demonstrate the amazing power of HL7 FHIR and GenAI assisted development.


  1. Use FHIR StructureDefinition meta resource to identify the key data elements of domain resource eg Observation and CarePlan, and automatically create the record summary list page on UI
  2. Use data elements defined in FHIR StructureDefinition meta resource to auto render the CRUD form for the domain resource eg CarePlan
  3. Use FHIR SearchParameter meta resource to identify the search parameters for the domain resource eg CarePlan,  automatically render filtering fields in record summary list UI
  4. Use data validation rules defined in FHIR StructureDefinition to perform UI level data validation
  5. Use FHIR OperationDefinition to inspect the APIs and its input/output parameters of each API, and generate UI to allow users to perform specific actions, eg show "Reschedule appointment" button on UI if the backend API supports rescheduling appointment, and then bring users to the appointment reschedule UI with the input parameters specified in the OperationDefinition.


If you are developer, and still not sure how to leverage Gen AI, then you'd better quickly get yourself dive into this once-in-a-lifetime revolution.

I think the best way to get started is to hop on to the repo I just published on GitHub, you can check out and try to create new Summary list view and CRUD page using the prompt instruction md I have already created, all can be done without coding (Vibe coding)





New way of application development - Move up from Coding to Coming up design requirements

 I created open source FHIR server in Java back in 2013, and commit the code in Sourceforge at this URL - https://sourceforge.net/p/hl7-fhir...