diff --git a/hapi-fhir-storage-cr/src/main/java/ca/uhn/fhir/cr/config/CrBaseConfig.java b/hapi-fhir-storage-cr/src/main/java/ca/uhn/fhir/cr/config/CrBaseConfig.java new file mode 100644 index 00000000000..c76d6683612 --- /dev/null +++ b/hapi-fhir-storage-cr/src/main/java/ca/uhn/fhir/cr/config/CrBaseConfig.java @@ -0,0 +1,35 @@ +/*- + * #%L + * HAPI FHIR - Clinical Reasoning + * %% + * Copyright (C) 2014 - 2024 Smile CDR, Inc. + * %% + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * #L% + */ +package ca.uhn.fhir.cr.config; + +import ca.uhn.fhir.cr.r4.measure.MeasureReportPeriodRequestValidatorAndConverter; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; + +import java.time.ZoneOffset; + +@Configuration +public class CrBaseConfig { + + @Bean + MeasureReportPeriodRequestValidatorAndConverter measureReportPeriodService() { + return new MeasureReportPeriodRequestValidatorAndConverter(ZoneOffset.UTC); + } +} diff --git a/hapi-fhir-storage-cr/src/main/java/ca/uhn/fhir/cr/config/dstu3/CrDstu3Config.java b/hapi-fhir-storage-cr/src/main/java/ca/uhn/fhir/cr/config/dstu3/CrDstu3Config.java index 733d469ba04..c1d4a483449 100644 --- a/hapi-fhir-storage-cr/src/main/java/ca/uhn/fhir/cr/config/dstu3/CrDstu3Config.java +++ b/hapi-fhir-storage-cr/src/main/java/ca/uhn/fhir/cr/config/dstu3/CrDstu3Config.java @@ -22,6 +22,7 @@ package ca.uhn.fhir.cr.config.dstu3; import ca.uhn.fhir.context.FhirContext; import ca.uhn.fhir.context.FhirVersionEnum; import ca.uhn.fhir.cr.common.IRepositoryFactory; +import ca.uhn.fhir.cr.config.CrBaseConfig; import ca.uhn.fhir.cr.config.ProviderLoader; import ca.uhn.fhir.cr.config.ProviderSelector; import ca.uhn.fhir.cr.config.RepositoryConfig; @@ -39,7 +40,7 @@ import java.util.Arrays; import java.util.Map; @Configuration -@Import({RepositoryConfig.class}) +@Import({RepositoryConfig.class, CrBaseConfig.class}) public class CrDstu3Config { @Bean diff --git a/hapi-fhir-storage-cr/src/main/java/ca/uhn/fhir/cr/config/r4/CrR4Config.java b/hapi-fhir-storage-cr/src/main/java/ca/uhn/fhir/cr/config/r4/CrR4Config.java index 072e3a088d2..1049fddf35f 100644 --- a/hapi-fhir-storage-cr/src/main/java/ca/uhn/fhir/cr/config/r4/CrR4Config.java +++ b/hapi-fhir-storage-cr/src/main/java/ca/uhn/fhir/cr/config/r4/CrR4Config.java @@ -23,6 +23,7 @@ import ca.uhn.fhir.context.FhirContext; import ca.uhn.fhir.context.FhirVersionEnum; import ca.uhn.fhir.cr.common.IRepositoryFactory; import ca.uhn.fhir.cr.common.RepositoryFactoryForRepositoryInterface; +import ca.uhn.fhir.cr.config.CrBaseConfig; import ca.uhn.fhir.cr.config.ProviderLoader; import ca.uhn.fhir.cr.config.ProviderSelector; import ca.uhn.fhir.cr.config.RepositoryConfig; @@ -39,7 +40,7 @@ import ca.uhn.fhir.cr.r4.measure.CareGapsOperationProvider; import ca.uhn.fhir.cr.r4.measure.CollectDataOperationProvider; import ca.uhn.fhir.cr.r4.measure.DataRequirementsOperationProvider; import ca.uhn.fhir.cr.r4.measure.MeasureOperationsProvider; -import ca.uhn.fhir.cr.r4.measure.MeasureReportPeriodRequestProcessingService; +import ca.uhn.fhir.cr.r4.measure.MeasureReportPeriodRequestValidatorAndConverter; import ca.uhn.fhir.cr.r4.measure.SubmitDataProvider; import ca.uhn.fhir.rest.server.RestfulServer; import org.opencds.cqf.fhir.cql.EvaluationSettings; @@ -58,13 +59,12 @@ import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Import; -import java.time.ZoneOffset; import java.util.Arrays; import java.util.Map; import java.util.concurrent.Executor; @Configuration -@Import({RepositoryConfig.class}) +@Import({RepositoryConfig.class, CrBaseConfig.class}) public class CrR4Config { @Bean @@ -149,9 +149,9 @@ public class CrR4Config { @Bean MeasureOperationsProvider r4MeasureOperationsProvider( IMeasureServiceFactory theR4MeasureServiceFactory, - MeasureReportPeriodRequestProcessingService theMeasureReportPeriodRequestProcessingService) { + MeasureReportPeriodRequestValidatorAndConverter theMeasureReportPeriodRequestValidatorAndConverter) { return new MeasureOperationsProvider( - theR4MeasureServiceFactory, theMeasureReportPeriodRequestProcessingService); + theR4MeasureServiceFactory, theMeasureReportPeriodRequestValidatorAndConverter); } @Bean @@ -173,9 +173,4 @@ public class CrR4Config { return new ProviderLoader(theRestfulServer, theApplicationContext, selector); } - - @Bean - MeasureReportPeriodRequestProcessingService measureReportPeriodService() { - return new MeasureReportPeriodRequestProcessingService(ZoneOffset.UTC); - } } diff --git a/hapi-fhir-storage-cr/src/main/java/ca/uhn/fhir/cr/r4/measure/MeasureOperationsProvider.java b/hapi-fhir-storage-cr/src/main/java/ca/uhn/fhir/cr/r4/measure/MeasureOperationsProvider.java index 27eaa8eb594..cd9806c1ec9 100644 --- a/hapi-fhir-storage-cr/src/main/java/ca/uhn/fhir/cr/r4/measure/MeasureOperationsProvider.java +++ b/hapi-fhir-storage-cr/src/main/java/ca/uhn/fhir/cr/r4/measure/MeasureOperationsProvider.java @@ -37,13 +37,13 @@ import org.opencds.cqf.fhir.utility.monad.Eithers; public class MeasureOperationsProvider { private final IMeasureServiceFactory myR4MeasureServiceFactory; - private final MeasureReportPeriodRequestProcessingService myMeasureReportPeriodRequestProcessingService; + private final MeasureReportPeriodRequestValidatorAndConverter myMeasureReportPeriodRequestProcessingService; public MeasureOperationsProvider( IMeasureServiceFactory theR4MeasureServiceFactory, - MeasureReportPeriodRequestProcessingService theMeasureReportPeriodRequestProcessingService) { + MeasureReportPeriodRequestValidatorAndConverter theMeasureReportPeriodRequestValidatorAndConverter) { myR4MeasureServiceFactory = theR4MeasureServiceFactory; - myMeasureReportPeriodRequestProcessingService = theMeasureReportPeriodRequestProcessingService; + myMeasureReportPeriodRequestProcessingService = theMeasureReportPeriodRequestValidatorAndConverter; } /** diff --git a/hapi-fhir-storage-cr/src/main/java/ca/uhn/fhir/cr/r4/measure/MeasureReportPeriodRequestProcessingService.java b/hapi-fhir-storage-cr/src/main/java/ca/uhn/fhir/cr/r4/measure/MeasureReportPeriodRequestValidatorAndConverter.java similarity index 97% rename from hapi-fhir-storage-cr/src/main/java/ca/uhn/fhir/cr/r4/measure/MeasureReportPeriodRequestProcessingService.java rename to hapi-fhir-storage-cr/src/main/java/ca/uhn/fhir/cr/r4/measure/MeasureReportPeriodRequestValidatorAndConverter.java index 20cf556f0e7..ac53d1a1163 100644 --- a/hapi-fhir-storage-cr/src/main/java/ca/uhn/fhir/cr/r4/measure/MeasureReportPeriodRequestProcessingService.java +++ b/hapi-fhir-storage-cr/src/main/java/ca/uhn/fhir/cr/r4/measure/MeasureReportPeriodRequestValidatorAndConverter.java @@ -53,8 +53,8 @@ import java.util.function.Function; *
  • yyyy-MM-ddTHH:mm:ss
  • * */ -public class MeasureReportPeriodRequestProcessingService { - private static final Logger ourLog = LoggerFactory.getLogger(MeasureReportPeriodRequestProcessingService.class); +public class MeasureReportPeriodRequestValidatorAndConverter { + private static final Logger ourLog = LoggerFactory.getLogger(MeasureReportPeriodRequestValidatorAndConverter.class); private static final DateTimeFormatter DATE_TIME_FORMATTER_YYYY_INPUT = DateTimeFormatter.ofPattern("yyyy"); private static final DateTimeFormatter DATE_TIME_FORMATTER_YYYY_MM_INPUT = DateTimeFormatter.ofPattern("yyyy-MM"); @@ -74,7 +74,7 @@ public class MeasureReportPeriodRequestProcessingService { private final ZoneId myFallbackTimezone; - public MeasureReportPeriodRequestProcessingService(ZoneId theFallbackTimezone) { + public MeasureReportPeriodRequestValidatorAndConverter(ZoneId theFallbackTimezone) { myFallbackTimezone = theFallbackTimezone; } diff --git a/hapi-fhir-storage-cr/src/test/java/ca/uhn/fhir/cr/r4/MeasureOperationProviderTest.java b/hapi-fhir-storage-cr/src/test/java/ca/uhn/fhir/cr/r4/MeasureOperationProviderTest.java index f30f53b6644..8b79582ce34 100644 --- a/hapi-fhir-storage-cr/src/test/java/ca/uhn/fhir/cr/r4/MeasureOperationProviderTest.java +++ b/hapi-fhir-storage-cr/src/test/java/ca/uhn/fhir/cr/r4/MeasureOperationProviderTest.java @@ -1,6 +1,7 @@ package ca.uhn.fhir.cr.r4; import ca.uhn.fhir.rest.server.provider.ProviderConstants; +import jakarta.annotation.Nullable; import org.hl7.fhir.r4.model.DateType; import org.hl7.fhir.r4.model.IdType; import org.hl7.fhir.r4.model.MeasureReport; @@ -12,6 +13,8 @@ import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; import org.springframework.test.context.junit.jupiter.SpringExtension; +import java.time.temporal.ChronoUnit; +import java.util.Date; import java.util.NoSuchElementException; import java.util.Optional; @@ -69,17 +72,17 @@ class MeasureOperationProviderTest extends BaseCrR4TestServer { void testHedis2022() { runWithPatient("BCSEHEDISMY2022", "Patient/Patient-5", 0, 0, 0, 0, false, - "Interval[2020-10-01T00:00:00.000, 2022-12-31T23:59:59.999]"); + "Interval[2020-10-01T00:00:00.000, 2022-12-31T23:59:59.000]"); runWithPatient("BCSEHEDISMY2022", "Patient/Patient-7", 1, 1, 0, 0, true, - "Interval[2020-10-01T00:00:00.000, 2022-12-31T23:59:59.999]"); + "Interval[2020-10-01T00:00:00.000, 2022-12-31T23:59:59.000]"); runWithPatient("BCSEHEDISMY2022", "Patient/Patient-9", 0, 0, 0, 0, true, - "Interval[2020-10-01T00:00:00.000, 2022-12-31T23:59:59.999]"); + "Interval[2020-10-01T00:00:00.000, 2022-12-31T23:59:59.000]"); runWithPatient("BCSEHEDISMY2022", "Patient/Patient-21", 1, 0, 1, 0, true, - "Interval[2020-10-01T00:00:00.000, 2022-12-31T23:59:59.999]"); + "Interval[2020-10-01T00:00:00.000, 2022-12-31T23:59:59.000]"); runWithPatient("BCSEHEDISMY2022", "Patient/Patient-23", 1, 1, 0, 0, true, - "Interval[2020-10-01T00:00:00.000, 2022-12-31T23:59:59.999]"); + "Interval[2020-10-01T00:00:00.000, 2022-12-31T23:59:59.000]"); runWithPatient("BCSEHEDISMY2022", "Patient/Patient-65", 1, 1, 0, 1, true, - "Interval[2020-10-01T00:00:00.000, 2022-12-31T23:59:59.999]"); + "Interval[2020-10-01T00:00:00.000, 2022-12-31T23:59:59.000]"); } void testClientNonPatientBasedMeasureEvaluate() { diff --git a/hapi-fhir-storage-cr/src/test/java/ca/uhn/fhir/cr/r4/measure/MeasureReportPeriodRequestProcessingServiceTest.java b/hapi-fhir-storage-cr/src/test/java/ca/uhn/fhir/cr/r4/measure/MeasureReportPeriodRequestValidatorAndConverterTest.java similarity index 97% rename from hapi-fhir-storage-cr/src/test/java/ca/uhn/fhir/cr/r4/measure/MeasureReportPeriodRequestProcessingServiceTest.java rename to hapi-fhir-storage-cr/src/test/java/ca/uhn/fhir/cr/r4/measure/MeasureReportPeriodRequestValidatorAndConverterTest.java index a48e9ac98c4..f43c239d1d9 100644 --- a/hapi-fhir-storage-cr/src/test/java/ca/uhn/fhir/cr/r4/measure/MeasureReportPeriodRequestProcessingServiceTest.java +++ b/hapi-fhir-storage-cr/src/test/java/ca/uhn/fhir/cr/r4/measure/MeasureReportPeriodRequestValidatorAndConverterTest.java @@ -17,11 +17,10 @@ import java.util.stream.Stream; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatThrownBy; -class MeasureReportPeriodRequestProcessingServiceTest { +class MeasureReportPeriodRequestValidatorAndConverterTest { - private final MeasureReportPeriodRequestProcessingService myTestSubject = new MeasureReportPeriodRequestProcessingService(ZoneOffset.UTC); + private final MeasureReportPeriodRequestValidatorAndConverter myTestSubject = new MeasureReportPeriodRequestValidatorAndConverter(ZoneOffset.UTC); - // LUKETODO: what happens if only one is null? @ParameterizedTest @CsvSource( nullValues = {"null"}, value={