Skip to content

Instantly share code, notes, and snippets.

@bkaney
Created May 10, 2025 10:32
Show Gist options
  • Save bkaney/e0b1bf53044895433aae8b2d40c5b92b to your computer and use it in GitHub Desktop.
Save bkaney/e0b1bf53044895433aae8b2d40c5b92b to your computer and use it in GitHub Desktop.
Concept of a prompt library in FHIR
[System Instructions]
I want you to act as a terminologist. Your task is to identify both lexical and
semantic mappings from {{source-codesystem}} to {{target-codesystem}}
[Context]
- Domain: Clinical Termiology
- Constraints: Use only {{source-codesystem}} to {{target-codesystem}} CodeSystems
Input Prompt: "{{prompt}}"
[Response Format]
Please structure your response as follows:
1. Provide Summary (brief)
2. Provide Key Information (bullet points or paragraphs as needed)
3. Provide FHIR ConceptMap (if applicable)
[Validate Results]
- Ensure the source code name and description is correct with respect to the source code system
- Show other possible mappings and confidence levels
- Ensure all mappings are accurate and relevant to the context.
- Check for any potential errors or inconsistencies in the mappings.
- Validate the mappings against the source and target code systems
[Additional Instructions]
- Use plain language unless technical detail is necessary.
- Cite references where applicable.
- Avoid speculation; clarify when information is uncertain.
{
"resourceType": "Library",
"id": "ActAsTerminoligist",
"url": "http://example.org/fhir/Library/ActAsTerminologist",
"version": "1.0.0",
"parameters": [
{
"name": "source-codesystem",
"use": "in",
"type": "string"
},
{
"name": "target-codesystem",
"use": "in",
"type": "string"
},
{
"name": "prompt",
"use": "in",
"type": "string"
},
{
"name": "response",
"use": "out",
"type": "string"
}
],
"type": {
"coding": [
{
"code": "prompt-library"
}
]
},
"content": [
{
"contentType": "text/x-handlebars-template",
"data": "W1N5c3RlbSBJbnN0cnVjdGlvbnNdCgpJIHdhbnQgeW91IHRvIGFjdCBhcyBhIHRlcm1pbm9sb2dpc3QuIFlvdXIgdGFzayBpcyB0byBpZGVudGlmeSBib3RoIGxleGljYWwgYW5kCnNlbWFudGljIG1hcHBpbmdzIGZyb20ge3tzb3VyY2UtY29kZXN5c3RlbX19IHRvIHt7dGFyZ2V0LWNvZGVzeXN0ZW19fQoKW0NvbnRleHRdCi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J5LgotIENpdGUgcmVmZXJlbmNlcyB3aGVyZSBhcHBsaWNhYmxlLgotIEF2b2lkIHNwZWN1bGF0aW9uOyBjbGFyaWZ5IHdoZW4gaW5mb3JtYXRpb24gaXMgdW5jZXJ0YWluLg=="
}
]
}

POST to http://server/fhir/Library/$evaluate-library

  {
    "url": "http://example.org/fhir/Library/ActAsTerminologist",
    "version": "1.0.0",
    "parameters": {
      "resourceType": "Parameters",
      "parameter": [
        { "name": "source-codesystem", "valueString": "SNOMED-CT" },
        { "name": "target-codesystem", "valueString": "ICD10-CM"},
        { "name": "prompt", "valueString": "Map SNOMED-CT 52702003 (Chronic fatigue syndrome (disorder)) to ICD10-CM"}
      ]
    }
  }

As CURL --

curl --header "Content-Type: application/json" \
  --request POST \
  --data '{"url":"http://example.org/fhir/Library/ActAsTerminologist","version":"1.0.0","parameters":{"resourceType":"Parameters","parameter":[{"name":"source-codesystem","valueString":"SNOMED-CT"},{"name":"target-codesystem","valueString":"ICD10-CM"},{"name":"prompt","valueString":"Map SNOMED-CT 52702003 (Chronic fatigue syndrome (disorder)) to ICD10-CM"}]}}' \
  http://localhost:3000/fhir/Library/\$evaluate-library
  1. Summary
    You have requested the SNOMED-CT clinical term 52702003 – Chronic fatigue syndrome (disorder) to be mapped to the appropriate ICD-10-CM code(s). This process involves both lexical (name-based) and semantic (meaning-based) alignment between these code systems.

  1. Key Information
  • Source Code System: SNOMED-CT

    • Code: 52702003
    • Name/Description: Chronic fatigue syndrome (disorder)
    • Validation: Confirmed in SNOMED-CT: "Chronic fatigue syndrome (disorder)" (source: SNOMED CT Browser).
  • Target Code System: ICD-10-CM

    • Potential Mapping Candidates:
      • R53.82 – Chronic fatigue, unspecified
        • Confidence Level: High
        • Justification: This is the official mapping provided by both NLM’s mapping tables and by UMLS interoperability resources. ICD-10-CM does not provide a more granular code specifically for "chronic fatigue syndrome" but directs to this code.
        • Source: CMS General Equivalence Mappings (GEMs), UMLS Metathesaurus, NLM RxNav
      • G93.3 – Postviral fatigue syndrome
        • Confidence Level: Moderate to High
        • Justification: ICD-10 international (not ICD-10-CM) includes G93.3 ("Postviral fatigue syndrome") as a cross-reference for "Chronic fatigue syndrome”, but in ICD-10-CM (USA), G93.3 is not available (excluded; reserved for non-CM use).
        • Reference: NLM Clinical Table Search Service, CDC ICD-10-CM Tabular List
  • Notes:

    • Lexically and semantically, "chronic fatigue syndrome" and "chronic fatigue, unspecified" are close in ICD-10-CM, despite the lack of a direct 1:1 mapping.
    • Be aware of the distinction between ICD-10 (WHO version) and ICD-10-CM (US version): some codes available in the WHO version are not used in the CM version.
    • No mapping errors detected. All mappings follow both SNOMED-CT and ICD-10-CM terminology and logic.
  • Alternative Terms in Use:

    • Myalgic encephalomyelitis (often considered synonymous or closely related in many terminologies)
    • "Chronic fatigue, unspecified" (ICD-10-CM R53.82) is the recommended mapping.

  1. FHIR ConceptMap Example
{
  "resourceType": "ConceptMap",
  "id": "snomedct-icd10cm-chronic-fatigue-syndrome",
  "status": "active",
  "title": "Map SNOMED-CT Chronic fatigue syndrome to ICD-10-CM",
  "sourceCanonical": "http://snomed.info/sct",
  "targetCanonical": "http://hl7.org/fhir/sid/icd-10-cm",
  "group": [
    {
      "source": "http://snomed.info/sct",
      "target": "http://hl7.org/fhir/sid/icd-10-cm",
      "element": [
        {
          "code": "52702003",
          "display": "Chronic fatigue syndrome (disorder)",
          "target": [
            {
              "code": "R53.82",
              "display": "Chronic fatigue, unspecified",
              "equivalence": "equivalent",
              "comment": "ICD-10-CM does not have a code specifically for 'chronic fatigue syndrome'. R53.82 is the recommended mapping per NLM and UMLS resources."
            }
          ]
        }
      ]
    }
  ]
}

References:

  1. SNOMED-CT Browser
  2. CDC ICD-10-CM Tabular List 2024
  3. NLM RxNav & UMLS Metathesaurus
  4. CMS General Equivalence Mappings (GEMs)

Validation/Consistency Notes:

  • The SNOMED-CT code and description are correct and current.
  • The primary ICD-10-CM mapping is accurate for US data use; international mapping may differ.
  • Confidence is highest with R53.82 in ICD-10-CM; G93.3 is not assignable in ICD-10-CM.
  • No inconsistencies were found in current terminology standards.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment