コード例 #1
0
        /// <summary>Updates the bed configuration.</summary>
        /// <param name="bed"> [in,out] The bed.</param>
        /// <param name="next">The next.</param>
        public static void UpdateBedConfiguration(
            ref Location bed,
            BedConfiguration next)
        {
            if (bed == null)
            {
                throw new ArgumentNullException(nameof(bed));
            }

            if (next == null)
            {
                throw new ArgumentNullException(nameof(next));
            }

            bed.Status            = GetLocationStatus(next.Availability);
            bed.OperationalStatus = FhirTriplet.OperationalStatus(next.Status).GetCoding();
        }
コード例 #2
0
        /// <summary>Generates a measure report.</summary>
        /// <param name="org">           The organization.</param>
        /// <param name="parentLocation">The parent location.</param>
        /// <param name="period">        The period.</param>
        /// <param name="bedsByConfig">  The beds by configuration.</param>
        /// <returns>The measure report.</returns>
        public static MeasureReport GenerateBedMeasureReportV01(
            Organization org,
            Location parentLocation,
            Period period,
            Dictionary <BedConfiguration, List <Location> > bedsByConfig)
        {
            if (org == null)
            {
                throw new ArgumentNullException(nameof(org));
            }

            if (parentLocation == null)
            {
                throw new ArgumentNullException(nameof(parentLocation));
            }

            if (period == null)
            {
                throw new ArgumentNullException(nameof(period));
            }

            if (bedsByConfig == null)
            {
                throw new ArgumentNullException(nameof(bedsByConfig));
            }

            int totalBedCount = 0;
            List <MeasureReport.StratifierGroupComponent> stratums = new List <MeasureReport.StratifierGroupComponent>();

            foreach (BedConfiguration bedConfig in bedsByConfig.Keys)
            {
                if (bedsByConfig[bedConfig].Count == 0)
                {
                    continue;
                }

                totalBedCount += bedsByConfig[bedConfig].Count;

                stratums.Add(new MeasureReport.StratifierGroupComponent()
                {
                    MeasureScore = new Quantity(bedsByConfig[bedConfig].Count, "Number"),
                    Component    = new List <MeasureReport.ComponentComponent>()
                    {
                        new MeasureReport.ComponentComponent()
                        {
                            Code  = FhirTriplet.SanerAvailabilityStatus.GetConcept(),
                            Value = FhirTriplet.AvailabilityStatus(bedConfig.Availability).GetConcept(),
                        },
                        new MeasureReport.ComponentComponent()
                        {
                            Code  = FhirTriplet.SanerOperationalStatus.GetConcept(),
                            Value = FhirTriplet.OperationalStatus(bedConfig.Status).GetConcept(),
                        },
                        new MeasureReport.ComponentComponent()
                        {
                            Code  = FhirTriplet.SanerType.GetConcept(),
                            Value = FhirTriplet.BedType(bedConfig.Type).GetConcept(),
                        },
                        new MeasureReport.ComponentComponent()
                        {
                            Code  = FhirTriplet.SanerFeature.GetConcept(),
                            Value = FhirTriplet.BedFeature(bedConfig.Feature).GetConcept(),
                        },
                        new MeasureReport.ComponentComponent()
                        {
                            Code  = FhirTriplet.SanerLocation.GetConcept(),
                            Value = new CodeableConcept(
                                $"{SystemLiterals.SanerCharacteristic}/partOf",
                                $"{parentLocation.ResourceType}/{parentLocation.Id}"),
                        },
                    },
                });
            }

            MeasureReport.GroupComponent component = new MeasureReport.GroupComponent()
            {
                MeasureScore = new Quantity(totalBedCount, "Number"),
                Stratifier   = new List <MeasureReport.StratifierComponent>()
                {
                    new MeasureReport.StratifierComponent()
                    {
                        Stratum = stratums,
                    },
                },
            };

            return(new MeasureReport()
            {
                Id = NextId,
                Status = MeasureReport.MeasureReportStatus.Complete,
                Type = MeasureReport.MeasureReportType.Summary,
                Date = new FhirDateTime(new DateTimeOffset(DateTime.Now)).ToString(),
                Period = period,
                Measure = SystemLiterals.MeasureReportMeasurement,
                Reporter = new ResourceReference($"{org.ResourceType}/{org.Id}"),
                Group = new List <MeasureReport.GroupComponent>()
                {
                    component
                },
                Text = new Narrative()
                {
                    Div = $"<div xmlns=\"http://www.w3.org/1999/xhtml\">" +
                          $" {org.Name} Bed report for" +
                          $" {period.Start.ToString(CultureInfo.InvariantCulture)}" +
                          $" to" +
                          $" {period.End.ToString(CultureInfo.InvariantCulture)}</div>",
                },
            });
        }
コード例 #3
0
        /// <summary>Generates a group.</summary>
        /// <exception cref="ArgumentNullException">Thrown when one or more required arguments are null.</exception>
        /// <param name="org">           The managing organization.</param>
        /// <param name="parentLocation">The parent location.</param>
        /// <param name="name">          The name.</param>
        /// <param name="bedConfig">     The bed configuration this group represents.</param>
        /// <param name="bedCount">      Number of beds.</param>
        /// <param name="period">        The period.</param>
        /// <returns>The group.</returns>
        public static Group GenerateGroup(
            Organization org,
            Location parentLocation,
            string name,
            BedConfiguration bedConfig,
            int bedCount,
            Period period)
        {
            if (org == null)
            {
                throw new ArgumentNullException(nameof(org));
            }

            if (parentLocation == null)
            {
                throw new ArgumentNullException(nameof(parentLocation));
            }

            if (bedConfig == null)
            {
                throw new ArgumentNullException(nameof(bedConfig));
            }

            List <Group.CharacteristicComponent> characteristics = new List <Group.CharacteristicComponent>()
            {
                new Group.CharacteristicComponent()
                {
                    Code    = FhirTriplet.SanerAvailabilityStatus.GetConcept(),
                    Value   = FhirTriplet.AvailabilityStatus(bedConfig.Availability).GetConcept(),
                    Exclude = false,
                },
                new Group.CharacteristicComponent()
                {
                    Code    = FhirTriplet.SanerOperationalStatus.GetConcept(),
                    Value   = FhirTriplet.OperationalStatus(bedConfig.Status).GetConcept(),
                    Exclude = false,
                },
                new Group.CharacteristicComponent()
                {
                    Code    = FhirTriplet.SanerType.GetConcept(),
                    Value   = FhirTriplet.BedType(bedConfig.Type).GetConcept(),
                    Exclude = false,
                },
                new Group.CharacteristicComponent()
                {
                    Code    = FhirTriplet.SanerFeature.GetConcept(),
                    Value   = FhirTriplet.BedFeature(bedConfig.Feature).GetConcept(),
                    Exclude = false,
                },
                new Group.CharacteristicComponent()
                {
                    Code    = FhirTriplet.SanerLocation.GetConcept(),
                    Value   = new ResourceReference($"{parentLocation.ResourceType}/{parentLocation.Id}"),
                    Exclude = false,
                },
                new Group.CharacteristicComponent()
                {
                    // Code = FhirTriplet.SanerPeriod.GetConcept(),
                    Code    = FhirTriplet.MeasureReportPeriod.GetConcept(),
                    Value   = FhirTriplet.EmptyRequired.GetConcept(),
                    Period  = period,
                    Exclude = false,
                },
            };

            return(new Group()
            {
                Id = NextId,
                Type = Group.GroupType.Device,
                Actual = true,
                Code = FhirTriplet.PhysicalTypeBed.GetConcept(),
                Name = name,
                Quantity = bedCount,
                ManagingEntity = new ResourceReference($"{org.ResourceType}/{org.Id}"),
                Characteristic = characteristics,
                Text = new Narrative()
                {
                    Div = $"<div xmlns=\"http://www.w3.org/1999/xhtml\">" +
                          $" {org.Name} Beds of type: {bedConfig.Type} ({bedConfig.Feature})" +
                          $" Flagged {bedConfig.Availability} and {bedConfig.Status}</div>",
                },
            });
        }
コード例 #4
0
        /// <summary>Builds a questionnaire.</summary>
        /// <exception cref="ArgumentNullException">Thrown when one or more required arguments are null.</exception>
        /// <param name="format">Describes the format to use.</param>
        /// <returns>A Questionnaire.</returns>
        private static Questionnaire BuildQuestionnaire(
            IReportingFormat format)
        {
            if (format == null)
            {
                throw new ArgumentNullException(nameof(format));
            }

            if (string.IsNullOrEmpty(format.Name))
            {
                throw new ArgumentNullException(nameof(format), $"Invalid IReportingFormat.Name: {format.Name}");
            }

            if ((format.Fields == null) || (format.Fields.Count == 0))
            {
                throw new ArgumentNullException(nameof(format), $"Invalid IReportingFormat.Fields: {format.Fields}");
            }

            if ((format.QuestionnaireSections == null) || (format.QuestionnaireSections.Count == 0))
            {
                throw new ArgumentNullException(nameof(format), $"Invalid IReportingFormat.QuestionnaireSections: {format.QuestionnaireSections}");
            }

            Questionnaire questionnaire = new Questionnaire()
            {
                Meta = new Meta()
                {
                    Profile = new string[]
                    {
                        FhirSystems.Questionnaire,
                    },
                },
                Id           = format.Name,
                Name         = format.Name,
                Url          = $"{CanonicalUrl}/Questionnaire/{format.Name}",
                Version      = QuestionnaireVersion,
                Title        = format.Title,
                Description  = new Markdown(format.Description),
                Status       = PublicationStatus.Draft,
                Date         = PublicationDate,
                Publisher    = Publisher,
                Jurisdiction = new List <CodeableConcept>()
                {
                    FhirTriplet.UnitedStates.GetConcept(),
                },
                UseContext = new List <UsageContext>()
                {
                    new UsageContext()
                    {
                        Code  = FhirTriplet.GetCode(FhirSystems.UsageContextType, CommonLiterals.ContextFocus),
                        Value = FhirTriplet.SctCovid.GetConcept(),
                    },
                },
                Item = new List <Questionnaire.ItemComponent>(),
            };

            int sectionNumber = -1;
            int itemNumber    = 0;

            foreach (QuestionnaireSection questionnaireSection in format.QuestionnaireSections)
            {
                sectionNumber++;
                itemNumber = 0;

                Questionnaire.ItemComponent section = new Questionnaire.ItemComponent()
                {
                    LinkId  = $"section_{sectionNumber}",
                    Type    = Questionnaire.QuestionnaireItemType.Group,
                    Item    = new List <Questionnaire.ItemComponent>(),
                    Repeats = false,
                };

#if false   // 2020.05.13 - Argonaut extensions aren't valid in R4 yet
                section.AddExtension(
                    "http://fhir.org/guides/argonaut/questionnaire/StructureDefinition/extension-itemOrder",
                    new FhirDecimal(sectionNumber));
#endif

                if (format.Fields.ContainsKey(questionnaireSection.Title))
                {
                    section.Text = $"{format.Fields[questionnaireSection.Title].Title}: {format.Fields[questionnaireSection.Title].Description}";
                }
                else
                {
                    section.Text = questionnaireSection.Title;
                }

                foreach (QuestionnaireQuestion question in questionnaireSection.Fields)
                {
                    Questionnaire.ItemComponent component = ComponentFromQuestion(
                        format,
                        question,
                        ref itemNumber);

                    if (component == null)
                    {
                        continue;
                    }

                    section.Item.Add(component);
                }

                questionnaire.Item.Add(section);
            }

            return(questionnaire);
        }
コード例 #5
0
        /// <summary>Builds a measure.</summary>
        /// <exception cref="ArgumentNullException">Thrown when one or more required arguments are null.</exception>
        /// <param name="format">Describes the format to use.</param>
        /// <returns>A Measure.</returns>
        private static Measure BuildMeasure(
            IReportingFormat format)
        {
            if (format == null)
            {
                throw new ArgumentNullException(nameof(format));
            }

            if (string.IsNullOrEmpty(format.Name))
            {
                throw new ArgumentNullException(nameof(format), $"Invalid IReportingFormat.Name: {format.Name}");
            }

            if ((format.Fields == null) || (format.Fields.Count == 0))
            {
                throw new ArgumentNullException(nameof(format), $"Invalid IReportingFormat.Fields: {format.Fields}");
            }

            if ((format.MeasureGroupings == null) || (format.MeasureGroupings.Count == 0))
            {
                throw new ArgumentNullException(nameof(format), $"Invalid IReportingFormat.MeasureGroupings: {format.MeasureGroupings}");
            }

            Measure measure = new Measure()
            {
                Meta = new Meta()
                {
                    Profile = new string[]
                    {
                        FhirSystems.Measure,
                        "http://hl7.org/fhir/us/saner/StructureDefinition/PublicHealthMeasure",
                    },
                },
                Id           = format.Name,
                Name         = format.Name,
                Url          = $"{CanonicalUrl}/Measure/{format.Name}",
                Version      = MeasureVersion,
                Title        = format.Title,
                Description  = new Markdown(format.Description),
                Status       = PublicationStatus.Draft,
                Experimental = true,
                Subject      = FhirTriplet.ResourceLocation.GetConcept(),
                Date         = PublicationDate,
                Publisher    = Publisher,
                Jurisdiction = new List <CodeableConcept>()
                {
                    FhirTriplet.UnitedStates.GetConcept(),
                },
                UseContext = new List <UsageContext>()
                {
                    new UsageContext()
                    {
                        Code  = FhirTriplet.GetCode(FhirSystems.UsageContextType, CommonLiterals.ContextFocus),
                        Value = FhirTriplet.SctCovid.GetConcept(),
                    },
                },
                Type = new List <CodeableConcept>()
                {
                    FhirTriplet.MeasureTypeComposite.GetConcept(),
                },
                Group   = new List <Measure.GroupComponent>(),
                Contact = SanerCommon.Contacts,
                Author  = format.Authors,
            };

            if ((format.Definition != null) && (format.Definition.Count > 0))
            {
                measure.Definition = new List <Markdown>();
                foreach (string definition in format.Definition)
                {
                    measure.Definition.Add(new Markdown(definition));
                }
            }

            if (format.Artifacts != null)
            {
                measure.RelatedArtifact = new List <RelatedArtifact>();
                measure.RelatedArtifact.AddRange(format.Artifacts);
            }

            foreach (MeasureGrouping grouping in format.MeasureGroupings)
            {
                if (grouping.CodeCoding != null)
                {
                    measure.Group.Add(GroupComponentFromNested(grouping, format));
                    continue;
                }

                if ((!string.IsNullOrEmpty(grouping.FieldName)) &&
                    format.Fields.ContainsKey(grouping.FieldName))
                {
                    measure.Group.Add(GroupComponentFromFlat(grouping, format));
                }
            }

            return(measure);
        }