Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Snapshot generation fails for extensions with value[x].code elements #5826

Open
ashtty11 opened this issue Apr 5, 2024 · 0 comments
Open

Comments

@ashtty11
Copy link

ashtty11 commented Apr 5, 2024

Bug
Snapshot generation fails for extensions where the differential section contains elements one level down from Extension.value[x], for e.g. Extension.value[x].code

  {
    "id": "Extension.value[x]",
    "path": "Extension.value[x]",
    "min": 1,
    "type": [
      {
        "code": "Coding"
      }
    ]
  },
  {
    "id": "Extension.value[x].system",
    "path": "Extension.value[x].system",
    "min": 1
  },
  {
    "id": "Extension.value[x].code",
    "path": "Extension.value[x].code",
    "min": 1
  }

HAPI library tries to throw the following error

Extension.value[x] has children for type Coding in profile icd-10-gm-mehrfachcodierungs-kennzeichen but can't find type

But this error is not handled properly. It ends up throwing an IndexOutOfBounds exception with the error message

Index 5 out of bounds for length 5

Either behavior is incorrect. This is a valid profile and snapshot generation should happen.

To Reproduce

  1. Using the following dependencies in pom.xml
<dependency>
            <groupId>ca.uhn.hapi.fhir</groupId>
            <artifactId>hapi-fhir-validation</artifactId>
            <version>7.0.2</version>
</dependency>
<dependency>
            <groupId>ca.uhn.hapi.fhir</groupId>
            <artifactId>hapi-fhir-client</artifactId>
            <version>7.0.2</version>
</dependency>
 <dependency>
            <groupId>ca.uhn.hapi.fhir</groupId>
            <artifactId>hapi-fhir-structures-r4</artifactId>
            <version>7.0.2</version>
</dependency>
  1. Convert the base StructureDefinition (in file extension.json attached) and current StructureDefinition(sd.json attached - taken from https://simplifier.net/Basisprofil-DE-R4/ExtensionMehrfachcodierungKennzeichen/~json ) into StructureDefinition objects.

extension.json
sd.json

String baseStructureDefinition;
String requestStructureDefinition;
org.hl7.fhir.r4.model.StructureDefinition baseDefinition = (org.hl7.fhir.r4.model.StructureDefinition) r4fhirContext.newJsonParser()
                        .parseResource(baseStructureDefinition);
org.hl7.fhir.r4.model.StructureDefinition requestDefinition = (org.hl7.fhir.r4.model.StructureDefinition) r4fhirContext.newJsonParser()
                .parseResource(requestStructureDefinition);

Use the HAPI snapshot generation APIs.

FhirContext fhirContext = FhirContext.forR4();
ProfileUtilities profileUtils = new ProfileUtilities(
                    new HapiWorkerContext(fhirContext, new DefaultProfileValidationSupport(fhirContext)), new ArrayList<ValidationMessage>(), null);
            profileUtils.generateSnapshot(baseDefinition, requestDefinition, null, null, null);

Expected behavior
Snapshot generation should happen successfully.

Screenshots
image

Environment (please complete the following information):

  • HAPI FHIR Version: 7.0.2 and earlier

Additional notes

Simplifier APIs are able to handle the snapshot generation - https://simplifier.net/Basisprofil-DE-R4/ExtensionMehrfachcodierungKennzeichen/~json

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant