protected void ValidateCodeConceptExtension(Extension extension, string vsetUri)
        {
            extension.Value.ShouldNotBeNull();
            extension.Value.ShouldBeOfType <CodeableConcept>();
            var concept = (CodeableConcept)extension.Value;

            var vset = ValueSetCache.Get(vsetUri);

            ShouldBeExactSingleCodingWhichIsInValueSet(vset, concept.Coding);
        }
        private static void TheListWarningCodeShouldBeValid(List list)
        {
            List <Extension> warningCodes = list.Extension.Where(extension => extension.Url.Equals(FhirConst.StructureDefinitionSystems.kExtListWarningCode)).ToList();

            warningCodes.Count.ShouldBeLessThanOrEqualTo(4);
            if (warningCodes.Count == 1)
            {
                Coding warningCode = (Coding)warningCodes.First().Value;
                var    valueSet    = ValueSetCache.Get(FhirConst.ValueSetSystems.kVsWarningCode);
                ValueSetContainsCodeAndDisplayAndSystem(valueSet, warningCode);
            }
        }
示例#3
0
        public void ThePractitionerCommunicationShouldBeValid()
        {
            Practitioners.ForEach(practitioner =>
            {
                practitioner.Communication.ForEach(codeableConcept =>
                {
                    var valueSet = ValueSetCache.Get(FhirConst.ValueSetSystems.kVsHumanLanguage);

                    ShouldBeSingleCodingWhichIsInValueSet(valueSet, codeableConcept.Coding);
                });
            });
        }
        public void ThePatientCommunicationShouldBeValid()
        {
            Patients.ForEach(patient =>
            {
                patient.Communication?.ForEach(communication =>
                {
                    communication.Language.ShouldNotBeNull("The communication language element should not be null");

                    var valueSet = ValueSetCache.Get(FhirConst.ValueSetSystems.kVsHumanLanguage);

                    ShouldBeSingleCodingWhichIsInValueSet(valueSet, communication.Language.Coding);
                });
            });
        }
        public void ThePatientContactRelationshipShouldBeValid()
        {
            Patients.ForEach(patient =>
            {
                patient.Contact.ForEach(contact =>
                {
                    contact.Relationship.ForEach(relationship =>
                    {
                        var valueSet = ValueSetCache.Get(FhirConst.ValueSetSystems.kVsRelationshipStatus);

                        ShouldBeSingleCodingWhichIsInValueSet(valueSet, relationship.Coding);
                    });
                });
            });
        }
        public void ThePatientOptionalElementsShouldBeValid()
        {
            Patients.ForEach(patient =>
            {
                //Would preferably check language as it has a binding strength of Required
                patient.Language?.IsLanguageFormat().ShouldBe(true, "A Patient Language has been provided but it does not conform to the required format. See: http://tools.ietf.org/html/bcp47");

                // EXTENSIONS
                var extensions = patient.Extension;
                ValidateMaxSingleCodeConceptExtension(extensions, FhirConst.StructureDefinitionSystems.kCCExtEthnicCategory, FhirConst.ValueSetSystems.kVsEthnicCategory);
                ValidateSingleExtension(extensions, FhirConst.StructureDefinitionSystems.kCcExtReligiousAffiliation); //Would preferably check codeable concept as it has a binding strength of Required
                ValidateSingleBooleanExtension(extensions, FhirConst.StructureDefinitionSystems.kCCExtPatientCadaver);
                ValidateMaxSingleCodeConceptExtension(extensions, FhirConst.StructureDefinitionSystems.kCCExtResidentialStatus, FhirConst.ValueSetSystems.kVsResidentialStatus);
                ValidateMaxSingleCodeConceptExtension(extensions, FhirConst.StructureDefinitionSystems.kCCExtTreatmentCategory, FhirConst.ValueSetSystems.kVsTreatmentCategory);
                ValidateNhsCommunicationExtension(extensions);


                //GENDER
                patient.Gender?.ShouldBeOfType <AdministrativeGender>();

                //NAMES
                patient.Name.ForEach(on =>
                {
                    on.Use.ShouldNotBeNull();
                    on.Use.ShouldBeOfType <HumanName.NameUse>();
                });

                //TELECOM
                ValidateTelecom(patient.Telecom, "Patient Telecom", true);

                //ADDRESS
                patient.Address.ForEach(add => ValidateAddress(add, "Patient Address"));

                //MARITAL STATUS
                if (patient.MaritalStatus != null)
                {
                    patient.MaritalStatus.Coding.Count.ShouldBe(1);
                    var vset = ValueSetCache.Get(FhirConst.ValueSetSystems.kVsMaritalStatus).WithComposeIncludes().ToList();
                    vset.AddRange(ValueSetCache.Get(FhirConst.ValueSetSystems.kVsNullFlavour).WithComposeIncludes().ToList());
                    ShouldBeSingleCodingWhichIsInCodeList(patient.MaritalStatus.Coding.First(), vset);
                }

                //CONTACT
                patient.Contact.ForEach(ValidateContact);
            });
        }
        public void ThePatientMaritalStatusShouldbeValid()
        {
            Patients.ForEach(patient =>
            {
                if (patient.MaritalStatus != null)
                {
                    patient.MaritalStatus.Coding.ShouldNotBeNull("Patient MaritalStatus coding cannot be null");


                    var maritalStatusList = ValueSetCache.Get(FhirConst.ValueSetSystems.kVsMaritalStatus).WithComposeIncludes().ToArray();
                    maritalStatusList.Concat(ValueSetCache.Get(FhirConst.ValueSetSystems.kVsNullFlavour).WithComposeIncludes().ToArray());
                    patient.MaritalStatus.Coding.ForEach(coding =>
                    {
                        coding.System.ShouldNotBeNull("MaritalStatus System should not be null");
                        coding.Code.ShouldBeOneOf(maritalStatusList.Select(c => c.Code).ToArray());
                        coding.Display.ShouldBeOneOf(maritalStatusList.Select(c => c.Display).ToArray());
                    });
                }
            });
        }
        public void ThePatientContactShouldBeValid()
        {
            Patients.ForEach(patient =>
            {
                patient.Contact.ForEach(contact =>
                {
                    // Contact Relationship Checks
                    contact.Relationship.ForEach(relationship =>
                    {
                        var valueSet = ValueSetCache.Get(FhirConst.ValueSetSystems.kVsRelationshipStatus);

                        ShouldBeSingleCodingWhichIsInValueSet(valueSet, relationship.Coding);
// github ref 126
// RMB 29/10/2018
                        relationship.Text.ShouldNotBeNull();
                        relationship.Coding.Count.ShouldBe(0);
                    });

                    contact.Name.ShouldBeNull();
                    contact.Name.Use.ShouldNotBeNull("Patient Name Use cannot be null");
                    contact.Name.Use.ShouldBeOfType <HumanName.NameUse>($"Patient Name Use is not a valid value within the value set {FhirConst.CodeSystems.kNameUse}");
                    contact.Name.Family.Count().ShouldBeLessThanOrEqualTo(1);
                    // Contact Name Checks
                    // Contact Telecom Checks
                    // Contact Address Checks
                    // Contact Gender Checks
                    // No mandatory fields and value sets are standard so will be validated by parse of response to fhir resource

                    // Contact Organization Checks
                    if (contact.Organization?.Reference != null)
                    {
                        _httpContext.FhirResponse.Entries.ShouldContain(
                            entry => entry.Resource.ResourceType.Equals(ResourceType.Organization) &&
                            entry.FullUrl.Equals(contact.Organization.Reference)
                            );
                    }
                });
            });
        }
        private void ValidatePatientRegistrationType(List <Extension> extList)
        {
            var extensions = extList.Where(extension => extension.Url.Equals(FhirConst.StructureDefinitionSystems.kCCExtRegistrationType)).ToList();

            extensions.Count.ShouldBeLessThanOrEqualTo(1, "The patient resource should contain a registration type extension.");

            if (extensions.Any())
            {
                var codeList = ValueSetCache.Get(FhirConst.ValueSetSystems.kVsGpcRegistrationType).WithComposeIncludes().ToList();

                extensions.ForEach(registrationTypeExtension =>
                {
                    registrationTypeExtension.Value.ShouldNotBeNull("The registration type extension should have a value element.");
                    registrationTypeExtension.Value.ShouldBeOfType <CodeableConcept>("The registration type extension should be a CodeableConcept.");

                    var concept = (CodeableConcept)registrationTypeExtension.Value;

                    concept.Coding.ForEach(code =>
                    {
                        ShouldBeSingleCodingWhichIsInCodeList(code, codeList);
                    });
                });
            }
        }
示例#10
0
        private void ValidateContact(Organization.ContactComponent contact)
        {
            if (contact != null)
            {
                contact.Extension.ForEach(ext => ext.Url.ShouldNotBeNullOrEmpty("Organisation Contact has an invalid extension. Extensions must have a URL element."));

                var contactPurpose = contact.Purpose;

                if (contactPurpose != null)
                {
                    var valueSet           = ValueSetCache.Get(FhirConst.ValueSetSystems.kVsContactEntityType);
                    var contactEntityTypes = valueSet.WithComposeImports().ToArray();

                    contactPurpose.Coding.ForEach(coding =>
                    {
                        if (coding.System.Equals(FhirConst.CodeSystems.kContactEntityType) && contactEntityTypes.Any() && !string.IsNullOrEmpty(coding.Code))
                        {
                            coding.Code.ShouldBeOneOf(contactEntityTypes, $"Organisation Contact Purpose System is {FhirConst.CodeSystems.kContactEntityType}, but the code provided is not valid for this ValueSet.");
                        }
                    });
                }

                var contactName = contact.Name;

                if (contactName != null)
                {
                    contactName.Use?.ShouldBeOfType <HumanName.NameUse>($"Organisation Contact Name Use is not a valid value within the value set {FhirConst.CodeSystems.kNameUse}");

                    contactName.Family.Count().ShouldBeLessThanOrEqualTo(1, "Organisation Contact Name Family Element should contain a maximum of 1.");
                }

                ValidateTelecom(contact.Telecom, "Organisation Contact Telecom");

                ValidateAddress(contact.Address, "Organisation Contact Address");
            }
        }