'Understanding liquid template in microsoft FHIR-Converter

I am trying to understand how liquid template is being used in the Microsoft FHIR-Converter: https://github.com/microsoft/FHIR-Converter/tree/9239c4183fafcc67fe0d07aaa90fec3b2df0bdd7

In its one of the hl7v2 template (https://github.com/microsoft/FHIR-Converter/blob/9239c4183fafcc67fe0d07aaa90fec3b2df0bdd7/data/Templates/Hl7v2/ORU_R01.liquid), it starts with line like this: {% assign firstSegments = hl7v2Data | get_first_segments: 'MSH|UAC|ORC' -%}

From what I understand as a person new to liquid and dotnet, firstSegment is variable being used in the template and it is type of hl7v2Data which is a custom object created in the project and it uses custom filter GetFirstSegments. However, this is my very high level assumption.

in later line in the template it has line like this: {% if firstSegments.MSH.7 -%}. I am not sure how liquid template understand and make connection to dotnet code. I am used to java and this line seems like there should property called MSH in firstSegment object.

Am I completely off here?



Solution 1:[1]

The | sign applies filter get_first_segments to hl7v2Data. From https://github.com/microsoft/FHIR-Converter/blob/main/docs/Filters-and-Tags.md I read that get_first_segments returns the first instance of the specified "segments". The resulting array is then stored in firstSegments

As for your template, you may have some luck consulting the arrays syntax in liquid, https://shopify.github.io/liquid/basics/types/#array

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 andrea m.