Search in sources :

Example 16 with Utkast

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

the class CreateDraftCertificateResponderImplTest method testCreateDraftCertificateMultipleMIUs.

@Test
public void testCreateDraftCertificateMultipleMIUs() {
    CreateNewDraftRequest draftRequest = createCreateNewDraftRequest(createVardenhet(createVardgivare()));
    CreateDraftCertificateType certificateType = createCertificateType();
    VardpersonReferens vardperson = createVardpersonReferens(certificateType.getIntyg().getSkapadAv().getPersonalId().getRoot(), certificateType.getIntyg().getSkapadAv().getFullstandigtNamn());
    Utkast utkast = createUtkast(UTKAST_ID, Long.parseLong(UTKAST_VERSION), UTKAST_TYPE, UtkastStatus.DRAFT_INCOMPLETE, UTKAST_JSON, vardperson);
    when(mockValidator.validate(any(Intyg.class))).thenReturn(new ResultValidator());
    when(mockRequestBuilder.buildCreateNewDraftRequest(any(Intyg.class), any(IntygUser.class))).thenReturn(draftRequest);
    when(mockUtkastService.createNewDraft(any(CreateNewDraftRequest.class))).thenReturn(utkast);
    when(takService.verifyTakningForCareUnit(any(String.class), any(String.class), any(SchemaVersion.class), any(IntygUser.class))).thenReturn(new TakResult(true, Lists.emptyList()));
    CreateDraftCertificateResponseType response = responder.createDraftCertificate(LOGICAL_ADDR, certificateType);
    verify(mockUtkastService).createNewDraft(any(CreateNewDraftRequest.class));
    verify(mockIntegreradeEnheterService).putIntegreradEnhet(any(IntegreradEnhetEntry.class), eq(false), eq(true));
    assertNotNull(response);
    assertEquals(response.getResult().getResultCode(), ResultCodeType.OK);
    assertEquals(response.getIntygsId().getExtension(), UTKAST_ID);
}
Also used : CreateDraftCertificateResponseType(se.riv.clinicalprocess.healthcond.certificate.createdraftcertificateresponder.v3.CreateDraftCertificateResponseType) IntegreradEnhetEntry(se.inera.intyg.webcert.web.integration.registry.dto.IntegreradEnhetEntry) CreateNewDraftRequest(se.inera.intyg.webcert.web.service.utkast.dto.CreateNewDraftRequest) CreateDraftCertificateType(se.riv.clinicalprocess.healthcond.certificate.createdraftcertificateresponder.v3.CreateDraftCertificateType) SchemaVersion(se.inera.intyg.common.support.modules.support.api.notification.SchemaVersion) TypAvIntyg(se.riv.clinicalprocess.healthcond.certificate.types.v3.TypAvIntyg) Intyg(se.riv.clinicalprocess.healthcond.certificate.createdraftcertificateresponder.v3.Intyg) Utkast(se.inera.intyg.webcert.persistence.utkast.model.Utkast) ResultValidator(se.inera.intyg.webcert.web.integration.validators.ResultValidator) TakResult(se.inera.intyg.webcert.integration.tak.model.TakResult) IntygUser(se.inera.intyg.infra.security.common.model.IntygUser) VardpersonReferens(se.inera.intyg.webcert.persistence.utkast.model.VardpersonReferens) BaseCreateDraftCertificateTest(se.inera.intyg.webcert.web.integration.interactions.createdraftcertificate.BaseCreateDraftCertificateTest) Test(org.junit.Test)

Example 17 with Utkast

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

the class ArendeConverterTest method testDecorateArendeFromUtkastHsaNotResponding.

@Test
public void testDecorateArendeFromUtkastHsaNotResponding() {
    Utkast utkast = new Utkast();
    utkast.setIntygsTyp("intygstyp");
    utkast.setEnhetsId("enhetsid");
    utkast.setSignatur(mock(Signatur.class));
    when(utkast.getSignatur().getSigneradAv()).thenReturn("signeratav");
    when(hsaEmployeeService.getEmployee(anyString(), eq(null))).thenThrow(new WebServiceException());
    try {
        ArendeConverter.decorateArendeFromUtkast(new Arende(), utkast, LocalDateTime.now(), hsaEmployeeService);
        fail("Should throw");
    } catch (WebCertServiceException e) {
        assertEquals(WebCertServiceErrorCodeEnum.EXTERNAL_SYSTEM_PROBLEM, e.getErrorCode());
    }
}
Also used : Signatur(se.inera.intyg.webcert.persistence.utkast.model.Signatur) WebServiceException(javax.xml.ws.WebServiceException) Utkast(se.inera.intyg.webcert.persistence.utkast.model.Utkast) Arende(se.inera.intyg.webcert.persistence.arende.model.Arende) WebCertServiceException(se.inera.intyg.webcert.common.service.exception.WebCertServiceException) Test(org.junit.Test)

Example 18 with Utkast

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

the class ArendeConverterTest method testCreateArendeQuestionFromUtkast.

@Test
public void testCreateArendeQuestionFromUtkast() throws CertificateSenderException {
    final ArendeAmne amne = ArendeAmne.OVRIGT;
    final String enhetsId = "enhetsId";
    final String intygsId = "intygsId";
    final String intygsTyp = "luse";
    final String meddelande = "meddelande";
    final String patientPersonId = "191212121212";
    final String rubrik = "rubrik";
    final String signeratAv = "hsa123";
    final String givenName = "givenname";
    final String surname = "surname";
    final String vardaktorName = "vardaktor namn";
    final String enhetName = "enhet namn";
    final String vardgivareName = "vardgivare namn";
    final LocalDateTime now = LocalDateTime.now();
    Utkast utkast = new Utkast();
    utkast.setEnhetsId(enhetsId);
    utkast.setEnhetsNamn(enhetName);
    utkast.setVardgivarNamn(vardgivareName);
    utkast.setIntygsId(intygsId);
    utkast.setIntygsTyp(intygsTyp);
    utkast.setPatientPersonnummer(Personnummer.createPersonnummer(patientPersonId).get());
    utkast.setSignatur(mock(Signatur.class));
    when(utkast.getSignatur().getSigneradAv()).thenReturn(signeratAv);
    when(hsaEmployeeService.getEmployee(signeratAv, null)).thenReturn(createHsaResponse(givenName, surname));
    Arende res = ArendeConverter.createArendeFromUtkast(amne, rubrik, meddelande, utkast, now, vardaktorName, hsaEmployeeService);
    assertNotNull(res);
    assertEquals(amne, res.getAmne());
    assertEquals(enhetsId, res.getEnhetId());
    assertEquals(enhetName, res.getEnhetName());
    assertEquals(vardgivareName, res.getVardgivareName());
    assertEquals(intygsId, res.getIntygsId());
    assertEquals(intygsTyp, res.getIntygTyp());
    assertEquals(meddelande, res.getMeddelande());
    assertNotNull(res.getMeddelandeId());
    assertNull(res.getPaminnelseMeddelandeId());
    assertEquals(patientPersonId, res.getPatientPersonId());
    assertNull(res.getReferensId());
    assertEquals(rubrik, res.getRubrik());
    assertEquals(now, res.getSenasteHandelse());
    assertEquals(now, res.getSkickatTidpunkt());
    assertEquals(now, res.getTimestamp());
    assertEquals(signeratAv, res.getSigneratAv());
    assertEquals(givenName + " " + surname, res.getSigneratAvName());
    assertNull(res.getSistaDatumForSvar());
    assertEquals(FrageStallare.WEBCERT.getKod(), res.getSkickatAv());
    assertEquals(Status.PENDING_EXTERNAL_ACTION, res.getStatus());
    assertNull(res.getSvarPaId());
    assertNull(res.getSvarPaReferens());
    assertEquals(Boolean.FALSE, res.getVidarebefordrad());
    assertEquals(vardaktorName, res.getVardaktorName());
}
Also used : LocalDateTime(java.time.LocalDateTime) Signatur(se.inera.intyg.webcert.persistence.utkast.model.Signatur) Utkast(se.inera.intyg.webcert.persistence.utkast.model.Utkast) ArendeAmne(se.inera.intyg.webcert.persistence.arende.model.ArendeAmne) Arende(se.inera.intyg.webcert.persistence.arende.model.Arende) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) Test(org.junit.Test)

Example 19 with Utkast

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

the class ArendeConverterTest method testDecorateArendeFromUtkast.

@Test
public void testDecorateArendeFromUtkast() throws WebCertServiceException {
    final String intygTyp = "intygTyp";
    final String signeratAv = "signeratAv";
    final String enhetId = "enhetId";
    final String enhetName = "enhetName";
    final String vardgivareName = "vardgivareName";
    final LocalDateTime now = LocalDateTime.now();
    final String givenName = "Test";
    final String surname = "Testorsson Svensson";
    Utkast utkast = new Utkast();
    utkast.setIntygsTyp(intygTyp);
    utkast.setEnhetsId(enhetId);
    utkast.setEnhetsNamn(enhetName);
    utkast.setVardgivarNamn(vardgivareName);
    utkast.setSignatur(mock(Signatur.class));
    when(utkast.getSignatur().getSigneradAv()).thenReturn(signeratAv);
    when(hsaEmployeeService.getEmployee(eq(signeratAv), eq(null))).thenReturn(createHsaResponse(givenName, surname));
    Arende res = new Arende();
    ArendeConverter.decorateArendeFromUtkast(res, utkast, now, hsaEmployeeService);
    assertNotNull(res);
    assertEquals(now, res.getTimestamp());
    assertEquals(now, res.getSenasteHandelse());
    assertEquals(Boolean.FALSE, res.getVidarebefordrad());
    assertEquals(Status.PENDING_INTERNAL_ACTION, res.getStatus());
    assertEquals(intygTyp, res.getIntygTyp());
    assertEquals(signeratAv, res.getSigneratAv());
    assertEquals(enhetId, res.getEnhetId());
    assertEquals(enhetName, res.getEnhetName());
    assertEquals(vardgivareName, res.getVardgivareName());
    assertEquals("Test Testorsson Svensson", res.getSigneratAvName());
}
Also used : LocalDateTime(java.time.LocalDateTime) Signatur(se.inera.intyg.webcert.persistence.utkast.model.Signatur) Utkast(se.inera.intyg.webcert.persistence.utkast.model.Utkast) Arende(se.inera.intyg.webcert.persistence.arende.model.Arende) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) Test(org.junit.Test)

Example 20 with Utkast

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

the class ArendeConverterTest method testDecorateArendeFromUtkastNoGivenName.

@Test
public void testDecorateArendeFromUtkastNoGivenName() throws WebCertServiceException {
    final String intygId = "intygsid";
    final String intygTyp = "intygTyp";
    final String signeratAv = "signeratAv";
    final String givenName = null;
    final String surname = "Testorsson Svensson";
    Arende arende = new Arende();
    arende.setIntygsId(intygId);
    Utkast utkast = new Utkast();
    utkast.setIntygsTyp(intygTyp);
    utkast.setSignatur(mock(Signatur.class));
    when(utkast.getSignatur().getSigneradAv()).thenReturn(signeratAv);
    when(hsaEmployeeService.getEmployee(eq(signeratAv), eq(null))).thenReturn(createHsaResponse(givenName, surname));
    Arende res = new Arende();
    ArendeConverter.decorateArendeFromUtkast(res, utkast, LocalDateTime.now(), hsaEmployeeService);
    assertNotNull(res);
    assertEquals("Testorsson Svensson", res.getSigneratAvName());
}
Also used : Signatur(se.inera.intyg.webcert.persistence.utkast.model.Signatur) Utkast(se.inera.intyg.webcert.persistence.utkast.model.Utkast) Arende(se.inera.intyg.webcert.persistence.arende.model.Arende) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) Test(org.junit.Test)

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