Code
import json
from datetime import datetime
# Example 1: Patient Resource
= {
patient "resourceType": "Patient",
"id": "patient-001",
"identifier": [{
"system": "http://hospital.example.org/patients",
"value": "12345"
}],"name": [{
"use": "official",
"family": "Smith",
"given": ["John", "A."]
}],"gender": "male",
"birthDate": "1985-03-15"
}
# Example 2: ServiceRequest (Imaging Order)
= {
imaging_order "resourceType": "ServiceRequest",
"id": "order-001",
"status": "active",
"intent": "order",
"code": {
"coding": [{
"system": "http://loinc.org",
"code": "36643-5",
"display": "Chest X-ray PA and lateral"
}]
},"subject": {
"reference": "Patient/patient-001"
},"authoredOn": "2024-01-15T09:00:00Z",
"requester": {
"reference": "Practitioner/dr-jones"
},"reasonCode": [{
"text": "Persistent cough for 2 weeks"
}]
}
# Example 3: ImagingStudy Resource
= {
imaging_study "resourceType": "ImagingStudy",
"id": "study-001",
"status": "available",
"subject": {
"reference": "Patient/patient-001"
},"started": "2024-01-15T10:30:00Z",
"basedOn": [{
"reference": "ServiceRequest/order-001"
}],"modality": [{
"system": "http://dicom.nema.org/resources/ontology/DCM",
"code": "CR",
"display": "Computed Radiography"
}],"numberOfSeries": 1,
"numberOfInstances": 2,
"series": [{
"uid": "1.2.840.113619.2.55.3.123456.1",
"modality": {
"system": "http://dicom.nema.org/resources/ontology/DCM",
"code": "CR"
},"numberOfInstances": 2,
"instance": [
{"uid": "1.2.840.113619.2.55.3.123456.1.1",
"sopClass": {
"system": "urn:ietf:rfc:3986",
"code": "urn:oid:1.2.840.10008.5.1.4.1.1.1.1"
},"title": "PA view"
},
{"uid": "1.2.840.113619.2.55.3.123456.1.2",
"sopClass": {
"system": "urn:ietf:rfc:3986",
"code": "urn:oid:1.2.840.10008.5.1.4.1.1.1.1"
},"title": "Lateral view"
}
]
}]
}
# Example 4: DiagnosticReport with Observations
= {
diagnostic_report "resourceType": "DiagnosticReport",
"id": "report-001",
"status": "final",
"code": {
"coding": [{
"system": "http://loinc.org",
"code": "36643-5",
"display": "Chest X-ray PA and lateral"
}]
},"subject": {
"reference": "Patient/patient-001"
},"issued": "2024-01-15T14:00:00Z",
"performer": [{
"reference": "Practitioner/radiologist-001"
}],"imagingStudy": [{
"reference": "ImagingStudy/study-001"
}],"conclusion": "No acute cardiopulmonary abnormality. Small left pleural effusion.",
"result": [
{"reference": "Observation/obs-001"
},
{"reference": "Observation/obs-002"
}
]
}
# Example 5: Observation (Finding)
= {
observation_pleural_effusion "resourceType": "Observation",
"id": "obs-001",
"status": "final",
"code": {
"coding": [{
"system": "http://snomed.info/sct",
"code": "60046008",
"display": "Pleural effusion"
}]
},"subject": {
"reference": "Patient/patient-001"
},"bodySite": {
"coding": [{
"system": "http://snomed.info/sct",
"code": "264231000",
"display": "Left lung"
}]
},"valueCodeableConcept": {
"coding": [{
"system": "http://snomed.info/sct",
"code": "255507004",
"display": "Small"
}]
}
}
# Example 6: Observation (Measurement)
= {
observation_cardiothoracic_ratio "resourceType": "Observation",
"id": "obs-002",
"status": "final",
"code": {
"coding": [{
"system": "http://loinc.org",
"code": "81269-2",
"display": "Cardiothoracic ratio"
}]
},"subject": {
"reference": "Patient/patient-001"
},"valueQuantity": {
"value": 0.45,
"unit": "ratio"
},"referenceRange": [{
"high": {
"value": 0.5
},"text": "Normal < 0.5"
}]
}
# Print examples in readable format
print("=== FHIR Radiology Workflow Example ===\n")
= [
resources "1. Patient", patient),
("2. Service Request (Order)", imaging_order),
("3. Imaging Study", imaging_study),
("4. Diagnostic Report", diagnostic_report),
("5. Observation - Finding", observation_pleural_effusion),
("6. Observation - Measurement", observation_cardiothoracic_ratio)
(
]
for title, resource in resources:
print(f"\n{title}:")
print(json.dumps(resource, indent=2))
print("-" * 50)
=== FHIR Radiology Workflow Example ===
1. Patient:
{
"resourceType": "Patient",
"id": "patient-001",
"identifier": [
{
"system": "http://hospital.example.org/patients",
"value": "12345"
}
],
"name": [
{
"use": "official",
"family": "Smith",
"given": [
"John",
"A."
]
}
],
"gender": "male",
"birthDate": "1985-03-15"
}
--------------------------------------------------
2. Service Request (Order):
{
"resourceType": "ServiceRequest",
"id": "order-001",
"status": "active",
"intent": "order",
"code": {
"coding": [
{
"system": "http://loinc.org",
"code": "36643-5",
"display": "Chest X-ray PA and lateral"
}
]
},
"subject": {
"reference": "Patient/patient-001"
},
"authoredOn": "2024-01-15T09:00:00Z",
"requester": {
"reference": "Practitioner/dr-jones"
},
"reasonCode": [
{
"text": "Persistent cough for 2 weeks"
}
]
}
--------------------------------------------------
3. Imaging Study:
{
"resourceType": "ImagingStudy",
"id": "study-001",
"status": "available",
"subject": {
"reference": "Patient/patient-001"
},
"started": "2024-01-15T10:30:00Z",
"basedOn": [
{
"reference": "ServiceRequest/order-001"
}
],
"modality": [
{
"system": "http://dicom.nema.org/resources/ontology/DCM",
"code": "CR",
"display": "Computed Radiography"
}
],
"numberOfSeries": 1,
"numberOfInstances": 2,
"series": [
{
"uid": "1.2.840.113619.2.55.3.123456.1",
"modality": {
"system": "http://dicom.nema.org/resources/ontology/DCM",
"code": "CR"
},
"numberOfInstances": 2,
"instance": [
{
"uid": "1.2.840.113619.2.55.3.123456.1.1",
"sopClass": {
"system": "urn:ietf:rfc:3986",
"code": "urn:oid:1.2.840.10008.5.1.4.1.1.1.1"
},
"title": "PA view"
},
{
"uid": "1.2.840.113619.2.55.3.123456.1.2",
"sopClass": {
"system": "urn:ietf:rfc:3986",
"code": "urn:oid:1.2.840.10008.5.1.4.1.1.1.1"
},
"title": "Lateral view"
}
]
}
]
}
--------------------------------------------------
4. Diagnostic Report:
{
"resourceType": "DiagnosticReport",
"id": "report-001",
"status": "final",
"code": {
"coding": [
{
"system": "http://loinc.org",
"code": "36643-5",
"display": "Chest X-ray PA and lateral"
}
]
},
"subject": {
"reference": "Patient/patient-001"
},
"issued": "2024-01-15T14:00:00Z",
"performer": [
{
"reference": "Practitioner/radiologist-001"
}
],
"imagingStudy": [
{
"reference": "ImagingStudy/study-001"
}
],
"conclusion": "No acute cardiopulmonary abnormality. Small left pleural effusion.",
"result": [
{
"reference": "Observation/obs-001"
},
{
"reference": "Observation/obs-002"
}
]
}
--------------------------------------------------
5. Observation - Finding:
{
"resourceType": "Observation",
"id": "obs-001",
"status": "final",
"code": {
"coding": [
{
"system": "http://snomed.info/sct",
"code": "60046008",
"display": "Pleural effusion"
}
]
},
"subject": {
"reference": "Patient/patient-001"
},
"bodySite": {
"coding": [
{
"system": "http://snomed.info/sct",
"code": "264231000",
"display": "Left lung"
}
]
},
"valueCodeableConcept": {
"coding": [
{
"system": "http://snomed.info/sct",
"code": "255507004",
"display": "Small"
}
]
}
}
--------------------------------------------------
6. Observation - Measurement:
{
"resourceType": "Observation",
"id": "obs-002",
"status": "final",
"code": {
"coding": [
{
"system": "http://loinc.org",
"code": "81269-2",
"display": "Cardiothoracic ratio"
}
]
},
"subject": {
"reference": "Patient/patient-001"
},
"valueQuantity": {
"value": 0.45,
"unit": "ratio"
},
"referenceRange": [
{
"high": {
"value": 0.5
},
"text": "Normal < 0.5"
}
]
}
--------------------------------------------------