Terminology
NCTS and terminology operations
Get NCTS access, then use $lookup, $validate-code, $expand and $translate against a terminology server.
Get access to the NCTS#
Register#
Create an account at the NCTS (healthterminologies.gov.au) and accept the SNOMED CT-AU and AMT licence. Approval can take a few days.
Create a client credential#
In the NCTS portal, create a system credential (client id and secret) for the national terminology server.
Get a token, then call the server#
The NCTS terminology server uses OAuth2 client credentials. Request a token with your id and secret, then send it as Authorization: Bearer <token>. The portal shows the exact token and server URLs.
Until your licence comes through, tx.fhir.org is a free public terminology server that works for most of the operations below, LOINC included.
Terminology operations#
All examples use TX=https://tx.fhir.org/r4. Swap in the NCTS URL and add your token once you have access.
$lookup: what does this code mean?#
curl -s "$TX/CodeSystem/\$lookup?system=http://loinc.org&code=8867-4" -H "Accept: application/fhir+json" \
| jq '.parameter[] | select(.name=="display") | .valueString'$validate-code: is this code valid in this ValueSet?#
curl -s "$TX/ValueSet/\$validate-code?url=http://hl7.org/fhir/ValueSet/administrative-gender&system=http://hl7.org/fhir/administrative-gender&code=female" \
-H "Accept: application/fhir+json" | jq '.parameter[] | select(.name=="result") | .valueBoolean'$expand: list the codes in a ValueSet (with a text filter)#
This is the operation behind every coded search box in a clinical system.
curl -s "$TX/ValueSet/\$expand?url=http://hl7.org/fhir/ValueSet/observation-category&count=20" \
-H "Accept: application/fhir+json" | jq -r '.expansion.contains[] | "\(.code)\t\(.display)"'For SNOMED CT you can expand by ECL (Expression Constraint Language) using an implicit ValueSet URL:
# Everything that is a kind of diabetes mellitus (73211009), filtered by text
$TX/ValueSet/$expand?url=http://snomed.info/sct?fhir_vs=ecl/<<73211009&filter=type 2&count=10URL-encode the url value (< → %3C) when you send this with curl.
$translate: map a code with a ConceptMap#
curl -s "$TX/ConceptMap/\$translate?url=<conceptmap-url>&system=<source-system>&code=<code>&targetsystem=<target-system>"Hook a terminology server into the lab#
- Validator CLI:
./validate file.json -tx https://<ncts-server>. The NCTS needs a token, so check the validator docs for how to pass credentials, or keeptx.fhir.orgfor anything that isn't SNOMED. - HAPI:
hapi.fhir.remote_terminology_servicesettings let HAPI send$validate-codeand$expandcalls to a remote server. See the commented examples in HAPI'sapplication.yaml.