forked from microsoft/FHIR-Converter
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into mcm/fix-spec-source
- Loading branch information
Showing
4 changed files
with
143 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,16 @@ | ||
{% assign lines = Address.streetAddressLine | to_array -%} | ||
{% if lines.first._ or Address.city._ or Address.state._ or Address.country._ or Address.postalCode._ or Address.county._ -%} | ||
"use": "{{ Address.use | get_property: 'ValueSet/AddressUse' }}", | ||
|
||
"line": [ | ||
{% assign lines = Address.streetAddressLine | to_array -%} | ||
{% for l in lines -%} | ||
{%- assign lines = Address.streetAddressLine | to_array -%} | ||
{%- for l in lines -%} | ||
"{{l._}}", | ||
{% endfor -%} | ||
{%- endfor -%} | ||
], | ||
"city": "{{Address.city._}}", | ||
"state": "{{Address.state._}}", | ||
"country": "{{Address.country._}}", | ||
"postalCode": "{{Address.postalCode._}}", | ||
"district": "{{Address.county._}}", | ||
{% endif -%} | ||
"period": { {% include 'DataType/Period' Period: Address.useablePeriod %} }, | ||
{% endif -%} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
130 changes: 130 additions & 0 deletions
130
src/Microsoft.Health.Fhir.Liquid.Converter.UnitTests/Templates/eCR/DataType/AddressTests.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,130 @@ | ||
using System.Collections.Generic; | ||
using System.IO; | ||
using DotLiquid; | ||
using Xunit; | ||
|
||
namespace Microsoft.Health.Fhir.Liquid.Converter.UnitTests | ||
{ | ||
public class AddressTests : BaseECRLiquidTests | ||
{ | ||
private static readonly string ECRPath = Path.Join( | ||
TestConstants.ECRTemplateDirectory, "DataType", "_Address.liquid" | ||
); | ||
|
||
[Fact] | ||
public void GivenNoAttributeReturnsEmpty() | ||
{ | ||
ConvertCheckLiquidTemplate(ECRPath, new Dictionary<string, object>(), string.Empty); | ||
} | ||
|
||
[Fact] | ||
public void GivenSingleStreetAddresReturnsLines() | ||
{ | ||
var attributes = new Dictionary<string, object>{ | ||
{"Address", Hash.FromAnonymousObject(new { streetAddressLine = new { _ = "132 Main St" }})} | ||
}; | ||
ConvertCheckLiquidTemplate( | ||
ECRPath, | ||
attributes, | ||
@"""use"": """", ""line"": [ ""132 Main St"", ], ""city"": """", ""state"": """", ""country"": """", ""postalCode"": """", ""district"": """", ""period"": { ""start"":"""", ""end"":"""", },"); | ||
} | ||
|
||
[Fact] | ||
public void GivenArrayStreetAddresReturnsLines() | ||
{ | ||
var attributes = new Dictionary<string, object>{ | ||
{"Address", Hash.FromAnonymousObject(new { streetAddressLine = new List<object> {new {_ = "132 Main St"}, new { _ ="Unit 2"} }})} | ||
}; | ||
ConvertCheckLiquidTemplate( | ||
ECRPath, | ||
attributes, | ||
@"""use"": """", ""line"": [ ""132 Main St"", ""Unit 2"", ], ""city"": """", ""state"": """", ""country"": """", ""postalCode"": """", ""district"": """", ""period"": { ""start"":"""", ""end"":"""", },"); | ||
} | ||
|
||
[Fact] | ||
public void GivenCityReturnsCity() | ||
{ | ||
var attributes = new Dictionary<string, object>{ | ||
{"Address", Hash.FromAnonymousObject(new { city = new { _ = "Town" }})} | ||
}; | ||
ConvertCheckLiquidTemplate( | ||
ECRPath, | ||
attributes, | ||
@"""use"": """", ""line"": [ ], ""city"": ""Town"", ""state"": """", ""country"": """", ""postalCode"": """", ""district"": """", ""period"": { ""start"":"""", ""end"":"""", },"); | ||
} | ||
|
||
[Fact] | ||
public void GivenStateReturnsState() | ||
{ | ||
var attributes = new Dictionary<string, object>{ | ||
{"Address", Hash.FromAnonymousObject(new { state = new { _ = "State" }})} | ||
}; | ||
ConvertCheckLiquidTemplate( | ||
ECRPath, | ||
attributes, | ||
@"""use"": """", ""line"": [ ], ""city"": """", ""state"": ""State"", ""country"": """", ""postalCode"": """", ""district"": """", ""period"": { ""start"":"""", ""end"":"""", },"); | ||
} | ||
|
||
[Fact] | ||
public void GivenPostalCodeReturnsPostalCode() | ||
{ | ||
var attributes = new Dictionary<string, object>{ | ||
{"Address", Hash.FromAnonymousObject(new { postalCode = new { _ = "PostalCode" }})} | ||
}; | ||
ConvertCheckLiquidTemplate( | ||
ECRPath, | ||
attributes, | ||
@"""use"": """", ""line"": [ ], ""city"": """", ""state"": """", ""country"": """", ""postalCode"": ""PostalCode"", ""district"": """", ""period"": { ""start"":"""", ""end"":"""", },"); | ||
} | ||
|
||
[Fact] | ||
public void GivenCountyReturnsDistrict() | ||
{ | ||
var attributes = new Dictionary<string, object>{ | ||
{"Address", Hash.FromAnonymousObject(new { county = new { _ = "County" }})} | ||
}; | ||
ConvertCheckLiquidTemplate( | ||
ECRPath, | ||
attributes, | ||
@"""use"": """", ""line"": [ ], ""city"": """", ""state"": """", ""country"": """", ""postalCode"": """", ""district"": ""County"", ""period"": { ""start"":"""", ""end"":"""", },"); | ||
} | ||
|
||
[Fact] | ||
public void GivenCountrReturnsCountry() | ||
{ | ||
var attributes = new Dictionary<string, object>{ | ||
{"Address", Hash.FromAnonymousObject(new { country = new { _ = "Country" }})} | ||
}; | ||
ConvertCheckLiquidTemplate( | ||
ECRPath, | ||
attributes, | ||
@"""use"": """", ""line"": [ ], ""city"": """", ""state"": """", ""country"": ""Country"", ""postalCode"": """", ""district"": """", ""period"": { ""start"":"""", ""end"":"""", },"); | ||
} | ||
|
||
[Fact] | ||
public void GivenPeriodReturnsNothing() | ||
{ | ||
var attributes = new Dictionary<string, object>{ | ||
{"Address", Hash.FromAnonymousObject(new { useablePeriod = new { low = new { value = "20240313"}} })} | ||
}; | ||
ConvertCheckLiquidTemplate( | ||
ECRPath, | ||
attributes, | ||
@""); | ||
} | ||
|
||
[Fact] | ||
public void GivenPeriodAndCountryReturnsBoth() | ||
{ | ||
var attributes = new Dictionary<string, object>{ | ||
{"Address", Hash.FromAnonymousObject(new { country = new {_ = "Country" }, useablePeriod = new { low = new { value = "20240313"}} })} | ||
}; | ||
ConvertCheckLiquidTemplate( | ||
ECRPath, | ||
attributes, | ||
@"""use"": """", ""line"": [ ], ""city"": """", ""state"": """", ""country"": ""Country"", ""postalCode"": """", ""district"": """", ""period"": { ""start"":""2024-03-13"", ""end"":"""", },"); | ||
} | ||
|
||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters