Beispiel #1
0
        public async void ValidateConditionalUpdate_Invalid_BadResourceType()
        {
            var service = new NrlsMaintain(_nrlsApiSettings, _fhirMaintain, _fhirSearch, _cache, _fhirValidation);

            var request = FhirRequests.Valid_Update;

            request.Resource = new Patient();

            var response = await service.ValidateConditionalUpdate(request);

            Assert.IsType <OperationOutcome>(response);

            var outcome = response as OperationOutcome;

            Assert.NotNull(outcome.Issue);
            Assert.NotEmpty(outcome.Issue);

            var details = outcome.Issue.FirstOrDefault().Details;

            Assert.NotNull(details);
            Assert.NotNull(details.Coding);
            Assert.NotEmpty(details.Coding);

            var errorDetail = details.Coding.FirstOrDefault();

            Assert.Equal("INVALID_RESOURCE", errorDetail.Code);
        }
Beispiel #2
0
        public async void ValidateConditionalUpdate_Invalid_PatientMismatch()
        {
            var service = new NrlsMaintain(_nrlsApiSettings, _fhirMaintain, _fhirSearch, _sdsService, _fhirValidation);

            var response = await service.ValidateConditionalUpdate(FhirRequests.Invalid_Update_PatientMismatch);

            Assert.IsType <OperationOutcome>(response);

            var outcome = response as OperationOutcome;

            Assert.NotNull(outcome.Issue);
            Assert.NotEmpty(outcome.Issue);

            var issue = outcome.Issue.FirstOrDefault();

            Assert.Equal("Resolved DocumentReference is not associated with the same patient.", issue.Diagnostics);

            var details = issue.Details;

            Assert.NotNull(details);
            Assert.NotNull(details.Coding);
            Assert.NotEmpty(details.Coding);

            var errorDetail = details.Coding.FirstOrDefault();

            Assert.Equal("INVALID_RESOURCE", errorDetail.Code);
        }
Beispiel #3
0
        public async void ValidateConditionalUpdate_Invalid_ReferenceMisMatchIdentifier()
        {
            var service = new NrlsMaintain(_nrlsApiSettings, _fhirMaintain, _fhirSearch, _sdsService, _fhirValidation);

            var response = await service.ValidateConditionalUpdate(FhirRequests.Invalid_Update_RelatesToInvalidRelatedIdentifier);

            Assert.IsType <OperationOutcome>(response);

            var outcome = response as OperationOutcome;

            Assert.NotNull(outcome.Issue);
            Assert.NotEmpty(outcome.Issue);

            var issue = outcome.Issue.FirstOrDefault();

            Assert.Equal("Resolved DocumentReference does not have a matching MasterIdentifier.", issue.Diagnostics);

            var details = issue.Details;

            Assert.NotNull(details);
            Assert.NotNull(details.Coding);
            Assert.NotEmpty(details.Coding);

            var errorDetail = details.Coding.FirstOrDefault();

            Assert.Equal("INVALID_RESOURCE", errorDetail.Code);
        }
Beispiel #4
0
        public async void ValidateCreate_Valid()
        {
            var service = new NrlsMaintain(_nrlsApiSettings, _fhirMaintain, _fhirSearch, _cache, _fhirValidation);

            var validation = await service.ValidateCreate <DocumentReference>(FhirRequests.Valid_Create);

            Assert.Null(validation);
        }
Beispiel #5
0
        public async void ValidateCreate_Invalid_MasterIdentifier()
        {
            var service = new NrlsMaintain(_nrlsApiSettings, _fhirMaintain, _fhirSearch, _cache, _fhirValidation);

            var validation = await service.ValidateCreate <DocumentReference>(FhirRequests.Valid_Create_MasterId);

            Assert.IsType <OperationOutcome>(validation);
        }
Beispiel #6
0
        public async void ValidateConditionalUpdate_Valid()
        {
            var service = new NrlsMaintain(_nrlsApiSettings, _fhirMaintain, _fhirSearch, _cache, _fhirValidation);

            var response = await service.ValidateConditionalUpdate(FhirRequests.Valid_Update);

            Assert.IsType <DocumentReference>(response);
        }
Beispiel #7
0
        public async void ValidateCreate_Invalid_Custodian()
        {
            var service = new NrlsMaintain(_nrlsApiSettings, _fhirMaintain, _fhirSearch, _sdsService, _fhirValidation);

            var validation = await service.ValidateCreate(FhirRequests.Invalid_Custodian);

            Assert.IsType <OperationOutcome>(validation);
        }
Beispiel #8
0
        public async void Create_Valid()
        {
            var service = new NrlsMaintain(_nrlsApiSettings, _fhirMaintain, _fhirSearch, _sdsService, _fhirValidation);

            var response = await service.CreateWithoutValidation(FhirRequests.Valid_Create);

            Assert.IsType <DocumentReference>(response);
        }
Beispiel #9
0
        public async void Supersede_Valid()
        {
            var service = new NrlsMaintain(_nrlsApiSettings, _fhirMaintain, _fhirSearch, _cache, _fhirValidation);

            var response = await service.SupersedeWithoutValidation <DocumentReference>(FhirRequests.Valid_Create, "5ab13f41957d0ad5d93a1339", "1");

            Assert.IsType <DocumentReference>(response);
        }
Beispiel #10
0
        public async void ValidateConditionalUpdate_Valid_NoRelatesTo()
        {
            var service = new NrlsMaintain(_nrlsApiSettings, _fhirMaintain, _fhirSearch, _cache, _fhirValidation);

            var response = await service.ValidateConditionalUpdate(FhirRequests.Valid_Create);

            Assert.Null(response);
        }
Beispiel #11
0
        public async void ConditionalDelete_InvalidAsidForCustodian()
        {
            var service = new NrlsMaintain(_nrlsApiSettings, _fhirMaintain, _fhirSearch, _sdsService, _fhirValidation);

            var response = await service.Delete(FhirRequests.Invalid_ConditionalDelete);

            Assert.IsType <OperationOutcome>(response);

            Assert.False(response.Success);
        }
Beispiel #12
0
        public async void Delete_Invalid_NotFound()
        {
            var service = new NrlsMaintain(_nrlsApiSettings, _fhirMaintain, _fhirSearch, _sdsService, _fhirValidation);

            var response = await service.Delete(FhirRequests.Valid_Delete_Alt);

            Assert.IsType <OperationOutcome>(response);

            Assert.False(response.Success);
        }
Beispiel #13
0
        public async void Delete_Valid_Conditional_Id()
        {
            var service = new NrlsMaintain(_nrlsApiSettings, _fhirMaintain, _fhirSearch, _sdsService, _fhirValidation);

            var response = await service.Delete(FhirRequests.Valid_Delete_Query_Id);

            Assert.IsType <OperationOutcome>(response);

            Assert.True(response.Success);
        }
Beispiel #14
0
        public async void ConditionalDelete_Invalid()
        {
            var service = new NrlsMaintain(_nrlsApiSettings, _fhirMaintain, _fhirSearch, _cache, _fhirValidation);

            var response = await service.Delete <DocumentReference>(FhirRequests.Invalid_ConditionalDelete);

            Assert.IsType <OperationOutcome>(response);

            Assert.False(response.Success);
        }
Beispiel #15
0
        public void BuildEnteredInError_InvalidVersion()
        {
            var service = new NrlsMaintain(_nrlsApiSettings, _fhirMaintain, _fhirSearch, _sdsService, _fhirValidation);

            Assert.Throws <HttpFhirException>(delegate
            {
                UpdateDefinition <BsonDocument> updates = null;

                service.BuildEnteredInError("bad-number", out updates);
            });
        }
Beispiel #16
0
        public void Delete_Invalid_Path_Id_And_Query()
        {
            var service = new NrlsMaintain(_nrlsApiSettings, _fhirMaintain, _fhirSearch, _sdsService, _fhirValidation);

            Assert.ThrowsAsync <HttpFhirException>(async delegate
            {
                await SystemTasks.Task.Run(async() => {
                    var response = await service.Delete(FhirRequests.Invalid_Delete_Path_Id_and_Query);
                });
            });
        }
Beispiel #17
0
        public void ConditionalDelete_Invalid_Subject()
        {
            var service = new NrlsMaintain(_nrlsApiSettings, _fhirMaintain, _fhirSearch, _cache, _fhirValidation);

            Assert.ThrowsAsync <HttpFhirException>(async delegate
            {
                await SystemTasks.Task.Run(async() => {
                    var response = await service.Delete <DocumentReference>(FhirRequests.Invalid_ConditionalDelete_NoSubject);
                });
            });
        }
Beispiel #18
0
        public void ConditionalDelete_Invalid_Identifier()
        {
            var service = new NrlsMaintain(_nrlsApiSettings, _fhirMaintain, _fhirSearch, _sdsService, _fhirValidation);


            Assert.ThrowsAsync <HttpFhirException>(async delegate
            {
                await SystemTasks.Task.Run(async() => {
                    var response = await service.Delete(FhirRequests.Invalid_ConditionalDelete_IncompleteIdentifier);
                });
            });
        }
Beispiel #19
0
        public void BuildSupersede_InvalidVersion()
        {
            var service = new NrlsMaintain(_nrlsApiSettings, _fhirMaintain, _fhirSearch, _cache, _fhirValidation);

            Assert.Throws <HttpFhirException>(delegate
            {
                UpdateDefinition <BsonDocument> updates = null;
                FhirRequest updateRequest = null;

                service.BuildSupersede("1", "bad-number", out updates, out updateRequest);
            });
        }
Beispiel #20
0
        public void BuildCreate_InvalidVersion()
        {
            var service = new NrlsMaintain(_nrlsApiSettings, _fhirMaintain, _fhirSearch, _cache, _fhirValidation);

            var response = service.SetMetaValues(FhirRequests.Valid_Create);

            Assert.IsType <FhirRequest>(response);

            Assert.NotNull(response.Resource);
            Assert.NotNull(response.Resource.Meta);

            Assert.NotEqual("2", response.Resource.Meta.VersionId);
        }
Beispiel #21
0
        public void ValidateCreate_Invalid_Pointer()
        {
            var service = new NrlsMaintain(_nrlsApiSettings, _fhirMaintain, _fhirSearch, _cache, _fhirValidation);


            Assert.ThrowsAsync <HttpFhirException>(async delegate
            {
                await SystemTasks.Task.Run(async() =>
                {
                    var validation = await service.ValidateCreate <DocumentReference>(FhirRequests.Invalid_Create);
                });
            });
        }
Beispiel #22
0
        public void BuildSupersede_Valid()
        {
            var service = new NrlsMaintain(_nrlsApiSettings, _fhirMaintain, _fhirSearch, _cache, _fhirValidation);

            UpdateDefinition <BsonDocument> updates = null;
            FhirRequest updateRequest = null;

            service.BuildSupersede("1", "2", out updates, out updateRequest);

            Assert.NotNull(updates);
            Assert.NotNull(updateRequest);

            Assert.Equal("1", updateRequest.Id);
        }
Beispiel #23
0
        public void BuildEnteredInError_ValidVersionNull()
        {
            var service = new NrlsMaintain(_nrlsApiSettings, _fhirMaintain, _fhirSearch, _sdsService, _fhirValidation);

            UpdateDefinition <BsonDocument> updates = null;

            service.BuildEnteredInError(null, out updates);

            Assert.NotNull(updates);

            var bson = updates.Render(BsonSerializer.LookupSerializer <BsonDocument>(), BsonSerializer.SerializerRegistry);

            BsonDocument updateElements = bson.Elements.FirstOrDefault().Value.ToBsonDocument();

            Assert.Equal("1", updateElements.Elements.FirstOrDefault(x => x.Name == "meta.versionId").Value.AsString);
        }
Beispiel #24
0
        public void BuildSupersede_ValidVersionAlt()
        {
            var service = new NrlsMaintain(_nrlsApiSettings, _fhirMaintain, _fhirSearch, _cache, _fhirValidation);

            UpdateDefinition <BsonDocument> updates = null;
            FhirRequest updateRequest = null;

            service.BuildSupersede("1", "10", out updates, out updateRequest);

            Assert.NotNull(updates);

            var bson = updates.Render(BsonSerializer.LookupSerializer <BsonDocument>(), BsonSerializer.SerializerRegistry);

            BsonDocument updateElements = bson.Elements.FirstOrDefault().Value.ToBsonDocument();

            Assert.Equal("11", updateElements.Elements.FirstOrDefault(x => x.Name == "meta.versionId").Value.AsString);
        }
Beispiel #25
0
        public async void Supersede_Invalid_Update()
        {
            var service = new NrlsMaintain(_nrlsApiSettings, _fhirMaintain, _fhirSearch, _cache, _fhirValidation);

            var response = await service.SupersedeWithoutValidation <DocumentReference>(FhirRequests.Valid_Create, "5ab13f41957d0ad5d93a1337", "1");

            Assert.IsType <OperationOutcome>(response);

            var outcome = response as OperationOutcome;

            Assert.False(outcome.Success);

            Assert.NotNull(outcome.Issue);
            Assert.NotEmpty(outcome.Issue);

            var issue = outcome.Issue.FirstOrDefault();

            Assert.Equal("Resource is invalid : relatesTo", issue.Diagnostics);
        }
Beispiel #26
0
        public async void ValidateConditionalUpdate_Invalid_Status()
        {
            var service = new NrlsMaintain(_nrlsApiSettings, _fhirMaintain, _fhirSearch, _sdsService, _fhirValidation);

            var response = await service.ValidateConditionalUpdate(FhirRequests.Invalid_Update_Bad_Status);

            Assert.IsType <OperationOutcome>(response);

            var outcome = response as OperationOutcome;

            Assert.NotNull(outcome.Issue);
            Assert.NotEmpty(outcome.Issue);

            var details = outcome.Issue.FirstOrDefault().Details;

            Assert.NotNull(details);
            Assert.NotNull(details.Coding);
            Assert.NotEmpty(details.Coding);

            var errorDetail = details.Coding.FirstOrDefault();

            Assert.Equal("BAD_REQUEST", errorDetail.Code);
        }
Beispiel #27
0
        public async void Create_Invalid()
        {
            var service = new NrlsMaintain(_nrlsApiSettings, _fhirMaintain, _fhirSearch, _cache, _fhirValidation);

            var response = await service.CreateWithoutValidation <DocumentReference>(FhirRequests.Invalid_Custodian);

            Assert.IsType <OperationOutcome>(response);

            var outcome = response as OperationOutcome;

            Assert.NotNull(outcome.Issue);
            Assert.NotEmpty(outcome.Issue);

            var details = outcome.Issue.FirstOrDefault().Details;

            Assert.NotNull(details);
            Assert.NotNull(details.Coding);
            Assert.NotEmpty(details.Coding);

            var errorDetail = details.Coding.FirstOrDefault();

            Assert.Equal("INVALID_RESOURCE", errorDetail.Code);
        }
Beispiel #28
0
        public async void Supersede_Fatal_ThrowsException()
        {
            var service = new NrlsMaintain(_nrlsApiSettings, _fhirMaintain, _fhirSearch, _cache, _fhirValidation);

            var exception = await Assert.ThrowsAsync <HttpFhirException>(async delegate
            {
                var response = await service.SupersedeWithoutValidation <DocumentReference>(FhirRequests.Valid_Create, "5ab13f41957d0ad5d93a1336", "1");
            });

            Assert.Equal("Error Updating DocumentReference", exception.Message);

            Assert.NotNull(exception.OperationOutcome);

            var outcome = exception.OperationOutcome;

            Assert.False(outcome.Success);

            Assert.NotNull(outcome.Issue);
            Assert.NotEmpty(outcome.Issue);

            var issue = outcome.Issue.FirstOrDefault();

            Assert.StartsWith("There has been an internal error when attempting to persist the DocumentReference. Please contact the national helpdesk quoting -", issue.Diagnostics);
        }