Exemplo n.º 1
0
        public async Task ShouldGetDemographics()
        {
            HCIM_IN_GetDemographicsResponse1 expected = new HCIM_IN_GetDemographicsResponse1();
            IConfiguration config = new ConfigurationBuilder()
                                    .AddJsonFile("UnitTest.json").Build();

            Mock <QUPA_AR101102_PortType> clientMock = new Mock <QUPA_AR101102_PortType>();

            clientMock.Setup(x => x.HCIM_IN_GetDemographicsAsync(It.IsAny <HCIM_IN_GetDemographicsRequest>())).ReturnsAsync(expected);
            HCIM_IN_GetDemographicsRequest request = new HCIM_IN_GetDemographicsRequest();

            IClientRegistriesDelegate service = new ClientRegistriesDelegate(
                clientMock.Object
                );

            // Act
            HCIM_IN_GetDemographicsResponse1 actual = await service.GetDemographicsAsync(request);

            // Verify
            Assert.Equal(expected, actual);
        }
Exemplo n.º 2
0
        public async Task ShouldGetDemographics()
        {
            // Setup
            string   expectedHdId         = "EXTRIOYFPNX35TWEBUAJ3DNFDFXSYTBC6J4M76GYE3HC5ER2NKWQ";
            string   expectedPhn          = "0009735353315";
            string   expectedResponseCode = "BCHCIM.GD.0.0013";
            string   expectedFirstName    = "Jane";
            string   expectedLastName     = "Doe";
            string   expectedGender       = "Female";
            DateTime expectedBirthDate    = DateTime.ParseExact("20001231", "yyyyMMdd", CultureInfo.InvariantCulture);


            HCIM_IN_GetDemographicsResponseIdentifiedPerson subjectTarget =
                new HCIM_IN_GetDemographicsResponseIdentifiedPerson()
            {
                id = new II[]
                {
                    new II()
                    {
                        root      = "2.16.840.1.113883.3.51.1.1.6",
                        extension = expectedHdId
                    }
                },
                identifiedPerson = new HCIM_IN_GetDemographicsResponsePerson()
                {
                    id = new II[]
                    {
                        new II()
                        {
                            root      = "2.16.840.1.113883.3.51.1.1.6.1",
                            extension = expectedPhn
                        }
                    },
                    name = new PN[]
                    {
                        new PN()
                        {
                            Items = new ENXP[] {
                                new engiven()
                                {
                                    Text = new string[] { expectedFirstName }
                                },
                                new enfamily()
                                {
                                    Text = new string[] { expectedLastName }
                                },
                            }
                        }
                    },
                    birthTime = new TS()
                    {
                        value = "20001231"
                    },
                    administrativeGenderCode = new CE()
                    {
                        code = "F"
                    }
                }
            };

            Mock <QUPA_AR101102_PortType> clientMock = new Mock <QUPA_AR101102_PortType>();

            clientMock.Setup(x => x.HCIM_IN_GetDemographicsAsync(It.IsAny <HCIM_IN_GetDemographicsRequest>())).ReturnsAsync(
                new HCIM_IN_GetDemographicsResponse1()
            {
                HCIM_IN_GetDemographicsResponse = new HCIM_IN_GetDemographicsResponse()
                {
                    controlActProcess = new HCIM_IN_GetDemographicsResponseQUQI_MT120001ControlActProcess()
                    {
                        queryAck = new HCIM_MT_QueryResponseQueryAck()
                        {
                            queryResponseCode = new CS()
                            {
                                code = expectedResponseCode
                            },
                        },
                        subject = new HCIM_IN_GetDemographicsResponseQUQI_MT120001Subject2[]
                        {
                            new HCIM_IN_GetDemographicsResponseQUQI_MT120001Subject2()
                            {
                                target = subjectTarget
                            }
                        }
                    }
                }
            }
                );
            using var loggerFactory = LoggerFactory.Create(builder => builder.AddConsole());
            IClientRegistriesDelegate patientDelegate = new ClientRegistriesDelegate(
                loggerFactory.CreateLogger <ClientRegistriesDelegate>(),
                clientMock.Object);


            // Act
            RequestResult <PatientModel> actual = await patientDelegate.GetDemographicsByHDIDAsync(expectedHdId);

            // Verify
            Assert.Equal(ResultType.Success, actual.ResultStatus);
            Assert.Equal(expectedHdId, actual.ResourcePayload.HdId);
            Assert.Equal(expectedPhn, actual.ResourcePayload.PersonalHealthNumber);
            Assert.Equal(expectedFirstName, actual.ResourcePayload.FirstName);
            Assert.Equal(expectedLastName, actual.ResourcePayload.LastName);
            Assert.Equal(expectedBirthDate, actual.ResourcePayload.Birthdate);
            Assert.Equal(expectedGender, actual.ResourcePayload.Gender);
        }