Stream: hapi
Topic: FhirTerser
Heath Dinkins (Aug 04 2020 at 15:38):
I'm interested in using the HAPI FhirTerser. I've been looking online for some examples to get started, but I've been unable to really find much.
I've been working with MeasureReports, but I keep getting back null, no matter what path I put in for the resource.
FhirTerser terser = ctx.newTerser();
IParser parser = ctx.newJsonParser();
MeasureReport measureReport = parser.parseResource(MeasureReport.class, fhirMessage);
String value = String.valueOf(terser.getSingleValueOrNull(measureReport, "MeasureReport.date"));
String value2 = String.valueOf(terser.getSingleValueOrNull(measureReport, "date"));
Maybe I'm using it wrong, or maybe my path is wrong. Does anyone have any simple examples of the FhirTerser? I'm just looking to pull simple values given a path.
Also, does anyone have an example of a path for lists of resources? Example: "group[0].code.coding.code" which might retrieve the first element in the list of groups.
James Agnew (Aug 11 2020 at 14:23):
@Heath Dinkins I'd actually recommend using FHIRPath instead for that kind of use case.
Terser is an older feature (it predates support for FHIRPath)- It still has its place (the model visitor is super useful for some use cases) but for extracting values it's definitely nicer to use ther FHIRPath support (ctx.newFhirPath())
Last updated: Apr 12 2022 at 19:14 UTC