/// <summary>
        /// Validates this Summary Of Medication Entries
        /// </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);
            }
        }
Esempio n. 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);
        }