Hi Russell,

FYI this is the HAPI-HL7v2 mailing list, it's probably better to ask this
question on the HAPI FHIR list at :
https://groups.google.com/forum/#!forum/hapi-fhir

That said, there isn't a built-in way of applying XPath, but you might look
at FhirContext#newFluentPath() (renamed to newFhrPath on HAPI FHIR
5.0.0-SNAPSHOT). This allows you to apply FHIRPath expressions to FHIR
resources. These are not exactly like xpath, but are just as expressive.

Cheers,
James

On Mon, Apr 6, 2020 at 2:10 PM Russell Bateman <r...@windofkeltia.com>
wrote:

> I wonder if there's a way to get an XPath within the source document for
> any, given piece of information I'm able to get out of the API. (Note that
> there is a way to do this using MDHT for HL7 v3 work; this is why I ask.) I
> need to annotate data I extract with the location where I found it in the
> original source document.
>
> For example, let's assume the following code:
>
> FhirContext context = FhirContext.forDstu3();
> IParser     parser  = context.newXmlParser();
> Patient     patient = parser.parseResource( Patient.class, getFhirRecord()
> );
>
> List< HumanName > names = patient.getName();
> for( HumanName name : names )
> {
>   String family = name.getFamily();
>   List< StringType > givenNames = name.getGiven();
>
>   for( StringType given : givenNames )
>   {
>     String name  = given.toString();
>     String xpath = ?;                 // x marks the spot
>   }
> }
>
> Neither by inspecting data structures in the debugger nor by examining the
> Javadoc for *org.hl7.fhir.dstu3.model.Patient* am I able to find way to
> get back something like
>
> *Patient/contained[1]/Patient/name/given[1]*
>
> for a given name at [x marks the spot above] .
>
> How are others solving this? Does anyone else need to solve this?
>
> Thanks
>
> _______________________________________________
> Hl7api-devel mailing list
> Hl7api-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/hl7api-devel
>
_______________________________________________
Hl7api-devel mailing list
Hl7api-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/hl7api-devel

Reply via email to