Пример #1
0
        public void TestCardinality()
        {
            OperationOutcome oo = new OperationOutcome();

            validateErrorOrFail(oo, true);

            oo.Issue = new List <OperationOutcome.OperationOutcomeIssueComponent>();
            validateErrorOrFail(oo, true);

            var issue = new OperationOutcome.OperationOutcomeIssueComponent();

            oo.Issue.Add(issue);
            validateErrorOrFail(oo, true);

            issue.Severity = OperationOutcome.IssueSeverity.Information;
            FhirValidator.Validate(oo, true);
        }
Пример #2
0
        public void ValidateEntry()
        {
            var pe = new ResourceEntry<Patient>(new Uri("http://www.nu.nl/fhir/Patient/1"), DateTimeOffset.Now, new Patient());
            Assert.IsNotNull(pe.Id);
            Assert.IsNotNull(pe.Title);
            Assert.IsNotNull(pe.LastUpdated);
            Assert.IsNotNull(pe.Resource);
            FhirValidator.Validate(pe);

            var b = new Bundle("A test feed", DateTimeOffset.Now);
            b.AuthorName = "Ewout";

            Assert.IsNotNull(pe.Id);
            Assert.IsNotNull(pe.Title);
            Assert.IsNotNull(pe.LastUpdated);
            b.Entries.Add(pe);
            FhirValidator.Validate(b);
        }
Пример #3
0
        public void ValidateDemoPatient()
        {
            var s = this.GetType().Assembly.GetManifestResourceStream("Hl7.Fhir.Test.patient-example.xml");

            var patient = (Patient)FhirParser.ParseResource(XmlReader.Create(s));

            ICollection <ValidationResult> results = new List <ValidationResult>();

            FhirValidator.Validate(patient, true);

            Assert.IsTrue(FhirValidator.TryValidate(patient, results, true));

            patient.Identifier[0].System = "urn:oid:crap really not valid";

            results = new List <ValidationResult>();

            Assert.IsFalse(FhirValidator.TryValidate(patient, results, true));
            Assert.IsTrue(results.Count > 0);
        }
Пример #4
0
        public void TestContainedConstraints()
        {
            var pat = new Patient();
            var patn = new Patient();
            pat.Contained = new List<Resource> { patn } ;
            patn.Contained = new List<Resource> { new Patient() };

            // Contained resources should not themselves contain resources
            validateErrorOrFail(pat);

            patn.Contained = null;
            FhirValidator.Validate(pat);

            patn.Text = new Narrative();
            patn.Text.Div = "<div>Narrative in contained resource</div>";

            // Contained resources should not contain narrative
            validateErrorOrFail(pat);
        }
Пример #5
0
        public void ValidateBundleEntry()
        {
            var e = new ResourceEntry <Patient>();

            e.Id    = new Uri("http://someserver.org/fhir/patient/@1");
            e.Title = "Some title";

            // Validates mandatory fields?
            validateErrorOrFail(e);
            e.LastUpdated = DateTimeOffset.Now;
            e.Resource    = new Patient();
            FhirValidator.Validate(e);

            // Checks nested errors on resource content?
            e.Resource = new Patient {
                Deceased = new FhirUri()
            };
            validateErrorOrFail(e, true);

            e.Resource = new Patient();

            var bundle = new Bundle()
            {
                Title = "Some feed title"
            };

            bundle.Id = new Uri("http://someserver.org/fhir/feed/@1424234232342");

            // Validates mandatory fields?
            validateErrorOrFail(bundle);
            bundle.LastUpdated = DateTimeOffset.Now;
            FhirValidator.Validate(bundle);

            // Checks nested errors on nested bundle element?
            bundle.Entries.Add(e);
            e.Id = null;
            validateErrorOrFail(bundle, true);
        }