Reference Points to the Wrong Resource Type
A profile constrains which resource types an element may reference. The reference points at a type that is not in the allowed list. For example a subject constrained to Patient that points at a Group.
FHIR · Error
The error
must reference one of the allowed target types but references anotherWhy it happens
Wiring a reference to the wrong resource, or reusing a generic linker that does not respect the profile constraint.
How to fix it
Point the reference at an allowed target type. The failure lists the permitted types. Use Patient/id where Patient is required rather than another resource type.
Example
The snippet below triggers the error:
{
"resourceType": "Observation",
"status": "final",
"code": { "text": "Glucose" },
"subject": { "reference": "Group/cohort-1" }
}The corrected version:
{
"resourceType": "Observation",
"status": "final",
"code": { "text": "Glucose" },
"subject": { "reference": "Patient/example" }
}Frequently asked questions
How does the validator know the target type?
It reads the resource type prefix of the reference string (the Type in Type/id) or the Reference.type element, then checks it against the profile-allowed target types.
Related
- Open the FHIR Profile Coverage (US Core / IPS)
- All validation errors
- resourceType Is Required
- Unknown FHIR R4 Resource Type
- Required Element Is Missing for This Resource
- gender Must Be male, female, other, or unknown
- birthDate Must Be YYYY, YYYY-MM, or YYYY-MM-DD
- instant Must Include a Timezone
- Resource id Has an Invalid Format
- subject Must Be a Reference Object, Not a String