Agent Skillsmaziyarpanahi/openmed › querying-terminology-service

querying-terminology-service

GitHub

作为OpenMed的薄客户端,调用用户指定的FHIR术语服务器执行代码验证、展开、查找和翻译。用于将实体跨度转化为有效的CodeableConcept,避免捆绑受限词汇表,支持Ontoserver等外部服务。

skills/querying-terminology-service/SKILL.md maziyarpanahi/openmed

Trigger Scenarios

terminology server $validate-code $expand ValueSet ECL SNOMED/RxNorm/LOINC lookups

Install

npx skills add maziyarpanahi/openmed --skill querying-terminology-service -g -y
More Options

Use without installing

npx skills use maziyarpanahi/openmed@querying-terminology-service

指定 Agent (Claude Code)

npx skills add maziyarpanahi/openmed --skill querying-terminology-service -a claude-code -g -y

安装 repo 全部 skill

npx skills add maziyarpanahi/openmed --all -g -y

预览 repo 内 skill

npx skills add maziyarpanahi/openmed --list

SKILL.md

Frontmatter
{
    "name": "querying-terminology-service",
    "license": "Apache-2.0",
    "metadata": {
        "pairs": "adjacent",
        "project": "OpenMed",
        "version": "1.0",
        "category": "fhir-interop"
    },
    "description": "Call a user-supplied FHIR terminology server ($validate-code, $expand, $lookup, $translate) to validate and expand clinical codes without bundling restricted vocabulary (SNOMED CT, RxNorm, LOINC, ICD-10) into OpenMed. Covers a thin local client, ValueSet $expand with filters\/ECL, CodeSystem $lookup, ConceptMap $translate, and pointing at Ontoserver \/ HAPI \/ tx.fhir.org. Use as the grounding step for OpenMed coding skills — turn an OpenMed entity span into a validated coded CodeableConcept — when the user mentions terminology server, $validate-code, $expand, ValueSet, ECL, SNOMED\/RxNorm\/LOINC lookups, or code validation. Pairs adjacent."
}

Querying a Terminology Service

OpenMed deliberately bundles no restricted vocabulary — no SNOMED CT, RxNorm, LOINC, ICD-10, UMLS. So when an OpenMed entity span needs a validated code (the grounding step exporting-to-fhir references), you call a FHIR terminology server the user already operates, with their own license. This skill is the thin client the coding skills lean on.

When to use

Use it whenever a span must become a coded CodeableConcept, when you need to confirm a code is valid in a system, expand a ValueSet for a picklist, look up a display, or map between vocabularies. Triggers: "terminology server", "$validate-code", "$expand", "ValueSet", "ECL", "is this a valid SNOMED/LOINC/ RxNorm code", "translate ICD-10 to SNOMED". It sits between OpenMed NER and exporting-to-fhir.

Bring your own server

The four operations are standard FHIR; point the client at whichever server the user is licensed for:

  • Ontoserver (CSIRO) — production SNOMED CT/LOINC, full ECL.
  • HAPI FHIR terminology module — self-hosted.
  • tx.fhir.org — HL7 public server (open content only; not for licensed SNOMED/full LOINC, and not for PHI).

OpenMed never ships or proxies these — the credentials and content are the user's.

The four operations

POST [tx]/CodeSystem/$validate-code   -> is this code valid in this system?
POST [tx]/ValueSet/$expand            -> enumerate the codes in a value set
POST [tx]/CodeSystem/$lookup          -> display + properties for a code
POST [tx]/ConceptMap/$translate       -> map a code from one system to another

$validate-code — confirm before you emit

curl -s -X POST 'https://tx.example/fhir/CodeSystem/$validate-code' \
  -H 'Content-Type: application/fhir+json' -d '{
    "resourceType": "Parameters",
    "parameter": [
      {"name": "url",  "valueUri":  "http://snomed.info/sct"},
      {"name": "code", "valueCode": "44054006"},
      {"name": "display", "valueString": "Diabetes mellitus type 2"}
    ]}'
# -> Parameters: { result: true, display: "Diabetes mellitus type 2" }

$expand — enumerate a ValueSet (with ECL for SNOMED)

# Expand "disorders of the lung" via an implicit SNOMED ECL value set
curl -s -X POST 'https://tx.example/fhir/ValueSet/$expand' \
  -H 'Content-Type: application/fhir+json' -d '{
    "resourceType": "Parameters",
    "parameter": [
      {"name": "url", "valueUri":
        "http://snomed.info/sct?fhir_vs=ecl/<<19829001"},
      {"name": "filter", "valueString": "pneumonia"},
      {"name": "count", "valueInteger": 20}
    ]}'

<<19829001 is ECL for "19829001 (Disorder of lung) or any subtype". Use $expand + filter to power autocomplete and to constrain which codes a span may map to.

$lookup and $translate

# Display + properties for a LOINC code
POST [tx]/CodeSystem/$lookup  { url=http://loinc.org, code=4548-4 }

# Map an ICD-10-CM code to SNOMED via a ConceptMap
POST [tx]/ConceptMap/$translate {
  url=<conceptmap-url>, system=http://hl7.org/fhir/sid/icd-10-cm,
  code=E11.9, targetsystem=http://snomed.info/sct }

A thin client used by the coding skills

import requests

class TxClient:
    def __init__(self, base, token=None):
        self.base = base.rstrip("/")
        self.h = {"Content-Type": "application/fhir+json"}
        if token:
            self.h["Authorization"] = f"Bearer {token}"

    def _params(self, **kv):
        return {"resourceType": "Parameters",
                "parameter": [{"name": k, **v} for k, v in kv.items()]}

    def validate_code(self, system, code, display=None):
        body = self._params(url={"valueUri": system}, code={"valueCode": code},
                            **({"display": {"valueString": display}} if display else {}))
        out = requests.post(f"{self.base}/CodeSystem/$validate-code",
                            json=body, headers=self.h, timeout=15).json()
        params = {p["name"]: p for p in out.get("parameter", [])}
        return bool(params.get("result", {}).get("valueBoolean"))

# Ground an OpenMed span only if the code validates:
tx = TxClient("https://tx.example/fhir", token="...")
if tx.validate_code("http://snomed.info/sct", "44054006", "Diabetes mellitus type 2"):
    from openmed.clinical.exporters.codeable_concept_simple import coding, codeable_concept
    cc = codeable_concept([coding("snomed", "44054006",
                                  "Diabetes mellitus type 2")], text=span.text)

The system URIs here line up with OpenMed's system_uri (snomed/loinc/rxnorm/icd-10-cm/hpo/mesh), so a validated code drops straight into coding(...).

Hand-off to / from OpenMed

  • From OpenMed: an EntityPrediction.text (the span surface form) plus your candidate code(s) are the input to $validate-code/$translate.
  • To OpenMed: a validated (system, code, display) tuple → coding(...)codeable_concept(...) (exporting-to-fhir). If a span fails validation, emit CodeableConcept with only text and flag it via OperationOutcomeIssue(severity="warning", code="code-invalid", ...).
  • No PHI to the server. You send codes and concept text, not patient notes. Never POST a clinical note or identifier to a terminology server.

Edge cases & gotchas

  • Out-of-process by design. OpenMed does not call the server for you; this thin client runs alongside, with the user's credentials. Keep it that way.
  • Licensing is the user's. SNOMED CT / full LOINC / RxNorm require the right affiliate/license; tx.fhir.org only serves open content. Do not route licensed lookups through a public server.
  • $expand can be enormous. Always pass count (paginate with offset) and filter; an unfiltered expand of a large hierarchy can time out.
  • ECL is SNOMED-specific. Use it via the implicit value set http://snomed.info/sct?fhir_vs=ecl/<expression>; other systems use $expand with filter/property.
  • Cache validated codes. The mapping from a normalised span to a validated code is stable; cache it to cut latency and server load — cache the code, never the source note.
  • version matters. SNOMED/LOINC editions change; pin the version parameter for reproducible validation in CI.
  • No PHI to tx.fhir.org. It is a public service — only synthetic/coded data.

Standards & references

Version History

  • f213557 Current 2026-07-23 00:45

Same Skill Collection

skills/benchmark-pii-recall/SKILL.md
skills/building-with-openmed/SKILL.md
skills/deidentify-a-dataset/SKILL.md
skills/extract-clinical-entities-to-fhir/SKILL.md
skills/loading-openmed-models/SKILL.md
skills/pick-a-pii-model/SKILL.md
skills/annotating-variants/SKILL.md
skills/assembling-fhir-bundles/SKILL.md
skills/auditing-deid-leakage/SKILL.md
skills/auditing-deidentification-runs/SKILL.md
skills/auditing-part11-trails/SKILL.md
skills/auditing-safe-harbor-checklist/SKILL.md
skills/auditing-subgroup-fairness/SKILL.md
skills/authoring-model-cards/SKILL.md
skills/batch-processing-clinical-text/SKILL.md
skills/benchmarking-clinical-ner/SKILL.md
skills/bridging-presidio-and-spacy/SKILL.md
skills/building-gold-corpus/SKILL.md
skills/building-patient-timelines/SKILL.md
skills/checking-hipaa-compliance/SKILL.md
skills/choosing-openmed-models/SKILL.md
skills/coding-hcc-risk-adjustment/SKILL.md
skills/coding-icd10/SKILL.md
skills/computing-ecqms/SKILL.md
skills/configuring-privacy-policies/SKILL.md
skills/defining-cohort-phenotypes/SKILL.md
skills/deidentifying-clinical-text/SKILL.md
skills/deidentifying-multilingual-text/SKILL.md
skills/deploying-openmed-mcp/SKILL.md
skills/detecting-pv-signals/SKILL.md
skills/enforcing-nophi-logging/SKILL.md
skills/etl-to-omop-cdm/SKILL.md
skills/evaluating-with-leakage-gates/SKILL.md
skills/exporting-bulk-fhir/SKILL.md
skills/exporting-to-fhir/SKILL.md
skills/extracting-clinical-entities/SKILL.md
skills/extracting-dicom-metadata/SKILL.md
skills/extracting-lab-tables/SKILL.md
skills/extracting-pii-entities/SKILL.md
skills/extracting-sdoh/SKILL.md
skills/fetching-fhir-resources/SKILL.md
skills/gating-deid-leakage/SKILL.md
skills/generating-synthea-data/SKILL.md
skills/generating-synthetic-surrogates/SKILL.md
skills/ingesting-clinical-documents/SKILL.md
skills/linking-umls-concepts/SKILL.md
skills/mapping-loinc/SKILL.md
skills/mapping-to-snomed/SKILL.md
skills/mining-pubmed-literature/SKILL.md
skills/normalizing-rxnorm/SKILL.md

Metadata

Files
0
Version
7df4a9f
Hash
d06957d4
Indexed
2026-07-23 00:45

Home - Wiki
Copyright © 2011-2026 iteam. Current version is 2.155.2. UTC+08:00, 2026-08-06 06:20
浙ICP备14020137号-1 $Map of visitor$