use of se.inera.intyg.webcert.web.web.controller.api.dto.QueryIntygResponse in project webcert by sklintyg.
the class UtkastApiController method filterDraftsForUnit.
/**
* Creates a filtered query to get drafts for a specific unit.
*/
@GET
@Path("/")
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON + UTF_8_CHARSET)
public Response filterDraftsForUnit(@QueryParam("") QueryIntygParameter filterParameters) {
authoritiesValidator.given(getWebCertUserService().getUser()).features(AuthoritiesConstants.FEATURE_HANTERA_INTYGSUTKAST).orThrow();
UtkastFilter utkastFilter = createUtkastFilter(filterParameters);
QueryIntygResponse queryResponse = performUtkastFilterQuery(utkastFilter);
return Response.ok(queryResponse).build();
}
use of se.inera.intyg.webcert.web.web.controller.api.dto.QueryIntygResponse in project webcert by sklintyg.
the class UtkastApiControllerTest method testFilterDraftsForUnitSkipsSekretessIntygForUserWithoutAuthorithy.
@Test
public void testFilterDraftsForUnitSkipsSekretessIntygForUserWithoutAuthorithy() {
setupUser("", LuseEntryPoint.MODULE_ID, AuthoritiesConstants.FEATURE_HANTERA_INTYGSUTKAST);
Map<Personnummer, SekretessStatus> sekretessMap = mock(Map.class);
when(sekretessMap.get(eq(PATIENT_PERSONNUMMER))).thenReturn(SekretessStatus.FALSE);
when(sekretessMap.get(eq(PATIENT_PERSONNUMMER_PU_SEKRETESS))).thenReturn(SekretessStatus.TRUE);
when(patientDetailsResolver.getSekretessStatusForList(anyList())).thenReturn(sekretessMap);
when(utkastService.filterIntyg(any())).thenReturn(Arrays.asList(buildUtkast(PATIENT_PERSONNUMMER), buildUtkast(PATIENT_PERSONNUMMER_PU_SEKRETESS)));
final Response response = utkastController.filterDraftsForUnit(buildQueryIntygParameter());
final QueryIntygResponse queryIntygResponse = response.readEntity(QueryIntygResponse.class);
assertEquals(1, queryIntygResponse.getTotalCount());
assertEquals(1, queryIntygResponse.getResults().size());
assertEquals(PATIENT_PERSONNUMMER, queryIntygResponse.getResults().get(0).getPatientId());
}
use of se.inera.intyg.webcert.web.web.controller.api.dto.QueryIntygResponse in project webcert by sklintyg.
the class UtkastApiControllerTest method testFilterDraftsForUnit.
@Test
public void testFilterDraftsForUnit() {
setupUser(AuthoritiesConstants.PRIVILEGE_HANTERA_SEKRETESSMARKERAD_PATIENT, LuseEntryPoint.MODULE_ID, AuthoritiesConstants.FEATURE_HANTERA_INTYGSUTKAST);
when(utkastService.filterIntyg(any())).thenReturn(Arrays.asList(buildUtkast(PATIENT_PERSONNUMMER), buildUtkast(PATIENT_PERSONNUMMER)));
final Response response = utkastController.filterDraftsForUnit(buildQueryIntygParameter());
final QueryIntygResponse queryIntygResponse = response.readEntity(QueryIntygResponse.class);
assertEquals(2, queryIntygResponse.getTotalCount());
assertEquals(2, queryIntygResponse.getResults().size());
}
use of se.inera.intyg.webcert.web.web.controller.api.dto.QueryIntygResponse in project webcert by sklintyg.
the class UtkastApiControllerTest method testFilterDraftsForUnitSkipAllIntygWithUndefinedSekretessStatus.
@Test
public void testFilterDraftsForUnitSkipAllIntygWithUndefinedSekretessStatus() {
setupUser(AuthoritiesConstants.PRIVILEGE_HANTERA_SEKRETESSMARKERAD_PATIENT, LuseEntryPoint.MODULE_ID, AuthoritiesConstants.FEATURE_HANTERA_INTYGSUTKAST);
Map<Personnummer, SekretessStatus> sekretessMap = mock(Map.class);
when(sekretessMap.get(any())).thenReturn(SekretessStatus.UNDEFINED);
when(patientDetailsResolver.getSekretessStatusForList(anyList())).thenReturn(sekretessMap);
when(utkastService.filterIntyg(any())).thenReturn(Arrays.asList(buildUtkast(PATIENT_PERSONNUMMER), buildUtkast(PATIENT_PERSONNUMMER)));
final Response response = utkastController.filterDraftsForUnit(buildQueryIntygParameter());
final QueryIntygResponse queryIntygResponse = response.readEntity(QueryIntygResponse.class);
assertEquals(0, queryIntygResponse.getTotalCount());
assertEquals(0, queryIntygResponse.getResults().size());
}
use of se.inera.intyg.webcert.web.web.controller.api.dto.QueryIntygResponse in project webcert by sklintyg.
the class UtkastApiControllerIT method testFilterDraftsForUnitPagination.
@Test
public void testFilterDraftsForUnitPagination() {
RestAssured.sessionId = getAuthSession(DEFAULT_LAKARE);
ArrayList<String> utkastIds = new ArrayList(), utkastPersonIds = new ArrayList();
for (int i = 0; i < 2; i++) {
for (int j = 0; j < 8; j++) {
utkastIds.add(createUtkast("luse", DEFAULT_PATIENT_PERSONNUMMER));
utkastPersonIds.add(DEFAULT_PATIENT_PERSONNUMMER);
}
// Sekretessmarkering på patient
utkastIds.add(createUtkast("luse", "195401232540"));
utkastPersonIds.add("19540123-2540");
}
// The newest utkast will be returned first, reverse the expected list
Collections.reverse(utkastIds);
Collections.reverse(utkastPersonIds);
QueryIntygResponse queryResponse = given().cookie("ROUTEID", BaseRestIntegrationTest.routeId).param("savedBy", DEFAULT_LAKARE.getHsaId()).param("enhetsId", DEFAULT_LAKARE.getEnhetId()).param("pageSize", 4).expect().statusCode(200).when().get("api/utkast").then().body(matchesJsonSchemaInClasspath("jsonschema/webcert-query-utkast-response-schema.json")).body("totalCount", equalTo(18)).extract().response().as(QueryIntygResponse.class);
Assert.assertEquals(4, queryResponse.getResults().size());
// Removed verification of intyg in the response.
// The timing resolution is too low on senastSparadDatum when running on the build environment.
// When running locally with dev profile and h2 we get millisecond resolution and the test works.
// We would need several seconds of sleep between createUtkast for this to work on the build environment.
/* for(int i = 0; i < 4; i++) {
ListIntygEntry entry = queryResponse.getResults().get(i);
Assert.assertEquals(utkastIds.get(i), entry.getIntygId());
Assert.assertEquals("fk7263", entry.getIntygType());
Assert.assertEquals(utkastPersonIds.get(i), entry.getPatientId().getPersonnummer());
}*/
QueryIntygResponse queryResponse2 = given().cookie("ROUTEID", BaseRestIntegrationTest.routeId).param("savedBy", DEFAULT_LAKARE.getHsaId()).param("enhetsId", DEFAULT_LAKARE.getEnhetId()).param("pageSize", 4).param("startFrom", 16).expect().statusCode(200).when().get("api/utkast").then().body(matchesJsonSchemaInClasspath("jsonschema/webcert-query-utkast-response-schema.json")).body("totalCount", equalTo(18)).extract().response().as(QueryIntygResponse.class);
Assert.assertEquals(2, queryResponse2.getResults().size());
/* for(int i = 0; i < 2; i++) {
ListIntygEntry entry = queryResponse2.getResults().get(i);
Assert.assertEquals(utkastIds.get(i + 16), entry.getIntygId());
Assert.assertEquals("fk7263", entry.getIntygType());
Assert.assertEquals(utkastPersonIds.get(i + 16), entry.getPatientId().getPersonnummer());
}*/
}
Aggregations