hapifhir / hapi-fhir

🔥 HAPI FHIR - Java API for HL7 FHIR Clients and Servers
http://hapifhir.io
Apache License 2.0
1.95k stars 1.3k forks source link

No support for implicit ValueSets from CodeSystem.url #3523

Open jpwiedekopf opened 2 years ago

jpwiedekopf commented 2 years ago

Describe the bug HAPI FHIR (JPA Server) is not able to expand FHIR ValueSets coming from the CodeSystem.valueSet parameter. This parameter can be set to a canonical URL of an implicit VS, which contains all codes within the CS. This is a core feature of a server implementing the FHIR Terminology package.

To Reproduce Steps to reproduce the behavior:

  1. Spin up a HAPI FHIR JPA Server
  2. POST/PUT a CodeSystem resource that includes the CodeSystem.valueSet parameter, e.g. from https://r4.ontoserver.csiro.au/fhir/CodeSystem/australian-immunisation-register-vaccine-20200531?_format=json
  3. Issue a ValueSet/$expand operation, e.g. using GET http://localhost:8080/fhir/ValueSet/$expand?url=https://www.humanservices.gov.au/organisations/health-professionals/enablers/air-vaccine-code-formats/vs
  4. See error:
{
  "resourceType": "OperationOutcome",
  "text": {
    "status": "generated",
    "div": "<div xmlns=\"http://www.w3.org/1999/xhtml\"><h1>Operation Outcome</h1><table border=\"0\"><tr><td style=\"font-weight: bold;\">ERROR</td><td>[]</td><td><pre>Unknown ValueSet: https%3A%2F%2Fwww.humanservices.gov.au%2Forganisations%2Fhealth-professionals%2Fenablers%2Fair-vaccine-code-formats%2Fvs</pre></td>\n\t\t\t</tr>\n\t\t</table>\n\t</div>"
  },
  "issue": [ {
    "severity": "error",
    "code": "processing",
    "diagnostics": "Unknown ValueSet: https%3A%2F%2Fwww.humanservices.gov.au%2Forganisations%2Fhealth-professionals%2Fenablers%2Fair-vaccine-code-formats%2Fvs"
  } ]
}

Expected behavior The server should recognize that the URL refers to an implicit ValueSet, and render the expansion dynamically from the list of concepts known to the server.

Environment (please complete the following information):

Additional context Currently, the CodeSytem.valueSet is not written to the respective tables in JPA, TermCodeSystem and/or TermCodeSystemVersion (neither explicitly as a column, nor via the resource column in TermCodeSystem, because the FHIR specification does not define a search parameter for CodeSystem.valueSet, and only search parameters are written to that table). Since versioning of the implicit VS should match the CS versioning, adding this information to TermCodeSystemVersion seems prudent.

Afterwards, a routine for retrieving matching CodeSystem versions and rendering the respecitive expansion should be implemented in the terminology server implementation of HAPI FHIR JPA.

I'll implement the above and send a pull request.

jpwiedekopf commented 2 years ago

R4 is implemented at: https://github.com/jpwiedekopf/hapi-fhir/tree/3523-vs-expand-implicit

I'll implement DSTU3 and R5 in a few days. DSTU2 is not needed (no VS/CS separation back then). I'll also look at writing tests for this.

vadi2 commented 3 months ago

What is the latest on this?