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

UpperCamelCaseExpressionNameResolver configuration causing issues while working with HL7.FHIR.R4 version 5.5.1 in Handlebar.net #582

Open
kalleo1996 opened this issue May 16, 2024 · 0 comments
Labels

Comments

@kalleo1996
Copy link

Describe the bug

I've attempted to utilize fhir.r4 version 5.5.1 alongside the latest Handlebars.Net version 2.1.6. However, it appears that the configuration (UpperCamelCaseExpressionNameResolver), which we're adding to convert expression names, is causing some complications, leading to deviations from the expected behavior.
example Link : - LinkToExample

Expected behavior:

Regardless of whether we include "ExpressionNameResolver = new UpperCamelCaseExpressionNameResolver()" in the configurations, the following content should appear twice, reflecting the two entries in the bundle we provide.

<content xsi:type="OBSERVATION" archetype_node_id="openEHR-EHR-OBSERVATION.blood_pressure.v1">
    <name>
        <value>there is entry</value>
    </name>
</content>
<content xsi:type="OBSERVATION" archetype_node_id="openEHR-EHR-OBSERVATION.blood_pressure.v1">
    <name>
        <value>there is entry</value>
    </name>
</content>

Test to reproduce

full example is available in thisLink

using ConsoleApp1;
using HandlebarsDotNet;
using HandlebarsDotNet.Compiler.Resolvers;
using Hl7.Fhir.FhirPath;
using Hl7.Fhir.Model;
using Hl7.Fhir.Serialization;
using System;
using System.Collections.Generic;
using System.IO;
//Example 1
//with fhir resource data passing as data to template
var bundle = new Bundle
{
    Type = Bundle.BundleType.Collection
};

// Create the first entry
var entry1 = new Bundle.EntryComponent
{
    FullUrl = "fullurl1",
    Resource = new Observation
    {
        Id = "observation1",
        Code = new CodeableConcept("http://loinc.org", "12345", "Some observation")
    }
};

// Create the second entry
var entry2 = new Bundle.EntryComponent
{
    FullUrl = "fullurl2",
    Resource = new Observation
    {
        Id = "observation2",
        Code = new CodeableConcept("http://loinc.org", "67890", "Another observation")
    }
};

// Add the entries to the bundle
bundle.Entry.Add(entry1);
bundle.Entry.Add(entry2);

Hl7.Fhir.Model.Resource rs = bundle;
// Render the template with the bundle

var datax = new
{
    resource = rs
};

// here  having UpperCamelCaseExpressionNameResolver 
HandlebarsConfiguration s_configuration = new HandlebarsConfiguration { ExpressionNameResolver = new UpperCamelCaseExpressionNameResolver() };
//without having UpperCamelCaseExpressionNameResolver
//uncomment  the below  code  and check the behaviour without the UpperCamelCaseExpressionNameResolver
//HandlebarsConfiguration s_configuration = new HandlebarsConfiguration {  };
IHandlebars s_handlebars = Handlebars.Create(s_configuration);
var template = File.ReadAllText(@"./Textfiles/Composition-template.hbs");
var compiledTemplate = s_handlebars.Compile(template);
string templateOutput = compiledTemplate(datax);
//here with UpperCamelCaseExpressionNameResolver you will not get <content> under {{#each resource.entry}} but without UpperCamelCaseExpressionNameResolver u will get it .

Console.WriteLine(templateOutput);

Other related info

This phenomenon occurs specifically when we utilize HL7 FHIR R4 version 5.5.1 related FHIR resources. Hence, I suspect it might be attributed to a modification they implemented from their end.


After submitting the issue

please go through the issue and let me know whether there is any modification can be done to fix the given issue while we are using the specific configuration( pperCamelCaseExpressionNameResolver ) under handlebarconfigurations.

@kalleo1996 kalleo1996 added the bug label May 16, 2024
@kalleo1996 kalleo1996 changed the title Some configuration causing issues while working with HL7.FHIR.R4 version 5.5.1 UpperCamelCaseExpressionNameResolver configuration causing issues while working with HL7.FHIR.R4 version 5.5.1 in Handlebar.net May 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant