Skip to content

Commit

Permalink
Add Patient Proficiency extension
Browse files Browse the repository at this point in the history
  • Loading branch information
BobanL committed Dec 21, 2024
1 parent 9ad09a2 commit 79ea6ea
Show file tree
Hide file tree
Showing 4 changed files with 157 additions and 0 deletions.
28 changes: 28 additions & 0 deletions data/Templates/eCR/Extension/_PatientProficiency.liquid
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{% if modeCode != null or proficiencyLevelCode != null %}
"url": "http://hl7.org/fhir/StructureDefinition/patient-proficiency",
"extension":
[
{% if modeCode %}
{
"url": "type",
"valueCoding":
{
"system": "http://terminology.hl7.org/CodeSystem/v3-LanguageAbilityMode",
"code": "{{ modeCode.code | downcase | get_property: 'ValueSet/LanguageAbilityMode', 'code' }}",
"display": "{{ modeCode.code | downcase | get_property: 'ValueSet/LanguageAbilityMode', 'display' }}",
},
},
{% endif -%}
{%if proficiencyLevelCode %}
{
"url": "level",
"valueCoding":
{
"system": "http://terminology.hl7.org/CodeSystem/v3-LanguageAbilityProficiency",
"code": "{{ proficiencyLevelCode.code | downcase | get_property: 'ValueSet/LanguageAbilityProficiency', 'code' }}",
"display": "{{ proficiencyLevelCode.code | downcase | get_property: 'ValueSet/LanguageAbilityProficiency', 'display' }}",
},
},
{% endif -%}
],
{% endif -%}
4 changes: 4 additions & 0 deletions data/Templates/eCR/Resource/_Patient.liquid
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,10 @@
{% if languageCommunication.preferenceInd.value -%}
"preferred": {{ languageCommunication.preferenceInd.value }},
{% endif -%}
"extension":
[
{ {% include 'Extension/PatientProficiency', modeCode: languageCommunication.modeCode, proficiencyLevelCode: languageCommunication.proficiencyLevelCode -%} },
],
},
{% endfor -%}
],
Expand Down
44 changes: 44 additions & 0 deletions data/Templates/eCR/ValueSet/ValueSet.json
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,50 @@
"code": ""
}
},
"ValueSet/LanguageAbilityMode": {
"esgn": {
"code": "ESGN",
"display": "Expressed signed"
},
"esp": {
"code": "ESP",
"display": "Expressed spoken"
},
"ewr": {
"code": "EWR",
"display": "Expressed written"
},
"rsgn": {
"code": "RSGN",
"display": "Received signed"
},
"rsp": {
"code": "RSP",
"display": "Received spoken"
},
"rwr": {
"code": "RWR",
"display": "Received written"
}
},
"ValueSet/LanguageAbilityProficiency": {
"e": {
"code": "E",
"display": "Excellent"
},
"f": {
"code": "F",
"display": "Fair"
},
"g": {
"code": "G",
"display": "Good"
},
"p": {
"code": "P",
"display": "Poor"
}
},
"ValueSet/Language": {
"en": {
"code": "en",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
using System.Collections.Generic;
using System.IO;
using Xunit;

namespace Microsoft.Health.Fhir.Liquid.Converter.UnitTests
{
public class PatientProficiencyTests : BaseECRLiquidTests
{
private static readonly string ECRPath = Path.Join(
TestConstants.ECRTemplateDirectory, "Extension", "_PatientProficiency.liquid");

[Fact]
public void GivenNoAttributeReturnsEmpty()
{
ConvertCheckLiquidTemplate(ECRPath, new Dictionary<string, object>(), string.Empty);
}

[Fact]
public void GivenModeCodeAndProficiencyLevelCodeReturnsBothInPatientProficiency()
{
var attributes = new Dictionary<string, object>
{
{
"modeCode", new Dictionary<string, string>
{
{ "code", "esp" },
}
},
{
"proficiencyLevelCode", new Dictionary<string, string>
{
{ "code", "e" },
}
},
};

ConvertCheckLiquidTemplate(
ECRPath,
attributes,
@"""url"": ""http://hl7.org/fhir/StructureDefinition/patient-proficiency"", ""extension"": [ { ""url"": ""type"", ""valueCoding"": { ""system"": ""http://terminology.hl7.org/CodeSystem/v3-LanguageAbilityMode"", ""code"": ""ESP"", ""display"": ""Expressed spoken"", }, }, { ""url"": ""level"", ""valueCoding"": { ""system"": ""http://terminology.hl7.org/CodeSystem/v3-LanguageAbilityProficiency"", ""code"": ""E"", ""display"": ""Excellent"", }, }, ],");
}

[Fact]
public void GivenModeCodeReturnsModeCodeInPatientProficiency()
{
var attributes = new Dictionary<string, object>
{
{
"modeCode", new Dictionary<string, string>
{
{ "code", "esp" },
}
},
};

ConvertCheckLiquidTemplate(
ECRPath,
attributes,
@"""url"": ""http://hl7.org/fhir/StructureDefinition/patient-proficiency"", ""extension"": [ { ""url"": ""type"", ""valueCoding"": { ""system"": ""http://terminology.hl7.org/CodeSystem/v3-LanguageAbilityMode"", ""code"": ""ESP"", ""display"": ""Expressed spoken"", }, }, ],");
}

[Fact]
public void GivenProficiencyLevelCodeReturnsProficiencyLevelCodeInPatientProficiency()
{
var attributes = new Dictionary<string, object>
{
{
"proficiencyLevelCode", new Dictionary<string, string>
{
{ "code", "e" },
}
},
};

ConvertCheckLiquidTemplate(
ECRPath,
attributes,
@"""url"": ""http://hl7.org/fhir/StructureDefinition/patient-proficiency"", ""extension"": [ { ""url"": ""level"", ""valueCoding"": { ""system"": ""http://terminology.hl7.org/CodeSystem/v3-LanguageAbilityProficiency"", ""code"": ""E"", ""display"": ""Excellent"", }, }, ],");
}
}
}

0 comments on commit 79ea6ea

Please sign in to comment.