Skip to content

Instantly share code, notes, and snippets.

@MattCordell
Created March 15, 2019 05:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save MattCordell/194668f1de5944df47626e1a07ccb29b to your computer and use it in GitHub Desktop.
Save MattCordell/194668f1de5944df47626e1a07ccb29b to your computer and use it in GitHub Desktop.
FHIR translate in C#
Console.WriteLine("Let's try translate!");
//Translate parameters
var revsertTranslateParameters = new Parameters
{
Parameter = new List<Parameters.ParameterComponent>
{
new Parameters.ParameterComponent
{
Name = "url",
Value = new FhirUri("http://snomed.info/sct?fhir_cm=281000036105")
},
new Parameters.ParameterComponent
{
Name = "system",
Value = new FhirUri("http://snomed.info/sct")
},
new Parameters.ParameterComponent
{
Name = "code",
Value = new FhirString("419442005")
},
new Parameters.ParameterComponent
{
Name = "target",
Value = new FhirUri("http://snomed.info/sct")
},
new Parameters.ParameterComponent
{
Name = "reverse",
Value = new FhirBoolean(true)
}
}
};
//Do the translation
var transResult = (Parameters)client.TypeOperation<ConceptMap>("translate", revsertTranslateParameters);
//Success or not?
Console.WriteLine(transResult.Parameter.First().Name + " : " + transResult.Parameter.First().Value.ToString());
//Get the actual "Coding" for each match.
foreach (var match in transResult.Parameter.Where<Parameters.ParameterComponent>(e => e.Name=="match"))
{
var valueCoding = match.Part.Where<Parameters.ParameterComponent>(p => p.Name.Equals("concept")).FirstOrDefault();
var coding = (Coding)valueCoding.Value;
Console.WriteLine(coding.Code + " " + coding.Display);
}
Console.WriteLine("Done");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment