Closed sumanathenahealth closed 1 week ago
getEffectiveDateTimeType
, which expects the type to be a DateTime and throws an exception if it is not. And that exception shows that the type is Period. You need to call getEffectivePeriod
from your com.gehcit.fhir.r4.text.NarrativeModelFactory
class instead. You can use methods like hasEffectivePeriod
to determine what the type of the element, or just call getEffective()
to fetch it regardless of datatype.
As Travel-History is one the type for OBSERVATION resource , Facing below exception , when we pass Period datatype for Obseravation.effective[x] in case of Travel-History for OBSERVATION resource
org.hl7.fhir.exceptions.FHIRException: Type mismatch: the type DateTimeType was expected, but org.hl7.fhir.r4.model.Period was encountered at org.hl7.fhir.r4.model.Observation.getEffectiveDateTimeType(Observation.java:2034) ~[org.hl7.fhir.r4-4.2.0.jar:?] at com.gehcit.fhir.r4.text.NarrativeModelFactory$24.getDates(NarrativeModelFactory.java:1033) ~[fhir-r4-api-0.0.1-SNAPSHOT.jar:?] at com.gehcit.fhir.r4.text.NarrativeTableViewGenerator.getBody(NarrativeTableViewGenerator.java:81) ~[fhir-r4-api-0.0.1-SNAPSHOT.jar:?] at com.gehcit.fhir.r4.text.NarrativeTableViewGenerator.getHtml(NarrativeTableViewGenerator.java:45) ~[fhir-r4-api-0.0.1-SNAPSHOT.jar:?] at com.gehcit.fhir.r4.text.NarrativeViewGenerator.populateResourceNarrative(NarrativeViewGenerator.java:29) ~[fhir-r4-api-0.0.1-SNAPSHOT.jar:?] at ca.uhn.fhir.parser.JsonParser.encodeCompositeElementChildrenToStreamWriter(JsonParser.java:394) ~[hapi-fhir-base-4.2.0.jar:?]
To Reproduce Steps to reproduce the behavior:
Expected behavior Expected behavior is hapi-fhir library , should not through the exception as per hl7 specification https://www.hl7.org/fhir/us/ecr/StructureDefinition-us-ph-travel-history.html
Screenshots hl7 Specification:
Environment (please complete the following information):
Additional context As per hl7 specification Obseravation.effective[x] should support dateTime, Period, Timing, instant data-types But when we use Period type which is applicable for travel-history , we are facing above mentioned exception