inferno-framework / fhir-validator-app

A standalone app for validating FHIR resources against an optional Implementation Guide
Apache License 2.0
36 stars 12 forks source link

Issue while validating resource against the http://hl7.org/fhir/StructureDefinition/Endpoint StructureDefinition #114

Open shupurwa opened 3 months ago

shupurwa commented 3 months ago

Hi Team,

We are getting the below error while validating resources against the http://hl7.org/fhir/StructureDefinition/Endpoint StructureDefinition. In managingOrganization section we provided reference as #2621 and reference 2621 do have a Contained section but still, we are getting the error 'SHALL have a contained resource if a local reference is provided'

Please let us know what is wrong with the JSON.

FYI We have validated same via other validator and results look good.(Ex: https://validator.fhir.org/)

image

{ "resourceType": "Bundle", "type": "collection", "entry": [ { "fullUrl": "https://fhir.dev.meditouchehr.com/api/fhir/r4/Endpoint/2621", "resource": { "resourceType": "Endpoint", "id": "2621", "contained": [ { "resourceType": "Organization", "id": "2621", "meta": { "profile": [ "http://hl7.org/fhir/us/core/StructureDefinition/us-core-organization" ] }, "active": true, "name": "Lozito Medical", "telecom": [ { "system": "phone", "value": "9734234770", "use": "work" } ], "address": [ { "country": "USA" } ] } ], "identifier": [ { "value": "2621" } ], "status": "active", "connectionType": { "system": "http://terminology.hl7.org/CodeSystem/endpoint-connection-type", "code": "hl7-fhir-rest" }, "managingOrganization": { "reference": "#2621" }, "period": { "start": "2006-08-25T16:00:34+05:30" }, "payloadType": [ { "coding": [ { "system": "http://hl7.org/fhir/us/davinci-pdex-plan-net/CodeSystem/EndpointPayloadTypeCS", "code": "NA" } ] } ], "payloadMimeType": [ "application/fhir+json", "application/json+fhir" ], "address": "https://fhir.dev.meditouchehr.com/api/fhir/r4/" } }, { "fullUrl": "https://fhir.dev.meditouchehr.com/api/fhir/r4/Endpoint/4011", "resource": { "resourceType": "Endpoint", "id": "4011", "contained": [ { "resourceType": "Organization", "id": "4011", "meta": { "profile": [ "http://hl7.org/fhir/us/core/StructureDefinition/us-core-organization" ] }, "active": true, "name": "Hawthorne Family Practice (frmrly Joel Victor)", "telecom": [ { "system": "phone", "value": "9734272421", "use": "work" } ], "address": [ { "line": [ "1111 Goffle Road" ], "country": "USA" } ] } ], "identifier": [ { "value": "4011" } ], "status": "active", "connectionType": { "system": "http://terminology.hl7.org/CodeSystem/endpoint-connection-type", "code": "hl7-fhir-rest" }, "managingOrganization": { "reference": "#4011" }, "period": { "start": "2006-08-25T16:16:17+05:30" }, "payloadType": [ { "coding": [ { "system": "http://hl7.org/fhir/us/davinci-pdex-plan-net/CodeSystem/EndpointPayloadTypeCS", "code": "NA" } ] } ], "payloadMimeType": [ "application/fhir+json", "application/json+fhir" ], "address": "https://fhir.dev.meditouchehr.com/api/fhir/r4/" } }, { "fullUrl": "https://fhir.dev.meditouchehr.com/api/fhir/r4/Endpoint/5036", "resource": { "resourceType": "Endpoint", "id": "5036", "contained": [ { "resourceType": "Organization", "id": "5036", "meta": { "profile": [ "http://hl7.org/fhir/us/core/StructureDefinition/us-core-organization" ] }, "active": true, "name": "Dr Marc Darr", "telecom": [ { "system": "phone", "value": "9284455339", "use": "work" } ], "address": [ { "line": [ "1672 Oaklawn Drive" ], "country": "USA" } ] } ], "identifier": [ { "value": "5036" } ], "status": "active", "connectionType": { "system": "http://terminology.hl7.org/CodeSystem/endpoint-connection-type", "code": "hl7-fhir-rest" }, "managingOrganization": { "reference": "#5036" }, "period": { "start": "2006-08-25T16:30:41+05:30" }, "payloadType": [ { "coding": [ { "system": "http://hl7.org/fhir/us/davinci-pdex-plan-net/CodeSystem/EndpointPayloadTypeCS", "code": "NA" } ] } ], "payloadMimeType": [ "application/fhir+json", "application/json+fhir" ], "address": "https://fhir.dev.meditouchehr.com/api/fhir/r4/" } }, { "fullUrl": "https://fhir.dev.meditouchehr.com/api/fhir/r4/Endpoint/1442", "resource": { "resourceType": "Endpoint", "id": "1442", "contained": [ { "resourceType": "Organization", "id": "1442", "meta": { "profile": [ "http://hl7.org/fhir/us/core/StructureDefinition/us-core-organization" ] }, "active": true, "name": "CLEVELAND CLINIC HOME CARE SERVICES", "telecom": [ { "system": "phone", "value": "2166368645", "use": "work" } ], "address": [ { "line": [ "6801Breckville Rd", "Suite" ], "city": "Independence", "state": "OH", "postalCode": "44131", "country": "USA" } ] } ], "identifier": [ { "value": "1442" } ], "status": "active", "connectionType": { "system": "http://terminology.hl7.org/CodeSystem/endpoint-connection-type", "code": "hl7-fhir-rest" }, "managingOrganization": { "reference": "#1442" }, "period": { "start": "2006-08-22T08:00:21+05:30" }, "payloadType": [ { "coding": [ { "system": "http://hl7.org/fhir/us/davinci-pdex-plan-net/CodeSystem/EndpointPayloadTypeCS", "code": "NA" } ] } ], "payloadMimeType": [ "application/fhir+json", "application/json+fhir" ], "address": "https://fhir.dev.meditouchehr.com/api/fhir/r4/" } } ] }

dehall commented 3 months ago

Hi, thanks for providing the full details, I was able to reproduce this both on the Inferno validator and validator.fhir.org.

The short answer is: don't specify the http://hl7.org/fhir/StructureDefinition/Endpoint profile. At best it's unnecessary, because the validator will always validate resources against the appropriate base FHIR StructureDefinition. In this case though it's incorrect, because the resource you're validating is a Bundle. It may contain Endpoints but it's still a Bundle. I think that caused the core validator to get confused. You can get the same behavior on validator.fhir.org by specifying that profile on the Options page: image --> image

For a little more detail, the validator will validate resources against 3 sets of profiles:

(There may even be more in certain situations)

The point is, there's no need to specify a base FHIR StructureDefinition since it will be validated automatically. Then in this case, the resource you're validating is a Bundle, so choosing a profile for a different resource can apparently confuse it and produce inconsistent results. If you pick out the individual Endpoints you can validate against whichever Endpoint profile you like and you'll get the expected results.

Please let us know if you continue to see unexpected error messages