Search in sources :

Example 81 with Utkast

use of se.inera.intyg.webcert.persistence.utkast.model.Utkast in project webcert by sklintyg.

the class PatientDetailsResolverTest method testSosDoiIntygIntegrationWithExistingDBIntygAndPuOk.

// - Dödsorsaksintyg - //
/**
 * DOI - Integration. DB finns, PU finns. Namn och adress från DB-intyget, avliden/sekr från PU.
 */
@Test
public void testSosDoiIntygIntegrationWithExistingDBIntygAndPuOk() throws ModuleNotFoundException, IOException {
    when(puService.getPerson(any(Personnummer.class))).thenReturn(buildPersonSvar());
    when(webCertUserService.getUser()).thenReturn(integratedWebCertUser);
    when(integratedWebCertUser.getValdVardgivare()).thenReturn(new Vardgivare("vg-1", "vardgivare-1"));
    List<Utkast> drafts = buildSosDBDrafts();
    when(utkastRepository.findDraftsByPatientAndVardgivareAndStatus(anyString(), anyString(), anyList(), anySet())).thenReturn(drafts);
    ModuleApi moduleApi = mock(ModuleApi.class);
    when(moduleApi.getUtlatandeFromJson(anyString())).thenReturn(buildSosDoiUtlatande());
    when(moduleRegistry.getModuleApi("db")).thenReturn(moduleApi);
    Patient patient = testee.resolvePatient(PNR, "doi");
    assertEquals(PNR.getPersonnummer(), patient.getPersonId().getPersonnummer());
    assertEquals(DB_FNAMN, patient.getFornamn());
    assertEquals(DB_MNAMN, patient.getMellannamn());
    assertEquals(DB_ENAMN, patient.getEfternamn());
    assertEquals(DB_POST_ADDR, patient.getPostadress());
    assertEquals(DB_POST_NR, patient.getPostnummer());
    assertEquals(DB_POST_ORT, patient.getPostort());
    assertEquals(PU_AVLIDEN || INTEGR_AVLIDEN, patient.isAvliden());
    assertEquals(false, patient.isSekretessmarkering());
}
Also used : Personnummer(se.inera.intyg.schemas.contract.Personnummer) ModuleApi(se.inera.intyg.common.support.modules.support.api.ModuleApi) Utkast(se.inera.intyg.webcert.persistence.utkast.model.Utkast) Patient(se.inera.intyg.common.support.model.common.internal.Patient) Vardgivare(se.inera.intyg.infra.integration.hsa.model.Vardgivare) Test(org.junit.Test)

Example 82 with Utkast

use of se.inera.intyg.webcert.persistence.utkast.model.Utkast in project webcert by sklintyg.

the class SignaturServiceImplTest method createUtkast.

private Utkast createUtkast(String intygId, long version, String type, UtkastStatus status, String model, VardpersonReferens vardperson, String enhetsId, String personId) {
    Utkast utkast = new Utkast();
    utkast.setIntygsId(intygId);
    utkast.setVersion(version);
    utkast.setIntygsTyp(type);
    utkast.setStatus(status);
    utkast.setModel(model);
    utkast.setSkapadAv(vardperson);
    utkast.setSenastSparadAv(vardperson);
    utkast.setEnhetsId(enhetsId);
    utkast.setPatientPersonnummer(Personnummer.createPersonnummer(personId).get());
    return utkast;
}
Also used : Utkast(se.inera.intyg.webcert.persistence.utkast.model.Utkast)

Example 83 with Utkast

use of se.inera.intyg.webcert.persistence.utkast.model.Utkast in project webcert by sklintyg.

the class SignaturServiceImplTest method serverSignatureFailureUniqueIntyg.

@Test
public void serverSignatureFailureUniqueIntyg() {
    Feature f = new Feature();
    f.setIntygstyper(ImmutableList.of(INTYG_TYPE));
    f.setGlobal(true);
    user.getFeatures().put(AuthoritiesConstants.FEATURE_UNIKT_INTYG, f);
    when(mockUtkastRepository.findOne(INTYG_ID)).thenReturn(completedUtkast);
    Utkast otherUtkast = createUtkast("otherId", 1L, INTYG_TYPE, UtkastStatus.SIGNED, "", null, "otherEnhet", PERSON_ID);
    otherUtkast.setSignatur(new Signatur());
    when(mockUtkastRepository.findAllByPatientPersonnummerAndIntygsTypIn(any(String.class), anySet())).thenReturn(ImmutableList.of(otherUtkast));
    try {
        intygSignatureService.serverSignature(INTYG_ID, completedUtkast.getVersion());
    } catch (WebCertServiceException e) {
        assertEquals(WebCertServiceErrorCodeEnum.INVALID_STATE_INTYG_EXISTS, e.getErrorCode());
    }
}
Also used : Signatur(se.inera.intyg.webcert.persistence.utkast.model.Signatur) Utkast(se.inera.intyg.webcert.persistence.utkast.model.Utkast) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) Feature(se.inera.intyg.infra.security.common.model.Feature) WebCertServiceException(se.inera.intyg.webcert.common.service.exception.WebCertServiceException) Test(org.junit.Test)

Example 84 with Utkast

use of se.inera.intyg.webcert.persistence.utkast.model.Utkast in project webcert by sklintyg.

the class GrpSignaturServiceTest method buildUtkast.

private Utkast buildUtkast() {
    Utkast utkast = new Utkast();
    utkast.setIntygsId(INTYG_ID);
    utkast.setIntygsTyp("fk7263");
    utkast.setStatus(UtkastStatus.DRAFT_COMPLETE);
    utkast.setVersion(VERSION);
    return utkast;
}
Also used : Utkast(se.inera.intyg.webcert.persistence.utkast.model.Utkast)

Example 85 with Utkast

use of se.inera.intyg.webcert.persistence.utkast.model.Utkast in project webcert by sklintyg.

the class UtkastServiceImplTest method createUtkast.

private Utkast createUtkast(String intygId, long version, String type, UtkastStatus status, String model, VardpersonReferens vardperson, Personnummer personnummer) {
    Utkast utkast = new Utkast();
    utkast.setIntygsId(intygId);
    utkast.setVersion(version);
    utkast.setIntygsTyp(type);
    utkast.setStatus(status);
    utkast.setModel(model);
    utkast.setSkapadAv(vardperson);
    utkast.setSenastSparadAv(vardperson);
    utkast.setPatientPersonnummer(personnummer);
    return utkast;
}
Also used : Utkast(se.inera.intyg.webcert.persistence.utkast.model.Utkast)

Aggregations

Utkast (se.inera.intyg.webcert.persistence.utkast.model.Utkast)171 Test (org.junit.Test)88 WebCertServiceException (se.inera.intyg.webcert.common.service.exception.WebCertServiceException)34 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)24 Personnummer (se.inera.intyg.schemas.contract.Personnummer)21 Signatur (se.inera.intyg.webcert.persistence.utkast.model.Signatur)21 VardpersonReferens (se.inera.intyg.webcert.persistence.utkast.model.VardpersonReferens)21 LogRequest (se.inera.intyg.webcert.web.service.log.dto.LogRequest)18 WebCertUser (se.inera.intyg.webcert.web.service.user.dto.WebCertUser)17 Arende (se.inera.intyg.webcert.persistence.arende.model.Arende)16 Utlatande (se.inera.intyg.common.support.model.common.internal.Utlatande)14 CreateNewDraftRequest (se.inera.intyg.webcert.web.service.utkast.dto.CreateNewDraftRequest)13 Patient (se.inera.intyg.common.support.model.common.internal.Patient)12 ModuleException (se.inera.intyg.common.support.modules.support.api.exception.ModuleException)12 ListIntygEntry (se.inera.intyg.webcert.web.web.controller.api.dto.ListIntygEntry)12 Transactional (org.springframework.transaction.annotation.Transactional)11 ModuleNotFoundException (se.inera.intyg.common.support.modules.registry.ModuleNotFoundException)11 MedicinsktArende (se.inera.intyg.webcert.persistence.arende.model.MedicinsktArende)11 CopyUtkastBuilderResponse (se.inera.intyg.webcert.web.service.utkast.dto.CopyUtkastBuilderResponse)10 ArrayList (java.util.ArrayList)9