### Example Text Search Query (HTTP POST) Source: https://github.com/hl7/fhir/blob/master/source/search.html This example shows an HTTP POST request for searching Condition resources using the _text parameter. The content-type is specified as application/x-www-form-urlencoded. This method is an alternative to GET for submitting search queries. ```http POST [base]/Condition/_search Content-Type: application/x-www-form-urlencoded _text=(bone OR liver) AND metastases ``` -------------------------------- ### Example Text Search Query (HTTP GET) Source: https://github.com/hl7/fhir/blob/master/source/search.html This example demonstrates an HTTP GET request using the _text search parameter to find Condition resources. It searches for resources containing 'metastases' and either 'bone' or 'liver' in their narrative. Servers may support thesaurus and proximity searches. ```http GET [base]/Condition?_text=(bone OR liver) AND metastases ``` -------------------------------- ### Execute Named Query (GET) Source: https://github.com/hl7/fhir/blob/master/source/search.html Example of executing a named query using an HTTP GET request without additional parameters. ```http GET [base]/Patient?_query=current-high-risk ``` -------------------------------- ### Iteratively Include Related Observations (GET) Source: https://github.com/hl7/fhir/blob/master/source/search.html Retrieve Observation resources and iteratively include related observations using _include:iterate. This example uses the HTTP GET method. ```http GET [base]/Observation?_include:iterate=Observation:has-member&criteria... ``` -------------------------------- ### GET /EpisodeOfCare/example Source: https://github.com/hl7/fhir/blob/master/source/episodeofcare/$everything-response.txt Retrieves the EpisodeOfCare resource for a specific example, linked to the nominated patient. ```APIDOC ## GET /EpisodeOfCare/example ### Description Retrieves the EpisodeOfCare resource for a specific example, linked to the nominated patient. This is often built automatically by publication tooling. ### Method GET ### Endpoint /EpisodeOfCare/example ### Response #### Success Response (200) - **bundle** (object) - A FHIR Bundle resource containing the EpisodeOfCare and related resources. #### Response Example ```json { "resourceType": "Bundle", "type": "collection", "entry": [ { "fullUrl": "http://example.org/fhir/EpisodeOfCare/example", "resource": { "resourceType": "EpisodeOfCare", "id": "example", "meta": { "profile": [ "http://hl7.org/fhir/StructureDefinition/EpisodeOfCare" ] }, "text": { "status": "generated", "div": "
[Generated text]
" }, "identifier": [ { "system": "http://example.org/fhir/identifiers/episode", "value": "EX1234" } ], "status": "active", "period": { "start": "2017-02-15" }, "type": [ { "coding": [ { "system": "http://example.org/fhir/ValueSet/episodeofcare-type", "code": "day", "display": "Day Program" } ] } ], "careManager": { "reference": "Practitioner/example", "display": "Dr. Adam Careful" }, "patient": { "reference": "Patient/example", "display": "Jim specified his location" }, "managingOrganization": { "reference": "Organization/1", "display": "ACME Corporation" } } } ] } ``` ``` -------------------------------- ### CodeSystem Resource Example Source: https://github.com/hl7/fhir/blob/master/source/terminologies-binding-examples.html A minimal CodeSystem resource example, often used in conjunction with binding definitions. ```json { "resourceType" : "CodeSystem", "id" : "example", "url" : "http://hl7.org/fhir/CodeSystem/example", "status" : "draft" } ``` -------------------------------- ### Ratio Data Type Examples Source: https://github.com/hl7/fhir/blob/master/source/datatypes-examples.html Examples of Ratio representing titers and unit costs. ```XML ``` ```JSON "result" : { "numerator" : { "value" : "1" }, "denominator" : { "value" : "128" } } ``` ```XML ``` ```JSON "charge" : { "numerator" : { "value" : "103.50", "unit" : "US$", "code" : "USD", "system" : "urn:iso:std:iso:4217" }, "denominator" : { "value" : "1", "unit" : "day", "code" : "day", "system" : "http://unitsofmeasure.org" } } ``` -------------------------------- ### Date Search Prefix Examples Source: https://github.com/hl7/fhir/blob/master/source/search.html Examples of using specific prefixes for date search parameters to filter resource periods. ```text [parameter]=le2015-04-13T20:27:01-04:00 ``` ```text [parameter]=sa2013-03-14 ``` ```text [parameter]=eb2013-03-14 ``` ```text [parameter]=ap2013-03-14 ``` -------------------------------- ### Quantity Data Type Examples Source: https://github.com/hl7/fhir/blob/master/source/datatypes-examples.html Examples of Quantity representing duration, concentration, and medication dosage. ```XML ``` ```JSON "time" : { "value" : "25", "unit" : "sec", "system" : "http://unitsofmeasure.org", "code" : "s" } ``` ```XML ``` ```JSON "result" : { "value" : "40000", "comparator" : ">", "unit" : "ug/L", "system" : "http://unitsofmeasure.org", "code" : "ug" } ``` ```XML ``` ```JSON "dose" : { "value" : "3", "unit" : "capsules", "system" : "http://snomed.info/sct", "code" : "385049006" } ``` -------------------------------- ### GET /open/MedicinalProductDefinition/example/$everything Source: https://github.com/hl7/fhir/blob/master/source/medicinalproductdefinition/$everything-request.txt Retrieves all resources associated with a specific medicinal product definition. ```APIDOC ## GET /open/MedicinalProductDefinition/example/$everything ### Description Retrieves all resources linked to a single medicinal product definition. ### Method GET ### Endpoint /open/MedicinalProductDefinition/example/$everything ### Parameters #### Query Parameters - **_format** (string) - Optional - The desired response format (e.g., application/json, application/xml). ### Request Example ```json { "example": "GET /open/MedicinalProductDefinition/example/$everything" } ``` ### Response #### Success Response (200) - **resourceType** (string) - Indicates the type of resource returned. - **entry** (array) - An array of resources linked to the medicinal product. - **resource** (object) - A single resource linked to the medicinal product. #### Response Example ```json { "resourceType": "Bundle", "entry": [ { "resource": { "resourceType": "MedicinalProductDefinition", "id": "example" } } ] } ``` ``` -------------------------------- ### Define Implementation Guide Environment Variables Source: https://github.com/hl7/fhir/blob/master/source/fhirpath.html Example of defining a custom environment variable for use in an implementation guide. ```FHIRPath %`us-zip` = '[0-9]{5}(-[0-9]{4}){0,1}' ``` -------------------------------- ### Example of Reference with Display Text Source: https://github.com/hl7/fhir/blob/master/source/references.html This example demonstrates how to use the `display` element within a reference to provide a human-readable short description of the target resource. This is useful when the reference cannot be resolved or to provide context. ```xml ``` -------------------------------- ### Execute Named Query with Parameter (GET) Source: https://github.com/hl7/fhir/blob/master/source/search.html Example of executing a named query with a 'ward' parameter using an HTTP GET request. ```http GET [base]/Patient?_query=current-high-risk&ward=Location/A1 ``` -------------------------------- ### Context-aware path evaluation Source: https://github.com/hl7/fhir/blob/master/source/fhirpath.md Examples showing how to evaluate paths with or without explicit context prefixes. ```text telecom(use = 'phone').value ``` ```text Patient.telecom(use = 'phone').value ``` -------------------------------- ### Search ImmunizationRecommendation by Dose Number (GET) Source: https://github.com/hl7/fhir/blob/master/source/search.html Example of searching for Immunization Recommendations for a second dose using an HTTP GET request. ```http GET [base]/ImmunizationRecommendation?dose-number=2 ``` -------------------------------- ### POST /[type] Source: https://github.com/hl7/fhir/blob/master/source/http.html Create a new resource instance. ```APIDOC ## POST /[type] ### Description Create a new resource instance. ### Method POST ### Endpoint /[type] ### Parameters #### Path Parameters - **type** (string) - Required - The resource type #### Request Body - **Resource** (object) - Required - The resource to create ### Response #### Success Response (201) - **Resource** (object) - The created resource #### Response Example { "resourceType": "Patient", "id": "new-id" } ``` -------------------------------- ### GET /open/Encounter/example/$everything Source: https://github.com/hl7/fhir/blob/master/source/encounter/$everything-request.txt Retrieves all resources associated with a specific patient, often used for a comprehensive patient summary. ```APIDOC ## GET /open/Encounter/example/$everything ### Description Retrieves all resources linked to a single patient. ### Method GET ### Endpoint /open/Encounter/example/$everything ### Parameters #### Query Parameters - **_id** (string) - Required - The ID of the patient for whom to retrieve resources. ### Request Example (No request body for GET requests) ### Response #### Success Response (200) - **resourceType** (string) - The type of the resource returned (e.g., 'Bundle'). - **entry** (array) - An array of FHIR resources associated with the patient. #### Response Example ```json { "resourceType": "Bundle", "entry": [ { "resource": { "resourceType": "Patient", "id": "example" } }, { "resource": { "resourceType": "Encounter", "id": "encounter-example-1" } } ] } ``` ``` -------------------------------- ### Search RiskAssessment by Probability (GET) Source: https://github.com/hl7/fhir/blob/master/source/search.html Example of searching for Risk Assessments with a probability greater than 0.8 using an HTTP GET request. ```http GET [base]/RiskAssessment?probability=gt0.8 ``` -------------------------------- ### Example Source Statement with Conditions and Logging Source: https://github.com/hl7/fhir/blob/master/source/mapping-language.html An example demonstrating a source statement with a default value, variable assignment, a 'where' condition, a 'check' condition, and a 'log' statement. ```plaintext src.value : integer 0..* default (10) first as vs0 where (value >= 10) check (value <= 100) log (value) ``` -------------------------------- ### Include Related Observations (GET) Source: https://github.com/hl7/fhir/blob/master/source/search.html Retrieve Observation resources and directly related observations using _include. This example uses the HTTP GET method. ```http GET [base]/Observation?_include=Observation:has-member&criteria... ``` -------------------------------- ### List Resource Entry Example Source: https://github.com/hl7/fhir/blob/master/source/profiling-examples.html A sample List resource demonstrating entries categorized by medication resource types. ```xml ... snip ... ... snip ... ``` -------------------------------- ### Period Example Source: https://github.com/hl7/fhir/blob/master/source/datatypes-examples.html Represents a time interval with a start and end date. ```xml ``` ```json "coverage" : { "start" : "2011-05-23", "end" : "2011-05-27" } ``` -------------------------------- ### GET /open/EpisodeOfCare/example/$everything Source: https://github.com/hl7/fhir/blob/master/source/episodeofcare/$everything-request.txt Retrieves all resources linked to a single patient. ```APIDOC ## GET /open/EpisodeOfCare/example/$everything ### Description Retrieves all resources linked to a single patient. ### Method GET ### Endpoint /open/EpisodeOfCare/example/$everything ### Parameters ### Request Body ### Request Example ```json { "example": "request body" } ``` ### Response #### Success Response (200) - **field1** (type) - Description #### Response Example ```json { "example": "response body" } ``` ``` -------------------------------- ### Include Prescribing Practitioner in MedicationDispense Search (GET) Source: https://github.com/hl7/fhir/blob/master/source/search.html Use _include to retrieve the prescribing Practitioner for MedicationDispense resources. This example shows the HTTP GET method. ```http GET [base]/MedicationDispense?_include=Medication:prescription &_include:iterate=MedicationRequest:requester&criteria... ``` -------------------------------- ### GET /open/Group/example/$everything Source: https://github.com/hl7/fhir/blob/master/source/group/$everything-request.txt Retrieves all resources linked to a single patient group. ```APIDOC ## GET /open/Group/example/$everything ### Description Retrieves all resources linked to a single patient group. ### Method GET ### Endpoint /open/Group/example/$everything ### Response #### Success Response (200) - **Bundle** (Resource) - A FHIR Bundle containing all resources linked to the specified patient group. ``` -------------------------------- ### Access primitive values and extensions Source: https://github.com/hl7/fhir/blob/master/source/fhirpath.html Examples showing how to access primitive values and their associated extensions. ```FHIRPath Patient.name.given = 'Ewout' // value of Patient.name.given as a string Patient.name.given.extension.first().value = true // extension of the primitive value !Patient.active.hasValue() and !Patient.active.empty() // can both be true, if there are extensions but no value for Patient.active ``` -------------------------------- ### Search by identifier modifier Source: https://github.com/hl7/fhir/blob/master/source/search.html Examples of using the identifier modifier in HTTP GET and POST requests. ```http GET [base]/Observation?subject:identifier=http://example.org/fhir/mrn|12345 ``` ```http POST [base]/Observation/_search Content-Type: application/x-www-form-urlencoded subject:identifier=http://example.org/fhir/mrn|12345 ``` -------------------------------- ### Perform Subsumption Testing Source: https://github.com/hl7/fhir/blob/master/source/terminology-service.html Examples of testing subsumption relationships between concepts using GET and POST requests. ```HTTP GET [base]/CodeSystem/$subsumes?system=http://snomed.info/sct&codeA=235856003&codeB=3738000 ``` ```XML POST [base]/CodeSystem/$subsumes [other headers] ``` -------------------------------- ### Search Resources by Profile Source: https://github.com/hl7/fhir/blob/master/source/search.html Use the `_profile` parameter to find resources that have a specific profile listed in their `Resource.meta.profile`. This example searches for `Observation` resources with the `bp` profile. ```http GET [base]/Observation?_profile=http://hl7.org/fhir/StructureDefinition/bp ``` ```http POST [base]/Observation/_search Content-Type: application/x-www-form-urlencoded _profile=http://hl7.org/fhir/StructureDefinition/bp ``` -------------------------------- ### Select elements by path Source: https://github.com/hl7/fhir/blob/master/source/fhirpath.md Basic path selection syntax for navigating resource elements. ```text path.subPath.subPath - select all the elements on the path ``` ```text telecom.value ``` -------------------------------- ### Unencoded FHIR Search Requests Source: https://github.com/hl7/fhir/blob/master/source/search.html Examples of unencoded HTTP GET and POST search requests for an Observation resource. ```http GET [base]/Observation?patient.identifier=http://example.com/fhir/identifier/mrn|123456 POST [base]/Observation/_search Content-Type: application/x-www-form-urlencoded patient.identifier=http://example.com/fhir/identifier/mrn|123456 ``` -------------------------------- ### Create a Coding Source: https://github.com/hl7/fhir/blob/master/source/fhirpath.html Constructs a Coding object with system, code, display, and version. ```FHIRPath %factory.Coding('http://loinc.org', '1234-5, 'An example test', '1.02') ``` -------------------------------- ### Expand Value Set Operation (GET) Source: https://github.com/hl7/fhir/blob/master/source/operations.html Example of invoking the $expand operation on a ValueSet using an HTTP GET request. Parameters are appended to the URL. This method is suitable when all parameters are primitive types and the operation does not affect state. ```http GET [base]/ValueSet/$expand?url=http://hl7.org/fhir/ValueSet/body-site&filter=abdo ``` -------------------------------- ### Nickname Usage Example Source: https://github.com/hl7/fhir/blob/master/source/datatypes-examples.html Demonstrates recording a nickname alongside an official name. ```xml ``` ```json "name" : [{ "use" : "official", "family" : "Brown", "given" : ["Steven"] }, { "use" : "nickname", "given" : ["Junior"] }] ``` -------------------------------- ### Representing a Simple Extension Source: https://github.com/hl7/fhir/blob/master/source/extensibility.html Examples of a simple extension with a valueCode in different formats. ```XML ``` ```JSON { "extension": [ { "url": "http://hl7.org/fhir/StructureDefinition/iso-21090-EN-use", "valueCode": "I" } ], "text": "Chief Red Cloud" } ``` ```Turtle ... fhir:extension ( [ fhir:url [ fhir:l ; fhir:v "http://hl7.org/fhir/StructureDefinition/iso-21090-EN-use"^^xsd:anyURI ] ; fhir:value [ a fhir:code ; fhir:v "I" ] ] ) ; fhir:text [ fhir:v "Chief Red Cloud" ] ; ``` -------------------------------- ### URL-Encoded FHIR Search Requests Source: https://github.com/hl7/fhir/blob/master/source/search.html Examples of the corresponding URL-encoded HTTP GET and POST search requests for transmission over the wire. ```http GET [base]/Observation?patient.identifier=http%3A%2F%2Fexample.com%2Ffhir%2Fidentifier%2Fmrn%7C123456 POST [base]/Observation/_search Content-Type: application/x-www-form-urlencoded patient.identifier=http%3A%2F%2Fexample.com%2Ffhir%2Fidentifier%2Fmrn%7C123456 ``` -------------------------------- ### POST /Resource Source: https://github.com/hl7/fhir/blob/master/source/exchanging.html Creates a new resource instance. ```APIDOC ## POST /Resource ### Description The data source POSTs a single resource instance to the RESTful endpoint of the data consumer. ### Method POST ### Endpoint /Resource ``` -------------------------------- ### Select Resource with Fields Source: https://github.com/hl7/fhir/blob/master/source/graphql.html Use the 'resource' selection to resolve a reference and include specific fields from the referenced resource. This example shows how to get the 'active' field from a subject resource. ```graphql { subject { reference, resource {active} } } ```