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

UnsupportedOperationException causing validation error while validating resources based on IHE MHD implementation guide #5924

Closed
subigre opened this issue May 11, 2024 · 0 comments · Fixed by #5925

Comments

@subigre
Copy link
Contributor

subigre commented May 11, 2024

Describe the bug
While validating Bundle resources using https://profiles.ihe.net/ITI/MHD/StructureDefinition/IHE.MHD.Minimal.ProvideBundle profile from IHE MHD IG (4.2.1), the following method from VersionSpecificWorkerContextWrapper is called:

	@Override
	public ValueSetExpansionOutcome expandVS(
			Resource src,
			org.hl7.fhir.r5.model.ElementDefinition.ElementDefinitionBindingComponent binding,
			boolean cacheOk,
			boolean Hierarchical) {
		throw new UnsupportedOperationException(Msg.code(663));
	}

As a result, the following error is returned in the validation result:

{
            "severity": "error",
            "code": "processing",
            "details": {
                "coding": [
                    {
                        "system": "http://hl7.org/fhir/java-core-messageId",
                        "code": "SLICING_CANNOT_BE_EVALUATED"
                    }
                ]
            },
            "diagnostics": "Slicing cannot be evaluated: Problem evaluating slicing expression for element in profile https://profiles.ihe.net/ITI/MHD/StructureDefinition/IHE.MHD.Minimal.ProvideBundle|4.2.2 path Bundle.entry[2] (fhirPath = true and resource.conformsTo('http://hl7.org/fhir/StructureDefinition/Binary') and (request.method memberOf 'http://hl7.org/fhir/ValueSet/http-verb|4.0.1')): HAPI-0663: ",
            "location": [
                "Bundle.entry[2]",
                "Line[141] Col[10]"
            ]
        }

To Reproduce

  1. Download IHE MHD implementation guide here
  2. Copy and paste the following class
import ca.uhn.fhir.context.FhirContext;
import ca.uhn.fhir.context.support.DefaultProfileValidationSupport;
import ca.uhn.fhir.validation.FhirValidator;
import ca.uhn.fhir.validation.ValidationResult;
import org.hl7.fhir.common.hapi.validation.support.CommonCodeSystemsTerminologyService;
import org.hl7.fhir.common.hapi.validation.support.InMemoryTerminologyServerValidationSupport;
import org.hl7.fhir.common.hapi.validation.support.NpmPackageValidationSupport;
import org.hl7.fhir.common.hapi.validation.support.SnapshotGeneratingValidationSupport;
import org.hl7.fhir.common.hapi.validation.support.ValidationSupportChain;
import org.hl7.fhir.common.hapi.validation.validator.FhirInstanceValidator;

import java.io.IOException;

public class HapiFhirIheMhdValidation {

  public static void main(String[] args) throws IOException {
  	var bundle = """
  		{
  		   	"resourceType": "Bundle",
  		   	"meta": {
  		   		"profile": [
  		   			"https://profiles.ihe.net/ITI/MHD/StructureDefinition/IHE.MHD.Minimal.ProvideBundle"
  		   		],
  		   		"security": [
  		   			{
  		   				"system": "http://terminology.hl7.org/CodeSystem/v3-ActReason",
  		   				"code": "HTEST"
  		   			}
  		   		]
  		   	},
  		   	"type": "transaction",
  		   	"timestamp": "2024-05-11T14:16:19.224Z",
  		   	"entry": [
  		   		{
  		   			"fullUrl": "urn:uuid:9649cc3d-eb0b-407b-b1ba-61c4eef4dba3",
  		   			"resource": {
  		   				"resourceType": "List",
  		   				"id": "9649cc3d-eb0b-407b-b1ba-61c4eef4dba3",
  		   				"meta": {
  		   					"profile": [
  		   						"https://profiles.ihe.net/ITI/MHD/StructureDefinition/IHE.MHD.Minimal.SubmissionSet"
  		   					],
  		   					"security": [
  		   						{
  		   							"system": "http://terminology.hl7.org/CodeSystem/v3-ActReason",
  		   							"code": "HTEST"
  		   						}
  		   					]
  		   				},
  		   				"text": {
  		   					"status": "extensions",
  		   					"div": "<div xmlns=\\"http://www.w3.org/1999/xhtml\\">SubmissionSet with Patient</div>"
  		   				},
  		   				"contained": [
  		   					{
  		   						"resourceType": "Practitioner",
  		   						"id": "622209e6-32ad-4283-b4eb-e2bea2aea856",
  		   						"telecom": [
  		   							{
  		   								"system": "email",
  		   								"value": "john.doe@localhost"
  		   							}
  		   						]
  		   					}
  		   				],
  		   				"extension": [
  		   					{
  		   						"url": "https://profiles.ihe.net/ITI/MHD/StructureDefinition/ihe-sourceId",
  		   						"valueIdentifier": {
  		   							"value": "urn:oid:1.2.3.4"
  		   						}
  		   					},
  		   					{
  		   						"url": "https://profiles.ihe.net/ITI/MHD/StructureDefinition/ihe-intendedRecipient",
  		   						"valueReference": {
  		   							"reference": "#622209e6-32ad-4283-b4eb-e2bea2aea856"
  		   						}
  		   					}
  		   				],
  		   				"identifier": [
  		   					{
  		   						"use": "usual",
  		   						"system": "urn:ietf:rfc:3986",
  		   						"value": "urn:oid:1.2.840.113556.1.8000.2554.58783.21864.3474.19410.44358.58254.41281.46343"
  		   					}
  		   				],
  		   				"status": "current",
  		   				"mode": "working",
  		   				"code": {
  		   					"coding": [
  		   						{
  		   							"system": "https://profiles.ihe.net/ITI/MHD/CodeSystem/MHDlistTypes",
  		   							"code": "submissionset"
  		   						}
  		   					]
  		   				},
  		   				"subject": {
  		   					"reference": "urn:uuid:51eb4fab-9d1a-4314-ad7c-363fc430f52c"
  		   				},
  		   				"date": "2004-10-25T23:50:50-05:00",
  		   				"entry": [
  		   					{
  		   						"item": {
  		   							"reference": "urn:uuid:f494ac72-be69-4910-baf4-0cce4a45e7c1"
  		   						}
  		   					}
  		   				]
  		   			},
  		   			"request": {
  		   				"method": "POST",
  		   				"url": "List"
  		   			}
  		   		},
  		   		{
  		   			"fullUrl": "urn:uuid:f494ac72-be69-4910-baf4-0cce4a45e7c1",
  		   			"resource": {
  		   				"resourceType": "DocumentReference",
  		   				"id": "f494ac72-be69-4910-baf4-0cce4a45e7c1",
  		   				"meta": {
  		   					"profile": [
  		   						"https://profiles.ihe.net/ITI/MHD/StructureDefinition/IHE.MHD.Minimal.DocumentReference"
  		   					],
  		   					"security": [
  		   						{
  		   							"system": "http://terminology.hl7.org/CodeSystem/v3-ActReason",
  		   							"code": "HTEST"
  		   						}
  		   					]
  		   				},
  		   				"masterIdentifier": {
  		   					"system": "urn:ietf:rfc:3986",
  		   					"value": "urn:oid:1.2.840.113556.1.8000.2554.53432.348.12973.17740.34205.4355.50220.62012"
  		   				},
  		   				"status": "current",
  		   				"subject": {
  		   					"reference": "urn:uuid:51eb4fab-9d1a-4314-ad7c-363fc430f52c"
  		   				},
  		   				"content": [
  		   					{
  		   						"attachment": {
  		   							"contentType": "text/plain",
  		   							"url": "urn:uuid:4d14267b-19ff-4237-a301-4cdcfd67d4f9",
  		   							"size": 11,
  		   							"hash": "MGE0ZDU1YThkNzc4ZTUwMjJmYWI3MDE5NzdjNWQ4NDBiYmM0ODZkMA=="
  		   						},
  		   						"format": {
  		   							"system": "http://ihe.net/fhir/ihe.formatcode.fhir/CodeSystem/formatcode",
  		   							"code": "urn:ihe:iti:xds-sd:text:2008"
  		   						}
  		   					}
  		   				]
  		   			},
  		   			"request": {
  		   				"method": "POST",
  		   				"url": "DocumentReference"
  		   			}
  		   		},
  		   		{
  		   			"fullUrl": "urn:uuid:4d14267b-19ff-4237-a301-4cdcfd67d4f9",
  		   			"resource": {
  		   				"resourceType": "Binary",
  		   				"id": "4d14267b-19ff-4237-a301-4cdcfd67d4f9",
  		   				"meta": {
  		   					"security": [
  		   						{
  		   							"system": "http://terminology.hl7.org/CodeSystem/v3-ActReason",
  		   							"code": "HTEST"
  		   						}
  		   					]
  		   				},
  		   				"contentType": "text/plain",
  		   				"data": "SGVsbG8gV29ybGQ="
  		   			},
  		   			"request": {
  		   				"method": "POST",
  		   				"url": "Binary"
  		   			}
  		   		},
  		   		{
  		   			"fullUrl": "urn:uuid:51eb4fab-9d1a-4314-ad7c-363fc430f52c",
  		   			"resource": {
  		   				"resourceType": "Patient",
  		   				"id": "51eb4fab-9d1a-4314-ad7c-363fc430f52c",
  		   				"meta": {
  		   					"security": [
  		   						{
  		   							"system": "http://terminology.hl7.org/CodeSystem/v3-ActReason",
  		   							"code": "HTEST"
  		   						}
  		   					]
  		   				},
  		   				"name": [
  		   					{
  		   						"family": "Doe",
  		   						"given": [
  		   							"John"
  		   						]
  		   					}
  		   				]
  		   			},
  		   			"request": {
  		   				"method": "POST",
  		   				"url": "Patient"
  		   			}
  		   		}
  		   	]
  		   }
  		""";

  	FhirContext fhirContext = FhirContext.forR4();

  	var validationSupport = new ValidationSupportChain();
  	validationSupport.addValidationSupport(new DefaultProfileValidationSupport(fhirContext));
  	validationSupport.addValidationSupport(new SnapshotGeneratingValidationSupport(fhirContext));
  	validationSupport.addValidationSupport(new CommonCodeSystemsTerminologyService(fhirContext));
  	validationSupport.addValidationSupport(new InMemoryTerminologyServerValidationSupport(fhirContext));

  	NpmPackageValidationSupport npmPackageValidationSupport = new NpmPackageValidationSupport(fhirContext);
  	npmPackageValidationSupport.loadPackageFromClasspath("classpath:package.tgz");
  	validationSupport.addValidationSupport(npmPackageValidationSupport);

  	var instanceValidator = new FhirInstanceValidator(validationSupport);
  	FhirValidator validator = fhirContext.newValidator();
  	validator.registerValidatorModule(instanceValidator);

  	ValidationResult validationResult = validator.validateWithResult(bundle);
  	if (validationResult.isSuccessful()) {
  		System.out.println("Validation successful");
  	} else {
  		System.out.println("Validation failed");
  		System.out.println(validationResult.getMessages());
  	}
  }
  1. Runs the class

Expected behavior
No validation error should be reported regarding the slice as the resource is valid.

Environment (please complete the following information):

  • HAPI FHIR Version: 7.0.2
  • OS: MacOS/Linux
  • Browser: n/a
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

Successfully merging a pull request may close this issue.

1 participant