/// <summary>Gets data from a Microsoft ECR server.</summary>
        /// <param name="baseUrl">            URL of the resource.</param>
        /// <param name="token">              The token.</param>
        /// <param name="outputDirectory">    Directory to use for export files.</param>
        /// <param name="generateCdcCsv">     True to generate CDC CSV files.</param>
        /// <param name="generateFemaXlsx">   True to generate FEMA XLSX files.</param>
        /// <param name="generateSanerBundle">True to generate FHIR SANER bundles.</param>
        private static void GetDataFromMsEcr(
            Uri baseUrl,
            string token,
            string outputDirectory,
            bool generateCdcCsv,
            bool generateFemaXlsx,
            bool generateSanerBundle)
        {
            Uri uri = new Uri(baseUrl, "/api/data/v9.0/");

            string result;

            using (HttpClient httpClient = new HttpClient())
            {
                httpClient.DefaultRequestHeaders.Authorization = new System.Net.Http.Headers.AuthenticationHeaderValue("Bearer", token);

                // get facilities
                result = httpClient.GetStringAsync(EcrFacility.GetUri(uri)).Result;
                ODataResponse <EcrFacility> facilities = JsonConvert.DeserializeObject <ODataResponse <EcrFacility> >(result);

                foreach (EcrFacility ecrFacility in facilities.Value)
                {
                    ReportData data = new ReportData();

                    LocationInfo locationInfo = new LocationInfo(
                        null,
                        ecrFacility.msft_facilityid,
                        null,
                        ecrFacility.msft_facilityname,
                        ecrFacility.msft_addressstreet,
                        ecrFacility.msft_addresscity,
                        ecrFacility.msft_addressstate,
                        null,
                        ecrFacility.msft_addresszip,
                        "US",
                        ecrFacility.msft_addresslat,
                        ecrFacility.msft_addresslong);

                    data.SetLocations(locationInfo, locationInfo, locationInfo);

                    data.AddVentilators(ecrFacility.msft_totalvents, null);

                    result = httpClient.GetStringAsync(EcrLocation.GetUri(uri, ecrFacility.msft_facilityid)).Result;
                    ODataResponse <EcrLocation> locations = JsonConvert.DeserializeObject <ODataResponse <EcrLocation> >(result);

                    foreach (EcrLocation ecrLoc in locations.Value)
                    {
                        switch (ecrLoc.msft_unit)
                        {
                        case "CARD":
                        case "ED":
                        case "GEN SURG":
                        case "MED SURG":

                            data.AddInpatientBeds(
                                ecrLoc.msft_totalbeds,
                                ecrLoc.msft_blockedbeds);

                            break;

                        case "CCU":
                        case "ICU":
                        case "NICU":
                        case "PICU":

                            data.AddIcuBeds(
                                ecrLoc.msft_totalbeds,
                                ecrLoc.msft_blockedbeds);

                            break;

                        case "TELE":
                        default:
                            break;
                        }

                        result = httpClient.GetStringAsync(EcrCovid.GetUri(uri, ecrLoc.msft_locationid)).Result;
                        ODataResponse <EcrCovid> covids = JsonConvert.DeserializeObject <ODataResponse <EcrCovid> >(result);

                        foreach (EcrCovid ecrCovid in covids.Value)
                        {
                            data.AddHospitalized(null, ecrCovid.msft_covidpos, null);
                            data.AddC19TestsToday(ecrCovid.msft_covidpui, ecrCovid.msft_covidpos, null);
                            data.AddC19TestsTotal(ecrCovid.msft_covidpui, ecrCovid.msft_covidpos, null);
                        }
                    }

                    if (generateCdcCsv)
                    {
                        WriteCdcCsv(outputDirectory, data);
                    }

                    if (generateFemaXlsx)
                    {
                        WriteFemaXlsx(outputDirectory, data);
                    }

                    if (generateSanerBundle)
                    {
                        WriteSanerJson(outputDirectory, data);
                    }
                }
            }
        }