Search in sources :

Example 36 with ResultValidator

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;
}
Also used : Personnummer(se.inera.intyg.schemas.contract.Personnummer) ResultValidator(se.inera.intyg.webcert.web.integration.validators.ResultValidator)

Example 37 with ResultValidator

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());
}
Also used : ResultValidator(se.inera.intyg.webcert.web.integration.validators.ResultValidator) Test(org.junit.Test) BaseCreateDraftCertificateValidatorTest(se.inera.intyg.webcert.web.integration.interactions.createdraftcertificate.BaseCreateDraftCertificateValidatorTest)

Example 38 with ResultValidator

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));
}
Also used : Personnummer(se.inera.intyg.schemas.contract.Personnummer) ResultValidator(se.inera.intyg.webcert.web.integration.validators.ResultValidator) Test(org.junit.Test) BaseCreateDraftCertificateValidatorTest(se.inera.intyg.webcert.web.integration.interactions.createdraftcertificate.BaseCreateDraftCertificateValidatorTest)

Example 39 with ResultValidator

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());
}
Also used : ResultValidator(se.inera.intyg.webcert.web.integration.validators.ResultValidator) Test(org.junit.Test) BaseCreateDraftCertificateValidatorTest(se.inera.intyg.webcert.web.integration.interactions.createdraftcertificate.BaseCreateDraftCertificateValidatorTest)

Example 40 with ResultValidator

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));
}
Also used : Personnummer(se.inera.intyg.schemas.contract.Personnummer) ResultValidator(se.inera.intyg.webcert.web.integration.validators.ResultValidator) Test(org.junit.Test) BaseCreateDraftCertificateValidatorTest(se.inera.intyg.webcert.web.integration.interactions.createdraftcertificate.BaseCreateDraftCertificateValidatorTest)

Aggregations

ResultValidator (se.inera.intyg.webcert.web.integration.validators.ResultValidator)61 Test (org.junit.Test)55 BaseCreateDraftCertificateValidatorTest (se.inera.intyg.webcert.web.integration.interactions.createdraftcertificate.BaseCreateDraftCertificateValidatorTest)44 Personnummer (se.inera.intyg.schemas.contract.Personnummer)17 BaseCreateDraftCertificateTest (se.inera.intyg.webcert.web.integration.interactions.createdraftcertificate.BaseCreateDraftCertificateTest)11 IntygUser (se.inera.intyg.infra.security.common.model.IntygUser)9 TakResult (se.inera.intyg.webcert.integration.tak.model.TakResult)8 SchemaVersion (se.inera.intyg.common.support.modules.support.api.notification.SchemaVersion)7 Intyg (se.riv.clinicalprocess.healthcond.certificate.createdraftcertificateresponder.v3.Intyg)7 Utkast (se.inera.intyg.webcert.persistence.utkast.model.Utkast)6 Utlatande (se.riv.clinicalprocess.healthcond.certificate.createdraftcertificateresponder.v1.Utlatande)6 CreateDraftCertificateResponseType (se.riv.clinicalprocess.healthcond.certificate.createdraftcertificateresponder.v3.CreateDraftCertificateResponseType)6 CreateDraftCertificateType (se.riv.clinicalprocess.healthcond.certificate.createdraftcertificateresponder.v3.CreateDraftCertificateType)6 TypAvIntyg (se.riv.clinicalprocess.healthcond.certificate.types.v3.TypAvIntyg)6 CreateDraftCertificateResponseType (se.riv.clinicalprocess.healthcond.certificate.createdraftcertificateresponder.v1.CreateDraftCertificateResponseType)5 CreateDraftCertificateType (se.riv.clinicalprocess.healthcond.certificate.createdraftcertificateresponder.v1.CreateDraftCertificateType)5 TypAvUtlatande (se.riv.clinicalprocess.healthcond.certificate.types.v1.TypAvUtlatande)5 VardpersonReferens (se.inera.intyg.webcert.persistence.utkast.model.VardpersonReferens)4 IntegreradEnhetEntry (se.inera.intyg.webcert.web.integration.registry.dto.IntegreradEnhetEntry)4 CreateNewDraftRequest (se.inera.intyg.webcert.web.service.utkast.dto.CreateNewDraftRequest)4