Exemplo n.º 1
0
        /// <summary>
        /// Validates this result value
        /// </summary>
        /// <param name="path">The path to this object as a string</param>
        /// <param name="messages">the validation messages to date, these may be added to within this method</param>
        public void Validate(string path, List <ValidationMessage> messages)
        {
            var validationBuilder = new ValidationBuilder(path, messages);

            if (ValueAsCodableText != null)
            {
                ValueAsCodableText.Validate(validationBuilder.Path + "ValueAsCodableText", messages);
            }

            if (TestResultValue != null)
            {
                TestResultValue.Validate(validationBuilder.Path + "TestResultValue", messages);
            }

            if (ValueAsQuantityRange != null)
            {
                ValueAsQuantityRange.Validate(validationBuilder.Path + "ValueAsQuantityRange", messages);
            }

            var choiceDictionary = new Dictionary <String, object>
            {
                { "ValueAsCodableText", ValueAsCodableText },
                { "ValueAsQuantity", TestResultValue },
                { "ValueAsQuantityRange", ValueAsQuantityRange }
            };

            validationBuilder.ChoiceCheck(choiceDictionary);
        }
        /// <summary>
        /// Validates this Reviewed Immunisations
        /// </summary>
        /// <param name="path">The path to this object as a string</param>
        /// <param name="messages">the validation messages, these may be added to within this method</param>
        public void Validate(string path, List <ValidationMessage> messages)
        {
            var vb = new ValidationBuilder(path, messages);

            if (AdministeredImmunisation != null)
            {
                for (var x = 0; x < AdministeredImmunisation.Count; x++)
                {
                    AdministeredImmunisation[x].Validate
                    (
                        vb.Path + string.Format("AdministeredImmunisation[{0}]", x), vb.Messages
                    );
                }
            }

            if (ExclusionStatement != null)
            {
                ExclusionStatement.Validate(vb.Path + "GeneralStatement", vb.Messages);
            }

            // Recommendations exclusion statement choice
            var medicationsChoice = new Dictionary <string, object>()
            {
                { "AdministeredImmunisations", AdministeredImmunisation },
                { "ExclusionStatement", ExclusionStatement }
            };

            vb.ChoiceCheck(medicationsChoice);
        }
Exemplo n.º 3
0
        /// <summary>
        /// Validates this medications object as a reviewed medications
        /// </summary>
        /// <param name="path">The path to this object as a string</param>
        /// <param name="messages">the validation messages to date, these may be added to within this method</param>
        void IMedications.Validate(string path, List <ValidationMessage> messages)
        {
            var vb = new ValidationBuilder(path, messages);

            var medicationsList = ((IMedications)this).Medications;

            if (medicationsList != null)
            {
                for (var x = 0; x < medicationsList.Count; x++)
                {
                    medicationsList[x].Validate(vb.Path + string.Format("MedicationsList[{0}]", x), vb.Messages);
                }
            }

            // Medications exclusion statement choice
            var adverseChoice = new Dictionary <string, object>()
            {
                { "Medications", medicationsList },
                { "GeneralStatement", ExclusionStatement }
            };

            vb.ChoiceCheck(adverseChoice);

            // Validate exclusion statement
            if (ExclusionStatement != null)
            {
                ExclusionStatement.Validate(vb.Path + "GeneralStatement", vb.Messages);
            }
        }
Exemplo n.º 4
0
        /// <summary>
        /// Validates this Adverse Substance Reaction
        /// </summary>
        /// <param name="path">The path to this object as a string</param>
        /// <param name="messages">the validation messages, these may be added to within this method</param>
        public void Validate(string path, List <ValidationMessage> messages)
        {
            var vb = new ValidationBuilder(path, messages);

            if (AdverseSubstanceReaction != null)
            {
                for (var x = 0; x < AdverseSubstanceReaction.Count; x++)
                {
                    AdverseSubstanceReaction[x].Validate(vb.Path + string.Format("AdverseSubstanceReaction[{0}]", x), vb.Messages);
                }
            }

            // Adverse reactions exclusion statement choice
            var adverseChoice = new Dictionary <string, object>()
            {
                { "AdverseSubstanceReaction", AdverseSubstanceReaction },
                { "GeneralStatement", ExclusionStatement }
            };

            vb.ChoiceCheck(adverseChoice);

            // Validate exclusion statement
            if (ExclusionStatement != null)
            {
                ExclusionStatement.Validate(vb.Path + "GeneralStatement", vb.Messages);
            }
        }
Exemplo n.º 5
0
        /// <summary>
        /// Validates this address as an IAddress
        /// </summary>
        /// <param name="path">The path to this object as a string</param>
        /// <param name="messages">the validation messages to date, these may be added to within this method</param>
        void IAddress.Validate(string path, List <ValidationMessage> messages)
        {
            var vb = new ValidationBuilder(path, messages);

            var addressChoice = new Dictionary <string, object>
            {
                { "AustralianAddress", AustralianAddress },
                { "InternationalAddress", InternationalAddress }
            };

            if (!AddressAbsentIndicator.HasValue)
            {
                if (vb.ChoiceCheck(addressChoice))
                {
                    if (AustralianAddress != null)
                    {
                        AustralianAddress.Validate(vb.Path + "AustralianAddress", messages);
                    }
                    else if (InternationalAddress != null)
                    {
                        InternationalAddress.Validate(vb.Path + "InternationalAddress", messages);
                    }

                    //vb.NoMatchCheck("AddressPurpose", AddressPurpose, AddressPurpose.Undefined);
                }
            }

            // 20/04/2018 Removed restriction as it does not seem relevant now

            //if (!(path.ToLowerInvariant().Contains("consumerenterednotes.scscontext.subjectofcare.participant.addresses")
            //          || path.ToLowerInvariant().Contains("consumerenteredhealthsummary.scscontext.subjectofcare.participant.addresses")
            //          || path.ToLowerInvariant().Contains("advancedcaredirective.scscontext.subjectofcare.participant.addresses")
            //          || path.ToLowerInvariant().Contains("nswhealthcheckassessment.scscontext.subjectofcare.participant.addresses")
            //          || path.ToLowerInvariant().Contains("personalhealthobservation.scscontext.subjectofcare.participant.addresses")
            //          || path.ToLowerInvariant().Contains("consumerquestionnaire.scscontext.subjectofcare.participant.addresses")
            //          || path.ToLowerInvariant().Contains("birthdetailsrecord.scscontext.subjectofcare.participant.addresses")
            //          || path.ToLowerInvariant().Contains("consumerenteredachievements.scscontext.subjectofcare.participant.addresses")
            //          || path.ToLowerInvariant().Contains("consumerquestionnaire.scscontext.subjectofcare.participant.addresses")
            //          || path.ToLowerInvariant().Contains("nswhealthcheckassessment.scscontext.subjectofcare.participant.addresses")
            //          || path.ToLowerInvariant().Contains("personalhealthobservation.scscontext.subjectofcare.participant.addresses")
            //          )
            //      )
            //{
            //    if (AddressAbsentIndicator != null)
            //    {
            //        if (AddressAbsentIndicator == CDA.Common.Enums.AddressAbsentIndicator.NotIndicated || AddressAbsentIndicator == CDA.Common.Enums.AddressAbsentIndicator.NotKnown)
            //        {
            //            vb.AddValidationMessage(vb.PathName, AddressAbsentIndicator.ToString(), "SubjectOfCare.Participant.Address null Flavor can only be 'No Fixed Addresss Indicator' for this document type");
            //        }
            //    }
            //}
        }
        /// <summary>
        /// Validates this StructuredText text (field is Mandatory)
        /// </summary>
        /// <param name="path">The path to this object as a string</param>
        /// <param name="messages">the validation messages to date, these may be added to within this method</param>
        public void Validate(string path, List <ValidationMessage> messages)
        {
            var vb = new ValidationBuilder(path, messages);

            // Directions can only contain a Directions or a NullFlavour
            var choiceCheck = new Dictionary <string, object>()
            {
                { "Text", Text },
                { "NullFlavour", NullFlavour }
            };

            vb.ChoiceCheck(choiceCheck);
        }
Exemplo n.º 7
0
        /// <summary>
        /// Validates the CdaInterval.
        /// </summary>
        /// <param name="path">The path to this object as a string</param>
        /// <param name="messages">the validation messages to date, these may be added to within this method</param>
        public void Validate(string path, List <ValidationMessage> messages)
        {
            var vb = new ValidationBuilder(path, messages);

            // Encounter Period can only contain a Encounter Period NullFlavor or a Encounter Period
            var participationPeriodDictionary = new Dictionary <string, object>()
            {
                { "Interval", Interval },
                { "Value", Value }
            };

            vb.ChoiceCheck(participationPeriodDictionary);
        }
        /// <summary>
        /// Validates this IAnatomicalSiteExtended Site
        /// </summary>
        /// <param name="path">The path to this object as a string</param>
        /// <param name="messages">the validation messages to date, these may be added to within this method</param>
        void IAnatomicalSiteExtended.Validate(string path, List <ValidationMessage> messages)
        {
            var vb = new ValidationBuilder(path, messages);

            if (SpecificLocation != null)
            {
                SpecificLocation.Validate(vb.Path + "AnatomicalLocation", messages);

                var choice1 = new Dictionary <string, object>()
                {
                    { "AnatomicalLocation.NameOfLocation", SpecificLocation.NameOfLocation },
                    { "Description", Description }
                };

                var choice2 = new Dictionary <string, object>()
                {
                    { "AnatomicalLocation.Side", SpecificLocation.Side },
                    { "Description", Description }
                };

                vb.ChoiceCheck(choice1);
                vb.ChoiceCheck(choice2);
            }
        }
Exemplo n.º 9
0
        /// <summary>
        /// Validates this AssessmentItem
        /// </summary>
        /// <param name="path">The path to this object as a string</param>
        /// <param name="messages">the validation messages to date, these may be added to within this method</param>
        public void Validate(string path, List <ValidationMessage> messages)
        {
            var vb = new ValidationBuilder(path, messages);

            vb.ArgumentRequiredCheck("QuestionData", QuestionData);
            vb.ArgumentRequiredCheck("AnswersData", AnswersData);

            // Medications exclusion statement choice
            var adverseChoice = new Dictionary <string, object>()
            {
                { "AnswersValue", AnswersValue },
                { "FreeText", FreeText }
            };

            vb.ChoiceCheck(adverseChoice);
        }
Exemplo n.º 10
0
        /// <summary>
        /// Validates this set of recommendations
        /// </summary>
        /// <param name="path">The path to this object as a string</param>
        /// <param name="messages">the validation messages to date, these may be added to within this method</param>
        public void Validate(string path, List <ValidationMessage> messages)
        {
            var vb = new ValidationBuilder(path, messages);

            if (Recommendation != null && Recommendation.Any())
            {
                Recommendation.ForEach(recomendation => recomendation.Validate(vb.Path + "Recommendation", messages));
            }

            // Recommendations exclusion statement choice
            var recommendationChoice = new Dictionary <string, object>()
            {
                { "Recommendation", Recommendation },
                { "GeneralStatement", ExclusionStatement }
            };

            vb.ChoiceCheck(recommendationChoice);
        }
Exemplo n.º 11
0
        /// <summary>
        /// Validates this Encounter
        /// </summary>
        /// <param name="path">The path to this object as a string</param>
        /// <param name="messages">the validation messages, these may be added to within this method</param>
        public void Validate(string path, List <ValidationMessage> messages)
        {
            var vb = new ValidationBuilder(path, messages);

            // Encounter Period can only contain a Encounter Period Null Flavor or a Encounter Period
            var encounterPeriod = new Dictionary <string, object>()
            {
                { "EncounterPeriod", EncounterPeriod },
                { "EncounterPeriodNullFlavor", EncounterPeriodNullFlavor }
            };

            vb.ChoiceCheck(encounterPeriod);


            if (vb.ArgumentRequiredCheck(vb.Path + "SeparationMode", SeparationMode))
            {
                SeparationMode.Validate(vb.Path + "SeparationMode", vb.Messages);
            }

            if (vb.ArgumentRequiredCheck(vb.Path + "ResponsibleHealthProfessional", ResponsibleHealthProfessional))
            {
                if (ResponsibleHealthProfessional != null)
                {
                    ResponsibleHealthProfessional.Validate(vb.Path + "ResponsibleHealthProfessional", messages);
                }
            }

            if (vb.ArgumentRequiredCheck(vb.Path + "Specialty", Specialty))
            {
                if (Specialty != null)
                {
                    Specialty.ForEach(specialty => specialty.Validate(vb.Path + "Specialty", messages));
                }
            }

            if (OtherParticipants != null)
            {
                OtherParticipants.ForEach(otherParticipants => otherParticipants.Validate(vb.Path + "OtherParticipants", messages));
            }
        }
        /// <summary>
        /// Validates this Current Medications object for a Discharge Summary
        /// </summary>
        /// <param name="path">The path to this object as a string</param>
        /// <param name="messages">the validation messages, these may be added to within this method</param>
        public void Validate(string path, List <ValidationMessage> messages)
        {
            var vb = new ValidationBuilder(path, messages);

            if (TherapeuticGoods != null)
            {
                TherapeuticGoods.ForEach(therapeuticGood => therapeuticGood.Validate(vb.Path + "TherapeuticGoods", vb.Messages));
            }

            // Exclusion statement choice
            var choiceCheck = new Dictionary <string, object>()
            {
                { "TherapeuticGoods", TherapeuticGoods },
                { "GeneralStatement", ExclusionStatement }
            };

            vb.ChoiceCheck(choiceCheck);

            if (ExclusionStatement != null)
            {
                ExclusionStatement.Validate(vb.Path + "GeneralStatement", vb.Messages);
            }
        }
Exemplo n.º 13
0
        /// <summary>
        /// Validates this Discharge Summary problem/diagnosis This Visit
        /// </summary>
        /// <param name="path">The path to this object as a string</param>
        /// <param name="messages">the validation messages to date, these may be added to within this method</param>
        public void Validate(string path, List <ValidationMessage> messages)
        {
            var vb = new ValidationBuilder(path, messages);

            if (ProblemDiagnosis != null)
            {
                ProblemDiagnosis.ForEach(problemDiagnosis => problemDiagnosis.Validate(vb.Path + "ProblemDiagnosis", vb.Messages));
            }

            // Problem diagnosis exclusion statement choice
            var problemDiagnosisChoice = new Dictionary <string, object>()
            {
                { "ProblemDiagnosis", ProblemDiagnosis },
                { "GeneralStatement", ExclusionStatement }
            };

            vb.ChoiceCheck(problemDiagnosisChoice);

            if (ExclusionStatement != null)
            {
                ExclusionStatement.Validate(vb.Path + "GeneralStatement", vb.Messages);
            }
        }
Exemplo n.º 14
0
        /// <summary>
        /// Validates this AdverseReactions
        /// </summary>
        /// <param name="path">The path to this object as a string</param>
        /// <param name="messages">the validation messages, these may be added to within this method</param>
        public void Validate(string path, List <ValidationMessage> messages)
        {
            var vb = new ValidationBuilder(path, messages);

            if (Reactions != null)
            {
                Reactions.ForEach(adverseReactions => adverseReactions.Validate(vb.Path + "Reactions", vb.Messages));
            }

            // Exclusion statement choice
            var choiceCheck = new Dictionary <string, object>()
            {
                { "Reactions", Reactions },
                { "GeneralStatement", ExclusionStatement }
            };

            vb.ChoiceCheck(choiceCheck);

            if (ExclusionStatement != null)
            {
                ExclusionStatement.Validate(vb.Path + "GeneralStatement", vb.Messages);
            }
        }
        /// <summary>
        /// Validates this Anatomical Site
        /// </summary>
        /// <param name="path">The path to this object as a string</param>
        /// <param name="messages">the validation messages to date, these may be added to within this method</param>
        public void Validate(string path, List <ValidationMessage> messages)
        {
            var vb = new ValidationBuilder(path, messages);

            if (SpecificLocation != null)
            {
                SpecificLocation.Validate(vb.Path + "AnatomicalLocation", messages);

                if (SpecificLocation.NameOfLocation != null && !SpecificLocation.NameOfLocation.HasCodeSystem)
                {
                    if (SpecificLocation.Side != null)
                    {
                        vb.AddValidationMessage(vb.PathName, null, "Can not have only a NameOfLocation (original text) and a Side");
                    }
                }
            }

            if (!Description.IsNullOrEmptyWhitespace())
            {
                if (SpecificLocation != null && SpecificLocation.Side != null)
                {
                    vb.AddValidationMessage(vb.PathName, null, "Can not have a description (original text) and a Side");
                }
            }

            // ReSharper disable once AssignNullToNotNullAttribute
            if ((new StackTrace()).GetFrames().Any(t => t.GetMethod().Name.Contains(CDADocumentType.EventSummary.ToString())))
            {
                // Only for EventSummary at this point eventually the if statement above will be removed
                var choice1 = new Dictionary <string, object>
                {
                    { "AnatomicalLocation", SpecificLocation },
                    { "Description", Description }
                };

                vb.ChoiceCheck(choice1);
            }
            ;

            if (Images != null && Images.Any())
            {
                foreach (var image in Images)
                {
                    if (image != null)
                    {
                        if (
                            image.ExternalDataMediaType == MediaType.GIF ||
                            image.ExternalDataMediaType == MediaType.JPEG ||
                            image.ExternalDataMediaType == MediaType.PNG
                            )
                        {
                            image.Validate(vb.Path + "Images", messages);
                        }
                        else
                        {
                            vb.AddValidationMessage(vb.PathName, null, "The image must be of a type GIF, JPEG or a PNG");
                        }
                    }
                }
            }
        }