Groups keyboard shortcuts have been updated
Dismiss
See shortcuts

Re: Issue with SlicingRules

9 views
Skip to first unread message

James Agnew

unread,
Apr 25, 2025, 3:17:40 PMApr 25
to Allen Walker, HAPI FHIR
Hi Allen,

The R5 bit is because the validator works in R5 internally. This should all normally be transparent to the user (i.e. you), but we automatically convert R4 structuredefinitions into R5 ones to feed to the validator, and it understands that it is validating R4 resources even though it is using up-converted structuredefinitions. This is done so that we don't need to maintain separate validator codebases for each version of FHIR.

As for your actual issue here, it's hard to say the cause without debugging the code. It could be an invalid profile, or it could even be a bug. My recommendation would be to try this using the very latest HAPI FHIR snapshot version available just to see if it still happens there. If not, it was probably a bug which has already been fixed. If so, you may need to debug into the code to see what is happening.

Cheers,
James

On Fri, Apr 25, 2025 at 12:07 PM Allen Walker <maria...@gmail.com> wrote:
Hello,
We have a need to validate resources based on custom profiles "https://gematik.de/fhir/isik/v3/Medikation/StructureDefinition/ISiKMedikationsVerabreichung". For that we load a lot of packages into PrePopulatedValidationSupport.

```
    "de.gematik.isip/1.0.2",
    "hl7.fhir.r4.core/4.0.1",
    "de.basisprofil.r4/1.4.0",
    "de.gematik.isik-medikation/3.0.4"
```

Then we build next bean:

```
    public ValidationSupportChain beanValidationSupportChain() {
        return new ValidationSupportChain(
                createPrePopulatedValidationSupport(),//with all packages
                new DefaultProfileValidationSupport(fhirContextR4),
                new InMemoryTerminologyServerValidationSupport(fhirContextR4),
                new CommonCodeSystemsTerminologyService(fhirContextR4),
                new SnapshotGeneratingValidationSupport(fhirContextR4)
        );
    }
```

and then we finally build our validator:

```
    private final FhirValidator validator;
    public PclFhirValidator(final FhirContext ctx, ValidationSupportChain validationSupportChain) {
        CachingValidationSupport.CacheTimeouts cacheTimeouts = new CachingValidationSupport.CacheTimeouts()
                .setLookupCodeMillis(10 * DateUtils.MILLIS_PER_MINUTE)
                .setExpandValueSetMillis(DateUtils.MILLIS_PER_MINUTE)
                .setTranslateCodeMillis(10 * DateUtils.MILLIS_PER_MINUTE)
                .setValidateCodeMillis(60 * DateUtils.MILLIS_PER_MINUTE)
                .setMiscMillis(10 * DateUtils.MILLIS_PER_MINUTE);

        CachingValidationSupport validationSupport = new CachingValidationSupport(validationSupportChain, cacheTimeouts);
        validator = ctx.newValidator();

        FhirInstanceValidator instanceValidator = new FhirInstanceValidator(validationSupport);
        validator.registerValidatorModule(instanceValidator);
    }
```
and then when Im trying to validate MedicationAdministration I get an error with R5 but I used R4:
```
Caused by: java.lang.NullPointerException: Cannot invoke "org.hl7.fhir.r5.model.ElementDefinition$SlicingRules.equals(Object)" because the return value of "org.hl7.fhir.r5.model.ElementDefinition$ElementDefinitionSlicingComponent.getRules()" is null
at org.hl7.fhir.validation.instance.InstanceValidator.assignChildren(InstanceValidator.java:6106)
at org.hl7.fhir.validation.instance.InstanceValidator.validateElement(InstanceValidator.java:5569)
at org.hl7.fhir.validation.instance.InstanceValidator.checkChildByDefinition(InstanceValidator.java:5828)
at org.hl7.fhir.validation.instance.InstanceValidator.checkChild(InstanceValidator.java:5628)
at org.hl7.fhir.validation.instance.InstanceValidator.validateElement(InstanceValidator.java:5576)
at org.hl7.fhir.validation.instance.InstanceValidator.startInner(InstanceValidator.java:5187)
at org.hl7.fhir.validation.instance.InstanceValidator.start(InstanceValidator.java:4980)
at org.hl7.fhir.validation.instance.InstanceValidator.validateResource(InstanceValidator.java:6484)
at org.hl7.fhir.validation.instance.InstanceValidator.validate(InstanceValidator.java:919)
at org.hl7.fhir.validation.instance.InstanceValidator.validate(InstanceValidator.java:753)
at org.hl7.fhir.common.hapi.validation.validator.ValidatorWrapper.validate(ValidatorWrapper.java:194)
at org.hl7.fhir.common.hapi.validation.validator.FhirInstanceValidator.validate(FhirInstanceValidator.java:239)
at org.hl7.fhir.common.hapi.validation.validator.BaseValidatorBridge.doValidate(BaseValidatorBridge.java:23)
at org.hl7.fhir.common.hapi.validation.validator.BaseValidatorBridge.validateResource(BaseValidatorBridge.java:59)
at org.hl7.fhir.common.hapi.validation.validator.FhirInstanceValidator.validateResource(FhirInstanceValidator.java:27)
at ca.uhn.fhir.validation.FhirValidator.validateResource(FhirValidator.java:357)
at ca.uhn.fhir.validation.FhirValidator.doValidate(FhirValidator.java:273)
at ca.uhn.fhir.validation.FhirValidator.validateWithResult(FhirValidator.java:258)
at ca.uhn.fhir.validation.FhirValidator.validateWithResult(FhirValidator.java:213)
```
Can someone help me fix it?

--
You received this message because you are subscribed to the Google Groups "HAPI FHIR" group.
To unsubscribe from this group and stop receiving emails from it, send an email to hapi-fhir+...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/hapi-fhir/152075d3-2b85-40f1-9a15-ab37da3c3c41n%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages