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



No comments:

Post a Comment

New way of application development - Move up from Coding to Business outcome and Design

Recently as we are propopsing HL7 FHIR as national standards for Singapore, I started to think about resuming the FHIR server implementation...