Beispiel #1
0
        public static Results ExpandValueSet(string valueset, string filter)
        {
            Results returnValueSet = new Results();

            switch (valueset)
            {
            case "top-2000-lab-observations-us":
                var client = new Hl7.Fhir.Rest.FhirClient(FHIR_EndPoint_LOINC);

                client.OnBeforeRequest += (object msender, BeforeRequestEventArgs mer) =>
                {
                    mer.RawRequest.Headers.Add("Authorization", "Basic " + "YWJoaWppdGd1bGFiOiFJbmRpYW5hMDAx");
                };

                var response = client.ExpandValueSet(ResourceIdentity.Build("ValueSet", valueset), filter: new FhirString(filter));
                var ValueSet = response.Expansion.Contains.Select(vs => new Result {
                    id = vs.Code, text = vs.Display
                });
                returnValueSet.results = ValueSet;
                break;

            case "ucum":
                var clientRest = new RestClient(FHIR_EndPoint_UCUM);
                var request    = new RestRequest("/ValueSet/ucum/$expand", Method.GET);
                request.AddQueryParameter("filter", filter);
                request.AddQueryParameter("_format", "json");
                var responseJson = clientRest.Execute(request).Content;

                //var result = JsonConvert.DeserializeObject<ValueSet>(responseJson);
                var      parser = new Hl7.Fhir.Serialization.FhirJsonParser();
                ValueSet result = parser.Parse <ValueSet>(responseJson);
                ValueSet = result.Expansion.Contains.Select(vs => new Result {
                    id = vs.Code, text = vs.Display
                });
                returnValueSet.results = ValueSet;
                break;

            default:
                returnValueSet.results = new List <Result>();
                break;
            }

            return(returnValueSet);
        }