use of se.inera.intyg.webcert.common.model.GroupableItem in project webcert by sklintyg.
the class UtkastRepositoryTest method testCountIntygWithStatusesGroupedByEnhetsId.
@Test
public void testCountIntygWithStatusesGroupedByEnhetsId() {
utkastRepository.save(UtkastTestUtil.buildUtkast(UtkastTestUtil.ENHET_1_ID, UtkastStatus.DRAFT_INCOMPLETE));
utkastRepository.save(UtkastTestUtil.buildUtkast(UtkastTestUtil.ENHET_2_ID, UtkastStatus.DRAFT_COMPLETE));
utkastRepository.save(UtkastTestUtil.buildUtkast(UtkastTestUtil.ENHET_3_ID, UtkastStatus.DRAFT_COMPLETE));
utkastRepository.save(UtkastTestUtil.buildUtkast(UtkastTestUtil.ENHET_1_ID, UtkastStatus.DRAFT_COMPLETE));
utkastRepository.save(UtkastTestUtil.buildUtkast(UtkastTestUtil.ENHET_2_ID, UtkastStatus.DRAFT_COMPLETE));
utkastRepository.save(UtkastTestUtil.buildUtkast(UtkastTestUtil.ENHET_1_ID, UtkastStatus.DRAFT_INCOMPLETE));
utkastRepository.save(UtkastTestUtil.buildUtkast(UtkastTestUtil.ENHET_3_ID, UtkastStatus.SIGNED));
List<GroupableItem> result = utkastRepository.getIntygWithStatusesByEnhetsId(Arrays.asList(UtkastTestUtil.ENHET_1_ID), Arrays.asList(UtkastStatus.DRAFT_COMPLETE, UtkastStatus.DRAFT_INCOMPLETE), Stream.of(UtkastTestUtil.INTYGSTYP_FK7263).collect(Collectors.toCollection(HashSet::new)));
assertThat(result.size(), is(3));
GroupableItem resObjs = result.get(0);
assertThat(resObjs.getEnhetsId(), equalTo(UtkastTestUtil.ENHET_1_ID));
assertThat(resObjs.getPersonnummer(), equalTo(PERSON_NUMMER.getPersonnummerWithDash()));
assertThat(resObjs.getIntygsTyp(), equalTo("fk7263"));
}
use of se.inera.intyg.webcert.common.model.GroupableItem in project webcert by sklintyg.
the class ArendeRepositoryTest method testCountUnhandledGroupedByEnhetIdsAndIntygstyper.
@Test
public void testCountUnhandledGroupedByEnhetIdsAndIntygstyper() {
// Question on enhet 1
repo.save(buildArende("signeratAv", "enhet1", Status.PENDING_INTERNAL_ACTION, "paminnelseMeddelandeId", null, "FKASSA", LocalDate.now(), ArendeAmne.KONTKT));
// Answer on enhet 1
repo.save(buildArende("signeratAv", "enhet1", Status.PENDING_INTERNAL_ACTION, "paminnelseMeddelandeId", "svarPaMeddelandeId", "FKASSA", LocalDate.now(), ArendeAmne.KONTKT));
// Closed question on enhet 1
repo.save(buildArende("signeratAv", "enhet1", Status.CLOSED, "paminnelseMeddelandeId", null, "FKASSA", LocalDate.now(), ArendeAmne.KONTKT));
// Reminder on enhet 1
repo.save(buildArende("signeratAv", "enhet1", Status.PENDING_INTERNAL_ACTION, "paminnelseMeddelandeId", null, "FKASSA", LocalDate.now(), ArendeAmne.PAMINN));
// Question on enhet 1
repo.save(buildArende("signeratAv", "enhet1", Status.PENDING_INTERNAL_ACTION, "paminnelseMeddelandeId", null, "FKASSA", LocalDate.now(), ArendeAmne.KONTKT));
// Question on enhet 2
repo.save(buildArende("signeratAv", "enhet2", Status.PENDING_INTERNAL_ACTION, "paminnelseMeddelandeId", null, "FKASSA", LocalDate.now(), ArendeAmne.KONTKT));
// Question on enhet 3
repo.save(buildArende("signeratAv", "enhet3", Status.PENDING_INTERNAL_ACTION, "paminnelseMeddelandeId", null, "FKASSA", LocalDate.now(), ArendeAmne.KONTKT));
// Question with type 2
Arende arendeType2 = buildArende("signeratAv", "enhet1", Status.PENDING_INTERNAL_ACTION, "paminnelseMeddelandeId", null, "FKASSA", LocalDate.now(), ArendeAmne.KONTKT);
arendeType2.setIntygTyp("INTYG_TYP_2");
repo.save(arendeType2);
// Question with type 3
Arende arendeType3 = buildArende("signeratAv", "enhet1", Status.PENDING_INTERNAL_ACTION, "paminnelseMeddelandeId", null, "FKASSA", LocalDate.now(), ArendeAmne.KONTKT);
arendeType2.setIntygTyp("INTYG_TYP_3");
repo.save(arendeType3);
List<String> enhetsIds = Arrays.asList("enhet1", "enhet2");
Set<String> intygsTyper = new HashSet<>(Arrays.asList("INTYG_TYP", "INTYG_TYP_2"));
List<GroupableItem> res = repo.getUnhandledByEnhetIdsAndIntygstyper(enhetsIds, intygsTyper);
assertNotNull(res);
assertEquals(4, res.size());
// assertEquals("enhet1", res.get(0)[0]);
// assertEquals(new Long(3), res.get(0)[1]);
// assertEquals("enhet2", res.get(1)[0]);
// assertEquals(new Long(1), res.get(1)[1]);
}
use of se.inera.intyg.webcert.common.model.GroupableItem in project webcert by sklintyg.
the class UtkastServiceImpl method getNbrOfUnsignedDraftsByCareUnits.
@Override
@Transactional(readOnly = true)
public Map<String, Long> getNbrOfUnsignedDraftsByCareUnits(List<String> careUnitIds) {
Map<String, Long> resultsMap = new HashMap<>();
if (careUnitIds == null || careUnitIds.isEmpty()) {
LOG.warn("No ids for Vardenheter was supplied");
return resultsMap;
}
WebCertUser user = webCertUserService.getUser();
// Get intygstyper from write privilege
Set<String> intygsTyper = authoritiesHelper.getIntygstyperForPrivilege(user, AuthoritiesConstants.PRIVILEGE_SKRIVA_INTYG);
List<GroupableItem> resultArr = utkastRepository.getIntygWithStatusesByEnhetsId(careUnitIds, ALL_DRAFT_STATUSES, intygsTyper);
return statisticsGroupByUtil.toSekretessFilteredMap(resultArr);
}
use of se.inera.intyg.webcert.common.model.GroupableItem in project webcert by sklintyg.
the class StatisticsGroupByUtil method toSekretessFilteredMap.
/**
* Takes a list of object[] where each object[] is one of utkast, fraga/svar or arende represented as:
*
* [0] id (unique, this is what we want to count per enhetsId)
* [1] enhetsId
* [2] personnummer
*
* This method will filter out any items belonging to a patient having sekretessmarkering and return the result as a
* map: EnhetsId -> number of id for that unit.
*
* @param groupableItems
* Each item is an array of: id, enhetsId, personnummer, intygsTyp.
* @return
* Map with enhetsId -> count, with personummer being sekretessmarkerade has been removed.
*/
public Map<String, Long> toSekretessFilteredMap(List<GroupableItem> groupableItems) {
if (groupableItems == null || groupableItems.size() == 0) {
return new HashMap<>();
}
List<GroupableItem> filteredGroupableItems = getFilteredGroupableItemList(groupableItems);
WebCertUser user = webCertUserService.getUser();
Map<Personnummer, SekretessStatus> sekretessStatusMap = patientDetailsResolver.getSekretessStatusForList(getPersonummerList(filteredGroupableItems));
// update sekretess status
filteredGroupableItems.forEach(item -> item.setSekretessStatus(sekretessStatusMap.get(createPnr(item.getPersonnummer()))));
return filteredGroupableItems.stream().filter(item -> item.getSekretessStatus() != SekretessStatus.UNDEFINED).filter(item -> authoritiesValidator.given(user, item.getIntygsTyp()).privilegeIf(AuthoritiesConstants.PRIVILEGE_HANTERA_SEKRETESSMARKERAD_PATIENT, item.getSekretessStatus() == SekretessStatus.TRUE).isVerified()).collect(Collectors.groupingBy(GroupableItem::getEnhetsId, Collectors.counting()));
}
use of se.inera.intyg.webcert.common.model.GroupableItem in project webcert by sklintyg.
the class StatisticsGroupByUtilTest method testFilterAndGroupForThreeResultsOfSameUnitTwoIsSekrForOfWhichOneIsTS.
@Test
public void testFilterAndGroupForThreeResultsOfSameUnitTwoIsSekrForOfWhichOneIsTS() {
when(webCertUserService.getUser()).thenReturn(createUser());
List<GroupableItem> queryResult = new ArrayList<>();
// No S. All can see.
queryResult.add(new GroupableItem("id-1", HSA1, PNR1, FK7263));
// Is S, LAKARE can see.
queryResult.add(new GroupableItem("id-2", HSA1, PNR2, FK7263));
// Should be OK
queryResult.add(new GroupableItem("id-3", HSA1, PNR1, TSBAS));
// Should be filtered away
queryResult.add(new GroupableItem("id-4", HSA1, PNR2, TSBAS));
Map<String, Long> result = testee.toSekretessFilteredMap(queryResult);
assertEquals(1, result.size());
assertEquals(new Long(3L), result.get(HSA1));
}
Aggregations