In the HL7v2 to FHIR conversion CodeSystem templates, their default, i.e., "else" part in the if-then-else rule, is not working.
For example, for Patient.communication.language in the Resource/_Patient.liquid template, it has the following line to map a language code to a dictionary containing "code", "display", and "system".
{% include 'DataType/CWECodeableConcept' mapping: 'CodeSystem/Language', CWE: PID.15 -%}
In the CodeSystem/_Language.liquid template, if no matching code, it would output the input values.
{% else -%}
"code" : "{{ inCode }}",
"display" : "{{ inCode }}",
"system" : "",
{% endif -%}
My case has PID.15="English" and it has no matching code. So, I expect the following output.
{
"code" : "English",
"display" : "English",
"system" : "",
}
What happens is no output at all.
I also tried to add the following rule with no success.
{% elsif inCode == 'English' -%}
"code" : "{{ inCode }}",
"display" : "{{ inCode }}",
"system" : "",
I appears that CodeSystem/_Language.liquid does not take changes, nor does it handle no-matched codes with "else" condition. I tested the changes with the "FHIR Converter" extension in Visual Studio Code. What can I do to make the "else" condition in CodeSystem/_Language.liquid working?
Make required changes in the /CodeSystem/CodeSystem.json file and that should work for you.
Also, update the VS Code extension to the latest version.
"CodeSystem/Language": {
"A": {
"code": "A's code",
"display": "A's display",
"system": "A's system"
},
"__default__": {
"code": "English",
"display": "English",
"system": "English"
}
},
The following statement is calling _DataType/CWECodeableConcept and passing 'CodeSystem/Language' to mapping parameter, and the value of PID.15 to the CWE parameter.
{% include 'DataType/CWECodeableConcept' mapping: 'CodeSystem/Language', CWE: PID.15 -%}
Inside the _CWECodeableConcept.liquid, since mapping is populated it executes the if blocks, and not the else blocks.
{% if mapping -%}
"code":"{{ CWE.1.Value | get_property: mapping, 'code' }}",
"display":"{{ CWE.1.Value | get_property: mapping, 'display' }}",
"system":"{{ CWE.1.Value | get_property: mapping, 'system' }}",
"version":"{{ CWE.1.Value | get_property: mapping, 'version' }}",
{% else -%}
"code":"{{ CWE.1.Value }}",
"display":"{{ CWE.2.Value }}",
"system":"{{ CWE.3.Value }}",
"version":"{{ CWE.7.Value }}",
{% endif -%}
Inside the if block, get_property is used to fetch the code, display, system, and version for the mapping CodeSystem/Language corresponding to the value in CWE.(1|4|10).Value.
get_property uses the /CodeSystem/CodeSystem.json file, and not the individual files under the CodeSystem folder.
The behavior of get_property is documented here. However, the documentation does not mention the name of the config file it uses. We are fixing the documentation in the next release.
For quicker turnaround, we recommend raising an issue on the FHIR converter github repo.