· May 30, 2022 3m read

FHIR Client to connect any open FHIR Server by using embedded python

Hi Community,

This post is a introduction of my open exchange iris-fhir-client application.

 iris-fhir-client can connect to any open FHIR Server by using embedded python with the help of fhirpy Library.
Get Resource information by terminal and by using CSP web application.

View and Activate Registered Servers 

Connect to IRIS Terminal

docker-compose exec iris iris session iris

Application will register InterSystems FHIR Server and SmartHealthIT Open FHIR Server by default and both are ready to use. 
Use below command to list down registered Severs 

do ##class(dc.FhirClient).ServerList()


InterSystems FHIR Server is active. In order to select SmartHealthIT Open FHIR Server use SetFhirServer function of dc.FhirClient class by passing server ID  

do ##class(dc.FhirClient).SetFhirServer(2)


Registered FHIR Servers

To Register New Server use RegisterServer() function of dc.FhirClient class
class(dc.FhirClient).RegsterServer("Server Name","Endpoint","ApiKey"[optional],"EndpointOAuth"[optional]

do ##class(dc.FhirClient).RegisterServer("INTERSYSTEMS FHIR Server","http://localhost:52773/csp/healthshare/samples/fhir/r4/","","")


Get Resources from the FHIR Servers

To Retrieve all the resources for the current server use ListResources() method of dc.FhirClient class

do ##class(dc.FhirClient).ListResources()

In order to display number of records of any resources use CountResource() method by passing Resource of dc.FhirClient
Below command will get counter of Patient Resource against active FHIR Server

set count = ##class(dc.FhirClient).CountResource("Patient")
write count

To Retrieve all the created Resources along with their count just pass 1 to ListResource() function

do ##class(dc.FhirClient).ListResources(1)

To get details of the resource use GetResource() by passing Resource of dc.FhirClient class
Below command will retrieve all the Patients from the active FHIR Server

do ##class(dc.FhirClient).GetResource("Patient")


Below command will retrieve all the Observations from the active FHIR Server

do ##class(dc.FhirClient).GetResource("Observation")



Get Resources for particular patient from the FHIR Servers

Below command will retrieve Observations detail against Patinet ID 1 from the active FHIR Server

do ##class(dc.FhirClient).GetPatientResources("Observation","1")


View FHIR Server information from CSP Web application

Navigate to http://localhost:55037/csp/fhirclient/index.csp
Index Page will show active server Patients,Observations,Practitioners and Encounters count along with Patient and Registered Servers details


Index page will display FHIR Server List with active server selected. Select other server from the list to view details of selected server

Hover to Patient ID and select to get details of Patient Resources

This page will display count of some of Patient Resources along with Patient Observations details

If you found this app useful, consider voting for my app.


Discussion (2)1
Log in or sign up to continue