Profiles & validation
The IG lab
Loaded implementation guides, the IG Explorer, the offline IG library and the strict AU Core mock server: what each is for and how to use it.
The IG lab has four parts. All of them are behind the login at fhir.fhirdrill.dev.
| Part | Where | Use it to |
|---|---|---|
| Loaded IGs | Main server /fhir |
Validate with $validate?profile=…, search profiles and value sets, expand value sets |
| IG Explorer | /explorer/ |
Read a profile as an element tree, validate your JSON against it, browse terminology |
| IG library | /ig/ |
Read the official IG websites, offline and pinned to the versions the lab runs |
| AU Core mock | https://fhir.fhirdrill.dev/au-core/fhir · LAN http://192.168.1.181:8081/au-core/fhir |
Practise against a strict server that rejects invalid writes, like a connectathon test server |
Packages loaded#
Both servers install these at startup:
| Package | Version | Main | Mock |
|---|---|---|---|
hl7.fhir.au.base |
6.0.0 | ✓ | ✓ |
hl7.fhir.au.core |
2.0.0 | ✓ | ✓ |
hl7.fhir.au.ereq |
1.0.1 | ✓ | |
hl7.fhir.au.ps |
1.0.0 | ✓ | |
hl7.fhir.uv.extensions.r4 |
5.2.0 | ✓ | ✓ |
hl7.terminology.r4 |
7.0.1 | ✓ | ✓ |
Dependencies aren't always installed for you
install_transitive_ig_dependencies is switched on, but HAPI still skipped AU Base, the extensions package and THO. Without them, AU Core validation fails with "Slicing cannot be evaluated … au-ihi" or "Unknown profile …individual-genderIdentity". Read the IG's package.json dependencies and list every package explicitly.
Add another IG#
Find the package and its dependencies#
curl -s https://packages.fhir.org/hl7.fhir.au.ereq | jq '."dist-tags", (.versions | keys)'
curl -sL https://packages.fhir.org/hl7.fhir.au.ereq/1.0.1 | tar -xzO package/package.json | jq .dependenciesAdd a block to the server's compose file#
In ~/fhir-lab/hapi/compose.yml (or ~/fhir-lab/mock-au-core/compose.yml), add one block per package. The key in the middle (myig) is any unique name:
hapi.fhir.implementationguides.myig.name: hl7.fhir.au.ereq
hapi.fhir.implementationguides.myig.version: 1.0.1
hapi.fhir.implementationguides.myig.installMode: STORE_AND_INSTALL
hapi.fhir.implementationguides.myig.reloadExisting: "false"Restart and watch it install#
docker compose up -d && docker compose logs -f hapi | grep -iE "Installing package|ERROR"A large package such as THO adds about 3 minutes to startup, but only the first time.
Check it arrived#
Open the Explorer. The home page lists every IG on each server and how many profiles it has.
Using the Explorer#
- Pick a server at the top. The main lab and the mock have different packages loaded.
- Filter with Ctrl K. Switch between Profiles, Extensions, Value sets and Code systems.
- Elements tab: key elements only shows what the profile changes, plus Must Support and required elements, together with their parents. That's the fastest way to learn what a profile actually asks for. Untick it to see the full snapshot.
- Constraints tab: the profile's own invariants with their FHIRPath. Tick the box to include the base FHIR ones.
- Validate tab: paste a resource, or start from Insert skeleton (blanks), which lists the required elements with empty values. It fails until you fill them in, so use the errors as a checklist. Ctrl+Enter validates. Your draft is kept per profile until you close the tab.
- On this server: resources that claim the profile in
meta.profile. - Official page ↗: opens the same profile in the offline IG library.
- Stable links:
/explorer/#/main/canonical/<canonical URL>opens a profile by its canonical URL on any server, for example#/au-core/canonical/http://hl7.org.au/fhir/core/StructureDefinition/au-core-patient.
Explorer validation and the CLI
The Explorer calls HAPI's $validate, which uses the terminology loaded on that server. SNOMED CT and LOINC codes can't be fully checked without a terminology server, so the validator CLI remains the final word.
The AU Core mock server#
A second HAPI that behaves like a strict connectathon test server:
- AU Core 2.0.0 and its dependencies are loaded.
- Request validation is on. Any write whose resource claims a profile in
meta.profile(and anything that breaks base FHIR) is checked, and rejected with422and an OperationOutcome when it fails. - Preloaded with AU Core's 65 official examples: 6 patients, plus their observations, conditions, medications, procedures and more.
- It uses its own small database (H2), so wiping it and starting again takes seconds.
M=http://192.168.1.181:8081/au-core/fhir
curl -s "$M/Patient?_profile=http://hl7.org.au/fhir/core/StructureDefinition/au-core-patient" | jq '.total'
# Rejected: claims AU Core but has no identifier, name or gender
curl -s -X POST "$M/Patient" -H "Content-Type: application/fhir+json" \
-d '{"resourceType":"Patient","meta":{"profile":["http://hl7.org.au/fhir/core/StructureDefinition/au-core-patient"]}}' \
| jq -r '.issue[] | select(.severity=="error") | .diagnostics'It only checks what a resource claims
HAPI validates against the profiles listed in a resource's own meta.profile. A Patient that claims no profile only has to be valid base FHIR. To test AU Core conformance, always set meta.profile, just as connectathon test scripts do.
Reset the mock#
cd ~/fhir-lab/mock-au-core
docker compose down -v && docker compose up -d # empty database, the packages install again (~3 min)
docker run --rm -v mock-au-core_data:/data alpine:3.20 chown -R 65532:65532 /data && docker compose restart
python3 load-examples.py examples/hl7.fhir.au.core-2.0.0.tgzload-examples.py loads the examples in repeated passes until every reference resolves, then loads any that point at each other (such as Condition/ckd and Procedure/dialysis) together in a single transaction.
Terminology expansion#
Both servers have HAPI's full-text index (Lucene) switched on, which ValueSet/$expand and text filters need. The index lives in a Docker volume (hapi_lucene, and /data/lucene for the mock). After a large package install, HAPI indexes in the background for a few minutes, and until then some value sets expand to 0 codes. To force a rebuild:
curl -s -X POST "http://192.168.1.181:8080/fhir/\$reindex-terminology" -H "Content-Type: application/fhir+json" -d '{"resourceType":"Parameters"}'