コード例 #1
0
        /// <summary>Writes an organization reports.</summary>
        /// <param name="orgId">      The organization.</param>
        /// <param name="dir">        The dir.</param>
        /// <param name="dateTime">   The period.</param>
        /// <param name="deviceData"> Information describing the device.</param>
        /// <param name="patientData">Information describing the patient.</param>
        /// <param name="testData">   Information describing the test.</param>
        /// <param name="workerData"> [out] Information describing the worker.</param>
        /// <param name="step">       Amount to increment by.</param>
        private static void WriteOrgReportBundle(
            string orgId,
            string dir,
            DateTime dateTime,
            OrgDeviceData deviceData,
            OrgPatientData patientData,
            OrgTestData testData,
            OrgWorkerData workerData,
            int step)
        {
            Dictionary <string, FieldValue> fields = OrgUtils.BuildFieldDict(
                deviceData,
                patientData,
                testData,
                workerData);

            ReportData data = new ReportData(
                dateTime,
                _orgById[orgId],
                _rootLocationByOrgId[orgId],
                fields);

            string filename = _outputFlat
                ? Path.Combine(dir, $"{orgId}-{_filenameAdditionForMeasureReports}-{step:0000}{_extension}")
                : Path.Combine(dir, $"{orgId}-{_filenameAdditionForMeasureReports}{_extension}");

            WriteBundle(
                filename,
                SanerMeasureReport.GetBundle(data, null));
        }
コード例 #2
0
        /// <summary>Creates aggregate data.</summary>
        /// <param name="orgId">      The organization.</param>
        /// <param name="deviceData"> [out] Information describing the device.</param>
        /// <param name="patientData">[out] Information describing the patient.</param>
        /// <param name="testData">   [out] Information describing the test.</param>
        /// <param name="workerData"> [out] Information describing the worker.</param>
        private static void CreateAggregateData(
            string orgId,
            out OrgDeviceData deviceData,
            out OrgPatientData patientData,
            out OrgTestData testData,
            out OrgWorkerData workerData)
        {
            int initialBedCount;

            if (_useLookup)
            {
                initialBedCount = HospitalManager.BedsForHospital(orgId);
            }
            else
            {
                initialBedCount = GeoManager.BedsForHospital();
            }

            double icuRate = (_rand.NextDouble() * (_maxIcuPercent - _minIcuPercent)) + _minIcuPercent;
            int    icuBeds = (int)(initialBedCount * icuRate);

            if (icuBeds < 1)
            {
                icuBeds = 1;
            }

            int inpatientBeds = initialBedCount - icuBeds;

            int ventilators = (int)(icuBeds * _ventilatorsPerIcu);

            if (ventilators < 1)
            {
                ventilators = 1;
            }

            // create device data for this org
            deviceData = new OrgDeviceData(
                initialBedCount,
                inpatientBeds,
                icuBeds,
                ventilators);

            // figure out patient numbers based on initial capacity
            int patients         = (int)(initialBedCount * _initialOccupancy);
            int positive         = (int)(patients * _positiveTestRate);
            int positiveNeedIcu  = (int)(positive * _patientToIcuRate);
            int positiveNeedVent = (int)(positive * _icuToVentilatorRate);
            int negative         = patients - positive;
            int negativeNeedIcu  = 0; // (int)(negative * _patientToIcuRate);
            int negativeNeedVent = 0; // (int)(negativeNeedIcu * _icuToVentilatorRate);
            int onsetInCare      = 0;
            int recovered        = 0;
            int dead             = 0;

            // create patient data
            patientData = new OrgPatientData(
                patients,
                positive,
                positiveNeedIcu,
                positiveNeedVent,
                negative,
                negativeNeedIcu,
                negativeNeedVent,
                onsetInCare,
                recovered,
                dead);

            // extrapolate test data
            int performedTests = (int)(patients / _hospitalizationRate);
            int positiveTests  = (int)(performedTests * _positiveTestRate);
            int negativeTests  = performedTests - positive;
            int pendingTests   = _rand.Next(0, 10);

            performedTests += pendingTests;

            // create test data record
            testData = new OrgTestData(
                performedTests,
                positiveTests,
                negativeTests,
                pendingTests);

            workerData = new OrgWorkerData();
        }
コード例 #3
0
        /// <summary>Updates the aggregate data for step.</summary>
        /// <param name="deviceData"> [in,out] Information describing the device.</param>
        /// <param name="patientData">[in,out] Information describing the patient.</param>
        /// <param name="testData">   [in,out] Information describing the test.</param>
        /// <param name="workerData"> [out] Information describing the worker.</param>
        private static void UpdateAggregateDataForStep(
            ref OrgDeviceData deviceData,
            ref OrgPatientData patientData,
            ref OrgTestData testData,
            ref OrgWorkerData workerData)
        {
            // increase testing
            int testDelta = (int)(testData.Performed * _changeFactor);

            if (testDelta == 0)
            {
                testDelta = 1;
            }

            int testPositiveDelta = (int)(testDelta * _positiveTestRate);
            int testNegativeDelta = testDelta - testPositiveDelta;
            int testPending       = _rand.Next(0, 10);

            int patientsShortCare =
                Math.Max(0, patientData.PositiveNeedVent - deviceData.Ventilators) +
                Math.Max(0, patientData.PositiveNeedIcu - deviceData.ICU) +
                Math.Max(0, patientData.PositiveNonIcu - deviceData.Inpatient);

            int patientsWithCare = patientData.Positive - patientsShortCare;

            double effectiveRecoveryRate = (patientData.Positive == 0)
                ? 0
                : ((_recoveryRate * patientsWithCare) + (_noResourceRecoveryRate * patientsShortCare)) /
                                           ((double)patientsWithCare + (double)patientsShortCare);

            double effectiveDeathRate = (patientData.Positive == 0)
                ? 0
                : ((_deathRate * patientsWithCare) + (_noResourceDeathRate * patientsShortCare)) /
                                        ((double)patientsWithCare + (double)patientsShortCare);

            double patientRemovalRate = effectiveDeathRate + effectiveRecoveryRate;

            int patientsRemoved = (int)(patientData.Positive * patientRemovalRate);
            int patientsDied;
            int patientsRecovered;

            if (_rand.NextDouble() < 0.5)
            {
                patientsDied      = (int)((double)patientData.Positive * effectiveDeathRate);
                patientsRecovered = patientsRemoved - patientsDied;
            }
            else
            {
                patientsRecovered = (int)((double)patientData.Positive * effectiveRecoveryRate);
                patientsDied      = patientsRemoved - patientsRecovered;
            }

            int positive = patientData.Positive
                           - patientsRemoved
                           + Math.Max((int)(testPositiveDelta * _hospitalizationRate), 1);
            int patients         = patientData.Total - patientData.Positive + positive;
            int positiveNeedIcu  = (int)(positive * _patientToIcuRate);
            int positiveNeedVent = (int)(positive * _icuToVentilatorRate);
            int negative         = patients - positive;
            int negativeNeedIcu  = 0; // (int)(negative * _patientToIcuRate);
            int negativeNeedVent = 0; // (int)(negativeNeedIcu * _icuToVentilatorRate);

            int dead      = patientData.Died + patientsDied;
            int recovered = patientData.Recovered + patientsRecovered;

            // update records
            testData.Update(
                testDelta,
                testPositiveDelta,
                testNegativeDelta,
                testPending);

            patientData.Update(
                patients,
                positive,
                positiveNeedIcu,
                positiveNeedVent,
                negative,
                negativeNeedIcu,
                negativeNeedVent,
                0,
                recovered,
                dead);

            workerData.Update();
        }