Skip to content

Commit

Permalink
build: enable standalone builds (#12)
Browse files Browse the repository at this point in the history
Updates needed so that the project can be built as a standalone binary.

To simplify the build, I removed the dependency on the Microsoft Health OSS package registry by removing the dependency on the measurement utility, which added some timing info we aren't using.
  • Loading branch information
mcmcgrath13 authored Nov 20, 2024
1 parent b6e0055 commit 66f0bbd
Show file tree
Hide file tree
Showing 8 changed files with 11 additions and 71 deletions.
2 changes: 1 addition & 1 deletion nuget.config
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<packageSources>
<!-- When <clear /> is present, previously defined sources are ignored -->
<clear />
<add key="Microsoft Health OSS" value="https://microsofthealthoss.pkgs.visualstudio.com/FhirServer/_packaging/Public/nuget/v3/index.json" />
<add key="nuget.org" value="https://api.nuget.org/v3/index.json" />
</packageSources>
<activePackageSource>
<add key="All" value="(Aggregate source)" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
<PackageReference Include="Ensure.That" Version="10.1.0" />
<PackageReference Include="Microsoft.Extensions.Logging" Version="6.0.0" />
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="6.0.0" />
<PackageReference Include="Microsoft.Health.MeasurementUtility" Version="7.1.12" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" NoWarn="NU1605" />
<PackageReference Include="NJsonSchema" Version="10.7.2" />
<PackageReference Include="xunit.abstractions" Version="2.0.3" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
using Microsoft.Health.Fhir.Liquid.Converter.Models;
using Microsoft.Health.Fhir.Liquid.Converter.OutputProcessors;
using Microsoft.Health.Fhir.Liquid.Converter.Utilities;
using Microsoft.Health.MeasurementUtility;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;

Expand All @@ -39,25 +38,13 @@ protected BaseProcessor(ProcessorSettings processorSettings, ILogger<BaseProcess
public string Convert(string data, string rootTemplate, ITemplateProvider templateProvider, CancellationToken cancellationToken, TraceInfo traceInfo = null)
{
cancellationToken.ThrowIfCancellationRequested();
string result;
using (ITimed totalConversionTime =
Performance.TrackDuration(duration => LogTelemetry(FhirConverterMetrics.TotalDuration, duration)))
{
result = InternalConvert(data, rootTemplate, templateProvider, traceInfo);
}

string result = InternalConvert(data, rootTemplate, templateProvider, traceInfo);
return result;
}

public string Convert(string data, string rootTemplate, ITemplateProvider templateProvider, TraceInfo traceInfo = null)
{
string result;
using (ITimed totalConversionTime =
Performance.TrackDuration(duration => LogTelemetry(FhirConverterMetrics.TotalDuration, duration)))
{
result = InternalConvert(data, rootTemplate, templateProvider, traceInfo);
}

string result = InternalConvert(data, rootTemplate, templateProvider, traceInfo);
return result;
}

Expand Down Expand Up @@ -104,13 +91,7 @@ protected string InternalConvertFromObject(object data, string rootTemplate, ITe
rootTemplate = templateProvider.IsDefaultTemplateProvider ? string.Format("{0}/{1}", DefaultRootTemplateParentPath, rootTemplate) : rootTemplate;

// Step: Retrieve Template
Template template;
using (ITimed totalConversionTime =
Performance.TrackDuration(duration => LogTelemetry(FhirConverterMetrics.TemplateRetrievalDuration, duration)))
{
template = templateProvider.GetTemplate(rootTemplate);
}

Template template = templateProvider.GetTemplate(rootTemplate);
if (template == null)
{
throw new RenderException(FhirConverterErrorCode.TemplateNotFound, string.Format(Resources.TemplateNotFound, rootTemplate));
Expand All @@ -120,21 +101,10 @@ protected string InternalConvertFromObject(object data, string rootTemplate, ITe
var context = CreateContext(templateProvider, dictionary, rootTemplate);

// Step: Render Template
string rawResult;
using (ITimed templateRenderTime =
Performance.TrackDuration(duration => LogTelemetry(FhirConverterMetrics.TemplateRenderDuration, duration)))
{
rawResult = RenderTemplates(template, context);
}
string rawResult = RenderTemplates(template, context);

// Step: Post-Process
JObject result;
using (ITimed postProcessTime =
Performance.TrackDuration(duration => LogTelemetry(FhirConverterMetrics.PostProcessDuration, duration)))
{
result = PostProcessor.Process(rawResult);
}

JObject result = PostProcessor.Process(rawResult);
CreateTraceInfo(data, context, traceInfo);

return result.ToString(Formatting.Indented);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
using Microsoft.Health.Fhir.Liquid.Converter.Models;
using Microsoft.Health.Fhir.Liquid.Converter.Parsers;
using Microsoft.Health.Fhir.Liquid.Converter.Utilities;
using Microsoft.Health.MeasurementUtility;

namespace Microsoft.Health.Fhir.Liquid.Converter.Processors
{
Expand All @@ -27,13 +26,7 @@ public CcdaProcessor(ProcessorSettings processorSettings, ILogger<CcdaProcessor>

protected override string InternalConvert(string data, string rootTemplate, ITemplateProvider templateProvider, TraceInfo traceInfo = null)
{
object ccdaData;
using (ITimed inputDeserializationTime =
Performance.TrackDuration(duration => LogTelemetry(FhirConverterMetrics.InputDeserializationDuration, duration)))
{
ccdaData = _parser.Parse(data);
}

object ccdaData = _parser.Parse(data);
return InternalConvertFromObject(ccdaData, rootTemplate, templateProvider, traceInfo);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
using Microsoft.Health.Fhir.Liquid.Converter.Models.Hl7v2;
using Microsoft.Health.Fhir.Liquid.Converter.Models.Json;
using Microsoft.Health.Fhir.Liquid.Converter.Parsers;
using Microsoft.Health.MeasurementUtility;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using NJsonSchema;
Expand Down Expand Up @@ -51,13 +50,7 @@ public FhirToHl7v2Processor(ProcessorSettings processorSettings, IDataParser par

protected override string InternalConvert(string data, string rootTemplate, ITemplateProvider templateProvider, TraceInfo traceInfo = null)
{
object jsonData;
using (ITimed inputDeserializationTime =
Performance.TrackDuration(duration => LogTelemetry(FhirConverterMetrics.InputDeserializationDuration, duration)))
{
jsonData = _parser.Parse(data);
}

object jsonData = _parser.Parse(data);
var result = InternalConvertFromObject(jsonData, rootTemplate, templateProvider, traceInfo);

var hl7Message = GenerateHL7Message(ConvertToJObject(result));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
using Microsoft.Health.Fhir.Liquid.Converter.Models.Hl7v2;
using Microsoft.Health.Fhir.Liquid.Converter.Parsers;
using Microsoft.Health.Fhir.Liquid.Converter.Utilities;
using Microsoft.Health.MeasurementUtility;

namespace Microsoft.Health.Fhir.Liquid.Converter.Processors
{
Expand All @@ -30,13 +29,7 @@ public Hl7v2Processor(ProcessorSettings processorSettings, ILogger<Hl7v2Processo

protected override string InternalConvert(string data, string rootTemplate, ITemplateProvider templateProvider, TraceInfo traceInfo = null)
{
object hl7v2Data;
using (ITimed inputDeserializationTime =
Performance.TrackDuration(duration => LogTelemetry(FhirConverterMetrics.InputDeserializationDuration, duration)))
{
hl7v2Data = _parser.Parse(data);
}

object hl7v2Data = _parser.Parse(data);
return InternalConvertFromObject(hl7v2Data, rootTemplate, templateProvider, traceInfo);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
using Microsoft.Health.Fhir.Liquid.Converter.Models;
using Microsoft.Health.Fhir.Liquid.Converter.Models.Json;
using Microsoft.Health.Fhir.Liquid.Converter.Parsers;
using Microsoft.Health.MeasurementUtility;
using Newtonsoft.Json.Linq;
using NJsonSchema;

Expand All @@ -38,13 +37,7 @@ public JsonProcessor(ProcessorSettings processorSettings, IDataParser parser, IL

protected override string InternalConvert(string data, string rootTemplate, ITemplateProvider templateProvider, TraceInfo traceInfo = null)
{
object jsonData;
using (ITimed inputDeserializationTime =
Performance.TrackDuration(duration => LogTelemetry(FhirConverterMetrics.InputDeserializationDuration, duration)))
{
jsonData = _parser.Parse(data);
}

object jsonData = _parser.Parse(data);
return InternalConvertFromObject(jsonData, rootTemplate, templateProvider, traceInfo);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
<dependency id="Microsoft.Extensions.Logging" version="3.1.9" exclude="Build,Analyzers" />
<dependency id="Microsoft.Extensions.Logging.Abstractions" version="3.1.9" exclude="Build,Analyzers" />
<dependency id="Microsoft.Extensions.Options" version="5.0.0" exclude="Build,Analyzers" />
<dependency id="Microsoft.Health.MeasurementUtility" version="7.1.12" exclude="Build,Analyzers" />
<dependency id="Newtonsoft.Json" version="13.0.1" exclude="Build,Analyzers" />
<dependency id="NJsonSchema" version="10.7.2" exclude="Build,Analyzers" />
<dependency id="Polly" version="7.2.4" exclude="Build,Analyzers" />
Expand All @@ -36,4 +35,4 @@
<file src="bin\Release\net6.0\Microsoft.Health.Fhir.Liquid.Converter.dll" target="lib\net6.0" />
<file src="bin\Release\net6.0\Microsoft.Health.Fhir.TemplateManagement.dll" target="lib\net6.0" />
</files>
</package>
</package>

0 comments on commit 66f0bbd

Please sign in to comment.