In Aidbox, you can easily define first-class extensions using the custom resource Attribute.
Let's create an extension definition of type Reference
in the REST Console of Aidbox:
You can quickly copy sample requests using the icon in the top right corner of code blocks. Block titles won't be copied.
Create new extension in the Aidbox format:PUT /Attribute/ServiceRequest.requestedOrganizationDepartment​resourceType: Attributedescription: Department in the organization that made the service requestresource: {id: ServiceRequest, resourceType: Entity}path: [requestedOrganizationDepartment]id: ServiceRequest.requestedOrganizationDepartmenttype: {id: Reference, resourceType: Entity}refers:- OrganizationextensionUrl: urn:extension:requestedOrganizationDepartment
The extensionUrl
property allows you to get the extension in the FHIR compatible way.
Now, you can create the ServiceRequest
resource using the new attribute requestedOrganizationDepartment
in the root of the resource:
Create resource in the Aidbox format:PUT /ServiceRequest/servicerequest-with-aidbox-native-extensions​requestedOrganizationDepartment:resourceType: Organizationdisplay: City Hospital Neurology Departmentidentifier: {system: 'urn:oid:1.2.3.4.5.6.7.8', value: '456'}category:- coding:- {code: '183829003',system: 'http://snomed.info/sct',display: "Refer for imaging"}authoredOn: '2020-01-18T15:08:00'resourceType: ServiceRequestrequester:resourceType: PractitionerRoledisplay: Din Morganidentifier: {value: "1760", system: 'urn:oid:1.2.3.4.5.6.7.6'}priority: routinestatus: activeintent: original-orderperformer:- resourceType: Organizationdisplay: Aga Khan University Hospital Laboratoryidentifier: {value: "1514", system: 'urn:oid:1.2.3.4.5.6.7.8'}subject:resourceType: Patientdisplay: Jack Black, 10.12.1941identifier: {value: '2155800871000065', system: 'urn:oid:1.2.3.4.5.6.7.9'}
You can get the resource in the FHIR format where our new attribute is rendered as the extension
element:
Note that the URL is different:GET /fhir/ServiceRequest/
Get the resource in the FHIR format:GET /fhir/ServiceRequest/servicerequest-with-aidbox-native-extensions
extension:- url: urn:extension:requestedOrganizationDepartmentvalueReference:type: Organizationidentifier: {value: '456', system: 'urn:oid:1.2.3.4.5.6.7.8'}display: City Hospital Neurology Departmentcategory:- coding:- {code: '183829003',system: 'http://snomed.info/sct',display: "Refer for imaging"}meta:lastUpdated: '2020-02-04T09:15:18.664293Z'versionId: '32'extension:- {url: 'ex:createdAt', valueInstant: '2020-02-04T09:12:20.103301Z'}authoredOn: '2020-01-18T15:08:00'resourceType: ServiceRequestrequester:type: PractitionerRoleidentifier: {value: '1760', system: 'urn:oid:1.2.3.4.5.6.7.6'}display: Din Morganpriority: routinestatus: activeid: servicerequest-with-aidbox-native-extensionsintent: original-ordersubject:type: Patientidentifier: {value: '2155800871000065',system: 'urn:oid:1.2.3.4.5.6.7.9'}display: Jack Black, 10.12.1941performer:- type: Organizationidentifier: {value: '1514', system: 'urn:oid:1.2.3.4.5.6.7.8'}display: Aga Khan University Hospital Laboratory
Let's create an extension of type Reference
and list allowed resource types (Organization in that case) in the refers
property.
managingOrganizationPUT /Attribute/ServiceRequest.managingOrganization​resourceType: Attributedescription: Organization that made the service requestresource: {id: ServiceRequest, resourceType: Entity}path: [managingOrganization]id: ServiceRequest.managingOrganizationtype: {id: Reference, resourceType: Entity}refers:- OrganizationextensionUrl: urn:extension:requestedOrganization
Extension of type Coding:
paymentTypePUT /Attribute/ServiceRequest.paymentType​resourceType: Attributedescription: Payment type for the service request, e.g. government health insuranceid: ServiceRequest.paymentTyperesource:id: ServiceRequestresourceType: Entitypath:- paymentTypetype:id: CodingresourceType: EntityextensionUrl: urn:extension:paymentType
Create resource using these extensions:PUT /ServiceRequest/servicerequest-with-aidbox-native-extensions​managingOrganization:resourceType: Organizationdisplay: City Hospitalidentifier: {value: "123", system: 'urn:oid:1.2.3.4.5.6.7.8'}requestedOrganizationDepartment:resourceType: Organizationdisplay: City Hospital Neurology Departmentidentifier: {system: 'urn:oid:1.2.3.4.5.6.7.8', value: '456'}paymentType: {system: 'urn:CodeSystem:paymentType',code: "1",display: "Government Health Insurance"}resourceType: ServiceRequeststatus: activeintent: original-ordersubject:resourceType: Patientdisplay: Jack Black, 10.12.1941identifier: {value: '2155800871000065', system: 'urn:oid:1.2.3.4.5.6.7.9'}
Get resource in the FHIR format:GET /fhir/ServiceRequest/servicerequest-with-aidbox-native-extensions
resourceType: ServiceRequestextension:- url: urn:extension:requestedOrganizationvalueReference:type: Organizationidentifier: {value: '123', system: 'urn:oid:1.2.3.4.5.6.7.8'}display: City Hospital- url: urn:extension:requestedOrganizationDepartmentvalueReference:type: Organizationidentifier: {value: '456', system: 'urn:oid:1.2.3.4.5.6.7.8'}display: City Hospital Neurology Department- url: urn:extension:paymentTypevalueCoding: {code: '1',system: 'urn:CodeSystem:paymentType',display: Government Health Insurance}status: activeid: servicerequest-with-aidbox-native-extensionsintent: original-ordersubject:type: Patientidentifier: {value: '2155800871000065', system: 'urn:oid:1.2.3.4.5.6.7.9'}display: Jack Black, 10.12.1941
Let's create a structure of nested attributes:
performerInfoPUT /Attribute/ServiceRequest.performerInfo​resourceType: Attributedescription: Information filled in by performerresource: {id: ServiceRequest, resourceType: Entity}path: [performerInfo]id: ServiceRequest.performerInfoextensionUrl: urn:extension:performerInfo
performerInfo.performedByPUT /Attribute/ServiceRequest.performerInfo.performedBy​resourceType: Attributedescription: 'Information filled in by performer: performed by ["Practitioner" "PractitionerRole" "Organization" "CareTeam" "HealthcareService" "Patient" "Device" "RelatedPerson"]'resource: {id: ServiceRequest, resourceType: Entity}path: [performerInfo, performedBy]id: ServiceRequest.performerInfo.performedBytype: {id: Reference, resourceType: Entity}isCollection: truerefers:- Practitioner- PractitionerRole- Organization- CareTeam- HealthcareService- Patient- Device- RelatedPersonextensionUrl: urn:extension:performerInfo.performedBy
performerInfo.actualLocationReferencePUT /Attribute/ServiceRequest.performerInfo.actualLocationReference​resourceType: Attributedescription: 'Information filled in by performer: actual location reference'resource: {id: ServiceRequest, resourceType: Entity}path: [performerInfo, actualLocationReference]id: ServiceRequest.performerInfo.actualLocationReferencetype: {id: Reference, resourceType: Entity}isCollection: truerefers:- LocationextensionUrl: urn:extension:performerInfo.actualLocationReference
performerInfo.requestStatusPUT /Attribute/ServiceRequest.performerInfo.requestStatus​resourceType: Attributedescription: 'Information filled in by performer: request status'resource: {id: ServiceRequest, resourceType: Entity}path: [performerInfo, requestStatus]id: ServiceRequest.performerInfo.requestStatustype: {id: code, resourceType: Entity}enum:- draft- new- in-progress- suspended- expanded- completed- archive- cancelledextensionUrl: urn:extension:performerInfo.requestStatus
performerInfo.requestActionHistoryPUT /Attribute/ServiceRequest.performerInfo.requestActionHistory​resourceType: Attributedescription: 'Information filled in by performer: request action history'resource: {id: ServiceRequest, resourceType: Entity}path: [performerInfo, requestActionHistory]id: ServiceRequest.performerInfo.requestActionHistoryisCollection: trueextensionUrl: urn:extension:performerInfo.requestActionHistory
performerInfo.requestActionHistory.actionPUT /Attribute/ServiceRequest.performerInfo.requestActionHistory.action​resourceType: Attributedescription: 'Information filled in by performer: request action history - action'resource: {id: ServiceRequest, resourceType: Entity}path: [performerInfo, requestActionHistory, action]id: ServiceRequest.performerInfo.requestActionHistory.actiontype: {id: string, resourceType: Entity}extensionUrl: urn:extension:performerInfo.requestActionHistory.action
performerInfo.requestActionHistory.datePUT /Attribute/ServiceRequest.performerInfo.requestActionHistory.date​resourceType: Attributedescription: 'Information filled in by performer: request action history - date'resource: {id: ServiceRequest, resourceType: Entity}path: [performerInfo, requestActionHistory, date]id: ServiceRequest.performerInfo.requestActionHistory.datetype: {id: dateTime, resourceType: Entity}extensionUrl: urn:extension:performerInfo.requestActionHistory.date
performerInfo.requestActionHistory.subjectPUT /Attribute/ServiceRequest.performerInfo.requestActionHistory.subject​resourceType: Attributedescription: 'Information filled in by performer: request action history - subject'resource: {id: ServiceRequest, resourceType: Entity}path: [performerInfo, requestActionHistory, subject]id: ServiceRequest.performerInfo.requestActionHistory.subjecttype: {id: Reference, resourceType: Entity}extensionUrl: urn:extension:performerInfo.requestActionHistory.subject
performerInfo.requestActionHistory.notePUT /Attribute/ServiceRequest.performerInfo.requestActionHistory.note​resourceType: Attributedescription: 'Information filled in by performer: request action history - note'resource: {id: ServiceRequest, resourceType: Entity}path: [performerInfo, requestActionHistory, note]id: ServiceRequest.performerInfo.requestActionHistory.notetype: {id: string, resourceType: Entity}extensionUrl: urn:extension:performerInfo.requestActionHistory.note
performerInfo.requestActionHistory.authorPUT /Attribute/ServiceRequest.performerInfo.requestActionHistory.author​resourceType: Attributedescription: 'Information filled in by performer: request action history - author'resource: {id: ServiceRequest, resourceType: Entity}path: [performerInfo, requestActionHistory, author]id: ServiceRequest.performerInfo.requestActionHistory.authortype: {id: Reference, resourceType: Entity}extensionUrl: urn:extension:performerInfo.requestActionHistory.author
Let's add a resource using created extensions:
Create resource in the Aidbox format:PUT /ServiceRequest/servicerequest-with-aidbox-native-extensions​resourceType: ServiceRequestperformerInfo:performedBy:- resourceType: Organizationdisplay: City Hospital- resourceType: PractitionerRoledisplay: Mark SloanrequestStatus: completedrequestActionHistory:- date: '2020-01-14T12:15:22'action: newauthor: {display: Meredith Grey (Psychiatrist-narcologist), resourceType: PractitionerRole}- date: '2020-01-14T12:15:36'action: in-progressauthor: {display: Derek Shepherd (General practitioner), resourceType: PractitionerRole}- date: '2020-01-14T12:19:00'action: in-progressauthor: {display: Derek Shepherd (General practitioner), resourceType: PractitionerRole}subject: {display: Mark Sloan (Dental surgeon), resourceType: PractitionerRole}note: Referred to Dr. Mark Sloan (Dental surgeon)- date: '2020-01-14T15:05:20'action: meetingauthor: {display: Mark Sloan (Dental surgeon), resourceType: PractitionerRole}- date: '2020-01-14T15:22:46'action: completedauthor: {display: Mark Sloan (Dental surgeon), resourceType: PractitionerRole}status: completedintent: original-ordercategory:- text: Telemedicine consultation referralcoding:- {code: "TMC", system: 'urn:CodeSystem:servicerequest-category', display: "Telemedicine consultation"}subject:resourceType: Patientdisplay: Jack Black, 10.12.1941identifier: {value: '2155800871000065', system: 'urn:oid:1.2.3.4.5.6.7.9'}
Get resource in the FHIR format:GET /fhir/ServiceRequest/servicerequest-with-aidbox-native-extensions
resourceType: ServiceRequestextension:- url: urn:extension:performerInfoextension:- url: urn:extension:performerInfo.performedByvalueReference: {display: City Hospital}- url: urn:extension:performerInfo.performedByvalueReference: {display: Mark Sloan}- {url: 'urn:extension:performerInfo.requestStatus', valueCode: completed}- url: urn:extension:performerInfo.requestActionHistoryextension:- {url: 'urn:extension:performerInfo.requestActionHistory.date', valueDateTime: '2020-01-14T12:15:22'}- {url: 'urn:extension:performerInfo.requestActionHistory.action', valueString: new}- url: urn:extension:performerInfo.requestActionHistory.authorvalueReference: {display: Meredith Grey (Psychiatrist-narcologist)}- url: urn:extension:performerInfo.requestActionHistoryextension:- {url: 'urn:extension:performerInfo.requestActionHistory.date', valueDateTime: '2020-01-14T12:15:36'}- {url: 'urn:extension:performerInfo.requestActionHistory.action', valueString: in-progress}- url: urn:extension:performerInfo.requestActionHistory.authorvalueReference: {display: Derek Shepherd (General practitioner)}- url: urn:extension:performerInfo.requestActionHistoryextension:- {url: 'urn:extension:performerInfo.requestActionHistory.date', valueDateTime: '2020-01-14T12:19:00'}- {url: 'urn:extension:performerInfo.requestActionHistory.note', valueString: Referred to Dr. Mark Sloan (Dental surgeon)}- {url: 'urn:extension:performerInfo.requestActionHistory.action', valueString: in-progress}- url: urn:extension:performerInfo.requestActionHistory.authorvalueReference: {display: Derek Shepherd (General practitioner)}- url: urn:extension:performerInfo.requestActionHistory.subjectvalueReference: {display: Mark Sloan (Dental surgeon)}- url: urn:extension:performerInfo.requestActionHistoryextension:- {url: 'urn:extension:performerInfo.requestActionHistory.date', valueDateTime: '2020-01-14T15:05:20'}- {url: 'urn:extension:performerInfo.requestActionHistory.action', valueString: meeting}- url: urn:extension:performerInfo.requestActionHistory.authorvalueReference: {display: Mark Sloan (Dental surgeon)}- url: urn:extension:performerInfo.requestActionHistory.subjectvalueReference: {display: '2020-01-08'}- url: urn:extension:performerInfo.requestActionHistoryextension:- {url: 'urn:extension:performerInfo.requestActionHistory.date', valueDateTime: '2020-01-14T15:22:46'}- {url: 'urn:extension:performerInfo.requestActionHistory.action', valueString: completed}- url: urn:extension:performerInfo.requestActionHistory.authorvalueReference: {display: Mark Sloan (Dental surgeon)}status: completedid: servicerequest-with-aidbox-native-extensionsintent: original-ordercategory:- text: Telemedicine consultation referralcoding:- {code: TMC, system: 'urn:CodeSystem:servicerequest-category', display: Telemedicine consultation}subject:identifier: {value: '2155800871000065', system: 'urn:oid:1.2.3.4.5.6.7.9'}display: Jack Black, 10.12.1941
FHIR extensions defined in the specification can be found in the registry http://hl7.org/fhir/extensibility-registry.html.
Let's create an attribute for the servicerequest-precondition extension:
PUT /Attribute/ServiceRequest.precondition​resourceType: Attributedescription: "The condition or state of the patient, prior or duringthe diagnostic procedure or test, for example, fasting, at-rest,or post-operative. This captures circumstances that may influencethe measured value and have bearing on the interpretation of the result."resource: {id: ServiceRequest, resourceType: Entity}path: [precondition]id: ServiceRequest.preconditiontype: {id: CodeableConcept, resourceType: Entity}isCollection: trueextensionUrl: "http://hl7.org/fhir/StructureDefinition/servicerequest-precondition"
Let's create resource in the FHIR format:
Create resource in the FHIR format:PUT /fhir/ServiceRequest/servicerequest-with-aidbox-native-extensions​resourceType: ServiceRequeststatus: activeintent: original-ordersubject:type: Patientdisplay: Jack Black, 10.12.1941extension:- url: http://hl7.org/fhir/StructureDefinition/servicerequest-preconditionvalueCodeableConcept:text: After calorie fastingcoding:- code: "726055006"system: http://snomed.info/sctdisplay: After calorie fasting- url: http://hl7.org/fhir/StructureDefinition/servicerequest-preconditionvalueCodeableConcept:text: At restcoding:- code: "263678003"system: http://snomed.info/sctdisplay: At rest
Let's get the resource in the Aidbox format:
Get resource in the Aidbox format:GET /ServiceRequest/servicerequest-with-aidbox-native-extensions
resourceType: ServiceRequestid: servicerequest-with-aidbox-native-extensionsintent: original-orderstatus: activesubject: {type: Patient, display: 'Jack Black, 10.12.1941'}precondition:- text: After calorie fastingcoding:- {code: '726055006',system: 'http://snomed.info/sct',display: After calorie fasting}- text: At restcoding:- {code: '263678003',system: 'http://snomed.info/sct',display: At rest}
If you are using some HTTP-client like Postman, you will need to specify some headers.
Header | Value |
Authorization | Bearer <your value> |
Content-Type | text/yaml |