From 056b584436a2f3e734df4cd7c8e4f7a32c36f501 Mon Sep 17 00:00:00 2001 From: Rostislav Antonov Date: Mon, 13 May 2024 15:58:42 +0200 Subject: [PATCH] add summary endpoint with identifier search param --- ips_ig/README.MD | 12 + ips_ig/src/data.json | 1523 -------------------------------------- ips_ig/src/index.ts | 2 - ips_ig/src/operations.ts | 109 ++- ips_ig/src/types.d.ts | 2 +- 5 files changed, 92 insertions(+), 1556 deletions(-) delete mode 100644 ips_ig/src/data.json diff --git a/ips_ig/README.MD b/ips_ig/README.MD index efa433b..342a975 100644 --- a/ips_ig/README.MD +++ b/ips_ig/README.MD @@ -61,6 +61,18 @@ For example: GET /fhir/Patient/2b90dd2b-2dab-4c75-9bb9-a355e07401e8/$summary ``` +Or you can use request with `identifier` search parameter: + +``` +GET /fhir/Patient/$summary?identifier= +``` + +For example: + +``` +GET /fhir/Patient/$summary?identifier=574687583 +``` + ## Step 5: Request $summary using HTTP Client If you're starting the Aidbox FHIR server for the first time, the initial step involves creating a _Client_ resource with an ID and secret. diff --git a/ips_ig/src/data.json b/ips_ig/src/data.json deleted file mode 100644 index 5a2690f..0000000 --- a/ips_ig/src/data.json +++ /dev/null @@ -1,1523 +0,0 @@ -{ - "resourceType": "Bundle", - "type": "transaction", - "entry": [ - { - "resource": { - "address": [ - { - "city": "Dordrecht", - "line": ["Laan Van Europa 1600"], - "country": "NL", - "postalCode": "3317 DB" - } - ], - "meta": { - "profile": ["http://hl7.org/fhir/uv/ips/StructureDefinition/Patient-uv-ips"] - }, - "name": [{ "given": ["Martha"], "family": "DeLarosa" }], - "birthDate": "1972-05-01", - "resourceType": "Patient", - "active": true, - "id": "2b90dd2b-2dab-4c75-9bb9-a355e07401e8", - "identifier": [ - { "value": "574687583", "system": "urn:oid:2.16.840.1.113883.2.4.6.3" } - ], - "telecom": [{ "use": "home", "value": "+31788700800", "system": "phone" }], - "gender": "female", - "contact": [ - { - "name": { "given": ["Martha"], "family": "Mum" }, - "address": { - "city": "Lyon", - "line": ["Promenade des Anglais 111"], - "country": "FR", - "postalCode": "69001" - }, - "telecom": [{ "use": "home", "value": "+33-555-20036", "system": "phone" }], - "relationship": [ - { - "coding": [ - { - "code": "MTH", - "system": "http://terminology.hl7.org/CodeSystem/v3-RoleCode" - } - ] - } - ] - } - ], - "text": { - "div": "

Generated Narrative: Patient

Resource Patient "2b90dd2b-2dab-4c75-9bb9-a355e07401e8"

identifier: id: 574687583

active: true

name: Martha DeLarosa

telecom: +31788700800

gender: female

birthDate: 1972-05-01

address: Laan Van Europa 1600 Dordrecht 3317 DB NL

Contacts

-RelationshipNameTelecomAddress
*mother (RoleCode#MTH)Martha Mum +33-555-20036Promenade des Anglais 111 Lyon 69001 FR
", - "status": "generated" - } - }, - "request": { - "method": "PUT", - "url": "/fhir/Patient/2b90dd2b-2dab-4c75-9bb9-a355e07401e8" - } - }, - { - "resource": { - "meta": { - "profile": [ - "http://hl7.org/fhir/uv/ips/StructureDefinition/MedicationStatement-uv-ips" - ] - }, - "dosage": [ - { - "route": { - "coding": [ - { - "code": "20053000", - "system": "http://standardterms.edqm.eu", - "display": "Oral use" - } - ] - }, - "timing": { "repeat": { "count": 1, "periodUnit": "d" } }, - "doseAndRate": [ - { - "doseQuantity": { - "code": "1", - "unit": "tablet", - "value": 1, - "system": "http://unitsofmeasure.org" - }, - "type": { - "coding": [ - { - "code": "ordered", - "system": "http://terminology.hl7.org/CodeSystem/dose-rate-type", - "display": "Ordered" - } - ] - } - } - ] - } - ], - "resourceType": "MedicationStatement", - "status": "active", - "id": "c220e36c-eb67-4fc4-9ba1-2fabc52acec6", - "identifier": [ - { - "value": "b75f92cb-61d4-469a-9387-df5ef70d25f0", - "system": "urn:oid:1.2.3.999" - } - ], - "medicationReference": { - "reference": "Medication/976d0804-cae0-45ae-afe3-a19f3ceba6bc" - }, - "subject": { "reference": "Patient/2b90dd2b-2dab-4c75-9bb9-a355e07401e8" }, - "effectivePeriod": { "start": "2015-03" }, - "text": { - "div": "

Generated Narrative: MedicationStatement

Resource MedicationStatement "c220e36c-eb67-4fc4-9ba1-2fabc52acec6"

identifier: id: b75f92cb-61d4-469a-9387-df5ef70d25f0

status: active

medication: See above (Medication/976d0804-cae0-45ae-afe3-a19f3ceba6bc)

subject: See above (Patient/2b90dd2b-2dab-4c75-9bb9-a355e07401e8)

effective: 2015-03 --> (ongoing)

dosage

timing: Count 1 times, Do Once

route: Oral use (standardterms.edqm.eu#20053000)

", - "status": "generated" - } - }, - "request": { - "method": "PUT", - "url": "/fhir/MedicationStatement/c220e36c-eb67-4fc4-9ba1-2fabc52acec6" - } - }, - { - "resource": { - "code": { - "coding": [ - { - "code": "108774000", - "system": "http://snomed.info/sct", - "display": "Product containing anastrozole (medicinal product)" - }, - { - "code": "99872", - "system": "urn:oid:2.16.840.1.113883.2.4.4.1", - "display": "ANASTROZOL 1MG TABLET" - }, - { - "code": "2076667", - "system": "urn:oid:2.16.840.1.113883.2.4.4.7", - "display": "ANASTROZOL CF TABLET FILMOMHULD 1MG" - }, - { - "code": "L02BG03", - "system": "http://www.whocc.no/atc", - "display": "anastrozole" - } - ] - }, - "meta": { - "profile": ["http://hl7.org/fhir/uv/ips/StructureDefinition/Medication-uv-ips"] - }, - "text": { - "div": "

Generated Narrative: Medication

Resource Medication "976d0804-cae0-45ae-afe3-a19f3ceba6bc"

code: Product containing anastrozole (medicinal product) (SNOMED CT#108774000; unknown#99872 "ANASTROZOL 1MG TABLET"; unknown#2076667 "ANASTROZOL CF TABLET FILMOMHULD 1MG"; WHO ATC#L02BG03 "anastrozole")

", - "status": "generated" - }, - "id": "976d0804-cae0-45ae-afe3-a19f3ceba6bc", - "resourceType": "Medication" - }, - "request": { - "method": "PUT", - "url": "/fhir/Medication/976d0804-cae0-45ae-afe3-a19f3ceba6bc" - } - }, - { - "resource": { - "code": { - "text": "Black Cohosh Extract herbal supplement", - "coding": [ - { - "code": "412588001", - "system": "http://snomed.info/sct", - "display": "Cimicifuga racemosa extract (substance)", - "_display": { - "extension": [ - { - "url": "http://hl7.org/fhir/StructureDefinition/translation", - "extension": [ - { "url": "lang", "valueCode": "nl-NL" }, - { "url": "content", "valueString": "Zwarte Cohosh Extract" } - ] - } - ] - } - }, - { - "code": "G02CX04", - "system": "http://www.whocc.no/atc", - "display": "Cimicifugae rhizoma" - } - ] - }, - "text": { - "div": "

Generated Narrative: Medication

Resource Medication "8adc0999-9468-4ac9-9557-680fa133d626"

code: Black Cohosh Extract herbal supplement (SNOMED CT#412588001 "Cimicifuga racemosa extract (substance)"; WHO ATC#G02CX04 "Cimicifugae rhizoma")

", - "status": "generated" - }, - "id": "8adc0999-9468-4ac9-9557-680fa133d626", - "resourceType": "Medication", - "meta": { - "lastUpdated": "2024-05-06T09:58:26.363476Z", - "versionId": "69", - "extension": [ - { "url": "ex:createdAt", "valueInstant": "2024-05-06T09:58:26.363476Z" } - ] - } - }, - "request": { - "method": "PUT", - "url": "/fhir/Medication/8adc0999-9468-4ac9-9557-680fa133d626" - } - }, - { - "resource": { - "code": { - "coding": [ - { - "code": "no-known-food-allergies", - "system": "http://hl7.org/fhir/uv/ips/CodeSystem/absent-unknown-uv-ips" - } - ] - }, - "meta": { - "profile": [ - "http://hl7.org/fhir/uv/ips/StructureDefinition/AllergyIntolerance-uv-ips" - ] - }, - "text": { - "div": "

Generated Narrative: AllergyIntolerance

Resource AllergyIntolerance "c7781f44-6df8-4a8b-9e06-0b34263a47c5"

clinicalStatus: Active (AllergyIntolerance Clinical Status Codes#active)

code: No known food allergies (Absent and Unknown Data - IPS#no-known-food-allergies)

patient: See above (Patient/2b90dd2b-2dab-4c75-9bb9-a355e07401e8)

", - "status": "generated" - }, - "patient": { "reference": "Patient/2b90dd2b-2dab-4c75-9bb9-a355e07401e8" }, - "clinicalStatus": { - "coding": [ - { - "code": "active", - "system": "http://terminology.hl7.org/CodeSystem/allergyintolerance-clinical" - } - ] - }, - "id": "c7781f44-6df8-4a8b-9e06-0b34263a47c5", - "resourceType": "AllergyIntolerance" - }, - "request": { - "method": "PUT", - "url": "/fhir/AllergyIntolerance/c7781f44-6df8-4a8b-9e06-0b34263a47c5" - } - }, - { - "resource": { - "patient": { "reference": "Patient/2b90dd2b-2dab-4c75-9bb9-a355e07401e8" }, - "category": ["medication"], - "criticality": "high", - "clinicalStatus": { - "coding": [ - { - "code": "active", - "system": "http://terminology.hl7.org/CodeSystem/allergyintolerance-clinical" - } - ] - }, - "meta": { - "profile": [ - "http://hl7.org/fhir/uv/ips/StructureDefinition/AllergyIntolerance-uv-ips" - ] - }, - "type": "allergy", - "resourceType": "AllergyIntolerance", - "id": "72884cad-ebe6-4f43-a51a-2f978275f132", - "code": { - "coding": [ - { - "code": "373270004", - "system": "http://snomed.info/sct", - "display": "Substance with penicillin structure and antibacterial mechanism of action (substance)" - } - ] - }, - "identifier": [ - { - "value": "3a462598-009c-484a-965c-d6b24a821424", - "system": "urn:oid:1.2.3.999" - } - ], - "onsetDateTime": "2010", - "verificationStatus": { - "coding": [ - { - "code": "confirmed", - "system": "http://terminology.hl7.org/CodeSystem/allergyintolerance-verification" - } - ] - }, - "text": { - "div": "

Generated Narrative: AllergyIntolerance

Resource AllergyIntolerance "72884cad-ebe6-4f43-a51a-2f978275f132"

identifier: id: 3a462598-009c-484a-965c-d6b24a821424

clinicalStatus: Active (AllergyIntolerance Clinical Status Codes#active)

verificationStatus: Confirmed (AllergyIntolerance Verification Status#confirmed)

type: allergy

category: medication

criticality: high

code: Substance with penicillin structure and antibacterial mechanism of action (substance) (SNOMED CT#373270004)

patient: See above (Patient/2b90dd2b-2dab-4c75-9bb9-a355e07401e8)

onset: 2010

", - "status": "generated" - } - }, - "request": { - "method": "PUT", - "url": "/fhir/AllergyIntolerance/72884cad-ebe6-4f43-a51a-2f978275f132" - } - }, - { - "resource": { - "category": [ - { - "coding": [ - { "code": "75326-9", "system": "http://loinc.org", "display": "Problem" } - ] - } - ], - "clinicalStatus": { - "coding": [ - { - "code": "active", - "system": "http://terminology.hl7.org/CodeSystem/condition-clinical" - } - ] - }, - "meta": { - "profile": ["http://hl7.org/fhir/uv/ips/StructureDefinition/Condition-uv-ips"] - }, - "resourceType": "Condition", - "recordedDate": "2016-10", - "id": "c64139e7-f02d-409c-bf34-75e8bf23bc80", - "severity": { - "coding": [ - { "code": "LA6751-7", "system": "http://loinc.org", "display": "Moderate" } - ] - }, - "code": { - "coding": [ - { - "code": "198436008", - "system": "http://snomed.info/sct", - "display": "Menopausal flushing (finding)", - "_display": { - "extension": [ - { - "url": "http://hl7.org/fhir/StructureDefinition/translation", - "extension": [ - { "url": "lang", "valueCode": "nl-NL" }, - { "url": "content", "valueString": "opvliegers" } - ] - } - ] - } - }, - { - "code": "N95.1", - "system": "http://hl7.org/fhir/sid/icd-10", - "display": "Menopausal and female climacteric states" - } - ] - }, - "identifier": [ - { - "value": "c87bf51c-e53c-4bfe-b8b7-aa62bdd93002", - "system": "urn:oid:1.2.3.999" - } - ], - "onsetDateTime": "2015", - "verificationStatus": { - "coding": [ - { - "code": "confirmed", - "system": "http://terminology.hl7.org/CodeSystem/condition-ver-status" - } - ] - }, - "subject": { "reference": "Patient/2b90dd2b-2dab-4c75-9bb9-a355e07401e8" }, - "text": { - "div": "

Generated Narrative: Condition

Resource Condition "c64139e7-f02d-409c-bf34-75e8bf23bc80"

identifier: id: c87bf51c-e53c-4bfe-b8b7-aa62bdd93002

clinicalStatus: Active (Condition Clinical Status Codes#active)

verificationStatus: Confirmed (ConditionVerificationStatus#confirmed)

category: Problem (LOINC#75326-9)

severity: Moderate (LOINC#LA6751-7)

code: Menopausal flushing (finding) (SNOMED CT#198436008; ICD-10#N95.1 "Menopausal and female climacteric states")

subject: See above (Patient/2b90dd2b-2dab-4c75-9bb9-a355e07401e8)

onset: 2015

recordedDate: 2016-10

", - "status": "generated" - } - }, - "request": { - "method": "PUT", - "url": "/fhir/Condition/c64139e7-f02d-409c-bf34-75e8bf23bc80" - } - }, - { - "resource": { - "category": [ - { - "coding": [ - { "code": "75326-9", "system": "http://loinc.org", "display": "Problem" } - ] - } - ], - "clinicalStatus": { - "coding": [ - { - "code": "remission", - "system": "http://terminology.hl7.org/CodeSystem/condition-clinical" - } - ] - }, - "meta": { - "profile": ["http://hl7.org/fhir/uv/ips/StructureDefinition/Condition-uv-ips"] - }, - "resourceType": "Condition", - "id": "c4597aa2-688a-401b-a658-70acc6de28c6", - "severity": { - "coding": [ - { "code": "LA6750-9", "system": "http://loinc.org", "display": "Severe" } - ] - }, - "code": { - "coding": [ - { - "code": "254837009", - "system": "http://snomed.info/sct", - "display": "Malignant tumor of breast", - "_display": { - "extension": [ - { - "url": "http://hl7.org/fhir/StructureDefinition/translation", - "extension": [ - { "url": "lang", "valueCode": "nl-NL" }, - { - "url": "content", - "valueString": "Borstkanker stadium II zonder aanwijzingen van recidieven na behandeling" - } - ] - } - ] - } - }, - { - "code": "8500/3", - "system": "http://terminology.hl7.org/CodeSystem/icd-o-3", - "display": "Infiltrating duct carcinoma, NOS" - } - ] - }, - "identifier": [ - { - "value": "66d4a8c7-9081-43e0-a63f-489c2ae6edd6", - "system": "urn:oid:1.2.3.999" - } - ], - "onsetDateTime": "2015-01", - "abatementDateTime": "2015-03", - "verificationStatus": { - "coding": [ - { - "code": "confirmed", - "system": "http://terminology.hl7.org/CodeSystem/condition-ver-status" - } - ] - }, - "subject": { "reference": "Patient/2b90dd2b-2dab-4c75-9bb9-a355e07401e8" }, - "text": { - "div": "

Generated Narrative: Condition

Resource Condition "c4597aa2-688a-401b-a658-70acc6de28c6"

identifier: id: 66d4a8c7-9081-43e0-a63f-489c2ae6edd6

clinicalStatus: Remission (Condition Clinical Status Codes#remission)

verificationStatus: Confirmed (ConditionVerificationStatus#confirmed)

category: Problem (LOINC#75326-9)

severity: Severe (LOINC#LA6750-9)

code: Malignant tumor of breast (SNOMED CT#254837009; International Classification of Diseases for Oncology, version 3.#8500/3 "Infiltrating duct carcinoma, NOS")

subject: See above (Patient/2b90dd2b-2dab-4c75-9bb9-a355e07401e8)

onset: 2015-01

abatement: 2015-03

", - "status": "generated" - } - }, - "request": { - "method": "PUT", - "url": "/fhir/Condition/c4597aa2-688a-401b-a658-70acc6de28c6" - } - }, - { - "resource": { - "resourceType": "Procedure", - "meta": { - "profile": ["http://hl7.org/fhir/uv/ips/StructureDefinition/Procedure-uv-ips"] - }, - "id": "eumfh-39-07-1", - "text": { - "status": "generated", - "div": "

Generated Narrative: Procedure

Resource Procedure "eumfh-39-07-1"

status: completed

category: Surgical procedure (SNOMED CT#387713003)

code: Previous balloon angioplasty on mid-LAD stenosis with STENT Implantation (SNOMED CT#36969009 "Placement of stent in coronary artery"; SNOMED CT#233258006 "Balloon angioplasty of artery")

subject: Patient/eumfh-39-07: Alexander Heig (inject 39-07) " HEIG"

performed: ?? --> (ongoing)

" - }, - "status": "completed", - "category": { - "coding": [ - { - "system": "http://snomed.info/sct", - "code": "387713003", - "display": "Surgical procedure" - } - ] - }, - "code": { - "coding": [ - { - "system": "http://snomed.info/sct", - "code": "36969009", - "display": "Placement of stent in coronary artery" - }, - { - "system": "http://snomed.info/sct", - "code": "233258006", - "display": "Balloon angioplasty of artery" - } - ], - "text": "Previous balloon angioplasty on mid-LAD stenosis with STENT Implantation" - }, - "subject": { - "reference": "Patient/2b90dd2b-2dab-4c75-9bb9-a355e07401e8" - }, - "performedPeriod": { - "extension": [ - { - "url": "http://hl7.org/fhir/StructureDefinition/data-absent-reason", - "valueCode": "unknown" - } - ] - } - }, - "request": { - "method": "PUT", - "url": "/fhir/Procedure/eumfh-39-07-1" - } - }, - { - "resource": { - "resourceType": "Immunization", - "meta": { - "profile": [ - "http://hl7.org/fhir/uv/ips/StructureDefinition/Immunization-uv-ips" - ] - }, - "id": "40b7b6a0-c043-423a-9959-be3707e728b2", - "language": "fr-LU", - "text": { - "status": "generated", - "div": "
\n\t\t\t\t\t\t

\n\t\t\t\t\t\t\tMarie Lux-Brennard\n\t\t\t\t\t\t\t(Apr 17, 1998)\n\t\t\t\t\t\t

\n\t\t\t\t\t\t

Vaccin anti diphtérie-coqueluche-tétanos-poliomyélite, Jun 3, 1998, 10:00:00 PM

\n\t\t\t\t\t\t

Voie intramusculaire, Cuisse droite

\n\t\t\t\t\t
" - }, - "status": "completed", - "vaccineCode": { - "coding": [ - { - "system": "http://snomed.info/sct", - "code": "836508001", - "display": "Bordetella pertussis and Clostridium tetani and Corynebacterium diphtheriae and Human poliovirus antigens-containing vaccine product", - "_display": { - "extension": [ - { - "url": "http://hl7.org/fhir/StructureDefinition/translation", - "extension": [ - { - "url": "lang", - "valueCode": "fr-LU" - }, - { - "url": "content", - "valueString": "Vaccin anti diphtérie-coqueluche-tétanos-poliomyélite" - } - ] - } - ] - } - }, - { - "system": "http://www.whocc.no/atc", - "code": "J07CA02", - "display": "diphtheria-pertussis-poliomyelitis-tetanus", - "_display": { - "extension": [ - { - "url": "http://hl7.org/fhir/StructureDefinition/translation", - "extension": [ - { - "url": "lang", - "valueCode": "fr-LU" - }, - { - "url": "content", - "valueString": "DIPHTERIE - COQUELUCHE - POLIOMYELITE - TETANOS" - } - ] - } - ] - } - } - ], - "text": "Vaccin anti diphtérie-coqueluche-tétanos-poliomyélite" - }, - "patient": { - "reference": "Patient/2b90dd2b-2dab-4c75-9bb9-a355e07401e8" - }, - "occurrenceDateTime": "1998-06-04T00:00:00+02:00", - "primarySource": true, - "lotNumber": "AXK23RWERS", - "expirationDate": "2000-06-01", - "site": { - "coding": [ - { - "system": "http://snomed.info/sct", - "code": "11207009", - "display": "Right thigh", - "_display": { - "extension": [ - { - "url": "http://hl7.org/fhir/StructureDefinition/translation", - "extension": [ - { - "url": "lang", - "valueCode": "fr-LU" - }, - { - "url": "content", - "valueString": "Cuisse droite" - } - ] - } - ] - } - } - ], - "text": "Cuisse droite" - }, - "route": { - "coding": [ - { - "system": "http://standardterms.edqm.eu", - "code": "20035000", - "display": "Intramuscular use", - "_display": { - "extension": [ - { - "url": "http://hl7.org/fhir/StructureDefinition/translation", - "extension": [ - { - "url": "lang", - "valueCode": "fr-LU" - }, - { - "url": "content", - "valueString": "Voie intramusculaire" - } - ] - } - ] - } - } - ], - "text": "Voie intramusculaire" - }, - "protocolApplied": [ - { - "targetDisease": [ - { - "coding": [ - { - "system": "http://snomed.info/sct", - "code": "27836007", - "display": "Pertussis" - }, - { - "system": "http://snomed.info/sct", - "code": "76902006", - "display": "Tetanus" - }, - { - "system": "http://snomed.info/sct", - "code": "398102009", - "display": "Acute poliomyelitis" - }, - { - "system": "http://snomed.info/sct", - "code": "397430003", - "display": "Diphtheria caused by Corynebacterium diphtheriae" - } - ] - } - ], - "doseNumberPositiveInt": 1 - } - ] - }, - "request": { - "method": "PUT", - "url": "/fhir/Immunization/40b7b6a0-c043-423a-9959-be3707e728b2" - } - }, - { - "resource": { - "resourceType": "Device", - "id": "ips-example-imaging-1", - "meta": { - "profile": ["http://hl7.org/fhir/uv/ips/StructureDefinition/Device-uv-ips"] - }, - "text": { - "status": "generated", - "div": "
No known devices in use
" - }, - "identifier": [ - { - "system": "http://my.organization.example/devicesID", - "value": "12345" - } - ], - "manufacturer": "Imaging Devices Manufacturer", - "deviceName": [ - { - "name": "H.I.A. BEGIN", - "type": "patient-reported-name" - } - ], - "modelNumber": "2.0.1", - "patient": { - "reference": "Patient/2b90dd2b-2dab-4c75-9bb9-a355e07401e8", - "display": "Annelise Black (inject 70-275)" - } - }, - "request": { - "method": "PUT", - "url": "/fhir/Device/ips-example-imaging-1" - } - }, - { - "resource": { - "resourceType": "DeviceUseStatement", - "meta": { - "profile": [ - "http://hl7.org/fhir/uv/ips/StructureDefinition/DeviceUseStatement-uv-ips" - ] - }, - "id": "eumfh-70-275-1", - "text": { - "status": "generated", - "div": "
No known devices in use
" - }, - "status": "active", - "subject": { - "reference": "Patient/2b90dd2b-2dab-4c75-9bb9-a355e07401e8", - "display": "Annelise Black (inject 70-275)" - }, - "timingDateTime": "2017-12", - "device": { - "reference": "Device/ips-example-imaging-1" - } - }, - "request": { - "method": "PUT", - "url": "/fhir/DeviceUseStatement/eumfh-70-275-1" - } - }, - { - "resource": { - "resourceType": "Observation", - "id": "pregnancy-outcome-example", - "meta": { - "profile": [ - "http://hl7.org/fhir/uv/ips/StructureDefinition/Observation-pregnancy-outcome-uv-ips" - ] - }, - "text": { - "status": "generated", - "div": "

Generated Narrative: Observation

Resource Observation "pregnancy-outcome-example"

status: final

code: [#] Births total (LOINC#11640-0)

subject: Patient/patient-example-female " DELAROSA"

effective: 2020-01-10

value: 1 1 (Details: UCUM code 1 = '1')

" - }, - "status": "final", - "code": { - "coding": [ - { - "system": "http://loinc.org", - "code": "11640-0", - "display": "[#] Births total" - } - ] - }, - "subject": { - "reference": "Patient/2b90dd2b-2dab-4c75-9bb9-a355e07401e8" - }, - "effectiveDateTime": "2020-01-10", - "valueQuantity": { - "value": 1, - "system": "http://unitsofmeasure.org", - "code": "1" - } - }, - "request": { - "method": "PUT", - "url": "/fhir/Observation/pregnancy-outcome-example" - } - }, - { - "resource": { - "resourceType": "Observation", - "id": "tobacco-use-example", - "meta": { - "profile": [ - "http://hl7.org/fhir/uv/ips/StructureDefinition/Observation-tobaccouse-uv-ips" - ] - }, - "text": { - "status": "generated", - "div": "

Generated Narrative: Observation

Resource Observation "tobacco-use-example"

status: final

code: Tobacco smoking status (LOINC#72166-2)

subject: Patient/patient-example-female " DELAROSA"

effective: 2019-07-15

value: Former smoker (LOINC#LA15920-4)

" - }, - "status": "final", - "code": { - "coding": [ - { - "system": "http://loinc.org", - "code": "72166-2", - "display": "Tobacco smoking status" - } - ] - }, - "subject": { - "reference": "Patient/2b90dd2b-2dab-4c75-9bb9-a355e07401e8" - }, - "effectiveDateTime": "2019-07-15", - "valueCodeableConcept": { - "coding": [ - { - "system": "http://loinc.org", - "code": "LA15920-4", - "display": "Former smoker" - } - ] - } - }, - "request": { - "method": "PUT", - "url": "/fhir/Observation/tobacco-use-example" - } - }, - { - "resource": { - "resourceType": "Observation", - "id": "hemoglobin", - "meta": { - "profile": [ - "http://hl7.org/fhir/uv/ips/StructureDefinition/Observation-results-laboratory-uv-ips" - ] - }, - "text": { - "status": "generated", - "div": "

Generated Narrative: Observation

Resource Observation "hemoglobin"

status: final

category: Laboratory (Observation Category Codes#laboratory)

code: Hemoglobin A1c/Hemoglobin.total in Blood by HPLC (LOINC#17856-6)

subject: Patient/eumfh-39-07 " HEIG"

effective: 2017-11-10 08:20:00+0100

performer: Organization/TII-Organization1 "Someplace General Hospital"

value: 7.5 % (Details: UCUM code % = '%')

note: Above stated goal of 7.0 %

" - }, - "status": "final", - "category": [ - { - "coding": [ - { - "system": "http://terminology.hl7.org/CodeSystem/observation-category", - "code": "laboratory" - } - ] - } - ], - "code": { - "coding": [ - { - "system": "http://loinc.org", - "code": "17856-6", - "display": "Hemoglobin A1c/Hemoglobin.total in Blood by HPLC" - } - ] - }, - "subject": { - "reference": "Patient/2b90dd2b-2dab-4c75-9bb9-a355e07401e8" - }, - "effectiveDateTime": "2017-11-10T08:20:00+01:00", - "performer": [ - { - "reference": "Organization/TII-Organization1" - } - ], - "valueQuantity": { - "value": 7.5, - "unit": "%", - "system": "http://unitsofmeasure.org", - "code": "%" - }, - "note": [ - { - "text": "Above stated goal of 7.0 %" - } - ] - }, - "request": { - "method": "PUT", - "url": "/fhir/Observation/hemoglobin" - } - }, - { - "resource": { - "resourceType": "DiagnosticReport", - "id": "hemoglobin", - "meta": { - "profile": [ - "http://hl7.org/fhir/uv/ips/StructureDefinition/DiagnosticReport-uv-ips" - ] - }, - "text": { - "status": "generated", - "div": "

Laboratory report (Laboratory)

SubjectAlexander Heig male, DoB: 1957 ( http://trilliumbridge.eu/fhir/demos/eumfh/inject/39-07)
When For2017-11-10
Reported2017-11-10 08:20:00+0100

Report Details

CodeValueNoteWhen For
Hemoglobin A1c/Hemoglobin.total in Blood by HPLC7.5 %Above stated goal of 7.0 %2017-11-10 08:20:00+0100
" - }, - "status": "final", - "category": [ - { - "coding": [ - { - "system": "http://terminology.hl7.org/CodeSystem/v2-0074", - "code": "LAB", - "display": "Laboratory" - } - ] - } - ], - "code": { - "coding": [ - { - "system": "http://loinc.org", - "code": "11502-2", - "display": "Laboratory report" - } - ] - }, - "subject": { - "reference": "Patient/2b90dd2b-2dab-4c75-9bb9-a355e07401e8" - }, - "effectiveDateTime": "2017-11-10", - "issued": "2017-11-10T08:20:00+01:00", - "performer": [ - { - "reference": "Organization/TII-Organization1", - "display": "Someplace General Hospital" - } - ], - "result": [ - { - "reference": "Observation/hemoglobin", - "display": "Above stated goal of 7.0 %" - } - ] - }, - "request": { - "method": "PUT", - "url": "/fhir/DiagnosticReport/hemoglobin" - } - }, - { - "resource": { - "resourceType": "Specimen", - "id": "specimen-example-1", - "meta": { - "profile": ["http://hl7.org/fhir/uv/ips/StructureDefinition/Specimen-uv-ips"] - }, - "text": { - "status": "generated", - "div": "

Generated Narrative: Specimen

Resource Specimen "specimen-example-1"

type: Urine specimen (SNOMED CT#122575003)

subject: Patient/66033 " LUX-BRENNARD"

Collections

-Method
*Urine specimen collection, clean catch (SNOMED CT#73416001)
" - }, - "type": { - "coding": [ - { - "system": "http://snomed.info/sct", - "code": "122575003", - "display": "Urine specimen" - } - ] - }, - "subject": { - "reference": "Patient/2b90dd2b-2dab-4c75-9bb9-a355e07401e8" - }, - "collection": { - "method": { - "coding": [ - { - "system": "http://snomed.info/sct", - "code": "73416001", - "display": "Urine specimen collection, clean catch" - } - ] - } - } - }, - "request": { - "method": "PUT", - "url": "/fhir/Specimen/specimen-example-1" - } - }, - { - "resource": { - "resourceType": "ImagingStudy", - "id": "TII-ImagingStudy-5-1", - "text": { - "status": "generated", - "div": "

Generated Narrative: ImagingStudy

Resource ImagingStudy "TII-ImagingStudy-5-1"

identifier: DICOM Unique Id/urn:oid:2.16.840.1.113883.2.9.999.1.12345

status: available

subject: Patient/eumfh-39-07 " HEIG"

procedureCode: SPECT Heart perfusion and wall motion at rest and W stress and W Tl-201 IV and W Tc-99m Sestamibi IV (LOINC#49569-7)

reasonCode: Chest pain, hypertension, type II diabetes mellitus. ()

Series

-UidModalityBodySite
*2.16.840.1.113883.2.9.999.2.12345Nuclear Medicine (Details: DICOM code NM = 'Nuclear Medicine', stated as 'Nuclear Medicine')Heart (Details: SNOMED CT code 80891009 = 'Heart', stated as 'Heart')
" - }, - "identifier": [ - { - "system": "urn:dicom:uid", - "value": "urn:oid:2.16.840.1.113883.2.9.999.1.12345" - } - ], - "status": "available", - "subject": { - "reference": "Patient/2b90dd2b-2dab-4c75-9bb9-a355e07401e8" - }, - "procedureCode": [ - { - "coding": [ - { - "system": "http://loinc.org", - "code": "49569-7", - "display": "SPECT Heart perfusion and wall motion at rest and W stress and W Tl-201 IV and W Tc-99m Sestamibi IV" - } - ] - } - ], - "reasonCode": [ - { - "text": "Chest pain, hypertension, type II diabetes mellitus." - } - ], - "series": [ - { - "uid": "2.16.840.1.113883.2.9.999.2.12345", - "modality": { - "system": "http://dicom.nema.org/resources/ontology/DCM", - "code": "NM", - "display": "Nuclear Medicine" - }, - "bodySite": { - "system": "http://snomed.info/sct", - "code": "80891009", - "display": "Heart" - } - } - ] - }, - "request": { - "method": "PUT", - "url": "/fhir/ImagingStudy/TII-ImagingStudy-5-1" - } - }, - { - "resource": { - "resourceType": "Practitioner", - "id": "eumfh-39-07", - "meta": { - "profile": [ - "http://hl7.org/fhir/uv/ips/StructureDefinition/Practitioner-uv-ips" - ] - }, - "text": { - "status": "generated", - "div": "

Generated Narrative: Practitioner

Resource Practitioner "eumfh-39-07"

name: Mark Antonio

" - }, - "name": [ - { - "family": "Antonio", - "given": ["Mark"], - "prefix": ["Dr."] - } - ] - }, - "request": { - "method": "PUT", - "url": "/fhir/Practitioner/eumfh-39-07" - } - }, - { - "resource": { - "resourceType": "MedicationRequest", - "id": "eumfh-39-07-1-request", - "meta": { - "profile": [ - "http://hl7.org/fhir/uv/ips/StructureDefinition/MedicationRequest-uv-ips" - ] - }, - "text": { - "status": "generated", - "div": "

Generated Narrative: MedicationRequest

Resource MedicationRequest "eumfh-39-07-1-request"

status: active

intent: order

medication: Medication/eumfh-39-07-1: simvastatin

subject: Patient/eumfh-39-07: Alexander Heig (inject 39-07) " HEIG"

dosageInstruction

text: 40 mg/day

timing: Once per 1 days

doseAndRate

DispenseRequests

-ValidityPeriod
*2021-01-01 --> (ongoing)
" - }, - "status": "active", - "intent": "order", - "medicationReference": { - "reference": "Medication/976d0804-cae0-45ae-afe3-a19f3ceba6bc", - "display": "simvastatin" - }, - "subject": { - "reference": "Patient/2b90dd2b-2dab-4c75-9bb9-a355e07401e8", - "display": "Alexander Heig (inject 39-07)" - }, - "dosageInstruction": [ - { - "text": "40 mg/day", - "doseAndRate": [ - { - "doseQuantity": { - "value": 40, - "unit": "mg", - "system": "http://unitsofmeasure.org", - "code": "mg" - } - } - ] - } - ], - "dispenseRequest": { - "validityPeriod": { - "start": "2021-01-01" - } - } - }, - "request": { - "method": "PUT", - "url": "/fhir/MedicationRequest/eumfh-39-07-1-request" - } - }, - { - "resource": { - "resourceType": "PractitionerRole", - "id": "simple-pr", - "text": { - "status": "generated", - "div": "

Generated Narrative: PractitionerRole

Resource PractitionerRole "simple-pr"

practitioner: Practitioner/eumfh-39-07 " ANTONIO"

organization: Organization/simple-org "Best Diagnostic Department"

" - }, - "practitioner": { - "reference": "Practitioner/eumfh-39-07" - }, - "organization": { - "reference": "Organization/TII-Organization1" - } - }, - "request": { - "method": "PUT", - "url": "/fhir/PractitionerRole/simple-pr" - } - }, - { - "resource": { - "resourceType": "Media", - "id": "media-example-smile", - "meta": { - "profile": [ - "http://hl7.org/fhir/uv/ips/StructureDefinition/Media-observation-uv-ips" - ] - }, - "text": { - "status": "generated", - "div": "

Generated Narrative: Media

Resource Media "media-example-smile"

status: completed

type: Image (Media Type#image)

subject: Patient/eumfh-39-07 " HEIG"

created: 2017-12-17

issued: Dec 17, 2017, 2:56:18\u202fPM

operator: Practitioner/eumfh-39-07 " ANTONIO"

height: 128

width: 128

content

id

a1

contentType: image/png

data: (base64 data - 1800 bytes)

creation: 2017-12-17

" - }, - "status": "completed", - "type": { - "coding": [ - { - "system": "http://terminology.hl7.org/CodeSystem/media-type", - "code": "image", - "display": "Image" - } - ] - }, - "subject": { - "reference": "Patient/2b90dd2b-2dab-4c75-9bb9-a355e07401e8" - }, - "createdDateTime": "2017-12-17", - "issued": "2017-12-17T14:56:18Z", - "operator": { - "reference": "Practitioner/eumfh-39-07" - }, - "height": 128, - "width": 128, - "content": { - "id": "a1", - "creation": "2017-12-17" - } - }, - "request": { - "method": "PUT", - "url": "/fhir/Media/media-example-smile" - } - }, - { - "resource": { - "resourceType": "Observation", - "id": "alcohol-use-example", - "meta": { - "profile": [ - "http://hl7.org/fhir/uv/ips/StructureDefinition/Observation-alcoholuse-uv-ips" - ] - }, - "text": { - "status": "generated", - "div": "

Generated Narrative: Observation

Resource Observation "alcohol-use-example"

status: final

code: Alcoholic drinks per day (LOINC#74013-4)

subject: Patient/patient-example-female " DELAROSA"

effective: 2019-07-15

value: 2 {wine glasses}/d (Details: UCUM code {wine glasses}/d = '{wine glasses}/d')

" - }, - "status": "final", - "code": { - "coding": [ - { - "system": "http://loinc.org", - "code": "74013-4", - "display": "Alcoholic drinks per day" - } - ] - }, - "subject": { - "reference": "Patient/2b90dd2b-2dab-4c75-9bb9-a355e07401e8" - }, - "effectiveDateTime": "2019-07-15", - "valueQuantity": { - "value": 2, - "system": "http://unitsofmeasure.org", - "code": "{wine glasses}/d" - } - }, - "request": { - "method": "PUT", - "url": "/fhir/Observation/alcohol-use-example" - } - }, - { - "resource": { - "resourceType": "Observation", - "id": "pregnancy-edd-example", - "meta": { - "profile": [ - "http://hl7.org/fhir/uv/ips/StructureDefinition/Observation-pregnancy-edd-uv-ips" - ] - }, - "text": { - "status": "generated", - "div": "

Generated Narrative: Observation

Resource Observation "pregnancy-edd-example"

status: final

code: Delivery date Estimated (LOINC#11778-8)

subject: Patient/patient-example-female " DELAROSA"

effective: 2020-01-10

value: 2020-05-02

" - }, - "status": "final", - "code": { - "coding": [ - { - "system": "http://loinc.org", - "code": "11778-8", - "display": "Delivery date Estimated" - } - ] - }, - "subject": { - "reference": "Patient/2b90dd2b-2dab-4c75-9bb9-a355e07401e8" - }, - "effectiveDateTime": "2020-01-10", - "valueDateTime": "2020-05-02" - }, - "request": { - "method": "PUT", - "url": "/fhir/Observation/pregnancy-edd-example" - } - }, - { - "resource": { - "resourceType": "Observation", - "id": "pregnancy-status-example", - "meta": { - "profile": [ - "http://hl7.org/fhir/uv/ips/StructureDefinition/Observation-pregnancy-status-uv-ips" - ] - }, - "text": { - "status": "generated", - "div": "

Generated Narrative: Observation

Resource Observation "pregnancy-status-example"

status: final

code: Pregnancy status (LOINC#82810-3)

subject: Patient/patient-example-female " DELAROSA"

effective: 2020-01-10

value: Pregnant (LOINC#LA15173-0)

hasMember: Observation/pregnancy-edd-example

" - }, - "status": "final", - "code": { - "coding": [ - { - "system": "http://loinc.org", - "code": "82810-3", - "display": "Pregnancy status" - } - ] - }, - "subject": { - "reference": "Patient/2b90dd2b-2dab-4c75-9bb9-a355e07401e8" - }, - "effectiveDateTime": "2020-01-10", - "valueCodeableConcept": { - "coding": [ - { - "system": "http://loinc.org", - "code": "LA15173-0", - "display": "Pregnant" - } - ] - }, - "hasMember": [ - { - "reference": "Observation/pregnancy-edd-example" - } - ] - }, - "request": { - "method": "PUT", - "url": "/fhir/Observation/pregnancy-status-example" - } - }, - { - "resource": { - "resourceType": "Observation", - "id": "pathology-cancer", - "meta": { - "profile": [ - "http://hl7.org/fhir/uv/ips/StructureDefinition/Observation-results-pathology-uv-ips" - ] - }, - "text": { - "status": "generated", - "div": "

Generated Narrative: Observation

Resource Observation "pathology-cancer"

status: final

category: Laboratory (Observation Category Codes#laboratory)

code: Estrogen receptor [Interpretation] in Tissue (LOINC#16112-5)

subject: Patient/eumfh-39-07 " HEIG"

effective: 2020-04-22 19:20:00+0200

performer: Organization/TII-Organization1 "Someplace General Hospital"

value: Estrogen receptor positive tumor (SNOMED CT#416053008)

method: Microscopy (SNOMED CT#117259009)

" - }, - "status": "final", - "category": [ - { - "coding": [ - { - "system": "http://terminology.hl7.org/CodeSystem/observation-category", - "code": "laboratory" - } - ] - } - ], - "code": { - "coding": [ - { - "system": "http://loinc.org", - "code": "16112-5", - "display": "Estrogen receptor [Interpretation] in Tissue" - } - ] - }, - "subject": { - "reference": "Patient/2b90dd2b-2dab-4c75-9bb9-a355e07401e8" - }, - "effectiveDateTime": "2020-04-22T19:20:00+02:00", - "performer": [ - { - "reference": "Organization/TII-Organization1" - } - ], - "valueCodeableConcept": { - "coding": [ - { - "system": "http://snomed.info/sct", - "code": "416053008", - "display": "Estrogen receptor positive tumor" - } - ] - }, - "method": { - "coding": [ - { - "system": "http://snomed.info/sct", - "code": "117259009", - "display": "Microscopy" - } - ] - } - }, - "request": { - "method": "PUT", - "url": "/fhir/Observation/pathology-cancer" - } - }, - { - "resource": { - "resourceType": "Observation", - "id": "ips-example-imaging-4", - "meta": { - "profile": [ - "http://hl7.org/fhir/uv/ips/StructureDefinition/Observation-results-uv-ips" - ] - }, - "text": { - "status": "generated", - "div": "
\n\t\t\t

\n\t\t\t\tdate: 1995-06-08\n

\n\t\t\t

\n\t\t\t\tsubject: Patient/eumfh-39-07\n\t\t\t

\n\t\t\t

\n\t\t\t\tCT Abdomen W contrast IV\n\t\t\t

\n\t\t\t

\n\t\t\t\tProcedure Description:Serial imaging was obtained in the upper abdomen with the administration of oral and intravenous contrast.

\n\t\t\t

\n\t\t\t\tFinding:The examination demonstrates a well circumscribed 3 cm lesion present within the medial aspect of the inferior right liver lobe. Initial evaluation demonstrates lack of contrast enhancement. Subsequent imaging (not shown) demonstrated typical contrast enhancement pattern of a benign hemangioma of the liver. The remaining contrast enhancement pattern in the liver is normal. There is normal appearance of the adrenal glands, spleen, kidneys, and pancreas. There is no evidence of liver metastasis.

\n\t\t\t

\n\t\t\t\tConclusion:3 cm nodule present in the inferior medial aspect of right liver lobe. Contrast enhancement pattern consistent with the diagnosis of hemangioma.\n

\n\t\t
" - }, - "partOf": [ - { - "reference": "ImagingStudy/TII-ImagingStudy-5-1" - } - ], - "status": "final", - "category": [ - { - "coding": [ - { - "system": "http://terminology.hl7.org/CodeSystem/observation-category", - "code": "imaging", - "display": "Imaging" - } - ] - } - ], - "code": { - "coding": [ - { - "system": "http://loinc.org", - "code": "79103-8", - "display": "CT Abdomen W contrast IV" - } - ], - "text": "Upper abdomen with the administration of oral and intravenous contrast (example-4)" - }, - "subject": { - "reference": "Patient/2b90dd2b-2dab-4c75-9bb9-a355e07401e8" - }, - "effectiveDateTime": "1995-06-08", - "performer": [ - { - "reference": "Practitioner/eumfh-39-07" - }, - { - "reference": "Organization/TII-Organization1" - } - ], - "valueString": "3 cm nodule present in the inferior medial aspect of right liver lobe. Contrast enhancement pattern consistent with the diagnosis of hemangioma.", - "component": [ - { - "code": { - "coding": [ - { - "system": "http://dicom.nema.org/resources/ontology/DCM", - "code": "121065", - "display": "Procedure Description" - } - ] - }, - "valueString": "Serial imaging was obtained in the upper abdomen with the administration of oral and intravenous contrast." - }, - { - "code": { - "coding": [ - { - "system": "http://dicom.nema.org/resources/ontology/DCM", - "code": "121071", - "display": "Finding" - } - ] - }, - "valueString": "The examination demonstrates a well circumscribed 3 cm lesion present within the medial aspect of the inferior right liver lobe. Initial evaluation demonstrates lack of contrast enhancement. Subsequent imaging (not shown) demonstrated typical contrast enhancement pattern of a benign hemangioma of the liver. The remaining contrast enhancement pattern in the liver is normal. There is normal appearance of the adrenal glands, spleen, kidneys, and pancreas. There is no evidence of liver metastasis." - } - ] - }, - "request": { - "method": "PUT", - "url": "/fhir/Observation/ips-example-imaging-4" - } - }, - { - "resource": { - "resourceType": "Observation", - "id": "ips-example-imaging-1", - "meta": { - "profile": [ - "http://hl7.org/fhir/uv/ips/StructureDefinition/Observation-results-radiology-uv-ips" - ] - }, - "text": { - "status": "generated", - "div": "
\n

\n CT Abdomen W contrast IV\n

\n

\n date: 1995-06-08\n

\n

\n subject:\n Patient/eumfh-39-07\n

\n

\n value: 3 cm nodule present in the inferior medial aspect of right liver lobe. Contrast enhancement pattern consistent with the diagnosis of hemangioma.\n

\n
" - }, - "status": "final", - "category": [ - { - "coding": [ - { - "system": "http://terminology.hl7.org/CodeSystem/observation-category", - "code": "imaging", - "display": "Imaging" - } - ] - } - ], - "code": { - "coding": [ - { - "system": "http://loinc.org", - "code": "79103-8", - "display": "CT Abdomen W contrast IV" - } - ], - "text": "Upper abdomen with the administration of oral and intravenous contrast (example-4)" - }, - "subject": { - "reference": "Patient/2b90dd2b-2dab-4c75-9bb9-a355e07401e8" - }, - "effectiveDateTime": "1995-06-08", - "performer": [ - { - "reference": "Practitioner/eumfh-39-07" - }, - { - "reference": "Organization/TII-Organization1" - } - ], - "valueString": "3 cm nodule present in the inferior medial aspect of right liver lobe. Contrast enhancement pattern consistent with the diagnosis of hemangioma." - }, - "request": { - "method": "PUT", - "url": "/fhir/Observation/ips-example-imaging-1" - } - }, - { - "resource": { - "resourceType": "Organization", - "id": "TII-Organization1", - "meta": { - "profile": [ - "http://hl7.org/fhir/uv/ips/StructureDefinition/Organization-uv-ips" - ] - }, - "text": { - "status": "generated", - "div": "

Generated Narrative: Organization

Resource Organization "TII-Organization1"

name: Someplace General Hospital

address: 123 Street Address Sometown Somecountry

" - }, - "name": "Someplace General Hospital", - "address": [ - { - "line": ["123 Street Address"], - "city": "Sometown", - "country": "Somecountry" - } - ] - }, - "request": { - "method": "PUT", - "url": "/fhir/Organization/TII-Organization1" - } - } - ] -} diff --git a/ips_ig/src/index.ts b/ips_ig/src/index.ts index d145b4a..6f0c494 100644 --- a/ips_ig/src/index.ts +++ b/ips_ig/src/index.ts @@ -6,8 +6,6 @@ import { Config, Client, Request, Operations, HttpClient } from "./types.js"; import { dispatch } from "./dispatch.js"; import * as operations from "./operations.js"; import { patientData } from "./patientData.js"; -// @ts-ignore -// import patientData from "./data.json" assert { type: "json" }; const fastify = Fastify({ logger: true }); diff --git a/ips_ig/src/operations.ts b/ips_ig/src/operations.ts index 486eb66..0fda83a 100644 --- a/ips_ig/src/operations.ts +++ b/ips_ig/src/operations.ts @@ -7,6 +7,40 @@ import { addFullUrl, getResourcesFromRefs, } from "./ips.js"; +import { Patient } from "@aidbox/sdk-r4/types"; + +const generateSummary = async ({ http, appConfig }: Request, patient: Patient) => { + try { + const patientId = patient.id!!; + const { sections, bundleData }: any = await generateSections(http, patientId); + const composition = createComposition(sections, patientId); + const refResources = await getResourcesFromRefs(http, bundleData); + + return { + resourceType: "Bundle", + type: "document", + timestamp: new Date().toISOString(), + meta: { + profile: ["http://hl7.org/fhir/uv/ips/StructureDefinition/Bundle-uv-ips"], + }, + identifier: { system: "urn:oid:2.16.724.4.8.10.200.10", value: randomUUID() }, + entry: [ + { + resource: composition, + fullUrl: `${appConfig.aidbox.url}/fhir/Composition/${composition.id}`, + }, + { + resource: patient, + fullUrl: `${appConfig.aidbox.url}/fhir/Patient/${patient.id}`, + }, + ...addFullUrl([...bundleData, ...refResources], appConfig.aidbox.url), + ], + }; + } catch (error: any) { + console.log(error); + return error.response; + } +}; export const patientSummary = { method: "GET", @@ -14,38 +48,53 @@ export const patientSummary = { fhirUrl: "http://hl7.org/fhir/uv/ips/OperationDefinition/summary", fhirResource: ["Patient"], path: ["fhir", "Patient", { name: "id" }, "$summary"], - handlerFn: async ( - { aidboxClient, http, body, appConfig }: Request, - reply: FastifyReply - ) => { + handlerFn: async (req: Request, reply: FastifyReply) => { try { - const patientId: string = body?.request?.["route-params"].id; - const patient = await aidboxClient.resource.get("Patient", patientId); - - const { sections, bundleData }: any = await generateSections(http, patientId); - const composition = createComposition(sections, patientId); - const refResources = await getResourcesFromRefs(http, bundleData); - - return reply.send({ - resourceType: "Bundle", - type: "document", - timestamp: new Date().toISOString(), - meta: { - profile: ["http://hl7.org/fhir/uv/ips/StructureDefinition/Bundle-uv-ips"], - }, - identifier: { system: "urn:oid:2.16.724.4.8.10.200.10", value: randomUUID() }, - entry: [ - { - resource: composition, - fullUrl: `${appConfig.aidbox.url}/fhir/Composition/${composition.id}`, - }, - { - resource: patient, - fullUrl: `${appConfig.aidbox.url}/fhir/Patient/${patient.id}`, + const patientId: string = req.body?.request?.["route-params"].id; + const patient = await req.aidboxClient.resource.get("Patient", patientId); + const summary = await generateSummary(req, patient); + return reply.send(summary); + } catch (error: any) { + console.log(error); + return reply.send(error.response); + } + }, +}; + +export const patientSummarySearch = { + method: "GET", + fhirCode: "summary", + fhirUrl: "http://hl7.org/fhir/uv/ips/OperationDefinition/summary", + fhirResource: ["Patient"], + path: ["fhir", "Patient", "$summary"], + handlerFn: async (req: Request, reply: FastifyReply) => { + try { + const patientIdentifier = req.body?.request?.params?.identifier; + + if (!patientIdentifier) { + return reply.code(400).send({ + resourceType: "OperationOutcome", + text: "Search parameter 'identifier' is required", + }); + } + + const data = await req.aidboxClient.resource + .list("Patient") + .where("identifier", patientIdentifier); + + if (!data.entry || data.total == 0) { + return reply.code(404).send({ + resourceType: "OperationOutcome", + id: "NotFound", + text: { + status: "generated", + div: `Resource Patient?identifier=${patientIdentifier} not found`, }, - ...addFullUrl([...bundleData, ...refResources], appConfig.aidbox.url), - ], - }); + }); + } + + const summary = await generateSummary(req, data.entry[0]?.resource); + return reply.send(summary); } catch (error: any) { console.log(error); return reply.send(error.response); diff --git a/ips_ig/src/types.d.ts b/ips_ig/src/types.d.ts index 4728984..5272894 100644 --- a/ips_ig/src/types.d.ts +++ b/ips_ig/src/types.d.ts @@ -30,7 +30,7 @@ export type Request = FastifyRequest<{ id: string; }; request: { - params: {}; + params: Record; "route-params": Record; headers: Record; "oauth/user": Record;