Beispiel #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");
                    }
                }
            }
        }
Beispiel #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);
                }
            }
        }
Beispiel #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");
                    }
                }
            }
        }
Beispiel #4
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);
        }