Created
March 15, 2019 05:23
-
-
Save MattCordell/194668f1de5944df47626e1a07ccb29b to your computer and use it in GitHub Desktop.
FHIR translate in C#
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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