hapifhir / hapi-fhir

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

Issue while validating target references of type `canonical` #4403

Open AmirthavalliG opened 1 year ago

AmirthavalliG commented 1 year ago

Describe the bug I am trying to validate a profile using hapi-fhir-validation version 6.1.3 wherin one of the elements contains a reference of type "canonical" and the targetProfile containing the url of the custom profile that I want to refer to. But the validation throws me an error saying "issue" : [ { "severity" : "error", "code" : "exception", "expression" : [ "StructureDefinition.differential.element[13].type[0].targetProfile[0]", "StructureDefinition-SamplePolicy.json" ], "details" : { "text" : "Profile http://sample.hl7/healthcare/fhir/StructureDefinition/SampleRolePermission is for type StructureDefinition[http://sample.hl7/healthcare/fhir/StructureDefinition/SampleRolePermission], which is not a Canonical Resource (which is required because the SamplePolicy.sampleRole element has type canonical)" }, "diagnostics" : "Profile http://sample.hl7/healthcare/fhir/StructureDefinition/SampleRolePermission is for type StructureDefinition[http://sample.hl7/healthcare/fhir/StructureDefinition/SampleRolePermission], which is not a Canonical Resource (which is required because the SamplePolicy.sampleRole element has type canonical)" }

This is my differential element in SD { "id": "SamplePolicy.sampleRole", "path": "SamplePolicy.sampleRole", "short": "A reference from one resource to another", "definition": "A reference from one resource to another.", "min": 1, "max": "*", "type": [ { "code": "canonical", "targetProfile": [ "http://sample.hl7/healthcare/fhir/StructureDefinition/SampleRolePermission" ] } ] }

Is it that the fhir validator only supports tha predefined target references (from fhir) ? If so how do I ensure that it doesnt fail on this?

AmirthavalliG commented 1 year ago

Another update is that in the custom resource Resource Type :"RolePermission"(For which we have defined the custom resource types) We debugged and found that https://github.com/hapifhir/org.hl7.fhir.core/blob/master/org.hl7.fhir.validation/src/main/java/org/hl7/fhir/validation/instance/type/StructureDefinitionValidator.java#L557 there is a hardcoding for fhir defined types (This is actually extensible). Is this not supported ?

AmirthavalliG commented 1 year ago

@jamesagnew : Can you help us out ?