Ejemplo n.º 1
0
        private async void GetDataButton_Click(object sender, EventArgs e)
        {
            if (this.resourceSelectorComboBox.SelectedIndex == 0)
            {
                if (MessageBox.Show("You must select a Resource...", "Alert!!", MessageBoxButtons.OK) == DialogResult.OK)
                {
                    return;
                }
            }
            string uri = ConfigurationManager.AppSettings["FHIRBaseAPIURI"];

            // Ensure an ID is selected for the appropriate Resource
            if (String.IsNullOrEmpty(this.resourceIDTextBox.Text))
            {
                if (this.resourceSelectorComboBox.SelectedIndex == 1)
                {
                    if (MessageBox.Show("Please enter a Patient ID. ", "Alert!!", MessageBoxButtons.OK) == DialogResult.OK)
                    {
                        return;
                    }
                }
                else if (this.resourceSelectorComboBox.SelectedIndex == 2)
                {
                    if (MessageBox.Show("Please enter an Encounter ID. ", "Alert!!", MessageBoxButtons.OK) == DialogResult.OK)
                    {
                        return;
                    }
                }
                else
                {
                    if (MessageBox.Show("Please enter an Observation ID. ", "Alert!!", MessageBoxButtons.OK) == DialogResult.OK)
                    {
                        return;
                    }
                }
            }
            else
            {
                // Set proper URI based on the resource
                uri += @"/" + this.resourceSelectorComboBox.Text + @"/" + this.resourceIDTextBox.Text;
            }


            var result = await this.GetTokenForConfidentialClient();

            if (result != null)
            {
                this.statusTextBox.Text += "Getting ready to invoke the API" + Environment.NewLine;
                var httpClient = new HttpClient();
                var apiCaller  = new ProtectedApiCallHelper(httpClient);
                //uri = String.IsNullOrEmpty(this.resourceIDTextBox.Text) ? this._patientURI : this._patientURI + @"/" + this.resourceIDTextBox.Text;
                await apiCaller.GetDataFromAPIAsync(uri, result.AccessToken, Display);
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Method to submit a list of FHIR resources to the API
        /// </summary>
        /// <param name="fhirResources"></param>
        private async void SubmitResourcesToAPI(IList <FHIRResource> fhirResources, string token)
        {
            // Acquire Token
            //var result = await this.GetTokenForConfidentialClient();

            if (!String.IsNullOrEmpty(token))
            {
                // Iterate through each resource to submit to the API
                foreach (var fhirResource in fhirResources)
                {
                    this.statusTextBox.Text += "Getting ready to invoke the API" + Environment.NewLine;
                    var httpClient = new HttpClient();
                    var apiCaller  = new ProtectedApiCallHelper(httpClient);
                    await apiCaller.SendFHIRResourceDataToAPI(ConfigurationManager.AppSettings["FHIRBaseAPIURI"], token, fhirResource, Display);

                    Thread.Sleep(10);
                }
            }
        }
Ejemplo n.º 3
0
        private async void PostPatientData(string fileName)
        {
            using (StreamReader reader = new StreamReader(fileName))
            {
                this.statusTextBox.Text = "Reading patient data from the file..." + Environment.NewLine;
                var fileContent = reader.ReadToEnd();

                var result = await this.GetTokenForConfidentialClient();

                if (result != null)
                {
                    this.statusTextBox.Text += "Getting ready to post data to the API" + Environment.NewLine;
                    var httpClient = new HttpClient();
                    var apiCaller  = new ProtectedApiCallHelper(httpClient);
                    //var uri = String.IsNullOrEmpty(this.patientIDTextBox.Text) ? this._patientURI : this._patientURI + @"/" + this.patientIDTextBox.Text;
                    await apiCaller.PostDataToAPIAsync(ConfigurationManager.AppSettings["BundleURI"], result.AccessToken, fileContent, Display);
                }
            }
        }