/// <summary>
        /// Validates this Prescription Request Item
        /// </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 (vb.ArgumentRequiredCheck("PrescriptionRequestItemIdentifier", PrescriptionRequestItemIdentifier))
            {
                PrescriptionRequestItemIdentifier.Validate(vb.Path + "PrescriptionRequestItemIdentifier", vb.Messages);
            }

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

            if (vb.ArgumentRequiredCheck("TherapeuticGoodIdentification", TherapeuticGoodIdentification))
            {
                if (PBSRPBSItemCode != null && TherapeuticGoodIdentification.OriginalText.IsNullOrEmptyWhitespace())
                {
                    vb.AddValidationMessage(vb.PathName, null, "TherapeuticGoodIdentification's OriginalText is a required field when PBSRPBSItemCode is present");
                }

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

            vb.ArgumentRequiredCheck("Directions", Directions);

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

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

            if (vb.ArgumentRequiredCheck("QuantityToDispense", QuantityToDispense))
            {
                QuantityToDispense.ValidateDispensingUnit(vb.Path + "QuantityToDispense", vb.Messages);
            }

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

            vb.ArgumentRequiredCheck("PBSPrescriptionType", QuantityToDispense);

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

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

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

            if (PBSExtemporaneousIngredient != null)
            {
                for (var x = 0; x < PBSExtemporaneousIngredient.Count; x++)
                {
                    PBSExtemporaneousIngredient[x].Validate(vb.Path + string.Format("PBSExtemporaneousIngredient[{0}]", x), vb.Messages);
                }
            }
        }
示例#2
0
        /// <summary>
        /// This is a generic validation function which is called by both interfaces
        /// </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 (vb.ArgumentRequiredCheck("TherapeuticGoodId", TherapeuticGoodId))
            {
                TherapeuticGoodId.Validate(vb.Path + "TherapeuticGoodId", vb.Messages);

                //1.	Ensure that if an AMT code is used as the primary code for Therapeutic Good Identification, then PBS Manufacturer Code is NOT ALLOWED to be present.
                if (TherapeuticGoodId.Code == CodingSystem.AMTV2.GetAttributeValue <NameAttribute, string>(x => x.Code) || TherapeuticGoodId.Code == CodingSystem.AMTV3.GetAttributeValue <NameAttribute, string>(x => x.Code))
                {
                    if (PBSManufacturerCode != null)
                    {
                        vb.AddValidationMessage("PBSManufacturerCode", String.Empty, "If AMT code is used as the primary code for Therapeutic Good Identification, then PBS Manufacturer Code is NOT ALLOWED to be present");
                    }
                }
            }

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

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

            if (PBSManufacturerCode != null)
            {
                // 2.	Ensure that if a PBS Manufacturer Code is present, then a PBS Item Code MUST BE present as either the primary code or a translation (AMT SHALL NOT be the primary code in this case) for Therapeutic Good Identification
                var foundPBSCode = false;

                if (TherapeuticGoodId.Translations != null)
                {
                    foreach (var translations in TherapeuticGoodId.Translations.Where(translations => translations.Code == CodingSystem.PBSCode.GetAttributeValue <NameAttribute, string>(x => x.Code) ||
                                                                                      translations.CodeSystemName == CodingSystem.PBSCode.GetAttributeValue <NameAttribute, string>(x => x.Name)))
                    {
                        foundPBSCode = true;
                    }
                }

                if (TherapeuticGoodId.Code == CodingSystem.PBSCode.GetAttributeValue <NameAttribute, string>(x => x.Code) || TherapeuticGoodId.CodeSystemName == CodingSystem.PBSCode.GetAttributeValue <NameAttribute, string>(x => x.Name))
                {
                    foundPBSCode = true;
                }

                if (foundPBSCode == false)
                {
                    vb.AddValidationMessage("PBSManufacturerCode", String.Empty, "If a PBS Manufacturer Code is present, then a PBS Item Code MUST BE present as either the primary code or a translation for the for Therapeutic Good Identification");
                }

                if (PBSManufacturerCode.Root != CodingSystem.AustralianPBSManufacturerCode.GetAttributeValue <NameAttribute, string>(x => x.Code))
                {
                    vb.AddValidationMessage("PBSManufacturerCode", String.Empty, "Ensure that the correct OID (1.2.36.1.2001.1005.23) is always used for the PBS Manufacturer Code when it is present");
                }

                PBSManufacturerCode.Validate(vb.Path + "PBSManufacturerCode", vb.Messages);
            }

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

            vb.ArgumentRequiredCheck("Status", Status);
            vb.ArgumentRequiredCheck("DateTimeOfDispenseEvent", DateTimeOfDispenseEvent);
        }
        /// <summary>
        /// Validates this Prescription Item
        /// </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 (vb.ArgumentRequiredCheck("DateTimePrescriptionExpires", DateTimePrescriptionExpires))
            {
                if (DateTimePrescriptionExpires.PrecisionIndicator == null || DateTimePrescriptionExpires.PrecisionIndicator.Value != ISO8601DateTime.Precision.Day || DateTimePrescriptionExpires.TimeZone != null)
                {
                    vb.AddValidationMessage(vb.PathName, null, "SHALL include a complete date (century, year, month and day)");
                }
            }

            vb.ArgumentRequiredCheck("PrescriptionItemIdentifier", PrescriptionItemIdentifier);

            vb.ArgumentRequiredCheck("Directions", Directions);

            if (vb.ArgumentRequiredCheck("TherapeuticGoodIdentification", TherapeuticGoodIdentification))
            {
                TherapeuticGoodIdentification.Validate(vb.Path + "TherapeuticGoodIdentification", messages);

                if (PBSRPBSItemCode != null && TherapeuticGoodIdentification.OriginalText.IsNullOrEmptyWhitespace())
                {
                    vb.AddValidationMessage(vb.PathName, null, "TherapeuticGoodIdentification's OriginalText is a required field when PBSRPBSItemCode is present");
                }

                if (TherapeuticGoodIdentification.Translations != null)
                {
                    vb.AddValidationMessage(vb.PathName, null, "Translations can not be set for TherapeuticGoodIdentification please use PBS/RPBS Item Code instead");
                }
            }

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

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

                if (Timing.TimingDescription.IsNullOrEmptyWhitespace())
                {
                    vb.AddValidationMessage(vb.PathName, string.Empty, "If TIMING is included, Timing Description SHALL be fully and automatically derived");
                }
            }

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

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

            if (vb.ArgumentRequiredCheck("QuantityToDispense", QuantityToDispense))
            {
                QuantityToDispense.ValidateDispensingUnit(vb.Path + "QuantityToDispense", messages);
            }

            vb.ArgumentRequiredCheck("MaximumNumberOfRepeats", MaximumNumberOfRepeats);

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

            vb.ArgumentRequiredCheck("PBSPrescriptionType", PBSPrescriptionType);

            if (vb.ArgumentRequiredCheck("MedicalBenefitCategoryType", MedicalBenefitCategoryType))
            {
                if (MedicalBenefitCategoryType.Value == Nehta.VendorLibrary.CDA.Common.Enums.MedicalBenefitCategoryType.CTG)
                {
                    vb.AddValidationMessage(vb.PathName, null, "Medical Benefit Category Type of CTG is not valid for this document");
                }
            }

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

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

                if (MedicalBenefitCategoryType.HasValue && !(MedicalBenefitCategoryType.Value == Nehta.VendorLibrary.CDA.Common.Enums.MedicalBenefitCategoryType.PBS ||
                                                             MedicalBenefitCategoryType.Value == Nehta.VendorLibrary.CDA.Common.Enums.MedicalBenefitCategoryType.RPBS))
                {
                    vb.AddValidationMessage(vb.PathName, null, "PBSRPBSManufacturerCode SHALL be present on an e-prescription where the Medical Benefit Type Category is one of the following: PBS  RPBS ");
                }
            }

            vb.ArgumentRequiredCheck("GroundsForConcurrentSupply", GroundsForConcurrentSupply);

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

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

                if (StateAuthorityNumber.Extension.IsNullOrEmptyWhitespace())
                {
                    vb.AddValidationMessage(vb.PathName, null, "Extension is required for StateAuthorityNumber");
                }
            }

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

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

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