示例#1
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");
                    }
                }
            }
        }
示例#2
0
        /// <summary>
        /// Validates this CDA Context
        /// </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 (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);
                }
            }
        }
示例#3
0
        /// <summary>
        /// Validates this CDA Context
        /// </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 ICDAContextMedicareOverview.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)
                {
                    var foundIdentifier = false;
                    foreach (var identifiers in Custodian.Participant.Organisation.Identifiers)
                    {
                        if (identifiers.AssigningAuthorityName == HealthIdentifierType.PAIO.GetAttributeValue <NameAttribute, string>(x => x.Code))
                        {
                            foundIdentifier = true;
                        }
                    }

                    if (!foundIdentifier)
                    {
                        vb.AddValidationMessage(vb.PathName, null, "At leat one PAI-O Required");
                    }
                }
            }
        }
示例#4
0
 void ICustodiansCommand.UpdateCustodian(Custodian custodian)
 {
     custodian.Validate();
     _repository.UpdateCustodian(custodian);
 }
示例#5
0
 void ICustodiansCommand.CreateCustodian(Custodian custodian)
 {
     custodian.Prepare();
     custodian.Validate();
     _repository.CreateCustodian(custodian);
 }
示例#6
0
        public override ErrorList Validate()
        {
            var result = new ErrorList();

            result.AddRange(base.Validate());

            if (MasterIdentifier != null)
            {
                result.AddRange(MasterIdentifier.Validate());
            }
            if (Identifier != null)
            {
                Identifier.ForEach(elem => result.AddRange(elem.Validate()));
            }
            if (Subject != null)
            {
                result.AddRange(Subject.Validate());
            }
            if (Type != null)
            {
                result.AddRange(Type.Validate());
            }
            if (Subtype != null)
            {
                result.AddRange(Subtype.Validate());
            }
            if (Author != null)
            {
                Author.ForEach(elem => result.AddRange(elem.Validate()));
            }
            if (Custodian != null)
            {
                result.AddRange(Custodian.Validate());
            }
            if (Authenticator != null)
            {
                result.AddRange(Authenticator.Validate());
            }
            if (CreatedElement != null)
            {
                result.AddRange(CreatedElement.Validate());
            }
            if (IndexedElement != null)
            {
                result.AddRange(IndexedElement.Validate());
            }
            if (StatusElement != null)
            {
                result.AddRange(StatusElement.Validate());
            }
            if (DocStatus != null)
            {
                result.AddRange(DocStatus.Validate());
            }
            if (Supercedes != null)
            {
                result.AddRange(Supercedes.Validate());
            }
            if (DescriptionElement != null)
            {
                result.AddRange(DescriptionElement.Validate());
            }
            if (Confidentiality != null)
            {
                result.AddRange(Confidentiality.Validate());
            }
            if (PrimaryLanguageElement != null)
            {
                result.AddRange(PrimaryLanguageElement.Validate());
            }
            if (MimeTypeElement != null)
            {
                result.AddRange(MimeTypeElement.Validate());
            }
            if (Format != null)
            {
                result.AddRange(Format.Validate());
            }
            if (SizeElement != null)
            {
                result.AddRange(SizeElement.Validate());
            }
            if (HashElement != null)
            {
                result.AddRange(HashElement.Validate());
            }
            if (LocationElement != null)
            {
                result.AddRange(LocationElement.Validate());
            }
            if (Service != null)
            {
                result.AddRange(Service.Validate());
            }
            if (Context != null)
            {
                result.AddRange(Context.Validate());
            }

            return(result);
        }
示例#7
0
        public override ErrorList Validate()
        {
            var result = new ErrorList();

            result.AddRange(base.Validate());

            if (Identifier != null)
            {
                result.AddRange(Identifier.Validate());
            }
            if (VersionIdentifier != null)
            {
                result.AddRange(VersionIdentifier.Validate());
            }
            if (CreatedElement != null)
            {
                result.AddRange(CreatedElement.Validate());
            }
            if (Type != null)
            {
                result.AddRange(Type.Validate());
            }
            if (Subtype != null)
            {
                result.AddRange(Subtype.Validate());
            }
            if (TitleElement != null)
            {
                result.AddRange(TitleElement.Validate());
            }
            if (StatusElement != null)
            {
                result.AddRange(StatusElement.Validate());
            }
            if (Confidentiality != null)
            {
                result.AddRange(Confidentiality.Validate());
            }
            if (Subject != null)
            {
                result.AddRange(Subject.Validate());
            }
            if (Author != null)
            {
                Author.ForEach(elem => result.AddRange(elem.Validate()));
            }
            if (Attester != null)
            {
                Attester.ForEach(elem => result.AddRange(elem.Validate()));
            }
            if (Custodian != null)
            {
                result.AddRange(Custodian.Validate());
            }
            if (Event != null)
            {
                result.AddRange(Event.Validate());
            }
            if (Encounter != null)
            {
                result.AddRange(Encounter.Validate());
            }
            if (ReplacesElement != null)
            {
                result.AddRange(ReplacesElement.Validate());
            }
            if (Provenance != null)
            {
                Provenance.ForEach(elem => result.AddRange(elem.Validate()));
            }
            if (Stylesheet != null)
            {
                result.AddRange(Stylesheet.Validate());
            }
            if (Representation != null)
            {
                result.AddRange(Representation.Validate());
            }
            if (Section != null)
            {
                Section.ForEach(elem => result.AddRange(elem.Validate()));
            }

            return(result);
        }
示例#8
0
        /// <summary>
        /// Validates a CDA Context document with a parent document
        /// </summary>
        /// <param name="path">The path to this object as a string</param>
        /// <param name="documentType">The parent document type</param>
        /// <param name="messages">the validation messages, these may be added to within this method</param>
        public void ValidateWithParentDocument(string path, CDADocumentType documentType, List <ValidationMessage> messages)
        {
            var vb = new ValidationBuilder(path, messages);

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

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

                    if ((ParentDocuments[x].ReleatedDocumentType == ReleatedDocumentType.Transform))
                    {
                        if (ParentDocuments[x].DocumentType.HasValue && ParentDocuments[x].DocumentType != documentType)
                        {
                            vb.AddValidationMessage(vb.PathName, null, string.Format("ParentDocuments of type 'XFRM' must have a document type of {0}", documentType.ToString()));
                        }

                        if (ParentDocuments[x].SetId != null && SetId != null && (SetId.Extension == ParentDocuments[x].SetId.Extension && SetId.Root == ParentDocuments[x].SetId.Root))
                        {
                            vb.AddValidationMessage(vb.PathName, null, "ParentDocuments of type 'XFRM' SHALL contain a new value for setId.");
                        }
                    }
                    else
                    {
                        if (ParentDocuments[x].DocumentType.HasValue && ParentDocuments[x].DocumentType != documentType)
                        {
                            vb.AddValidationMessage(vb.PathName, null, string.Format("ParentDocuments of type 'RPLC' must have a document type of {0}", documentType.ToString()));
                        }

                        if (ParentDocuments[x].SetId != null && SetId != null && (SetId.Extension != ParentDocuments[x].SetId.Extension || SetId.Root != ParentDocuments[x].SetId.Root))
                        {
                            vb.AddValidationMessage(vb.PathName, null, "ParentDocuments of type 'RPLC' the ClinicalDocument/versionNumber SHALL match the setId of the current document");
                        }

                        if (ParentDocuments[x].VersionNumber != null && !Version.IsNullOrEmptyWhitespace() && Version == ParentDocuments[x].VersionNumber)
                        {
                            vb.AddValidationMessage(vb.PathName, null, "ParentDocuments of type 'RPLC' SHALL contain an incremented value of ClinicalDocument/VersionNumber");
                        }
                    }
                }

                if (ParentDocuments.Any() && ParentDocuments.Count > 1)
                {
                    if (ParentDocuments.Count > 2)
                    {
                        vb.AddValidationMessage(vb.PathName, null, "ParentDocument can only have the following combinations 'XFRM', 'XFRM' and 'RPLC'");
                    }

                    if (ParentDocuments.Count == 2)
                    {
                        if (!(ParentDocuments.Any(u => u.ReleatedDocumentType == ReleatedDocumentType.Transform) || ParentDocuments.Any(u => u.ReleatedDocumentType == ReleatedDocumentType.Replace)))
                        {
                            vb.AddValidationMessage(vb.PathName, null, "ParentDocument can only have the following combinations 'XFRM', 'XFRM' and 'RPLC'");
                        }
                    }

                    if (ParentDocuments.Count == 1)
                    {
                        if (!(ParentDocuments.Any(u => u.ReleatedDocumentType == ReleatedDocumentType.Transform)))
                        {
                            vb.AddValidationMessage(vb.PathName, null, "ParentDocument can only have the following combinations 'XFRM', 'XFRM' and 'RPLC'");
                        }
                    }
                }
            }

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

            vb.ArgumentRequiredCheck("DocumentId", DocumentId);
        }