Example #1
0
        /// <summary>
        /// Create the records and post to the given endpoint
        /// </summary>
        /// <param name="endpointNumber"></param>
        /// <returns></returns>
        public JsonResult CreateAndPostData(int endpointNumber)
        {
            string endpoint = "";

            switch (endpointNumber)
            {
            case 1:
                //MiHIN
                endpoint = "http://52.72.172.54:8080/fhir/baseDstu2/";
                break;

            case 2:
                //Georgia Tech
                endpoint = "http://polaris.i3l.gatech.edu:8080/gt-fhir-webapp/base/";
                break;

            case 3:
                //custom
                endpoint = "http://104.197.124.155/gt-fhir-webapp/base/";
                break;

            case 4:
                //smartfhir
                endpoint = "https://fhir-open-api-dstu2.smarthealthit.org";
                break;

            default:
                break;
            }


            CreatedDataContainer data = CreateData();

            return(PostData(data, endpoint));
        }
Example #2
0
        /// <summary>
        /// Try to post the data
        /// </summary>
        /// <param name="data"></param>
        /// <returns>True if successfull</returns>
        public JsonResult PostData(CreatedDataContainer data, string endpoint)
        {
            //establish client
            var fhirClient = new FhirClient(endpoint);

            int patUpdSuccess  = 0;
            int obsUpdSuccess  = 0;
            int condUpdSuccess = 0;
            int patUpdFail     = 0;
            int obsUpdFail     = 0;
            int condUpdFail    = 0;


            //add the patients
            foreach (var patient in data.Patients)
            {
                try
                {
                    fhirClient.Update(patient);
                    patUpdSuccess++;
                }
                catch (Exception ex)
                {
                    patUpdFail++;
                }
            }

            //add the observations
            foreach (var observation in data.Observations)
            {
                try
                {
                    fhirClient.Update(observation);
                    obsUpdSuccess++;
                }
                catch (Exception ex)
                {
                    obsUpdFail++;
                }
            }

            //add the conditions
            foreach (var condition in data.Conditions)
            {
                try
                {
                    fhirClient.Update(condition);
                    condUpdSuccess++;
                }
                catch (Exception ex)
                {
                    condUpdFail++;
                }
            }

            string resultsString = "Patient Updates S:" + patUpdSuccess + " F:" + patUpdFail + Environment.NewLine
                                   + "Observation Updates S:" + obsUpdSuccess + " F:" + obsUpdFail + Environment.NewLine
                                   + "Condition Updates S:" + condUpdSuccess + " F:" + condUpdFail + Environment.NewLine;

            return(Json(resultsString));
        }