Skip to content

Commit

Permalink
Update DotLiquid (#381)
Browse files Browse the repository at this point in the history
* Update DotLiquid

* Remove useless comments

* Fix incorrect template

* Use GetValueOrDefault in SectionFilter

Co-authored-by: sowu880 <57981365+sowu880@users.noreply.github.com>
  • Loading branch information
QuanWanxx and sowu880 committed Apr 21, 2022
1 parent bcd3a25 commit dc17525
Show file tree
Hide file tree
Showing 7 changed files with 22 additions and 22 deletions.
14 changes: 6 additions & 8 deletions data/Templates/Ccda/Resource/_AllergyIntolerance.liquid
Original file line number Diff line number Diff line change
Expand Up @@ -42,15 +42,13 @@
],
"onset": "{{ r.observation.effectiveTime.low.value | format_as_date_time }}",
{% endif -%}
{% for templateId in r.observation.templateId -%}
{% if templateId.root == "2.16.840.1.113883.10.20.22.4.8" -%}
{% if r.observation.value.translation -%}
"severity":"{{ r.observation.value.translation.displayName | downcase | get_property: 'ValueSet/AllergySeverity' }}",
{% else -%}
"severity":"{{ r.observation.value.displayName | downcase | get_property: 'ValueSet/AllergySeverity' }}",
{% endif -%}
{% if r.observation.templateId | to_json_string | contains: '"2.16.840.1.113883.10.20.22.4.8"' -%}
{% if r.observation.value.translation -%}
"severity":"{{ r.observation.value.translation.displayName | downcase | get_property: 'ValueSet/AllergySeverity' }}",
{% else -%}
"severity":"{{ r.observation.value.displayName | downcase | get_property: 'ValueSet/AllergySeverity' }}",
{% endif -%}
{% endfor -%}
{% endif -%}
},
{% endfor -%}

Expand Down
2 changes: 1 addition & 1 deletion data/Templates/Stu3ToR4/CarePlan.liquid
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{% mergeDiff msg -%}
{
"contained" : [ {{msg.contained | to_array | batch_render : 'Resource', 'msg'}} ],
"instantiatesCanonical" : {% include 'DataType/ReferenceToCanonical'' msg: msg.definition -%},
"instantiatesCanonical" : {% include 'DataType/ReferenceToCanonical' msg: msg.definition -%},
"encounter" : {{msg.context | to_json_string | default : '""'}},
"activity" : [ {{ msg.activity | to_array | batch_render: 'CarePlan/Activity', 'msg' }} ],
"context" : "",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -726,7 +726,8 @@
}
]
}
]
],
"severity": "mild"
}
],
"patient": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -905,7 +905,8 @@
}
]
}
]
],
"severity": "mild"
}
],
"patient": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1033,7 +1033,8 @@
}
]
}
]
],
"severity": "mild"
}
],
"patient": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;
using DotLiquid;

namespace Microsoft.Health.Fhir.Liquid.Converter
{
Expand All @@ -18,7 +17,7 @@ public partial class Filters
{
private static readonly Regex NormalizeSectionNameRegex = new Regex("[^A-Za-z0-9]");

public static IDictionary<string, object> GetFirstCcdaSections(Hash data, string sectionNameContent)
public static IDictionary<string, object> GetFirstCcdaSections(IDictionary<string, object> data, string sectionNameContent)
{
var sectionLists = Filters.GetCcdaSectionLists(data, sectionNameContent);
var result = new Dictionary<string, object>();
Expand All @@ -30,7 +29,7 @@ public static IDictionary<string, object> GetFirstCcdaSections(Hash data, string
return result;
}

public static IDictionary<string, object> GetCcdaSectionLists(Hash data, string sectionNameContent)
public static IDictionary<string, object> GetCcdaSectionLists(IDictionary<string, object> data, string sectionNameContent)
{
var result = new Dictionary<string, object>();
var sectionNames = sectionNameContent.Split("|", StringSplitOptions.RemoveEmptyEntries);
Expand Down Expand Up @@ -67,7 +66,7 @@ public static IDictionary<string, object> GetCcdaSectionLists(Hash data, string
return result;
}

public static IDictionary<string, object> GetFirstCcdaSectionsByTemplateId(Hash data, string templateIdContent)
public static IDictionary<string, object> GetFirstCcdaSectionsByTemplateId(IDictionary<string, object> data, string templateIdContent)
{
var result = new Dictionary<string, object>();
var templateIds = templateIdContent.Split("|", StringSplitOptions.RemoveEmptyEntries);
Expand Down Expand Up @@ -96,12 +95,12 @@ public static IDictionary<string, object> GetFirstCcdaSectionsByTemplateId(Hash
return result;
}

private static List<object> GetComponents(Hash data)
private static List<object> GetComponents(IDictionary<string, object> data)
{
var dataComponents = (((data["ClinicalDocument"] as Hash)?
["component"] as Hash)?
["structuredBody"] as Hash)?
["component"];
var dataComponents = (((data["ClinicalDocument"] as Dictionary<string, object>)?
.GetValueOrDefault("component") as Dictionary<string, object>)?
.GetValueOrDefault("structuredBody") as Dictionary<string, object>)?
.GetValueOrDefault("component");

if (dataComponents == null)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

<ItemGroup>
<PackageReference Include="Antlr4.Runtime.Standard" Version="4.8.0" />
<PackageReference Include="DotLiquid" Version="2.0.366" />
<PackageReference Include="DotLiquid" Version="2.2.580" />
<PackageReference Include="Microsoft.Extensions.Logging" Version="3.1.9" />
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="3.1.9" />
<PackageReference Include="Newtonsoft.Json" Version="12.0.3" />
Expand Down

0 comments on commit dc17525

Please sign in to comment.