Skip to content

Commit

Permalink
feat: adding conversion of profile names to fsh conversion
Browse files Browse the repository at this point in the history
  • Loading branch information
Win Swarr authored and Win Swarr committed Jun 26, 2024
1 parent 9816252 commit fc83b66
Showing 1 changed file with 46 additions and 0 deletions.
46 changes: 46 additions & 0 deletions canary/Models/Record.cs
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,18 @@ private async static Task<string> getFshData(string fhirMessage)
{
string ret = string.Empty;

string rawFsh = await getRawFshData(fhirMessage);

ret = await convertFshDataProfileNames(rawFsh);

return ret;

}

private async static Task<string> getRawFshData(string fhirMessage)
{
string ret = string.Empty;

try
{

Expand Down Expand Up @@ -266,6 +278,40 @@ private async static Task<string> getFshData(string fhirMessage)
return ret;
}


private async static Task<string> convertFshDataProfileNames(string rawFshData)
{
string ret = string.Empty;

try
{

byte[] bytes = Encoding.ASCII.GetBytes(rawFshData);

var fhrContent = Regex.Replace(rawFshData, @"(""[^""\\]*(?:\\.[^""\\]*)*"")|\s+", "$1");

var options = new RestClientOptions("https://cte-nvss-canary-a213fdc38384.azurewebsites.net")
{
MaxTimeout = -1,
};
var client = new RestClient(options);
var request = new RestRequest("/api/ConvertInstanceOf", Method.Post);
request.AddHeader("Cache-Control", "no-cache");
request.AddHeader("Host", "cte-nvss-canary-a213fdc38384.azurewebsites.net");
request.AddJsonBody(rawFshData);
RestResponse response = await client.ExecuteAsync(request);
ret = response.Content;

}
catch (Exception ex)
{
ret = ex.Message;
}
return ret;
}



/// <summary>Recursively call InnerException and add all errors to the list until we reach the BaseException.</summary>
public static List<Dictionary<string, string>> DecorateErrors(Exception e)
{
Expand Down

0 comments on commit fc83b66

Please sign in to comment.