Search in sources :

Example 26 with Personnummer

use of se.inera.intyg.schemas.contract.Personnummer in project webcert by sklintyg.

the class CreateDraftCertificateValidatorImpl method validateApplicationErrors.

@Override
public ResultValidator validateApplicationErrors(Utlatande utlatande, IntygUser user) {
    ResultValidator errors = ResultValidator.newInstance();
    String personId = utlatande.getPatient().getPersonId().getExtension();
    Personnummer personnummer = createPersonnummer(errors, personId).orElse(null);
    if (errors.hasErrors()) {
        return errors;
    }
    // Check if PU-service is responding
    validatePUServiceResponse(errors, personnummer);
    if (errors.hasErrors()) {
        return errors;
    }
    validateSekretessmarkeringOchIntygsTyp(errors, personnummer, utlatande.getTypAvUtlatande(), user);
    validateCreateForAvlidenPatientAllowed(errors, personnummer, utlatande.getTypAvUtlatande().getCode());
    return errors;
}
Also used : Personnummer(se.inera.intyg.schemas.contract.Personnummer) ResultValidator(se.inera.intyg.webcert.web.integration.validators.ResultValidator)

Example 27 with Personnummer

use of se.inera.intyg.schemas.contract.Personnummer in project webcert by sklintyg.

the class CreateDraftCertificateValidatorImpl method validateApplicationErrors.

@Override
public ResultValidator validateApplicationErrors(Intyg intyg, IntygUser user) {
    ResultValidator errors = ResultValidator.newInstance();
    String personId = intyg.getPatient().getPersonId().getExtension();
    Personnummer personnummer = createPersonnummer(errors, personId).orElse(null);
    if (errors.hasErrors()) {
        return errors;
    }
    // Check if PU-service is responding
    validatePUServiceResponse(errors, personnummer);
    if (errors.hasErrors()) {
        return errors;
    }
    validateSekretessmarkeringOchIntygsTyp(errors, personnummer, intyg.getTypAvIntyg(), user);
    validateCreateForAvlidenPatientAllowed(errors, personnummer, intyg.getTypAvIntyg().getCode());
    return errors;
}
Also used : Personnummer(se.inera.intyg.schemas.contract.Personnummer) ResultValidator(se.inera.intyg.webcert.web.integration.validators.ResultValidator)

Example 28 with Personnummer

use of se.inera.intyg.schemas.contract.Personnummer in project webcert by sklintyg.

the class StatisticsGroupByUtilTest method testFilterInvalidPersonnummer.

@Test
public void testFilterInvalidPersonnummer() {
    List<GroupableItem> queryResult = new ArrayList<>();
    queryResult.add(new GroupableItem("id-1", HSA1, PNR1, FK7263));
    queryResult.add(new GroupableItem("id-2", HSA2, PNR2, TSBAS));
    queryResult.add(new GroupableItem("id-3", HSA1, null, FK7263));
    queryResult.add(new GroupableItem("id-4", HSA1, "", TSBAS));
    queryResult.add(new GroupableItem("id-5", HSA2, "thisisainvalidparameter", FK7263));
    List<Personnummer> result = testee.getPersonummerList(queryResult);
    assertEquals(2, result.size());
}
Also used : Personnummer(se.inera.intyg.schemas.contract.Personnummer) GroupableItem(se.inera.intyg.webcert.common.model.GroupableItem) ArrayList(java.util.ArrayList) Test(org.junit.Test)

Example 29 with Personnummer

use of se.inera.intyg.schemas.contract.Personnummer in project webcert by sklintyg.

the class StatisticsGroupByUtilTest method testFilterAndGroupForTwoResultsOfSameUnitOneIsSekrForVardadmin.

@Test
public void testFilterAndGroupForTwoResultsOfSameUnitOneIsSekrForVardadmin() {
    when(webCertUserService.getUser()).thenReturn(buildUserOfRole(AUTHORITIES_RESOLVER.getRole("VARDADMINISTRATOR")));
    Personnummer pnr1 = Personnummer.createPersonnummer(PNR1).get();
    Personnummer pnr2 = Personnummer.createPersonnummer(PNR2).get();
    Map<Personnummer, SekretessStatus> sekrMap = new HashMap<>();
    sekrMap.put(pnr1, SekretessStatus.FALSE);
    sekrMap.put(pnr2, SekretessStatus.TRUE);
    when(patientDetailsResolver.getSekretessStatusForList(anyList())).thenReturn(sekrMap);
    List<GroupableItem> queryResult = new ArrayList<>();
    queryResult.add(new GroupableItem("id-1", HSA1, PNR1, FK7263));
    queryResult.add(new GroupableItem("id-2", HSA1, PNR2, FK7263));
    // Should be filtered away
    queryResult.add(new GroupableItem("id-3", HSA1, PNR2, TSBAS));
    Map<String, Long> result = testee.toSekretessFilteredMap(queryResult);
    assertEquals(1, result.size());
    assertEquals(new Long(1L), result.get(HSA1));
}
Also used : Personnummer(se.inera.intyg.schemas.contract.Personnummer) GroupableItem(se.inera.intyg.webcert.common.model.GroupableItem) SekretessStatus(se.inera.intyg.webcert.common.model.SekretessStatus) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) Test(org.junit.Test)

Example 30 with Personnummer

use of se.inera.intyg.schemas.contract.Personnummer in project webcert by sklintyg.

the class StatisticsGroupByUtilTest method setup.

@Before
public void setup() {
    Personnummer pnr1 = Personnummer.createPersonnummer(PNR1).get();
    Personnummer pnr2 = Personnummer.createPersonnummer(PNR2).get();
    Personnummer pnr3 = Personnummer.createPersonnummer(PNR3).get();
    Map<Personnummer, SekretessStatus> sekrMap = new HashMap<>();
    sekrMap.put(pnr1, SekretessStatus.FALSE);
    sekrMap.put(pnr2, SekretessStatus.TRUE);
    sekrMap.put(pnr3, SekretessStatus.FALSE);
    when(patientDetailsResolver.getSekretessStatusForList(anyList())).thenReturn(sekrMap);
}
Also used : Personnummer(se.inera.intyg.schemas.contract.Personnummer) SekretessStatus(se.inera.intyg.webcert.common.model.SekretessStatus) HashMap(java.util.HashMap) Before(org.junit.Before)

Aggregations

Personnummer (se.inera.intyg.schemas.contract.Personnummer)44 Test (org.junit.Test)15 SekretessStatus (se.inera.intyg.webcert.common.model.SekretessStatus)15 WebCertServiceException (se.inera.intyg.webcert.common.service.exception.WebCertServiceException)11 Utkast (se.inera.intyg.webcert.persistence.utkast.model.Utkast)11 PersonSvar (se.inera.intyg.infra.integration.pu.model.PersonSvar)8 HashMap (java.util.HashMap)6 Map (java.util.Map)6 Response (javax.ws.rs.core.Response)6 WebCertUser (se.inera.intyg.webcert.web.service.user.dto.WebCertUser)6 LocalDateTime (java.time.LocalDateTime)4 ArrayList (java.util.ArrayList)4 List (java.util.List)4 Path (javax.ws.rs.Path)4 Produces (javax.ws.rs.Produces)4 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)4 GroupableItem (se.inera.intyg.webcert.common.model.GroupableItem)4 Collectors (java.util.stream.Collectors)3 Autowired (org.springframework.beans.factory.annotation.Autowired)3 Fk7263EntryPoint (se.inera.intyg.common.fk7263.support.Fk7263EntryPoint)3