Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix filters in if tag #385

Merged
merged 7 commits into from
Apr 27, 2022
Merged

Conversation

QuanWanxx
Copy link
Contributor

Fix the filters in liquid if tag, filters are only supported on a subset of tags (e.g. assign tag), which don't include if, for or case tags. Refer to this issue in Shopify/liquid repo.

E.g. The below condition will always true as long as relationship.observation.templateId is not null, the followed filter pipes | to_json_string | contains: '"2.16.840.1.113883.10.20.22.4.7"' takes no effetcs.

{% if relationship.observation.templateId | to_json_string | contains: '"2.16.840.1.113883.10.20.22.4.7"' -%}

@QuanWanxx QuanWanxx changed the title Personal/quwan/fix filters in if Fix filters in if tag Apr 22, 2022
@yankunhuang-pku
Copy link
Contributor

yankunhuang-pku commented Apr 24, 2022

Could you help to double confirm these changes of C-CDA templates? @hongyh13

{% include 'Resource/Condition' conditionEntry: entryRelationship.observation, ID: observationId -%}
{% assign fullObservationId = observationId | prepend: 'Condition/' -%}
{% include 'Reference/MedicationAdministration/ReasonReference' ID: substanceAdministrationId, REF: fullObservationId-%}
{% endif -%}

{% if entryRelationship.supply.templateId | to_json_string | contains '"2.16.840.1.113883.10.20.22.4.17"' -%}
{% assign templateIdString = entryRelationship.supply.templateId | to_json_string -%}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Need we double-check what happens when reassigning a new value to templateIdString?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I checked the re-assignment case, the newest assign takes effect, which means the assign behavior align with our expects.

Templates:

{
...
 {% assign templateIdString = r.observation.templateId | to_json_string -%}
 "templateIdString1": "{{ templateIdString | escape_special_chars }}",
...
{% assign templateIdString = allergyEntry.entryRelationship | to_json_string -%}
  "templateIdString2": "{{ templateIdString | escape_special_chars }}",
...
}

Result:

"templateIdString1": "{\"root\":\"2.16.840.1.113883.10.20.22.4.9\"}",
"templateIdString2": "[{\"typeCode\":\"SUBJ\",\"inversionInd\":\"true\",\"observation\":......"

@QuanWanxx QuanWanxx merged commit bb2b83d into dotliquid Apr 27, 2022
@QuanWanxx QuanWanxx deleted the personal/quwan/Fix_Filters_In_If branch April 27, 2022 03:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants