use of se.inera.intyg.webcert.web.integration.validators.ResultValidator 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;
}
use of se.inera.intyg.webcert.web.integration.validators.ResultValidator in project webcert by sklintyg.
the class CreateDraftCertificateValidatorImplTest method testValidatePatientPersonIdMissing.
@Test
public void testValidatePatientPersonIdMissing() {
ResultValidator result = validator.validate(buildIntyg(LUSE, "efternamn", "förnamn", null, "fullständigt namn", "hosHsaId", "enhetsnamn", "enhetHsaId", true));
assertTrue(result.hasErrors());
}
use of se.inera.intyg.webcert.web.integration.validators.ResultValidator in project webcert by sklintyg.
the class CreateDraftCertificateValidatorImplTest method testTsBasIsNotAllowedWhenPatientIsSekretessmarkerad.
@Test
public void testTsBasIsNotAllowedWhenPatientIsSekretessmarkerad() {
when(authoritiesHelper.getIntygstyperAllowedForSekretessmarkering()).thenReturn(new HashSet<>(Arrays.asList(Fk7263EntryPoint.MODULE_ID)));
when(patientDetailsResolver.getPersonFromPUService(any(Personnummer.class))).thenReturn(buildPersonSvar(PersonSvar.Status.FOUND));
when(patientDetailsResolver.getSekretessStatus(any(Personnummer.class))).thenReturn(SekretessStatus.TRUE);
ResultValidator result = validator.validateApplicationErrors(buildIntyg(TSBAS, "efternamn", "förnamn", "fullständigt namn", "enhetsnamn", true), user);
assertTrue(result.hasErrors());
verify(patientDetailsResolver).getSekretessStatus(any(Personnummer.class));
}
use of se.inera.intyg.webcert.web.integration.validators.ResultValidator in project webcert by sklintyg.
the class CreateDraftCertificateValidatorImplTest method testValidatePatientEfternamnMissing.
@Test
public void testValidatePatientEfternamnMissing() {
ResultValidator result = validator.validate(buildIntyg(LUSE, null, "förnamn", "fullständigt namn", "enhetsnamn", true));
assertTrue(result.hasErrors());
}
use of se.inera.intyg.webcert.web.integration.validators.ResultValidator in project webcert by sklintyg.
the class CreateDraftCertificateValidatorImplTest method testCreateDBAllowedWhenPatientIsDeceased.
@Test
public void testCreateDBAllowedWhenPatientIsDeceased() {
when(patientDetailsResolver.getPersonFromPUService(any(Personnummer.class))).thenReturn(buildPersonSvar(PersonSvar.Status.FOUND));
when(patientDetailsResolver.getSekretessStatus(any(Personnummer.class))).thenReturn(SekretessStatus.FALSE);
when(patientDetailsResolver.isAvliden(any(Personnummer.class))).thenReturn(true);
ResultValidator result = validator.validateApplicationErrors(buildIntyg(DbModuleEntryPoint.MODULE_ID, "efternamn", "förnamn", "fullständigt namn", "enhetsnamn", true), buildUserUnauthorized());
assertFalse(result.hasErrors());
verify(patientDetailsResolver).isAvliden(any(Personnummer.class));
}
Aggregations