/// <summary>
        /// Validates this procedure
        /// </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 ValidateNoCaption(string path, List <ValidationMessage> messages)
        {
            var vb = new ValidationBuilder(path, messages);

            vb.ArgumentRequiredCheck("ExternalDataMediaType", ExternalDataMediaType);

            vb.ArgumentRequiredCheck("ID", ID);

            if ((!Path.IsNullOrEmptyWhitespace() && ByteArrayInput != null) || (Path.IsNullOrEmptyWhitespace() && ByteArrayInput == null))
            {
                vb.AddValidationMessage("FileName", null, "The Path and Base64Input are Mutually exclusive, please pass the file by File path or Base64");
            }

            if (!Path.IsNullOrEmptyWhitespace())
            {
                if (!File.Exists(Path))
                {
                    vb.AddValidationMessage("FileName", Path, Path + " does not Exist");
                }
            }

            if (ByteArrayInput != null)
            {
                vb.ArgumentRequiredCheck("Base64Input.ByteArray", ByteArrayInput.ByteArray);
                vb.ArgumentRequiredCheck("ExternalDataMediaType", ByteArrayInput.FileName);
            }

            vb.ArgumentRequiredCheck("FileStorageType", FileStorageType);

            if (!Caption.IsNullOrEmptyWhitespace())
            {
                vb.AddValidationMessage("External Data - Caption", Caption, "Please note the caption in this instance is populated by the 'Report Description' field, so please do not populate this field");
            }
        }
        /// <summary>
        /// Validates this AdministrationDetails
        /// </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 (Route != null)
            {
                Route.Validate(vb.Path + "Route", messages);

                if (Route.CodeSystemCode != CodingSystem.SNOMED.GetAttributeValue <NameAttribute, string>(x => x.Code))
                {
                    vb.AddValidationMessage(vb.Path + "Route", null, "Route must have a code system of SNOMED");
                }
            }

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

                if (AnatomicalSite.CodeSystemCode != CodingSystem.SNOMED.GetAttributeValue <NameAttribute, string>(x => x.Code))
                {
                    vb.AddValidationMessage(vb.Path + "AnatomicalSite", null, "AnatomicalSite must have a code system of SNOMED");
                }
            }

            if (MedicationDeliveryMethod != null)
            {
                MedicationDeliveryMethod.Validate(vb.Path + "MedicationDeliveryMethod", messages);
            }
        }
Exemple #3
0
        /// <summary>
        /// Validates this codable 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 ValidateMandatory(string path, List <ValidationMessage> messages)
        {
            var vb = new ValidationBuilder(path, messages);

            if (NullFlavour.HasValue)
            {
                vb.AddValidationMessage(vb.PathName + "NullFlavour", null, "NullFlavour can not be specified for this coadable text field");
                return;
            }

            if (QualifierCodes != null)
            {
                foreach (var qualifierCode in QualifierCodes)
                {
                    qualifierCode.Validate(path, messages);
                }
            }

            if (QualifierCodes != null && OriginalText.IsNullOrEmptyWhitespace())
            {
                vb.AddValidationMessage(vb.PathName + "QualifierCodes & OriginalText", null, "OriginalText must be provided with QualifierCodes");
            }

            Validate(path, messages);
        }
        /// <summary>
        /// Validates this medical history for the SHS 1.4
        /// </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>
        /// <param name="showExclusionStatements">Validate showExclusionStatements</param>
        public void ValidateShs(string path, List <ValidationMessage> messages, bool showExclusionStatements)
        {
            var vb = new ValidationBuilder(path, messages);

            Validate(path, messages, showExclusionStatements);

            var medicalHistory = (IMedicalHistory)this;

            if (medicalHistory.ProblemDiagnosis != null)
            {
                for (var x = 0; x < medicalHistory.ProblemDiagnosis.Count; x++)
                {
                    if (medicalHistory.ProblemDiagnosis[x].DateOfOnset != null &&
                        medicalHistory.ProblemDiagnosis[x].DateOfOnset.PrecisionIndicator != ISO8601DateTime.Precision.Day &&
                        medicalHistory.ProblemDiagnosis[x].DateOfOnset.PrecisionIndicator != ISO8601DateTime.Precision.Month &&
                        medicalHistory.ProblemDiagnosis[x].DateOfOnset.PrecisionIndicator != ISO8601DateTime.Precision.Year)
                    {
                        vb.AddValidationMessage(vb.Path + string.Format("ProblemDiagnosis[{0}].DateOfOnset", x), null, "The effectiveTime/@value SHALL NOT include a time.");
                    }

                    if (medicalHistory.ProblemDiagnosis[x].DateOfResolutionRemission != null &&
                        medicalHistory.ProblemDiagnosis[x].DateOfResolutionRemission.PrecisionIndicator != ISO8601DateTime.Precision.Day &&
                        medicalHistory.ProblemDiagnosis[x].DateOfResolutionRemission.PrecisionIndicator != ISO8601DateTime.Precision.Month &&
                        medicalHistory.ProblemDiagnosis[x].DateOfResolutionRemission.PrecisionIndicator != ISO8601DateTime.Precision.Year)
                    {
                        vb.AddValidationMessage(vb.Path + string.Format("ProblemDiagnosis[{0}].DateOfResolutionRemission", x), null, "The value SHALL NOT include a time.");
                    }
                }
            }

            if (medicalHistory.ProblemDiagnosisExclusionStatement != null && medicalHistory.ProblemDiagnosisExclusionStatement.Value == NCTISGlobalStatementValues.NotAsked)
            {
                vb.AddValidationMessage(vb.Path + "Problem Diagnosis Exclusion Statement", null, "The value/@code SHALL NOT be 02.");
            }

            if (medicalHistory.ProceduresExclusionStatement != null && medicalHistory.ProceduresExclusionStatement.Value == NCTISGlobalStatementValues.NotAsked)
            {
                vb.AddValidationMessage(vb.Path + "Procedures Exclusion Statement", null, "The value/@code SHALL NOT be 02.");
            }

            if (medicalHistory.Procedures != null)
            {
                for (var x = 0; x < medicalHistory.Procedures.Count; x++)
                {
                    vb.ArgumentRequiredCheck(string.Format("Procedures[{0}].ProcedureDateTime", x), medicalHistory.Procedures[x].ProcedureDateTime);
                }
            }
        }
        /// <summary>
        /// Validates this Response
        /// </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 ((Procedures == null && Diagnoses == null && OtherDiagnosisEntries == null) ||
                (Procedures == null || !Procedures.Any()) && (Diagnoses == null || !Diagnoses.Any()) && (OtherDiagnosisEntries == null || !OtherDiagnosisEntries.Any()))
            {
                vb.AddValidationMessage("Response Details", null, "Response Details - 'section' tag shall have either an 'PROCEDURE' or 'DIAGNOSIS' or 'OTHER DIAGNOSIS PROCEDURE ENTRY'");
            }

            if (Procedures != null)
            {
                Procedures.ForEach(procedure => procedure.Validate(vb.Path + "Procedure", messages));
            }

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

            if (OtherDiagnosisEntries != null && OtherDiagnosisEntries.Any())
            {
                for (int x = 0; x < OtherDiagnosisEntries.Count; x++)
                {
                    vb.ArgumentRequiredCheck(string.Format("OtherDiagnosisEntries[{0}]", x), OtherDiagnosisEntries[x]);
                }
            }

            vb.ArgumentRequiredCheck("ResponseNarrative", ResponseNarrative);
        }
        void ICurrentService.Validate(string path, List <ValidationMessage> messages)
        {
            var vb = new ValidationBuilder(path, messages);

            if (ServiceBookingStatus != EventTypes.Event)
            {
                vb.AddValidationMessage(vb.PathName, string.Empty, "ServiceBookingStatus for CurrentService needs to be an EVENT");
            }

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

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

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

            vb.ArgumentRequiredCheck("RequestedServiceDateTime", RequestedServiceDateTime);
        }
Exemple #7
0
        /// <summary>
        /// Validates this CDA Context for a ICDAContextPrescriptionAndDispenseView
        /// </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>
        void ICDAContextPrescriptionAndDispenseView.Validate(string path, List <ValidationMessage> messages)
        {
            var vb = new ValidationBuilder(path, messages);

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

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

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

                // Check for PAI-O
                if (Custodian.Participant.Organisation != null && Custodian.Participant.Organisation.Identifiers != null)
                {
                    if (!Custodian.Participant.Organisation.Identifiers.Select(identifiers => identifiers.AssigningAuthorityName).Contains(HealthIdentifierType.PAIO.GetAttributeValue <NameAttribute, string>(x => x.Code)))
                    {
                        vb.AddValidationMessage(vb.PathName, null, "At leat one PAI-O Required");
                    }
                }
            }
        }
Exemple #8
0
        void IHealthPersonOrOrganisation.Validate(string path, List <ValidationMessage> messages)
        {
            var healthPersonOrOrganisation = (IHealthPersonOrOrganisation)this;
            var person    = ((IHealthPersonOrOrganisation)this).Person;
            var addresses = ((IHealthPersonOrOrganisation)this).Addresses;

            var vb = new ValidationBuilder(path, messages);

            // Check for correct Person / Organisation structure
            if ((person == null && healthPersonOrOrganisation.Organisation == null) || (person != null && healthPersonOrOrganisation.Organisation != null))
            {
                vb.AddValidationMessage(vb.PathName, null, "A Person or a Organisation must be provided");
            }
            else
            {
                // A Person
                if (person != null)
                {
                    if (vb.ArgumentRequiredCheck("Person", person))
                    {
                        person.Validate(vb.Path + "Person", vb.Messages);
                    }

                    vb.ArgumentRequiredCheck("Addresses", addresses);
                }

                // An Organisation
                if (healthPersonOrOrganisation.Organisation != null)
                {
                    if (vb.ArgumentRequiredCheck("Organisation", healthPersonOrOrganisation.Organisation))
                    {
                        healthPersonOrOrganisation.Organisation.Validate("Organisation", vb.Messages);
                    }
                }
            }

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

            if (ElectronicCommunicationDetails != null)
            {
                for (var x = 0; x < ElectronicCommunicationDetails.Count; x++)
                {
                    if (ElectronicCommunicationDetails[x] != null)
                    {
                        ElectronicCommunicationDetails[x].Validate(
                            vb.Path + string.Format("ElectronicCommunicationDetails[{0}]", x), vb.Messages);
                    }
                }
            }
        }
        /// <summary>
        /// Validate the SCS Content for the Australian Childhood Immunisation Register Entries
        /// </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 (vb.ArgumentRequiredCheck("AustralianChildhoodImmunisationRegisterEntry", AustralianChildhoodImmunisationRegisterEntry))
            {
                for (var x = 0; x < AustralianChildhoodImmunisationRegisterEntry.Count; x++)
                {
                    AustralianChildhoodImmunisationRegisterEntry[x].Validate(vb.Path + string.Format("AustralianChildhoodImmunisationRegisterEntry[{0}]", x), vb.Messages);

                    //Check to see if BOTH exist in single entry
                    if (AustralianChildhoodImmunisationRegisterEntry[x].VaccineAdministrationEntry != null && AustralianChildhoodImmunisationRegisterEntry[x].VaccineCancellationEntry != null)
                    {
                        vb.AddValidationMessage("AustralianChildhoodImmunisationRegisterEntry", null, "Exactly one 'VACCINE ADMINISTRATION ENTRY' OR exactly one 'VACCINE CANCELLATION ENTRY' SHALL be present per instance of the parent choice ('AUSTRALIAN CHILDHOOD IMMUNISATION REGISTER ENTRY').");
                    }
                }

                //AustralianChildhoodImmunisationRegisterEntry[0].
                //PW: 28/08/2016
                //THIS IS WRONG - SHOULD ALLOW MULTIPLE ENTRIES, BUT JUST A SINGLE 'ENTRY' or 'CANCELLATION' WITHIN an ENTRY
                //if (AustralianChildhoodImmunisationRegisterEntry.Count != 1)
                //{
                //vb.AddValidationMessage("AustralianChildhoodImmunisationRegisterEntry",null, "Exactly one 'VACCINE ADMINISTRATION ENTRY' OR exactly one 'VACCINE CANCELLATION ENTRY' SHALL be present per instance of the parent choice ('AUSTRALIAN CHILDHOOD IMMUNISATION REGISTER ENTRY').");
                //}
            }

            if (vb.ArgumentRequiredCheck("AustralianChildhoodImmunisationRegisterDocumentProvenanceLink", AustralianChildhoodImmunisationRegisterDocumentLink))
            {
                AustralianChildhoodImmunisationRegisterDocumentLink.Validate("AustralianChildhoodImmunisationRegisterDocumentProvenanceLink", messages);
            }
        }
Exemple #10
0
        /// <summary>
        /// Validates this diagnostic investigation
        /// </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 (PathologyTestResult != null && PathologyTestResult.Any())
            {
                PathologyTestResult.ForEach(pathologyTestResult => pathologyTestResult.Validate(path + ".PathologyTestResult", messages));
            }

            if (ImagingExaminationResult != null && ImagingExaminationResult.Any())
            {
                ImagingExaminationResult.ForEach(imagingExaminationResult => imagingExaminationResult.Validate(path + ".ImagingExaminationResult", messages));
            }

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

            if (RequestedService == null && ImagingExaminationResult == null && PathologyTestResult == null)
            {
                vb.AddValidationMessage(vb.PathName, null, "Each instance of this Diagnostic Investigations section SHALL have at least one instance of 'PATHOLOGY TEST RESULT' OR 'IMAGING EXAMINATION RESULT' OR 'REQUESTED SERVICE'");
            }
        }
        /// <summary>
        /// Validates this diagnostic investigation
        /// </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 (PathologyTestResult != null && PathologyTestResult.Any())
            {
                PathologyTestResult.ForEach(pathologyTestResult => pathologyTestResult.Validate(path + ".PathologyTestResult", messages));
            }

            if (ImagingExaminationResult != null && ImagingExaminationResult.Any())
            {
                ImagingExaminationResult.ForEach(imagingExaminationResult => imagingExaminationResult.Validate(path + ".ImagingExaminationResult", messages));
            }

            if (RequestedService != null && RequestedService.Any())
            {
                RequestedService.ForEach(requestedService => requestedService.Validate(path + ".RequestedService", messages));
            }

            if (RequestedService == null && ImagingExaminationResult == null && PathologyTestResult == null && OtherTestResult == null)
            {
                vb.AddValidationMessage(vb.PathName, null, "Each instance of this Diagnostic Investigations section SHALL have at least one instance of 'PATHOLOGY TEST RESULT' OR 'IMAGING EXAMINATION RESULT' OR 'REQUESTED SERVICE OR 'OTHER TEST RESULT'");
            }

            if (OtherTestResult != null && OtherTestResult.Any())
            {
                OtherTestResult.ForEach(otherTestResult => otherTestResult.Validate(path + ".OtherTestResult", messages));
            }
        }
Exemple #12
0
        /// <summary>
        /// Validates this MeasurementInformation
        /// </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 (HeadCircumference == null && BodyHeight == null && BodyMassIndex == null && BodyWeight == null)
            {
                vb.AddValidationMessage("MeasurementInformation", null, "Please provide an entry for MeasurementInformation");
            }

            if (HeadCircumference != null)
            {
                HeadCircumference.Validate(path, messages);
            }

            if (BodyHeight != null)
            {
                BodyHeight.Validate(path, messages);
            }

            if (BodyMassIndex != null)
            {
                BodyMassIndex.Validate(path, messages);
            }

            if (BodyWeight != null)
            {
                BodyWeight.Validate(path, messages);
            }
        }
        /// <summary>
        /// Validates this PhysicalMeasurement 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);

            int tally = 0;

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

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

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

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

            if (tally == 0)
            {
                vb.AddValidationMessage(vb.Path + "Physical Measurement", null, "Each instance of this Choice SHALL contain exactly one 'Head Circumference (BODY PART CIRCUMFERENCE)' OR exactly one 'BODY WEIGHT' OR exactly one 'BODY HEIGHT/LENGTH' OR exactly one 'BODY MASS INDEX'.");
            }
        }
        /// <summary>
        /// Validates this Quantity Unit
        /// </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 (Unit != null)
            {
                if (Unit.CodeSystemName != CodingSystem.SNOMED.GetAttributeValue <NameAttribute, string>(x => x.Name))
                {
                    vb.AddValidationMessage(vb.PathName, null, string.Format("Unit must use a {0} CodeSystemName", CodingSystem.SNOMED.GetAttributeValue <NameAttribute, string>(x => x.Name)));
                }

                if (Unit.CodeSystemCode != CodingSystem.SNOMED.GetAttributeValue <NameAttribute, string>(x => x.Code))
                {
                    vb.AddValidationMessage(vb.Path + "Unit", null, "Route must have a code system of SNOMED");
                }
            }
        }
        /// <summary>
        /// Validates this identifier
        /// </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("Root", Root))
            {
                // Check that the Root is a valid OID or UUID
                if (!(System.Text.RegularExpressions.Regex.IsMatch(Root, OID) || System.Text.RegularExpressions.Regex.IsMatch(Root, UID)))
                {
                    vb.AddValidationMessage(vb.PathName, null, "Identifiers must be a valid OID or UID");
                }

                if (Root != null && Root.Contains("urn:uuid:"))
                {
                    vb.AddValidationMessage(vb.PathName, null, "Identifiers must not contain 'urn:uuid:'");
                }
            }
        }
        /// <summary>
        /// Validates this ISetComponentTS
        /// </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 (Value == null)
            {
                vb.AddValidationMessage(vb.PathName, null, "Need to specify a value");
            }
        }
        /// <summary>
        /// Validates the FrequencyQuantity
        /// </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 (NullFlavor.HasValue && Denominator != null && Numerator != null)
            {
                vb.AddValidationMessage(vb.Path, null, "If nullFlavor is specified then Denominator and Numerator SHALL not be included");
            }
        }
        /// <summary>
        /// Validates this EncapsulatedData
        /// </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 (ExternalData == null && Text.IsNullOrEmptyWhitespace())
            {
                vb.AddValidationMessage(path + ".ExternalData", string.Empty, "Please specify exactly one ExternalData or a Text object for Encapsulated Data");
            }

            if (ExternalData != null && !Text.IsNullOrEmptyWhitespace())
            {
                vb.AddValidationMessage(path + ".ExternalData", string.Empty, "Please specify exactly one ExternalData or a Text object for Encapsulated Data");
            }

            if (ExternalData != null)
            {
                ExternalData.Validate(path + ".ExternalData", messages);
            }
        }
Exemple #19
0
        /// <summary>
        /// Validates this identifier
        /// </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 (NullFlavour.HasValue)
            {
                if (!Root.IsNullOrEmptyWhitespace())
                {
                    vb.AddValidationMessage(vb.PathName, null, "Root can not be provided with a NullFlavour within an Identifier");
                }

                if (!Extension.IsNullOrEmptyWhitespace())
                {
                    vb.AddValidationMessage(vb.PathName, null, "Extension can not be provided with a NullFlavour within an Identifier");
                }

                if (!AssigningAuthorityName.IsNullOrEmptyWhitespace())
                {
                    vb.AddValidationMessage(vb.PathName, null, "AssigningAuthorityName can not be provided with a NullFlavour within an Identifier");
                }

                if (!AssigningGeographicArea.IsNullOrEmptyWhitespace())
                {
                    vb.AddValidationMessage(vb.PathName, null, "AssigningGeographicArea can not be provided with a NullFlavour within an Identifier");
                }

                if (Code != null)
                {
                    vb.AddValidationMessage(vb.PathName, null, "Code can not be provided with a NullFlavour within an Identifier");
                }

                if (NullFlavour.Value != CDA.Common.Enums.NullFlavour.Unknown)
                {
                    vb.AddValidationMessage(vb.PathName, null, "NullFlavour for Identifier can only be specified as Unknown (UNK)");
                }
            }
            else
            {
                if (vb.ArgumentRequiredCheck("Root", Root))
                {
                    // Check that the Root is a valid OID or UUID
                    if (!(System.Text.RegularExpressions.Regex.IsMatch(Root, OID) || System.Text.RegularExpressions.Regex.IsMatch(Root, UID)))
                    {
                        vb.AddValidationMessage(vb.PathName, null, "Identifiers must be a valid OID or UID");
                    }

                    if (Root != null && Root.Contains("urn:uuid:"))
                    {
                        vb.AddValidationMessage(vb.PathName, null, "Identifiers must not contain 'urn:uuid:'");
                    }
                }
            }
        }
Exemple #20
0
        /// <summary>
        /// Validate the SCS Content for the Vaccine Cancellation Entry Component
        /// </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 (VaccineType.HasValue && VaccineTypeNullFlavour.HasValue)
            {
                vb.AddValidationMessage(vb.Path + "VaccineType or VaccineTypeNullFlavour", null, "lease specify only one VaccineType or VaccineTypeNullFlavour");
            }

            if (!VaccineType.HasValue && !VaccineTypeNullFlavour.HasValue)
            {
                vb.AddValidationMessage(vb.Path + "VaccineType or VaccineTypeNullFlavour", null, "Please specify only one VaccineType or VaccineTypeNullFlavour");
            }

            if (vb.ArgumentRequiredCheck("VaccineCancellationReasonPeriod", VaccineCancellationReasonPeriod))
            {
                VaccineCancellationReasonPeriod.Validate("VaccineCancellationReasonPeriod", messages);
            }

            vb.ArgumentRequiredCheck("VaccineCancellationReasonComment", VaccineCancellationReasonComment);
        }
        /// <summary>
        /// Validates this Quantity Unit for Dispensing Unit
        /// </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 ValidateDispensingUnit(string path, List <ValidationMessage> messages)
        {
            Validate(path, messages);

            var vb = new ValidationBuilder(path, messages);

            if (Quantity != null && Quantity.Value != null && (Quantity.Units == null && Unit == null))
            {
                vb.AddValidationMessage(vb.PathName, string.Empty, "'Quantity' and 'Dose Unit' elements SHALL be provided together.");
            }

            if (Quantity != null && (Quantity.Units != null && Unit != null))
            {
                vb.AddValidationMessage(vb.PathName, string.Empty, "Please choose only 'Quantity.Units' or 'Unit' not both");
            }

            if (!QuantityDescription.IsNullOrEmptyWhitespace() && (Quantity != null || Unit != null))
            {
                vb.AddValidationMessage(vb.PathName, string.Empty, "'Quantity Description' SHALL NOT co-exist with 'Quantity' and 'Unit'");
            }
        }
        /// <summary>
        /// Validates this procedure
        /// </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("ExternalDataMediaType", ExternalDataMediaType);

            vb.ArgumentRequiredCheck("ID", ID);

            if ((!Path.IsNullOrEmptyWhitespace() && ByteArrayInput != null) || (Path.IsNullOrEmptyWhitespace() && ByteArrayInput == null))
            {
                vb.AddValidationMessage("FileName", null, "The Path and Base64Input are Mutually exclusive, please pass the file by File path or Base64");
            }

            if (!Path.IsNullOrEmptyWhitespace())
            {
                if (!File.Exists(Path))
                {
                    vb.AddValidationMessage("FileName", Path, Path + " does not exist");
                }

                var fileName = System.IO.Path.GetFileName(Path);
                if (fileName != null && fileName.Contains(" "))
                {
                    vb.AddValidationMessage("FileName", Path, "Can not contain a character with a space");
                }
            }

            if (ByteArrayInput != null)
            {
                vb.ArgumentRequiredCheck("Base64Input.ByteArray", ByteArrayInput.ByteArray);
                vb.ArgumentRequiredCheck("ExternalDataMediaType", ByteArrayInput.FileName);
            }

            vb.ArgumentRequiredCheck("FileStorageType", FileStorageType);

            if (ExternalDataMediaType == MediaType.TXT || ExternalDataMediaType == MediaType.PDF)
            {
                vb.ArgumentRequiredCheck("Caption", Caption);
            }
        }
Exemple #23
0
        /// <summary>
        /// Validates this codable text
        /// </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 (!HasCodeSystem && !Code.IsNullOrEmptyWhitespace())
            {
                vb.AddValidationMessage(vb.PathName, null, "Code can only be provided if a CodeSystem is specified");
            }

            if (!HasCodeSystem && !DisplayName.IsNullOrEmptyWhitespace())
            {
                vb.AddValidationMessage(vb.PathName, null, "DisplayName can only be provided if a CodeSystem is specified");
            }

            if (DisplayName.IsNullOrEmptyWhitespace() && OriginalText.IsNullOrEmptyWhitespace() && NullFlavour == null)
            {
                vb.AddValidationMessage(vb.PathName, null, "Either OriginalText or DisplayName or a NullFlavour must be provided");
            }

            if (Translations != null)
            {
                foreach (var translation in Translations)
                {
                    translation.Validate(path, messages);
                }
            }

            if (QualifierCodes != null)
            {
                foreach (var qualifierCode in QualifierCodes)
                {
                    qualifierCode.Validate(path, messages);
                }
            }

            if (QualifierCodes != null && OriginalText.IsNullOrEmptyWhitespace())
            {
                vb.AddValidationMessage(vb.PathName + "QualifierCodes & OriginalText", null, "OriginalText must be provided with QualifierCodes");
            }
        }
Exemple #24
0
        /// <summary>
        /// Validates this specimen detail
        /// </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 validationBuilder = new ValidationBuilder(path, messages);

            validationBuilder.ArgumentRequiredCheck("CollectionDateTime", CollectionDateTime);

            if (AnatomicalSite != null && AnatomicalSite.Any())
            {
                AnatomicalSite.ForEach(anatomicalSite => anatomicalSite.Validate(path + ".AnatomicalSite", messages));
            }

            if (PhysicalDetails != null && PhysicalDetails.Any())
            {
                PhysicalDetails.ForEach(physicalDetail => physicalDetail.Validate(path + ".PhysicalDetails", messages));

                if (PhysicalDetails.Count > 1)
                {
                    validationBuilder.AddValidationMessage(path + ".physicalDetails", null, "Only one physical details item can be specified");
                }
            }

            if (SpecimenTissueType != null)
            {
                SpecimenTissueType.Validate(path + ".SpecimenTissueType", messages);
            }

            if (CollectionProcedure != null)
            {
                CollectionProcedure.Validate(path + ".CollectionProcedure", messages);
            }

            if (SamplingPreconditions != null)
            {
                SamplingPreconditions.Validate(path + ".SamplingPreconditions", messages);
            }

            if (SpecimenIdentifier != null)
            {
                SpecimenIdentifier.Validate(path + ".SpecimenIdentifier", messages);
            }

            if (ParentSpecimenIdentifier != null)
            {
                ParentSpecimenIdentifier.Validate(path + ".ParentSpecimenIdentifier", messages);
            }

            if (ContainerIdentifier != null)
            {
                ContainerIdentifier.Validate(path + ".ContainerIdentifier", messages);
            }
        }
Exemple #25
0
        /// <summary>
        /// Validates this request
        /// </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 ITestRequest.Validate(string path, List <ValidationMessage> messages)
        {
            var validationBuilder = new ValidationBuilder(path, messages);

            if (RequesterOrderIdentifier != null)
            {
                RequesterOrderIdentifier.Validate(validationBuilder.Path, messages);
            }

            if (ReportIdentifier != null)
            {
                ReportIdentifier.Validate(validationBuilder.Path, messages);
            }

            if (StudyIdentifier != null)
            {
                StudyIdentifier.Validate(validationBuilder.Path, messages);
            }

            if (RequesterOrderIdentifier != null)
            {
                RequesterOrderIdentifier.Validate(validationBuilder.Path, messages);
            }

            if (TestsRequestedName != null && TestsRequestedName.Any())
            {
                foreach (var testsRequestedName in TestsRequestedName)
                {
                    testsRequestedName.Validate(path, messages);
                }
            }

            if (RequesterOrderIdentifier != null && TestsRequestedName == null)
            {
                validationBuilder.AddValidationMessage("RequesterOrderIdentifier", null, "This value requires that TestsRequestedName be populated");
            }

            if (LaboratoryTestResultIdentifier != null)
            {
                LaboratoryTestResultIdentifier.Validate(validationBuilder.Path, messages);
            }

            if (ImageDetails != null && ImageDetails.Any())
            {
                foreach (var imageDetail in ImageDetails)
                {
                    imageDetail.Validate(validationBuilder.Path, messages);
                }
            }
        }
        /// <summary>
        /// Validates this Dispensing Information object
        /// </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);

            validationBuilder.ArgumentRequiredCheck("QuantityDescription", QuantityDescription);

            if (MinimumIntervalBetweenRepeats != null)
            {
                if (MinimumIntervalBetweenRepeats.IntervalWidth == null)
                {
                    validationBuilder.AddValidationMessage(validationBuilder.PathName, null, "MinimumIntervalBetweenRepeats must be and IntervalWidth and use a mesure of time");
                }
            }
        }
        /// <summary>
        /// Validate the SCS Content for the Australian Childhood Immunisation Register Entries
        /// </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 (VaccineAdministrationEntry == null && VaccineCancellationEntry == null)
            {
                vb.AddValidationMessage(vb.Path + "VaccineAdministrationEntry or VaccineCancellationEntry", null, "Please specify an VaccineAdministrationEntry or a VaccineCancellationEntry.");
            }

            if (VaccineAdministrationEntry != null && VaccineCancellationEntry != null)
            {
                vb.AddValidationMessage(vb.Path + "VaccineAdministrationEntry and VaccineCancellationEntry", null, "Both the VaccineAdministrationEntry and the VaccineCancellationEntry have been specified; only one instance of these is allowed.");
            }

            if (VaccineCancellationReason != null && VaccineCancellationEntry == null)
            {
                vb.AddValidationMessage(vb.Path + "VaccineCancellationReason or VaccineCancellationReason", null, "A VaccineCancellationEntry must be exist for a VaccineCancellationReason to be included.");
            }

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

            if (VaccineAdministrationEntry != null)
            {
                VaccineAdministrationEntry.Validate("VaccineAdministrationEntry", messages);
            }

            if (VaccineCancellationEntry != null)
            {
                VaccineCancellationEntry.Validate("VaccineCancellationEntry", messages);
            }
        }
Exemple #28
0
        /// <summary>
        /// Validates this specimen detail with a PIT narrative
        /// </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>
        /// <param name="xPreNarrative">Indicate whether an xPreNarrative is used for this validation</param>
        public void Validate(string path, List <ValidationMessage> messages, Boolean xPreNarrative)
        {
            var validationBuilder = new ValidationBuilder(path, messages);

            Validate(path, messages);

            if (xPreNarrative)
            {
                if (AnatomicalSite != null && AnatomicalSite.Any())
                {
                    foreach (var anatomicalSite in AnatomicalSite)
                    {
                        if (anatomicalSite.Images != null && anatomicalSite.Images.Any())
                        {
                            foreach (var images in anatomicalSite.Images)
                            {
                                if (images != null)
                                {
                                    validationBuilder.AddValidationMessage(path + ".Images", null, "AnatomicalSite Images can not be included where PathologyTestResult - xPreNarrative is specified");
                                }
                            }
                        }
                    }
                }

                if (PhysicalDetails != null && PhysicalDetails.Any())
                {
                    foreach (var physicalDetails in PhysicalDetails)
                    {
                        if (physicalDetails.Image != null)
                        {
                            validationBuilder.AddValidationMessage(path + ".Images", null, "PhysicalDetails - Image can not be included where PathologyTestResult - xPreNarrative is specified");
                        }
                    }
                }
            }
        }
        /// <summary>
        /// Validate the SCS Content for Pharmaceutical Benefits History
        /// </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 (ExclusionStatement != null)
            {
                ExclusionStatement.Validate("ExclusionStatement", vb.Messages);
            }

            if (PharmaceuticalBenefitItems != null)
            {
                PharmaceuticalBenefitItems.Validate("PharmaceuticalBenefitItems", vb.Messages);
            }

            if (ExclusionStatement == null && PharmaceuticalBenefitItems == null)
            {
                vb.AddValidationMessage(vb.Path + "ExclusionStatement or PharmaceuticalBenefitItems", null, "Please specify an ExclusionStatement or a PharmaceuticalBenefitItems item");
            }

            if (ExclusionStatement != null && PharmaceuticalBenefitItems != null)
            {
                vb.AddValidationMessage(vb.Path + "ExclusionStatement and PharmaceuticalBenefitItems", null, "Both the ExclusionStatement and the PharmaceuticalBenefitItems items have been specified; only one instance of these is allowed.");
            }
        }
        /// <summary>
        /// Validate the SCS Content for the Australian Childhood Immunisation Register History Entries
        /// </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 (ExclusionStatement == null && AustralianChildhoodImmunisationRegisterEntries == null)
            {
                vb.AddValidationMessage(vb.Path + "ExclusionStatement or AustralianChildhoodImmunisationRegister", null, "Please specify an ExclusionStatement or a AustralianChildhoodImmunisationRegisterEntry.");
            }

            if (ExclusionStatement != null && AustralianChildhoodImmunisationRegisterEntries != null)
            {
                vb.AddValidationMessage(vb.Path + "ExclusionStatement and AustralianChildhoodImmunisationRegisterEntry", null, "Both the ExclusionStatement and the AustralianChildhoodImmunisationRegisterEntry have been specified; only one instance of these is allowed.");
            }

            if (ExclusionStatement != null)
            {
                ExclusionStatement.Validate("ExclusionStatement", messages);
            }

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