Пример #1
0
        public async Task ShouldReturnListOfPatientDto()
        {
            //Given
            var openmrsClientMock   = new Mock <IOpenMrsClient>();
            var discoveryDataSource = new FhirDiscoveryDataSource(openmrsClientMock.Object);

            openmrsClientMock
            .Setup(x => x.GetAsync(Endpoints.Fhir.OnPatientPath))
            .ReturnsAsync(new HttpResponseMessage
            {
                StatusCode = HttpStatusCode.OK,
                Content    = new StringContent(PatientSample)
            })
            .Verifiable();

            //When
            var patients = await discoveryDataSource.LoadPatientsAsync(null, null, null);

            //Then
            var firstPatient = patients[0];

            firstPatient.Name[0].GivenElement.First().ToString().Should().Be("Test");
            firstPatient.Gender.Should().Be(AdministrativeGender.Female);
            firstPatient.BirthDate.Should().Be("1982-05-05");
            var secondPatient = patients[1];

            secondPatient.Name[0].GivenElement.First().ToString().Should().Be("David");
            secondPatient.Gender.Should().Be(AdministrativeGender.Male);
            secondPatient.BirthDate.Should().Be("1997-04-10");
        }
Пример #2
0
        public async Task ShouldReturnEmptyListIfAllResourcesAreDifferentFromPatient()
        {
            //Given
            var openMrsClientMock   = new Mock <IOpenMrsClient>();
            var discoveryDataSource = new FhirDiscoveryDataSource(openMrsClientMock.Object);

            openMrsClientMock
            .Setup(x => x.GetAsync(Endpoints.Fhir.OnPatientPath))
            .ReturnsAsync(new HttpResponseMessage
            {
                StatusCode = HttpStatusCode.OK,
                Content    = new StringContent(PersonsSample)
            })
            .Verifiable();

            //When
            var patients = await discoveryDataSource.LoadPatientsAsync(null, null, null);

            //Then
            patients.Should().BeEmpty();
        }
Пример #3
0
        public async Task ShouldReturnEmptyListWhenGotNoRecord()
        {
            //Given
            var openmrsClientMock   = new Mock <IOpenMrsClient>();
            var discoveryDataSource = new FhirDiscoveryDataSource(openmrsClientMock.Object);

            openmrsClientMock
            .Setup(x => x.GetAsync(Endpoints.Fhir.OnPatientPath))
            .ReturnsAsync(new HttpResponseMessage
            {
                StatusCode = HttpStatusCode.OK,
                Content    = new StringContent(NotFoundData)
            })
            .Verifiable();

            //When
            var patients = await discoveryDataSource.LoadPatientsAsync(null, null, null);

            //Then
            patients.Count.Should().Be(0);
            patients.Should().BeEmpty();
        }
Пример #4
0
        public async Task ShouldQueryDataSourceByNameAccordingToTheFilter(
            string expectedPath, string name, AdministrativeGender?gender, string yearOfBrith)
        {
            //Given
            var openmrsClientMock   = new Mock <IOpenMrsClient>();
            var discoveryDataSource = new FhirDiscoveryDataSource(openmrsClientMock.Object);

            openmrsClientMock
            .Setup(x => x.GetAsync(It.IsAny <string>()))
            .ReturnsAsync(new HttpResponseMessage
            {
                StatusCode = HttpStatusCode.OK,
                Content    = new StringContent(PatientSample)
            })
            .Verifiable();

            //When
            var patients = await discoveryDataSource.LoadPatientsAsync(name, gender, yearOfBrith);

            //Then
            openmrsClientMock.Verify(client => client.GetAsync(expectedPath), Times.Once);
        }
Пример #5
0
        public async Task ShouldGetPatientDataRealCallAsync()
        {
            //Given
            // Disable SSL verification in test only
            var handler = new HttpClientHandler()
            {
                ServerCertificateCustomValidationCallback =
                    HttpClientHandler.DangerousAcceptAnyServerCertificateValidator
            };
            var httpClient           = new HttpClient(handler);
            var openmrsConfiguration = new OpenMrsConfiguration
            {
                Url      = "https://someurl/openmrs/",
                Username = "******",
                Password = "******"
            };
            var openmrsClient       = new OpenMrsClient(httpClient, openmrsConfiguration);
            var discoveryDataSource = new FhirDiscoveryDataSource(openmrsClient);
            //When
            var patients = await discoveryDataSource.LoadPatientsAsync(null, null, null);

            //Then
            patients.Should().NotBeEmpty();
        }