Search in sources :

Example 16 with Personnummer

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

the class ElegWebCertUserDetailsService method decorateWebcertUserWithSekretessMarkering.

private void decorateWebcertUserWithSekretessMarkering(WebCertUser webCertUser, HoSPersonType hosPerson) {
    // Make sure we have a valid personnr to work with..
    Personnummer personNummer = Personnummer.createPersonnummer(hosPerson.getPersonId().getExtension()).orElseThrow(() -> new WebCertServiceException(WebCertServiceErrorCodeEnum.PU_PROBLEM, String.format("Can't determine sekretesstatus for invalid personId %s", hosPerson.getPersonId().getExtension())));
    PersonSvar person = puService.getPerson(personNummer);
    if (person.getStatus() == PersonSvar.Status.FOUND) {
        webCertUser.setSekretessMarkerad(person.getPerson().isSekretessmarkering());
    } else {
        throw new WebCertServiceException(WebCertServiceErrorCodeEnum.PU_PROBLEM, String.format("PU replied with %s - Sekretesstatus cannot be determined for person %s", person.getStatus(), personNummer.getPersonnummerWithDash()));
    }
}
Also used : Personnummer(se.inera.intyg.schemas.contract.Personnummer) PersonSvar(se.inera.intyg.infra.integration.pu.model.PersonSvar) WebCertServiceException(se.inera.intyg.webcert.common.service.exception.WebCertServiceException)

Example 17 with Personnummer

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

the class IntygServiceTest method testHandleSignedWithSigneraSkickaDirekt.

@Test
public void testHandleSignedWithSigneraSkickaDirekt() throws Exception {
    final String intygId = "intygId";
    final String intygTyp = "intygTyp";
    final String relationIntygId = "relationIntygId";
    final String recipient = new Fk7263EntryPoint().getDefaultRecipient();
    final Personnummer personnummer = PERSNR;
    Fk7263Utlatande utlatande = objectMapper.readValue(json, Fk7263Utlatande.class);
    utlatande.setId(intygId);
    utlatande.setTyp(intygTyp);
    utlatande.getGrundData().getPatient().setPersonId(personnummer);
    Utkast utkast = new Utkast();
    utkast.setIntygsId(intygId);
    utkast.setIntygsTyp(intygTyp);
    utkast.setModel(json);
    when(utkastRepository.findOne(intygId)).thenReturn(utkast);
    when(moduleFacade.getUtlatandeFromInternalModel(eq(intygTyp), anyString())).thenReturn(utlatande);
    when(certificateRelationService.getNewestRelationOfType(eq(intygId), eq(RelationKod.ERSATT), eq(Arrays.asList(UtkastStatus.SIGNED)))).thenReturn(Optional.empty());
    when(moduleRegistry.getModuleEntryPoint(intygTyp)).thenReturn(new Fk7263EntryPoint());
    when(authoritiesHelper.isFeatureActive(AuthoritiesConstants.FEATURE_SIGNERA_SKICKA_DIREKT, intygTyp)).thenReturn(true);
    intygService.handleAfterSigned(utkast);
    verify(certificateSenderService).sendCertificate(eq(intygId), eq(personnummer), anyString(), eq(recipient), eq(true));
    verify(mockMonitoringService).logIntygSent(intygId, recipient);
    verify(logservice).logSendIntygToRecipient(any(LogRequest.class));
    verify(arendeService, never()).closeCompletionsAsHandled(relationIntygId, intygTyp);
    verify(notificationService).sendNotificationForIntygSent(intygId);
    ArgumentCaptor<Utkast> utkastCaptor = ArgumentCaptor.forClass(Utkast.class);
    verify(utkastRepository).save(utkastCaptor.capture());
    assertNotNull(utkastCaptor.getValue().getSkickadTillMottagareDatum());
    assertEquals(recipient, utkastCaptor.getValue().getSkickadTillMottagare());
}
Also used : Personnummer(se.inera.intyg.schemas.contract.Personnummer) LogRequest(se.inera.intyg.webcert.web.service.log.dto.LogRequest) Fk7263Utlatande(se.inera.intyg.common.fk7263.model.internal.Fk7263Utlatande) Utkast(se.inera.intyg.webcert.persistence.utkast.model.Utkast) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) Fk7263EntryPoint(se.inera.intyg.common.fk7263.support.Fk7263EntryPoint) Test(org.junit.Test)

Example 18 with Personnummer

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

the class PersonApiControllerTest method testGetPersonuppgifterMissingPerson.

@Test
public void testGetPersonuppgifterMissingPerson() {
    Personnummer personnummer = createPnr("19010101-0101");
    when(puService.getPerson(any(Personnummer.class))).thenReturn(new PersonSvar(null, PersonSvar.Status.NOT_FOUND));
    Response response = personCtrl.getPersonuppgifter(personnummer.getPersonnummer());
    assertNotNull(response);
    assertEquals(response.getStatus(), Response.Status.OK.getStatusCode());
    PersonuppgifterResponse res = (PersonuppgifterResponse) response.getEntity();
    assertEquals(PersonSvar.Status.NOT_FOUND, res.getStatus());
    assertNull(res.getPerson());
    verify(mockMonitoringService).logPULookup(personnummer, "NOT_FOUND");
}
Also used : Personnummer(se.inera.intyg.schemas.contract.Personnummer) PersonuppgifterResponse(se.inera.intyg.webcert.web.web.controller.api.dto.PersonuppgifterResponse) Response(javax.ws.rs.core.Response) PersonuppgifterResponse(se.inera.intyg.webcert.web.web.controller.api.dto.PersonuppgifterResponse) PersonSvar(se.inera.intyg.infra.integration.pu.model.PersonSvar) Test(org.junit.Test)

Example 19 with Personnummer

use of se.inera.intyg.schemas.contract.Personnummer 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());
}
Also used : Personnummer(se.inera.intyg.schemas.contract.Personnummer) Response(javax.ws.rs.core.Response) QueryIntygResponse(se.inera.intyg.webcert.web.web.controller.api.dto.QueryIntygResponse) QueryIntygResponse(se.inera.intyg.webcert.web.web.controller.api.dto.QueryIntygResponse) SekretessStatus(se.inera.intyg.webcert.common.model.SekretessStatus) Test(org.junit.Test)

Example 20 with Personnummer

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

the class IntygModuleApiControllerIT method testCompletionContainsCommentStringInOvrigt.

@Test
public void testCompletionContainsCommentStringInOvrigt() throws Exception {
    final String personnummer = "19121212-1212";
    final String kommentar = "Testkommentar";
    Personnummer pers = Personnummer.createPersonnummer(personnummer).get();
    RestAssured.sessionId = getAuthSession(DEFAULT_LAKARE);
    String intygsTyp = "lisjp";
    String intygsId = createSignedIntyg(intygsTyp, personnummer);
    createArendeQuestion(intygsTyp, intygsId, personnummer, ArendeAmne.KOMPLT);
    Map<String, String> pathParams = new HashMap<>();
    pathParams.put("intygsTyp", intygsTyp);
    pathParams.put("intygsId", intygsId);
    CopyIntygRequest copyIntygRequest = new CopyIntygRequest();
    copyIntygRequest.setPatientPersonnummer(pers);
    copyIntygRequest.setKommentar(kommentar);
    final Response response = given().cookie("ROUTEID", BaseRestIntegrationTest.routeId).contentType(ContentType.JSON).and().pathParams(pathParams).and().body(copyIntygRequest).expect().statusCode(200).when().post("moduleapi/intyg/{intygsTyp}/{intygsId}/komplettera").then().body("intygsUtkastId", not(isEmptyString())).body("intygsUtkastId", not(equalTo(intygsId))).body("intygsTyp", equalTo(intygsTyp)).extract().response();
    JsonPath intygJson = new JsonPath(response.body().asString());
    String newUtkastId = intygJson.getString("intygsUtkastId");
    given().cookie("ROUTEID", BaseRestIntegrationTest.routeId).expect().statusCode(200).when().get("moduleapi/intyg/" + intygsTyp + "/" + newUtkastId).then().body(matchesJsonSchemaInClasspath("jsonschema/webcert-get-intyg-response-schema.json")).body("contents.ovrigt", containsString(kommentar));
}
Also used : Personnummer(se.inera.intyg.schemas.contract.Personnummer) Response(com.jayway.restassured.response.Response) HttpServletResponse(javax.servlet.http.HttpServletResponse) CopyIntygRequest(se.inera.intyg.webcert.web.web.controller.api.dto.CopyIntygRequest) HashMap(java.util.HashMap) Matchers.isEmptyString(org.hamcrest.Matchers.isEmptyString) Matchers.containsString(org.hamcrest.Matchers.containsString) JsonPath(com.jayway.restassured.path.json.JsonPath) BaseRestIntegrationTest(se.inera.intyg.webcert.web.web.controller.integrationtest.BaseRestIntegrationTest) Test(org.junit.Test)

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