### Configure Additional Resource Folders for Package Installation
Source: https://hapifhir.io/hapi-fhir/docs/server_jpa/packages.html
Use setAdditionalResourceFolders to include non-standard folders like 'example' during package installation.
```java
PackageInstallationSpec spec = new PackageInstallationSpec()
.setName("com.example.my-ig")
.setVersion("1.0.0")
.setInstallMode(PackageInstallationSpec.InstallModeEnum.STORE_AND_INSTALL)
.setAdditionalResourceFolders(Set.of("example"));
```
--------------------------------
### Upload example resources
Source: https://hapifhir.io/hapi-fhir/docs/tools/hapi_fhir_cli.html
Populates a running FHIR server with standard FHIR example resources.
```bash
hapi-fhir-cli upload-examples -v dstu3 -t http://localhost:8080/baseDstu3
```
--------------------------------
### Expected Java Version Output
Source: https://hapifhir.io/hapi-fhir/docs/tools/hapi_fhir_cli.html
Example of the output expected when Java is correctly installed.
```text
java version "1.8.0_60"
Java(TM) SE Runtime Environment (build 1.8.0_60-b27)
Java HotSpot(TM) 64-Bit Server VM (build 25.60-b23, mixed mode)
```
--------------------------------
### Configure Package Installation with Dependencies
Source: https://hapifhir.io/hapi-fhir/docs/server_jpa/packages.html
Demonstrates setting up a package installation specification with dependency fetching enabled and specific exclusions defined via regex.
```java
PackageInstallationSpec spec = new PackageInstallationSpec()
.setName("hl7.fhir.us.core")
.setVersion("7.0.0")
.setInstallMode(PackageInstallationSpec.InstallModeEnum.STORE_AND_INSTALL)
.setFetchDependencies(true)
.addDependencyExclude("^hl7\\.fhir\\.r4\\.core$")
.addDependencyExclude("^hl7\\.terminology.*");
```
```json
{
"name": "hl7.fhir.us.core",
"version": "7.0.0",
"installMode": "STORE_AND_INSTALL",
"fetchDependencies": true,
"dependencyExcludes": [
"^hl7\\.fhir\\.r4\\.core$",
"^hl7\\.terminology.*"
]
}
```
--------------------------------
### Configure Package Installation Specification
Source: https://hapifhir.io/hapi-fhir/docs/server_jpa/packages.html
Sets up a package installation specification with a specific version policy to control how canonical resources are matched during installation.
```java
PackageInstallationSpec spec = new PackageInstallationSpec()
.setName("hl7.fhir.us.core")
.setVersion("7.0.0")
.setInstallMode(PackageInstallationSpec.InstallModeEnum.INSTALL_ONLY)
.setVersionPolicy(PackageInstallationSpec.VersionPolicyEnum.SINGLE_VERSION);
```
--------------------------------
### Install a package asynchronously
Source: https://hapifhir.io/hapi-fhir/docs/server_jpa/packages.html
Use the asynchronous installation method for batch processing of packages.
```java
myPackageInstallerSvc.installAsynchronously(spec);
```
--------------------------------
### HTTP GET request for MDM query links
Source: https://hapifhir.io/hapi-fhir/docs/server_jpa_mdm/mdm_operations.html
Example of invoking the operation using an HTTP GET request with query parameters.
```http
http://example.com/$mdm-query-links?matchResult=POSSIBLE_MATCH
```
```http
http://example.com/$mdm-query-links?_offset=10&_count=2
```
--------------------------------
### Verify Java Installation
Source: https://hapifhir.io/hapi-fhir/docs/tools/hapi_fhir_cli.html
Check the installed Java version to ensure compatibility with the CLI tool.
```bash
java -version
```
--------------------------------
### Get CLI Migration Help
Source: https://hapifhir.io/hapi-fhir/docs/server_jpa/upgrading.html
Displays detailed help and available options for the migrate-database command.
```bash
./hapi-fhir-cli help migrate-database
```
--------------------------------
### Example incoming Practitioner resource
Source: https://hapifhir.io/hapi-fhir/docs/server_jpa_mdm/mdm_rules.html
A sample Practitioner resource used for testing candidate search logic.
```json
{
"resourceType": "Practitioner",
"id": "example",
"identifier": [
{
"system": "urn:oid:1.2.36.146.595.404.0.1",
"value": "56789"
}
],
"name": [
{
"family": "Smith",
"given": ["Adam"]
}
]
}
```
--------------------------------
### GET PlanDefinition/$r5.apply
Source: https://hapifhir.io/hapi-fhir/docs/clinical_reasoning/plan_definitions.html
Applies a PlanDefinition and returns a Bundle of resources instead of a CarePlan.
```APIDOC
## GET [base]/PlanDefinition/[id]/$r5.apply
### Description
An R5 version of the apply operation that returns a Bundle of resources instead of a CarePlan.
### Method
GET
### Endpoint
[base]/PlanDefinition/[id]/$r5.apply
```
--------------------------------
### List Partitions Response Body
Source: https://hapifhir.io/hapi-fhir/docs/server_jpa_partitioning/partitioning_management_operations.html
Example response body for the $partition-management-list-partitions operation.
```json
{
"resourceType": "Parameters",
"parameter": [ {
"name": "partition",
"part": [ {
"name": "id",
"valueInteger": 1
}, {
"name": "name",
"valueCode": "PARTITION-1"
}, {
"name": "description",
"valueString": "a description1"
} ]
}, {
"name": "partition",
"part": [ {
"name": "id",
"valueInteger": 2
}, {
"name": "name",
"valueCode": "PARTITION-2"
}, {
"name": "description",
"valueString": "a description2"
} ]
} ]
}
```
--------------------------------
### Observation Resource Example
Source: https://hapifhir.io/hapi-fhir/docs/server_jpa/elastic.html
A sample Observation resource used to demonstrate how text fields are indexed.
```json
{
"resourceType" : "Observation",
"code" : {
"coding" : [{
"system" : "http://loinc.org",
"code" : "15074-8",
"display" : "Glucose [Moles/volume] in Blood Found during patient's visit!"
}]
}
"valueQuantity" : {
"value" : 6.3,
"unit" : "mmol/l",
"system" : "http://unitsofmeasure.org",
"code" : "mmol/L"
}
}
```
--------------------------------
### Install a package using Java API
Source: https://hapifhir.io/hapi-fhir/docs/server_jpa/packages.html
Configure a PackageInstallationSpec to fetch and install a package from the FHIR NPM registry.
```java
PackageInstallationSpec spec = new PackageInstallationSpec()
.setName("hl7.fhir.us.core")
.setVersion("7.0.0")
.setInstallMode(PackageInstallationSpec.InstallModeEnum.STORE_AND_INSTALL)
.setFetchDependencies(true);
myPackageInstallerSvc.install(spec);
```
--------------------------------
### MDM Link History Request Example
Source: https://hapifhir.io/hapi-fhir/docs/server_jpa_mdm/mdm_operations.html
Example HTTP GET request to retrieve link history for specific golden and source resource IDs.
```http
http://example.com/$mdm-link-history?goldenResourceId=1553&resourceId=1552
```
--------------------------------
### Start a local FHIR server
Source: https://hapifhir.io/hapi-fhir/docs/tools/hapi_fhir_cli.html
Starts a local, fully functional FHIR server using a Derby database instance.
```bash
hapi-fhir-cli run-server
```
--------------------------------
### Simple FHIRPath expressions
Source: https://hapifhir.io/hapi-fhir/docs/server_jpa/fhir_patch.html
Examples of simple dot-notation paths for navigating resource structures.
```FHIRPath
Patient.birthDate
Patient.name.family
Observation.code.coding
```
--------------------------------
### GET PlanDefinition/$apply
Source: https://hapifhir.io/hapi-fhir/docs/clinical_reasoning/plan_definitions.html
Applies a PlanDefinition to a given context using query parameters.
```APIDOC
## GET [base]/PlanDefinition/[id]/$apply
### Description
Applies a PlanDefinition to a given context, such as a patient or encounter, to generate a CarePlan.
### Method
GET
### Endpoint
[base]/PlanDefinition/[id]/$apply
### Parameters
#### Query Parameters
- **subject** (string) - Optional - The subject(s) that is/are the target of the plan definition to be applied.
- **encounter** (string) - Optional - The encounter in context, if any.
- **practitioner** (string) - Optional - The practitioner applying the plan definition.
- **organization** (string) - Optional - The organization applying the plan definition.
- **userType** (CodeableConcept) - Optional - The type of user initiating the request.
- **userLanguage** (CodeableConcept) - Optional - Preferred language of the person using the system.
- **userTaskContext** (CodeableConcept) - Optional - The task the system user is performing.
- **setting** (CodeableConcept) - Optional - The current setting of the request.
- **settingContext** (CodeableConcept) - Optional - Additional detail about the setting of the request.
- **useServerData** (boolean) - Optional - Whether to use data from the server performing the evaluation.
```
--------------------------------
### Logging Interceptor Output Example
Source: https://hapifhir.io/hapi-fhir/docs/interceptors/built_in_server_interceptors.html
Example of the log output generated by the LoggingInterceptor.
```text
2014-09-04 02:37:30.030 Source[127.0.0.1] Operation[vread Patient/1667/_history/1] UA[Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/37.0.2062.94 Safari/537.36] Params[?_format=json]
2014-09-04 03:30:00.443 Source[127.0.0.1] Operation[search-type Organization] UA[Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1)] Params[]
```
--------------------------------
### Composite Parameter URL Example
Source: https://hapifhir.io/hapi-fhir/docs/server_plain/rest_operations_search.html
Example URL format for invoking a search method that utilizes a composite parameter.
```text
http://fhir.example.com/Observation?name-value-date=PROCTIME$2001-02-02
```
--------------------------------
### Install hapi-fhir-cli via Homebrew
Source: https://hapifhir.io/hapi-fhir/docs/tools/hapi_fhir_cli.html
Use this command to install the CLI tool on macOS systems.
```bash
brew install hapi-fhir-cli
```
--------------------------------
### StandardizingInterceptor Configuration Example
Source: https://hapifhir.io/hapi-fhir/docs/interceptors/built_in_server_interceptors.html
A sample JSON configuration file for the StandardizingInterceptor, defining FHIRPath rules and standardizers for specific resource types.
```json
{
"Person" : {
"Person.name.family" : "NAME_FAMILY",
"Person.name.given" : "NAME_GIVEN",
"Person.telecom.where(system='phone').value" : "PHONE"
},
"Patient" : {
"name.family" : "NAME_FAMILY",
"name.given" : "NAME_GIVEN",
"telecom.where(system='phone').value" : "PHONE"
},
"*" : {
"telecom.where(system='email').value" : "org.example.s13n.MyCustomStandardizer"
}
}
```
--------------------------------
### Example incoming Patient resource
Source: https://hapifhir.io/hapi-fhir/docs/server_jpa_mdm/mdm_rules.html
A sample Patient resource used for testing candidate search logic.
```json
{
"resourceType": "Patient",
"id": "example",
"identifier": [
{
"system": "urn:oid:1.2.36.146.595.217.0.1",
"value": "12345"
}
],
"name": [
{
"family": "Chalmers",
"given": ["Peter", "James"]
}
]
}
```
--------------------------------
### Verify Maven Build Output
Source: https://hapifhir.io/hapi-fhir/docs/contributing/hacking_guide.html
Example of the expected console output upon a successful Maven build completion.
```text
------------------------------------------------------------------------
[INFO] Reactor Summary:
[INFO]
[INFO] HAPI-FHIR .......................................... SUCCESS [ 4.456 s]
[INFO] HAPI FHIR - Deployable Artifact Parent POM ......... SUCCESS [ 2.841 s]
[INFO] HAPI FHIR - Core Library ........................... SUCCESS [01:00 min]
[INFO] HAPI Tinder Plugin ................................. SUCCESS [ 19.259 s]
[INFO] HAPI FHIR Structures - DSTU1 (FHIR v0.80) .......... SUCCESS [01:40 min]
[INFO] HAPI FHIR Structures - DSTU2 (FHIR v1.0.0) ......... SUCCESS [01:14 min]
[INFO] HAPI FHIR Structures - DSTU3 ....................... SUCCESS [02:11 min]
.... some lines removed .....
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 20:45 min
[INFO] Finished at: 2016-02-27T15:05:35+00:00
```
--------------------------------
### Query MDM Links via GET
Source: https://hapifhir.io/hapi-fhir/docs/server_jpa_mdm/mdm_operations.html
Perform a paginated query for MDM links using GET parameters.
```http
GET http://example.com/$mdm-query-links?_offset=0&_count=2
```
--------------------------------
### Example Resource with Absolute Reference
Source: https://hapifhir.io/hapi-fhir/docs/server_jpa/configuration.html
A sample Patient resource containing an absolute URL in the managingOrganization reference.
```xml
```
--------------------------------
### Define Patient Resource Examples for Blocking
Source: https://hapifhir.io/hapi-fhir/docs/server_jpa_mdm/mdm_customizations.html
Example Patient resources used to demonstrate how block list rules evaluate based on FHIRPath.
```json
{
"resourceType": "Patient",
"name": [{
"family": "doe",
"given": [
"jane"
]
}]
}
```
```json
{
"resourceType": "Patient",
"name": [{
"family": "jetson",
"given": [
"jane"
]
},{
"family": "doe",
"given": [
"jane"
]
}]
}
```
--------------------------------
### Configure Installed Resource Types
Source: https://hapifhir.io/hapi-fhir/docs/server_jpa/packages.html
Use setInstallResourceTypes to specify which resource types should be installed from a package. This overrides the default list of supported resource types.
```java
PackageInstallationSpec spec = new PackageInstallationSpec()
.setName("hl7.fhir.us.core")
.setVersion("7.0.0")
.setInstallMode(PackageInstallationSpec.InstallModeEnum.STORE_AND_INSTALL)
.setInstallResourceTypes(List.of("StructureDefinition", "ValueSet", "CodeSystem"));
```
--------------------------------
### PlanDefinition JSON Resource
Source: https://hapifhir.io/hapi-fhir/docs/clinical_reasoning/plan_definitions.html
A complete PlanDefinition resource example illustrating metadata, clinical focus, and action definitions for an opioid prescribing guideline.
```json
{
"resourceType": "PlanDefinition",
"id": "opioidcds-04",
"url": "http://hl7.org/fhir/ig/opioid-cds/PlanDefinition/opioidcds-04",
"identifier": [
{
"system": "urn:ietf:rfc:3986",
"value": "urn:oid:2.16.840.1.113883.4.642.11.4"
},
{
"use": "official",
"value": "cdc-opioid-guidance"
}
],
"version": "0.1.0",
"name": "Cdcopioid04",
"title": "CDC Opioid Prescribing Guideline Recommendation #4",
"type": {
"coding": [
{
"system": "http://terminology.hl7.org/CodeSystem/plan-definition-type",
"code": "eca-rule",
"display": "ECA Rule"
}
]
},
"status": "draft",
"date": "2018-03-19",
"publisher": "Centers for Disease Control and Prevention (CDC)",
"description": "When starting opioid therapy for chronic pain, clinicians should prescribe immediate-release opioids instead of extended-release/long-acting (ER/LA) opioids.",
"useContext": [
{
"code": {
"system": "http://terminology.hl7.org/CodeSystem/usage-context-type",
"code": "focus",
"display": "Clinical Focus"
},
"valueCodeableConcept": {
"coding": [
{
"system": "http://snomed.info/sct",
"code": "182888003",
"display": "Medication requested (situation)"
}
]
}
},
{
"code": {
"system": "http://terminology.hl7.org/CodeSystem/usage-context-type",
"code": "focus",
"display": "Clinical Focus"
},
"valueCodeableConcept": {
"coding": [
{
"system": "http://snomed.info/sct",
"code": "82423001",
"display": "Chronic pain (finding)"
}
]
}
}
],
"jurisdiction": [
{
"coding": [
{
"system": "urn:iso:std:iso:3166",
"code": "US",
"display": "United States of America"
}
]
}
],
"purpose": "CDC’s Guideline for Prescribing Opioids for Chronic Pain is intended to improve communication between providers and patients about the risks and benefits of opioid therapy for chronic pain, improve the safety and effectiveness of pain treatment, and reduce the risks associated with long-term opioid therapy, including opioid use disorder and overdose. The Guideline is not intended for patients who are in active cancer treatment, palliative care, or end-of-life care.",
"usage": "Providers should use caution when prescribing extended-release/long-acting (ER/LA) opioids as they carry a higher risk and negligible benefit compared to immediate-release opioids.",
"copyright": "© CDC 2016+.",
"topic": [
{
"text": "Opioid Prescribing"
}
],
"author": [
{
"name": "Kensaku Kawamoto, MD, PhD, MHS"
},
{
"name": "Bryn Rhodes"
},
{
"name": "Floyd Eisenberg, MD, MPH"
},
{
"name": "Robert McClure, MD, MPH"
}
],
"relatedArtifact": [
{
"type": "documentation",
"display": "CDC guideline for prescribing opioids for chronic pain",
"document": {
"url": "https://guidelines.gov/summaries/summary/50153/cdc-guideline-for-prescribing-opioids-for-chronic-pain---united-states-2016#420"
}
},
{
"type": "documentation",
"display": "MME Conversion Tables",
"document": {
"url": "https://www.cdc.gov/drugoverdose/pdf/calculating_total_daily_dose-a.pdf"
}
}
],
"library": [
"http://example.org/fhir/Library/opioidcds-recommendation-04"
],
"action": [
{
"title": "Extended-release opioid prescription triggered.",
"description": "Checking if the trigger prescription meets the inclusion criteria for recommendation #4 workflow.",
"documentation": [
{
"type": "documentation",
"document": {
"extension": [
{
"url": "http://hl7.org/fhir/StructureDefinition/cqf-strengthOfRecommendation",
"valueCodeableConcept": {
"coding": [
{
"system": "http://terminology.hl7.org/CodeSystem/recommendation-strength",
"code": "strong",
"display": "Strong"
}
]
}
},
{
"url": "http://hl7.org/fhir/StructureDefinition/cqf-qualityOfEvidence"
```
--------------------------------
### JSON Output Example
Source: https://hapifhir.io/hapi-fhir/docs/getting_started/introduction.html
The resulting JSON string output from the encoding process.
```json
{
"resourceType":"Patient",
"identifier":[
{
"system":"http://example.com/fictitious-mrns",
"value":"MRN001"
}
],
"name":[
{
"use":"official",
"family":[
"Tester"
],
"given":[
"John",
"Q"
]
}
]
}
```
--------------------------------
### Example Resource with Profile Declaration
Source: https://hapifhir.io/hapi-fhir/docs/validation/repository_validating_interceptor.html
A sample Patient resource containing the meta.profile field required to satisfy profile declaration rules.
```json
{
"resourceType": "Patient",
"id": "123",
"meta": {
"profile": [
"http://hl7.org/fhir/us/core/StructureDefinition/us-core-patient"
]
}
}
```
--------------------------------
### GET /$diff
Source: https://hapifhir.io/hapi-fhir/docs/server_jpa/diff.html
Compares two arbitrary resources of any type by specifying their references.
```APIDOC
## GET /$diff
### Description
Compares two arbitrary resources of any type. The operation is invoked against the server base URL.
### Method
GET
### Endpoint
/$diff
### Parameters
#### Query Parameters
- **from** (reference) - Required - Specifies the source of the comparison (e.g., Patient/123 or Patient/123/_history/2).
- **to** (reference) - Required - Specifies the target of the comparison (e.g., Patient/123 or Patient/123/_history/2).
- **includeMeta** (boolean) - Optional - If true, changes to Resource.meta will be included in the diff.
### Request Example
GET http://fhir.example.com/baseR4/$diff?from=Patient/1&to=Patient/2
### Response
#### Success Response (200)
- **resourceType** (string) - The type of the returned resource (Parameters).
- **parameter** (array) - A list of differences found between the two resources.
#### Response Example
{
"resourceType": "Parameters",
"parameter": [ {
"name": "operation",
"part": [ {
"name": "type",
"valueCode": "replace"
}, {
"name": "path",
"valueString": "Patient.id"
}, {
"name": "previousValue",
"valueId": "1"
}, {
"name": "value",
"valueId": "2"
} ]
} ]
}
```
--------------------------------
### Parameters resource response body
Source: https://hapifhir.io/hapi-fhir/docs/server_jpa_mdm/mdm_operations.html
Example of the Parameters resource returned by the $mdm-query-links operation containing link details.
```json
{
"resourceType": "Parameters",
"parameter": [ {
"name": "prev",
"valueUri": "http://example.com$mdm-query-links?_offset=8_count=2"
}, {
"name": "self",
"valueUri": "http://example.com$mdm-query-links?_offset=10_count=10"
}, {
"name": "next",
"valueUri": "http://example.com$mdm-query-links?_offset=20_count=10"
}, {
"name": "link",
"part": [ {
"name": "goldenResourceId",
"valueString": "Patient/123"
}, {
"name": "sourceResourceId",
"valueString": "Patient/456"
}, {
"name": "matchResult",
"valueString": "POSSIBLE_MATCH"
}, {
"name": "linkSource",
"valueString": "AUTO"
}, {
"name": "eidMatch",
"valueBoolean": false
}, {
"name": "hadToCreateNewResource",
"valueBoolean": false
}, {
"name": "score",
"valueDecimal": 1.8
} ]
} ]
}
```
--------------------------------
### Example Questionnaire Resource
Source: https://hapifhir.io/hapi-fhir/docs/clinical_reasoning/questionnaires.html
A sample JSON structure for a Questionnaire resource, including extensions for knowledge capabilities and item population context.
```json
{
"resourceType": "Questionnaire",
"id": "ASLPA1",
"meta": {
"versionId": "1",
"lastUpdated": "2023-05-09T19:02:10.538-06:00",
"source": "#jucRbegv3NMJkZ8X"
},
"extension": [
{
"url": "http://hl7.org/fhir/uv/cpg/StructureDefinition/cpg-knowledgeCapability",
"valueCode": "shareable"
},
{
"url": "http://hl7.org/fhir/uv/cpg/StructureDefinition/cpg-knowledgeCapability",
"valueCode": "computable"
},
{
"url": "http://hl7.org/fhir/uv/cpg/StructureDefinition/cpg-knowledgeCapability",
"valueCode": "publishable"
},
{
"url": "http://hl7.org/fhir/uv/cpg/StructureDefinition/cpg-knowledgeRepresentationLevel",
"valueCode": "structured"
},
{
"url": "http://hl7.org/fhir/StructureDefinition/cqf-library",
"valueCanonical": "http://example.org/sdh/dtr/aslp/Library/ASLPDataElements"
}
],
"url": "http://example.org/sdh/dtr/aslp/Questionnaire/ASLPA1",
"name": "ASLPA1",
"title": "ASLP.A1 Adult Sleep Studies",
"status": "active",
"experimental": false,
"description": "Adult Sleep Studies Prior Authorization Form",
"useContext": [
{
"code": {
"system": "http://terminology.hl7.org/CodeSystem/usage-context-type",
"code": "task",
"display": "Workflow Task"
},
"valueCodeableConcept": {
"coding": [
{
"system": "http://fhir.org/guides/nachc/hiv-cds/CodeSystem/activity-codes",
"code": "ASLP.A1",
"display": "Adult Sleep Studies"
}
]
}
}
],
"item": [
{
"extension": [
{
"url": "http://hl7.org/fhir/uv/sdc/StructureDefinition/sdc-questionnaire-itemPopulationContext",
"valueExpression": {
"language": "text/cql-identifier",
"expression": "Sleep Study"
}
}
],
"linkId": "0",
"definition": "http://example.org/sdh/dtr/aslp/StructureDefinition/aslp-sleep-study-order",
"text": "A sleep study procedure being ordered",
"type": "group",
"repeats": true,
"item": [
{
"linkId": "1",
"definition": "http://example.org/sdh/dtr/aslp/StructureDefinition/aslp-sleep-study-order#ServiceRequest.code",
"text": "A sleep study procedure being ordered",
"type": "choice",
"answerValueSet": "http://example.org/sdh/dtr/aslp/ValueSet/aslp-a1-de1-codes-grouper"
},
{
"linkId": "2",
"definition": "http://example.org/sdh/dtr/aslp/StructureDefinition/aslp-sleep-study-order#ServiceRequest.occurrence[x]",
"text": "Date of the procedure",
"type": "dateTime"
}
]
},
{
"extension": [
{
"url": "http://hl7.org/fhir/uv/sdc/StructureDefinition/sdc-questionnaire-initialExpression",
"valueExpression": {
"language": "text/cql-identifier",
"expression": "Diagnosis of Obstructive Sleep Apnea"
}
}
],
"linkId": "3",
"definition": "http://example.org/sdh/dtr/aslp/StructureDefinition/aslp-diagnosis-of-obstructive-sleep-apnea#Condition.code",
"text": "Diagnosis of Obstructive Sleep Apnea",
"type": "choice",
"answerValueSet": "http://example.org/sdh/dtr/aslp/ValueSet/aslp-a1-de17"
},
{
"extension": [
{
"url": "http://hl7.org/fhir/uv/sdc/StructureDefinition/sdc-questionnaire-initialExpression",
"valueExpression": {
"language": "text/cql-identifier",
"expression": "History of Hypertension"
}
}
],
"linkId": "4"
}
]
}
```
--------------------------------
### Sort specification for MDM query links
Source: https://hapifhir.io/hapi-fhir/docs/server_jpa_mdm/mdm_operations.html
Example of using the _sort parameter with comma-separated property names and optional descending order prefix.
```http
http://example.com/$mdm-query-links?_sort=-myScore,myCreated
```
--------------------------------
### Bundle Output with Included Resource
Source: https://hapifhir.io/hapi-fhir/docs/model/references.html
Example XML output of a bundle containing a patient and an included organization entry.
```xml
```
--------------------------------
### Contention aware update request
Source: https://hapifhir.io/hapi-fhir/docs/server_plain/rest_operations.html
Example of a PUT request using an ETag for version-specific updates.
```http
PUT [serverBase]/Patient/123
{ ..resource body.. }
```
--------------------------------
### Evaluate Measure Request
Source: https://hapifhir.io/hapi-fhir/docs/clinical_reasoning/measures.html
Example of a GET request to the $evaluate-measure operation using the reportType parameter.
```http
GET fhir/Measure//$evaluate-measure?reportType=subject-list
```
--------------------------------
### POST $partition-management-list-partitions
Source: https://hapifhir.io/hapi-fhir/docs/server_jpa_partitioning/partitioning_management_operations.html
Lists all existing partitions in the system.
```APIDOC
## POST $partition-management-list-partitions
### Description
Retrieves a list of all existing partitions.
### Method
POST
### Endpoint
/DEFAULT/$partition-management-list-partitions
### Response
#### Success Response (200)
- **Parameters** (Resource) - A Parameters resource containing a list of partition details including id, name, and description.
#### Response Example
{
"resourceType": "Parameters",
"parameter": [ {
"name": "partition",
"part": [ {
"name": "id",
"valueInteger": 1
}, {
"name": "name",
"valueCode": "PARTITION-1"
}, {
"name": "description",
"valueString": "a description1"
} ]
}, {
"name": "partition",
"part": [ {
"name": "id",
"valueInteger": 2
}, {
"name": "name",
"valueCode": "PARTITION-2"
}, {
"name": "description",
"valueString": "a description2"
} ]
} ]
}
```
--------------------------------
### Conditional Create HTTP Transaction
Source: https://hapifhir.io/hapi-fhir/docs/server_plain/rest_operations.html
Example of the HTTP request structure for a conditional create operation.
```http
POST http://fhir.example.com/Patient
{ ...resource body... }
```
--------------------------------
### Execute a basic HFQL query
Source: https://hapifhir.io/hapi-fhir/docs/hfql/hfql.html
A sample query demonstrating how to select specific fields and filter by resource properties.
```sql
SELECT
name[0].family as family,
name[0].given[0] as given,
birthDate,
identifier.where(system='http://hl7.org/fhir/sid/us-ssn').value as SSN
FROM
Patient
WHERE
active = true
```
--------------------------------
### Configure Multitenant Server
Source: https://hapifhir.io/hapi-fhir/docs/server_jpa_partitioning/partitioning.html
Initializes a RestfulServer with partitioning enabled, a URL-based tenant identification strategy, and the required partition interceptor.
```java
public class MultitenantServer extends RestfulServer {
@Autowired
private PartitionSettings myPartitionSettings;
@Override
protected void initialize() {
// Enable partitioning
myPartitionSettings.setPartitioningEnabled(true);
// Set the tenant identification strategy
setTenantIdentificationStrategy(new UrlBaseTenantIdentificationStrategy());
// Use the tenant ID supplied by the tenant identification strategy
// to serve as the partitioning ID
registerInterceptor(new RequestTenantPartitionInterceptor());
// ....Register some providers and other things....
}
}
```
--------------------------------
### MDM Query Response Format
Source: https://hapifhir.io/hapi-fhir/docs/server_jpa_mdm/mdm_operations.html
Example of the Parameters resource returned by MDM query operations containing pagination links.
```json
{
"resourceType": "Parameters",
"parameter": [ {
"name": "prev",
"valueUri": "http://example.com/$mdm-query-links?_offset=0&_count=10"
}, {
"name": "self",
"valueUri": "http://example.com/$mdm-query-links?_offset=10&_count=10"
}, {
"name": "next",
"valueUri": "http://example.com/$mdm-query-links?_offset=20&_count=10"
},...(truncated)
```
--------------------------------
### Implement Quantity Search Parameter
Source: https://hapifhir.io/hapi-fhir/docs/server_plain/rest_operations_search.html
Uses QuantityParam to accept numeric values with units and comparators. The example demonstrates extracting the prefix, value, and units from the parameter.
```java
@Search()
public List getObservationsByQuantity(
@RequiredParam(name = Observation.SP_VALUE_QUANTITY) QuantityParam theQuantity) {
List retVal = new ArrayList();
ParamPrefixEnum prefix = theQuantity.getPrefix();
BigDecimal value = theQuantity.getValue();
String units = theQuantity.getUnits();
// .. Apply these parameters ..
// ... populate ...
return retVal;
}
```
--------------------------------
### GET /Observation
Source: https://hapifhir.io/hapi-fhir/docs/server_plain/rest_operations_search.html
Search for observations using a composite parameter that combines a token (name) and a date (value).
```APIDOC
## GET /Observation
### Description
Search for observations using a composite parameter (name-value-date) which filters by both a token and a date.
### Method
GET
### Endpoint
/Observation
### Parameters
#### Query Parameters
- **name-value-date** (string) - Required - A composite parameter formatted as [token]$[date] (e.g., PROCTIME$2001-02-02)
### Request Example
http://fhir.example.com/Observation?name-value-date=PROCTIME$2001-02-02
### Response
#### Success Response (200)
- **List** (array) - A list of Observation resources matching the composite criteria.
```
--------------------------------
### GET /Patient
Source: https://hapifhir.io/hapi-fhir/docs/server_plain/rest_operations_search.html
Search for patients with an identifier and limit the number of results returned using the _count parameter.
```APIDOC
## GET /Patient
### Description
Search for patients by identifier and limit the result set size.
### Method
GET
### Endpoint
/Patient
### Parameters
#### Query Parameters
- **identifier** (String) - Required - The patient identifier to search for.
- **_count** (Integer) - Optional - The number of resources to return.
```
--------------------------------
### Implement a RestfulServer class
Source: https://hapifhir.io/hapi-fhir/docs/server_plain/resource_providers.html
Extend RestfulServer and override the initialize method to register resource providers. This example uses Servlet 3.0 annotations to define the URL pattern.
```java
/**
* In this example, we are using Servlet 3.0 annotations to define
* the URL pattern for this servlet, but we could also
* define this in a web.xml file.
*/
@WebServlet(
urlPatterns = {"/fhir/*"},
displayName = "FHIR Server")
public class ExampleRestfulServlet extends RestfulServer {
private static final long serialVersionUID = 1L;
/**
* The initialize method is automatically called when the servlet is starting up, so it can
* be used to configure the servlet to define resource providers, or set up
* configuration, interceptors, etc.
*/
@Override
protected void initialize() throws ServletException {
/*
* The servlet defines any number of resource providers, and
* configures itself to use them by calling
* setResourceProviders()
*/
List resourceProviders = new ArrayList();
resourceProviders.add(new RestfulPatientResourceProvider());
resourceProviders.add(new RestfulObservationResourceProvider());
setResourceProviders(resourceProviders);
}
}
```
--------------------------------
### Example Observation valueQuantity JSON
Source: https://hapifhir.io/hapi-fhir/docs/server_jpa/schema.html
An example of a valueQuantity object in an Observation resource that would be indexed in the HFJ_SPIDX_QUANTITY_NRML table when normalized quantity search is enabled.
```json
"valueQuantity" : {
"value" : 172,
"unit" : "lb_av",
"system" : "http://unitsofmeasure.org",
"code" : "[lb_av]"
},
```
--------------------------------
### GET $mdm-duplicate-golden-resources
Source: https://hapifhir.io/hapi-fhir/docs/server_jpa_mdm/mdm_operations.html
Retrieves a list of duplicate Golden Resources.
```APIDOC
## GET $mdm-duplicate-golden-resources
### Description
Use this operation to request a list of duplicate Golden Resources.
### Method
GET
### Endpoint
/$mdm-duplicate-golden-resources
### Parameters
#### Query Parameters
- **_offset** (int) - Optional - The offset to begin returning records at.
- **_count** (int) - Optional - The number of links to be returned in a page.
- **resourceType** (String) - Optional - The resource type (e.g. Patient)
### Response
#### Success Response (200)
- **Parameters** (Object) - Returns a Parameters resource containing a list of duplicate links.
```
--------------------------------
### Implement IBundleProvider for Paging
Source: https://hapifhir.io/hapi-fhir/docs/server_plain/paging.html
This implementation demonstrates how to return a bundle provider that fetches resources on demand based on stored IDs. The loadResourcesByIds method must be implemented to retrieve actual resources from the database.
```java
public class PagingPatientProvider implements IResourceProvider {
/**
* Search for Patient resources matching a given family name
*/
@Search
public IBundleProvider search(@RequiredParam(name = Patient.SP_FAMILY) StringParam theFamily) {
final InstantType searchTime = InstantType.withCurrentTime();
/**
* First, we'll search the database for a set of database row IDs that
* match the given search criteria. That way we can keep just the row IDs
* around, and load the actual resources on demand later as the client
* pages through them.
*/
final List matchingResourceIds = null; // <-- implement this
/**
* Return a bundle provider which can page through the IDs and return the
* resources that go with them.
*/
return new IBundleProvider() {
@Override
public Integer size() {
return matchingResourceIds.size();
}
@Nonnull
@Override
public List getResources(
int theFromIndex,
int theToIndex,
@Nonnull ResponsePage.ResponsePageBuilder theResponsePageBuilder) {
int end = Math.max(theToIndex, matchingResourceIds.size() - 1);
List idsToReturn = matchingResourceIds.subList(theFromIndex, end);
return loadResourcesByIds(idsToReturn);
}
@Override
public InstantType getPublished() {
return searchTime;
}
@Override
public Integer preferredPageSize() {
// Typically this method just returns null
return null;
}
@Override
public String getUuid() {
return null;
}
};
}
/**
* Load a list of patient resources given their IDs
*/
private List loadResourcesByIds(List theIdsToReturn) {
// .. implement this search against the database ..
return null;
}
@Override
public Class extends IBaseResource> getResourceType() {
return Patient.class;
}
}
```
--------------------------------
### GET /Patient (Offset Paging)
Source: https://hapifhir.io/hapi-fhir/docs/server_plain/rest_operations_search.html
Search for patients with an identifier, using _count and _offset parameters to perform database-level paging.
```APIDOC
## GET /Patient
### Description
Search for patients by identifier using offset-based paging to retrieve specific pages of results.
### Method
GET
### Endpoint
/Patient
### Parameters
#### Query Parameters
- **identifier** (String) - Required - The patient identifier to search for.
- **_count** (Integer) - Optional - The number of resources to return per page.
- **_offset** (Integer) - Optional - The number of records to skip before starting to return results.
```
--------------------------------
### Build the HFQL JDBC driver from source
Source: https://hapifhir.io/hapi-fhir/docs/hfql/hfql.html
Use this Maven command to compile the hapi-fhir-jpaserver-hfql module from the source code.
```bash
mvn -DskipTests -P DIST clean install -pl :hapi-fhir-jpaserver-hfql -am
```
--------------------------------
### Update with History Rewrite Request
Source: https://hapifhir.io/hapi-fhir/docs/server_plain/rest_operations.html
Example of a PUT request to update a historical version of a resource. Requires the X-Rewrite-History header set to true.
```http
PUT [serverBase]/Patient/123/_history/3
{
..
id: "123",
meta: {
versionId: "3",
..
}
..
}
```
--------------------------------
### GET [base]/ValueSet/$hapi.fhir.expansion-status
Source: https://hapifhir.io/hapi-fhir/docs/server_jpa/valueset_expansion.html
Retrieves a list of ValueSets that have failed the expansion process.
```APIDOC
## GET [base]/ValueSet/$hapi.fhir.expansion-status
### Description
Retrieves a list of ValueSets that have failed to expand. Each returned entry includes an errorMessage field detailing the failure reason.
### Method
GET
### Endpoint
[base]/ValueSet/$hapi.fhir.expansion-status
### Parameters
#### Query Parameters
- **expansionStatus** (string) - Required - The status to filter by, e.g., FAILED_TO_EXPAND
### Response
#### Success Response (200)
- **ValueSet** (object) - A list of ValueSet resources that failed to expand, including an errorMessage field.
```
--------------------------------
### Create a Resource with Generic Client
Source: https://hapifhir.io/hapi-fhir/docs/client/generic_client.html
Demonstrates creating a Patient resource and configuring the request to use pretty-printed JSON encoding.
```java
Patient patient = new Patient();
// ..populate the patient object..
patient.addIdentifier().setSystem("urn:system").setValue("12345");
patient.addName().setFamily("Smith").addGiven("John");
// Invoke the server create method (and send pretty-printed JSON
// encoding to the server
// instead of the default which is non-pretty printed XML)
MethodOutcome outcome = client.create()
.resource(patient)
.prettyPrint()
.encodedJson()
.execute();
// The MethodOutcome object will contain information about the
// response from the server, including the ID of the created
// resource, the OperationOutcome response, etc. (assuming that
// any of these things were provided by the server! They may not
// always be)
IIdType id = outcome.getId();
System.out.println("Got ID: " + id.getValue());
```
--------------------------------
### Instantiate and Use Custom Resource Type
Source: https://hapifhir.io/hapi-fhir/docs/model/custom_structures.html
Demonstrates how to instantiate the custom resource, set values for custom fields, and encode the resource to a string using a HAPI FHIR parser.
```java
MyPatient patient = new MyPatient();
patient.setPetName(new StringType("Fido"));
patient.getImportantDates().add(new DateTimeType("2010-01-02"));
patient.getImportantDates().add(new DateTimeType("2014-01-26T11:11:11"));
patient.addName().setFamily("Smith").addGiven("John").addGiven("Quincy").addSuffix("Jr");
IParser p = FhirContext.forDstu2().newXmlParser().setPrettyPrint(true);
String messageString = p.encodeResourceToString(patient);
System.out.println(messageString);
```
--------------------------------
### GET /Measure/{id}/$evaluate-measure
Source: https://hapifhir.io/hapi-fhir/docs/clinical_reasoning/measures.html
Executes a Measure evaluation for a specific Measure resource.
```APIDOC
## GET /Measure/{id}/$evaluate-measure
### Description
Executes a Measure as specified by FHIR Resources against a subject or set of subjects.
### Method
GET
### Endpoint
/Measure/{id}/$evaluate-measure
### Parameters
#### Path Parameters
- **id** (string) - Required - The ID of the Measure resource to evaluate.
#### Query Parameters
- **periodStart** (string) - Optional - The start date of the reporting period (YYYY, YYYY-MM, or YYYY-MM-DD) or DateTime (YYYY-MM-DDThh:mm:ss).
- **periodEnd** (string) - Optional - The end date of the reporting period (YYYY, YYYY-MM, or YYYY-MM-DD) or DateTime (YYYY-MM-DDThh:mm:ss).
- **subject** (string) - Optional - The subject or set of subjects to evaluate.
- **reportType** (string) - Optional - The type of report to generate.
```
--------------------------------
### Search with Multi-valued Parameters
Source: https://hapifhir.io/hapi-fhir/docs/client/generic_client.html
Demonstrates how to search for resources where any of the provided values match a specific parameter (OR logic).
```APIDOC
## Search - Multi-valued Parameters (ANY/OR)
### Description
Searches for resources where a parameter matches any of the provided values, resulting in a comma-separated query parameter in the underlying request.
### Usage
```java
response = client.search()
.forResource(Patient.class)
.where(Patient.FAMILY.matches().values("Smith", "Smyth"))
.returnBundle(Bundle.class)
.execute();
```
```
--------------------------------
### Delete Extension FHIR Patch
Source: https://hapifhir.io/hapi-fhir/docs/server_jpa/fhir_patch.html
Example of a Parameters resource used to delete an extension from a resource.
```json
{
"resourceType": "Parameters",
"parameter": [ {
"name": "operation",
"part": [ {
"name": "type",
"valueCode": "delete"
}, {
"name": "path",
"valueString": "Patient.extension.where(url='http://example.org/fhir/my-extension')"
} ]
} ]
}
```
--------------------------------
### POST PlanDefinition/$package
Source: https://hapifhir.io/hapi-fhir/docs/clinical_reasoning/plan_definitions.html
Generates a Bundle of resources including the PlanDefinition and related resources based on CRMI IG guidance.
```APIDOC
## POST PlanDefinition/$package
### Description
The $package operation generates a Bundle of resources that includes the PlanDefinition as well as any related resources which can then be shared.
### Parameters
#### Query Parameters
- **id** (string) - Optional - The logical id of an existing Resource to package on the server.
- **canonical** (canonical) - Optional - A canonical url (optionally version specific) of a Resource to package on the server.
- **url** (uri) - Optional - A canonical or artifact reference to a Resource to package on the server. Exclusive with canonical.
- **version** (string) - Optional - The version of the Resource. Exclusive with canonical.
- **usePut** (boolean) - Optional - Determines the type of method returned in the Bundle Entries: POST if False (default), PUT if True.
```