-
Notifications
You must be signed in to change notification settings - Fork 17
Open
Description
The is operator, as operator, and ofType() function currently only perform exact type matching and do not recognize FHIR type inheritance. According to the FHIRPath specification, these should return true for "the type specified in the second operand, or a subclass thereof."
Failing test cases:
Observation is DomainResource→ Expected: true, Got: falseObservation is Resource→ Expected: true, Got: falseObservation.value is Element→ Expected: true, Got: falsePatient.contact is Element→ Expected: true, Got: false
Root Cause:
The current implementation in Collection.filterByType() uses exact type matching via equals():
case FHIR_NAMESPACE -> getFhirType().filter(type.toFhirType()::equals).map(t -> this);Implementation Note:
Use HAPI FHIR implementation classes to check for subtypes. FHIR type names follow a consistent naming convention to their implementing classes in the R4 model (e.g., "Element" → org.hl7.fhir.r4.model.Element). Use Class.isAssignableFrom() to check inheritance relationships.
Affected Components:
Collection.filterByType()ResourceCollection.filterByType()isoperatorasoperatorofType()function
Metadata
Metadata
Assignees
Labels
No labels