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()));
}
}
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());
}
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");
}
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());
}
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));
}
Aggregations