Exemplo n.º 1
0
        public void Test_HISearchMedicareNumber()
        {
            IResourceServiceOutcomeFactory IResourceServiceOutcomeFactory = CommonTestSetup.TestSetupMocks.GetIResourceServiceOutcomeFactory();
            IPyroFhirUriFactory            IPyroFhirUriFactory            = CommonTestSetup.TestSetupMocks.GetIPyroFhirUriFactory();
            IResourceServices     IResourceServices     = GetIResourceServices();
            IGlobalProperties     IGlobalProperties     = CommonTestSetup.TestSetupMocks.GetIGlobalProperties();
            IHiServiceApi         IHiServiceApi         = GetMokIHiServiceApi();
            IMedicareNumberParser IMedicareNumberParser = new MedicareNumberParser();
            IIndividualHealthcareIdentifierParser IIndividualHealthcareIdentifierParser = new IndividualHealthcareIdentifierParser();
            IDVANumberParser    IDVANumberParser   = new DVANumberParser();
            IRequestMetaFactory RequestMetaFactory = CommonTestSetup.TestSetupMocks.GetIRequestMetaFactory();
            INationalHealthcareIdentifierInfo INationalHealthcareIdentifierInfo = new NationalHealthcareIdentifierInfo();
            IMedicareNumberInfo IMedicareNumberInfo = new MedicareNumberInfo();

            Common.PyroHealthFhirResource.CodeSystems.IPyroFhirServer IPyroFhirServerCodeSystem = new Common.PyroHealthFhirResource.CodeSystems.PyroFhirServer();


            IHISearchOrValidateOperation IHISearchOrValidateOperationService = new IHISearchOrValidateOperation(
                IResourceServiceOutcomeFactory,
                IResourceServices,
                IGlobalProperties,
                IHiServiceApi,
                RequestMetaFactory,
                IMedicareNumberParser,
                IIndividualHealthcareIdentifierParser,
                IDVANumberParser,
                INationalHealthcareIdentifierInfo,
                IMedicareNumberInfo,
                IPyroFhirServerCodeSystem);

            OperationClass OperationClass = new OperationClass()
            {
                Scope = Common.Enum.FhirOperationEnum.OperationScope.Resource,
                Type  = Common.Enum.FhirOperationEnum.OperationType.xIHISearchOrValidate
            };

            //var SearchParameterGeneric = new Common.Search.SearchParameterGeneric();

            var PyroRequestUri = CommonTestSetup.TestSetupMocks.GetIPyroRequestUriFactory().CreateFhirRequestUri();

            PyroRequestUri.FhirRequestUri = CommonTestSetup.TestSetupMocks.GetIPyroRequestUriFactory().CreateFhirRequestUri().FhirRequestUri = new Pyro.Common.Tools.UriSupport.PyroFhirUri(CommonTestSetup.TestSetupMocks.GetIPrimaryServiceRootCache());
            PyroRequestUri.FhirRequestUri.Parse($"{StaticTestData.FhirEndpoint()}/{ResourceType.Patient.GetLiteral()}/{Common.Enum.FhirOperationEnum.OperationType.xIHISearchOrValidate.GetPyroLiteral()}");
            IRequestMeta RequestMeta = RequestMetaFactory.CreateRequestMeta();

            RequestMeta.PyroRequestUri         = PyroRequestUri;
            RequestMeta.RequestHeader          = CommonTestSetup.TestSetupMocks.GetIRequestHeaderFactory().CreateRequestHeader();
            RequestMeta.SearchParameterGeneric = CommonTestSetup.TestSetupMocks.GetISearchParameterGenericFactory().CreateDtoSearchParameterGeneric();

            Parameters ParametersResource = GenerateRequestParametersResource();

            IResourceServiceOutcome ResourceServiceOutcome = IHISearchOrValidateOperationService.IHISearchOrValidate(
                OperationClass,
                ParametersResource,
                RequestMeta
                );

            Assert.NotNull(ResourceServiceOutcome.ResourceResult);
            Assert.AreEqual(ResourceType.Parameters.GetLiteral(), ResourceServiceOutcome.ResourceResult.TypeName);
        }
Exemplo n.º 2
0
        public static IDtoRootUrlStore GetIDtoRootUrlStore()
        {
            Mock <IDtoRootUrlStore> MokIDtoRootUrlStore = new Mock <IDtoRootUrlStore>();

            MokIDtoRootUrlStore.Setup(x => x.Id).Returns(1);
            MokIDtoRootUrlStore.Setup(x => x.IsServersPrimaryUrlRoot).Returns(true);
            MokIDtoRootUrlStore.Setup(x => x.RootUri).Returns(new Uri(StaticTestData.FhirEndpoint()));
            MokIDtoRootUrlStore.Setup(x => x.Url).Returns(StaticTestData.FhirEndpoint());
            return(MokIDtoRootUrlStore.Object);
        }
Exemplo n.º 3
0
        public static IGlobalProperties GetIGlobalProperties()
        {
            Mock <IGlobalProperties> MokIGlobalProperties = new Mock <IGlobalProperties>();

            MokIGlobalProperties.Setup(x => x.HIServiceConnectivityActive).Returns(true);
            MokIGlobalProperties.Setup(x => x.NumberOfRecordsPerPageDefault).Returns(50);
            MokIGlobalProperties.Setup(x => x.MaxNumberOfRecordsPerPage).Returns(100);
            MokIGlobalProperties.Setup(x => x.ServiceBaseURL).Returns(StaticTestData.FhirEndpoint());
            return(MokIGlobalProperties.Object);
        }
Exemplo n.º 4
0
        /// <summary>
        /// Setup the mocked pyro ResourceService which mocks the response from the Pyro database when commiting the
        /// SoapRequest and SoapResponse FHIR Binary resources
        /// </summary>
        /// <returns></returns>
        private IResourceServices GetIResourceServices()
        {
            var FhirRequestUriForBinaryRequestPut = CommonTestSetup.TestSetupMocks.GetIPyroRequestUriFactory().CreateFhirRequestUri().FhirRequestUri = new Pyro.Common.Tools.UriSupport.PyroFhirUri(CommonTestSetup.TestSetupMocks.GetIPrimaryServiceRootCache());

            FhirRequestUriForBinaryRequestPut.Parse($"{StaticTestData.FhirEndpoint()}/{ResourceType.Binary.GetLiteral()}/{SoapRequestId}");

            Mock <IResourceServiceOutcome> MokIResourceServiceOutcomeOne = new Mock <IResourceServiceOutcome>();

            MokIResourceServiceOutcomeOne.Setup(x => x.FhirResourceId).Returns(SoapRequestId);
            MokIResourceServiceOutcomeOne.Setup(x => x.FormatMimeType).Returns((string)null);
            MokIResourceServiceOutcomeOne.Setup(x => x.HttpStatusCode).Returns(System.Net.HttpStatusCode.Created);
            MokIResourceServiceOutcomeOne.Setup(x => x.IsDeleted).Returns(false);
            MokIResourceServiceOutcomeOne.Setup(x => x.LastModified).Returns(DateTimeOffset.Now);
            MokIResourceServiceOutcomeOne.Setup(x => x.OperationType).Returns(RestEnum.CrudOperationType.Create);
            MokIResourceServiceOutcomeOne.Setup(x => x.RequestUri).Returns(FhirRequestUriForBinaryRequestPut);
            MokIResourceServiceOutcomeOne.Setup(x => x.ResourceResult).Returns(new Binary());
            MokIResourceServiceOutcomeOne.Setup(x => x.ResourceVersionNumber).Returns("1");
            MokIResourceServiceOutcomeOne.Setup(x => x.SuccessfulTransaction).Returns(true);
            MokIResourceServiceOutcomeOne.Setup(x => x.SummaryType).Returns((Hl7.Fhir.Rest.SummaryType?)null);

            var FhirRequestUriForBinaryResponsePut = CommonTestSetup.TestSetupMocks.GetIPyroRequestUriFactory().CreateFhirRequestUri().FhirRequestUri = new Pyro.Common.Tools.UriSupport.PyroFhirUri(CommonTestSetup.TestSetupMocks.GetIPrimaryServiceRootCache());

            FhirRequestUriForBinaryRequestPut.Parse($"{StaticTestData.FhirEndpoint()}/{ResourceType.Binary.GetLiteral()}/{SoapResponseId}");

            Mock <IResourceServiceOutcome> MokIResourceServiceOutcomeTwo = new Mock <IResourceServiceOutcome>();

            MokIResourceServiceOutcomeTwo.Setup(x => x.FhirResourceId).Returns(SoapResponseId);
            MokIResourceServiceOutcomeTwo.Setup(x => x.FormatMimeType).Returns((string)null);
            MokIResourceServiceOutcomeTwo.Setup(x => x.HttpStatusCode).Returns(System.Net.HttpStatusCode.Created);
            MokIResourceServiceOutcomeTwo.Setup(x => x.IsDeleted).Returns(false);
            MokIResourceServiceOutcomeTwo.Setup(x => x.LastModified).Returns(DateTimeOffset.Now);
            MokIResourceServiceOutcomeTwo.Setup(x => x.OperationType).Returns(RestEnum.CrudOperationType.Create);
            MokIResourceServiceOutcomeTwo.Setup(x => x.RequestUri).Returns(FhirRequestUriForBinaryResponsePut);
            MokIResourceServiceOutcomeTwo.Setup(x => x.ResourceResult).Returns(new Binary());
            MokIResourceServiceOutcomeTwo.Setup(x => x.ResourceVersionNumber).Returns("1");
            MokIResourceServiceOutcomeTwo.Setup(x => x.SuccessfulTransaction).Returns(true);
            MokIResourceServiceOutcomeTwo.Setup(x => x.SummaryType).Returns((Hl7.Fhir.Rest.SummaryType?)null);

            Mock <IResourceServices> MokIResourceServices = new Mock <IResourceServices>();

            MokIResourceServices.SetupSequence(x => x.Put(It.IsAny <string>(), It.IsAny <Binary>(), It.IsAny <IRequestMeta>()))
            .Returns(MokIResourceServiceOutcomeOne.Object)
            .Returns(MokIResourceServiceOutcomeTwo.Object);
            MokIResourceServices.SetReturnsDefault <IResourceServiceOutcome>(MokIResourceServiceOutcomeOne.Object);
            return(MokIResourceServices.Object);
        }
Exemplo n.º 5
0
        public static IPrimaryServiceRootCache GetIPrimaryServiceRootCache()
        {
            Mock <IPrimaryServiceRootCache> MokIPrimaryServiceRootCache = new Mock <IPrimaryServiceRootCache>();

            MokIPrimaryServiceRootCache.Setup(x => x.GetPrimaryRootUrlFromDatabase()).Returns(TestSetupMocks.GetIDtoRootUrlStore());
            MokIPrimaryServiceRootCache.Setup(x => x.GetPrimaryRootUrlFromWebConfig()).Returns(StaticTestData.FhirEndpoint());
            return(MokIPrimaryServiceRootCache.Object);
        }