Install any skill in seconds. Free to start, no credit card required.
Get Started Free →Reads, writes, and queries FHIR REST API healthcare resources such as Patient, Observation, Condition, and MedicationRequest.
Use this skill ↓82% 91%+9 ptsof test cases passed
Passed 20 of 22 test cases with the skill, and 18 of 22 without it.
Write a Python script to create a male patient named John Doe born May 15, 1980 on the public HAPI FHIR R4 server and output the created resource ID.
The request body passes patient.dict() to the json parameter.
3 of 3 safety checks passed
FHIR (Fast Healthcare Interoperability Resources) tools for reading, writing, and querying healthcare data via FHIR REST APIs. Work with Patient, Observation, Condition, MedicationRequest, and Encounter resources from EHR systems.
uv pip install fhir.resources requests
import requests
from fhir.resources.patient import Patient
base_url = "https://hapi.fhir.org/baseR4"
resp = requests.get(f"{base_url}/Patient", params={"family": "Smith", "birthdate": "gt1970"})
data = resp.json()
for entry in data.get("entry", []):
patient = Patient.parse_obj(entry["resource"])
name = patient.name[0]
print(f"{name.family}, {name.given[0]}")
patient = Patient(
name=[{"family": "Doe", "given": ["John"], "use": "official"}],
birthDate="1980-05-15",
gender="male",
)
resp = requests.post(
f"{base_url}/Patient",
json=patient.dict(),
headers={"Content-Type": "application/fhir+json"},
)
print(f"Created: {resp.json()['id']}")
Next to this one in the catalogue, plus more from the same author.