From 7bcfa97e4cb84135a0bd4d13eb6e80ae32a0cb8d Mon Sep 17 00:00:00 2001 From: Edwin Tan Date: Thu, 9 Jan 2025 09:27:15 -0800 Subject: [PATCH] MAT-8017: add intended venue to qi-core measures --- pom.xml | 2 +- .../resources/MeasureControllerMvcTest.java | 182 ++++++++++++++++++ 2 files changed, 183 insertions(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index cc3794b5..81ed5e08 100644 --- a/pom.xml +++ b/pom.xml @@ -133,7 +133,7 @@ gov.cms.madie madie-java-models - 0.6.73-SNAPSHOT + 0.6.75-SNAPSHOT gov.cms.madie diff --git a/src/test/java/cms/gov/madie/measure/resources/MeasureControllerMvcTest.java b/src/test/java/cms/gov/madie/measure/resources/MeasureControllerMvcTest.java index 2e6b36ef..e5dab099 100644 --- a/src/test/java/cms/gov/madie/measure/resources/MeasureControllerMvcTest.java +++ b/src/test/java/cms/gov/madie/measure/resources/MeasureControllerMvcTest.java @@ -1184,6 +1184,188 @@ public void testNewMeasureFailedWithoutSecurityToken() throws Exception { assertEquals("Forbidden", resultStr); } + @Test + public void testNewFhirMeasurePassesWithValidIntendedVenueOfEh() throws Exception { + CodeConcept eh = + CodeConcept.builder() + .code("eh") + .codeSystem("http://hl7.org/fhir/us/cqfmeasures/CodeSystem/intended-venue-codes") + .display("EH") + .definition( + "An eligible hospital is an acute care facility that is eligible to participate in a quality measurement initiative.") + .build(); + + FhirMeasure measure = + FhirMeasure.builder() + .id("testId") + .model(String.valueOf(ModelType.QI_CORE)) + .measureSetId("testMeasureSetId") + .cqlLibraryName("TestCqlLibraryName") + .ecqmTitle("testECqm") + .measureName("testMeasureName") + .versionId("0.0.000") + .build(); + + measure.setIntendedVenue(eh); + + final String measureAsJson = toJsonString(measure); + + when(measureService.createMeasure( + any(Measure.class), anyString(), anyString(), any(Boolean.class))) + .thenReturn(measure); + + mockMvc + .perform( + post("/measure") + .with(user(TEST_USER_ID)) + .with(csrf()) + .header("Authorization", TEST_USER_ID) + .content(measureAsJson) + .contentType(MediaType.APPLICATION_JSON) + .accept(MediaType.APPLICATION_JSON)) + .andExpect(status().isCreated()); + + verify(measureService, times(1)) + .createMeasure( + measureArgumentCaptor.capture(), anyString(), anyString(), any(Boolean.class)); + verifyNoMoreInteractions(measureRepository); + } + + @Test + public void testNewFhirMeasurePassesWithValidIntendedVenueOfEc() throws Exception { + CodeConcept ec = + CodeConcept.builder() + .code("ec") + .codeSystem("http://hl7.org/fhir/us/cqfmeasures/CodeSystem/intended-venue-codes") + .display("EC") + .definition( + "An eligible clinician is a clinician who is eligible to participate in a quality measurement initiative.") + .build(); + + FhirMeasure measure = + FhirMeasure.builder() + .id("testId") + .model(String.valueOf(ModelType.QI_CORE)) + .measureSetId("testMeasureSetId") + .cqlLibraryName("TestCqlLibraryName") + .ecqmTitle("testECqm") + .measureName("testMeasureName") + .versionId("0.0.000") + .build(); + + measure.setIntendedVenue(ec); + + final String measureAsJson = toJsonString(measure); + + when(measureService.createMeasure( + any(Measure.class), anyString(), anyString(), any(Boolean.class))) + .thenReturn(measure); + + mockMvc + .perform( + post("/measure") + .with(user(TEST_USER_ID)) + .with(csrf()) + .header("Authorization", TEST_USER_ID) + .content(measureAsJson) + .contentType(MediaType.APPLICATION_JSON) + .accept(MediaType.APPLICATION_JSON)) + .andExpect(status().isCreated()); + + verify(measureService, times(1)) + .createMeasure( + measureArgumentCaptor.capture(), anyString(), anyString(), any(Boolean.class)); + verifyNoMoreInteractions(measureRepository); + } + + @Test + public void testNewFhirMeasurePassesWithInvalidIntendedVenueOfEh() throws Exception { + CodeConcept invalidEh = + CodeConcept.builder() + .code("invalidEh") + .codeSystem("http://hl7.org/fhir/us/cqfmeasures/CodeSystem/intended-venue-codes") + .display("EH") + .definition( + "An eligible hospital is an acute care facility that is eligible to participate in a quality measurement initiative.") + .build(); + + FhirMeasure measure = + FhirMeasure.builder() + .id("testId") + .model(String.valueOf(ModelType.QI_CORE)) + .measureSetId("testMeasureSetId") + .cqlLibraryName("TestCqlLibraryName") + .ecqmTitle("testECqm") + .measureName("testMeasureName") + .versionId("0.0.000") + .build(); + + measure.setIntendedVenue(invalidEh); + + final String measureAsJson = toJsonString(measure); + + when(measureService.createMeasure( + any(Measure.class), anyString(), anyString(), any(Boolean.class))) + .thenReturn(measure); + + mockMvc + .perform( + post("/measure") + .with(user(TEST_USER_ID)) + .with(csrf()) + .header("Authorization", TEST_USER_ID) + .content(measureAsJson) + .contentType(MediaType.APPLICATION_JSON) + .accept(MediaType.APPLICATION_JSON)) + .andExpect(status().isBadRequest()) + .andExpect(jsonPath("$.validationErrors.measure").value("Intended Venue is invalid")); + verifyNoInteractions(measureRepository); + } + + @Test + public void testNewFhirMeasurePassesWithInvalidIntendedVenueOfEc() throws Exception { + CodeConcept invalidEc = + CodeConcept.builder() + .code("invalidEc") + .codeSystem("http://hl7.org/fhir/us/cqfmeasures/CodeSystem/intended-venue-codes") + .display("EH") + .definition( + "An eligible hospital is an acute care facility that is eligible to participate in a quality measurement initiative.") + .build(); + + FhirMeasure measure = + FhirMeasure.builder() + .id("testId") + .model(String.valueOf(ModelType.QI_CORE)) + .measureSetId("testMeasureSetId") + .cqlLibraryName("TestCqlLibraryName") + .ecqmTitle("testECqm") + .measureName("testMeasureName") + .versionId("0.0.000") + .build(); + + measure.setIntendedVenue(invalidEc); + + final String measureAsJson = toJsonString(measure); + + when(measureService.createMeasure( + any(Measure.class), anyString(), anyString(), any(Boolean.class))) + .thenReturn(measure); + + mockMvc + .perform( + post("/measure") + .with(user(TEST_USER_ID)) + .with(csrf()) + .header("Authorization", TEST_USER_ID) + .content(measureAsJson) + .contentType(MediaType.APPLICATION_JSON) + .accept(MediaType.APPLICATION_JSON)) + .andExpect(status().isBadRequest()) + .andExpect(jsonPath("$.validationErrors.measure").value("Intended Venue is invalid")); + verifyNoInteractions(measureRepository); + } + @Test public void testGetMeasuresNoQueryParams() throws Exception { MeasureListDTO m1 =