Esempio n. 1
0
        public void TestCodeableConceptValidation()
        {
            var val = new BindingValidator(_termService, "Demo");

            var binding = new ElementDefinition.BindingComponent
            {
                ValueSet = new ResourceReference("http://hl7.org/fhir/ValueSet/data-absent-reason"),
                Strength = BindingStrength.Required
            };

            var cc = new CodeableConcept();

            cc.Coding.Add(new Coding("http://hl7.org/fhir/data-absent-reason", "NaN"));
            cc.Coding.Add(new Coding("http://hl7.org/fhir/data-absent-reason", "not-asked"));

            var result = val.ValidateBinding(cc, binding);

            Assert.True(result.Success);

            cc.Coding.First().Code = "NaNX";
            result = val.ValidateBinding(cc, binding);
            Assert.True(result.Success);

            cc.Coding.Skip(1).First().Code = "did-ask";
            result = val.ValidateBinding(cc, binding);
            Assert.False(result.Success);

            //EK 2017-07-6 No longer reports warnings when failing a preferred binding
            binding.Strength = BindingStrength.Preferred;
            result           = val.ValidateBinding(cc, binding);
            Assert.True(result.Success);
            Assert.Equal(0, result.Warnings);
        }
Esempio n. 2
0
        public void TestEmptyIllegalAndLegalCode()
        {
            var val = new BindingValidator(_termService, "Demo");

            var binding = new ElementDefinition.BindingComponent
            {
                ValueSet = new ResourceReference("http://hl7.org/fhir/ValueSet/data-absent-reason"),
                Strength = BindingStrength.Required
            };

            var cc = new CodeableConcept();

            cc.Coding.Add(new Coding(null, null, "Just some display text"));

            // First, with no code at all in a CC
            var result = val.ValidateBinding(cc, binding);

            Assert.False(result.Success);
            Assert.Contains("No code found in instance", result.ToString());

            // Now with no code + illegal code
            cc.Coding.Add(new Coding("urn:oid:1.2.3.4.5", "16", "Here's a code"));
            result = val.ValidateBinding(cc, binding);
            Assert.False(result.Success);
            Assert.Contains("None of the Codings in the CodeableConcept were valid for the binding", result.ToString());

            // Now, add a third valid code according to the binding.
            cc.Coding.Add(new Coding("http://hl7.org/fhir/data-absent-reason", "asked"));
            result = val.ValidateBinding(cc, binding);
            Assert.True(result.Success);
        }
Esempio n. 3
0
        public void TestCodingValidation()
        {
            var val     = new BindingValidator(_termService, "Demo");
            var binding = new ElementDefinition.BindingComponent
            {
                ValueSet = new ResourceReference("http://hl7.org/fhir/ValueSet/data-absent-reason"),
                Strength = BindingStrength.Required
            };

            var c      = new Coding("http://hl7.org/fhir/data-absent-reason", "NaN");
            var result = val.ValidateBinding(c, binding);

            Assert.True(result.Success);

            c.Code = "NaNX";
            result = val.ValidateBinding(c, binding);
            Assert.False(result.Success);

            c.Code           = "NaN";
            binding.Strength = null;
            result           = val.ValidateBinding(c, binding);
            Assert.True(result.Success);
            Assert.Equal(1, result.Warnings);  // missing binding strength

            c.Display        = "Not a Number";
            binding.Strength = BindingStrength.Required;
            result           = val.ValidateBinding(c, binding);
            Assert.True(result.Success);

            c.Display = "Not a NumberX";
            result    = val.ValidateBinding(c, binding);
            Assert.True(result.Success);        // local terminology service treats incorrect displays as warnings (GH#624)

            // But this won't, it's also a composition, but without expansion - the local term server won't help you here
            var binding2 = new ElementDefinition.BindingComponent
            {
                ValueSet = new FhirUri("http://hl7.org/fhir/ValueSet/allergyintolerance-substance-code"),
                Strength = BindingStrength.Required
            };

            c      = new Coding("http://snomed.info/sct", "160244002");
            result = val.ValidateBinding(c, binding2);
            Assert.True(result.Success);
            Assert.NotEmpty(result.Where(type: OperationOutcome.IssueType.NotSupported));
        }