Search in sources :

Example 41 with Patient

use of se.inera.intyg.common.support.model.common.internal.Patient in project webcert by sklintyg.

the class UtkastModuleApiControllerTest method getDraftShouldNotPatchIfNewAddressIsIncomplete.

@Test
public void getDraftShouldNotPatchIfNewAddressIsIncomplete() throws Exception {
    // Given
    String intygsTyp = "gdsnpinaii-intygsTyp";
    String intygsId = "gdsnpinaii-intygsId";
    setupUser(AuthoritiesConstants.PRIVILEGE_SKRIVA_INTYG, intygsTyp, false, AuthoritiesConstants.FEATURE_HANTERA_INTYGSUTKAST);
    when(utkastService.getDraft(CERTIFICATE_ID, intygsTyp)).thenReturn(buildUtkast(intygsTyp, intygsId));
    when(certificateRelationService.getRelations(eq(intygsId))).thenReturn(new Relations());
    String postadress = "gdsnpinaii-postadress";
    String postort = "";
    String postnummer = "gdsnpinaii-postnummer";
    Patient patientWithIncompleteAddress = buildPatient();
    patientWithIncompleteAddress.setPostadress(postadress);
    patientWithIncompleteAddress.setPostort(postort);
    patientWithIncompleteAddress.setPostnummer(postnummer);
    when(patientDetailsResolver.resolvePatient(any(Personnummer.class), anyString())).thenReturn(patientWithIncompleteAddress);
    // When
    Response response = moduleApiController.getDraft(intygsTyp, CERTIFICATE_ID, request);
    // Then
    ArgumentCaptor<Patient> argumentCaptor = ArgumentCaptor.forClass(Patient.class);
    verify(moduleApi).updateBeforeSave(anyString(), argumentCaptor.capture());
    assertNotEquals(postadress, argumentCaptor.getValue().getPostadress());
    assertNotEquals(postnummer, argumentCaptor.getValue().getPostnummer());
}
Also used : Personnummer(se.inera.intyg.schemas.contract.Personnummer) Response(javax.ws.rs.core.Response) SaveDraftResponse(se.inera.intyg.webcert.web.service.utkast.dto.SaveDraftResponse) Patient(se.inera.intyg.common.support.model.common.internal.Patient) Relations(se.inera.intyg.webcert.web.web.controller.api.dto.Relations) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) Test(org.junit.Test)

Example 42 with Patient

use of se.inera.intyg.common.support.model.common.internal.Patient in project webcert by sklintyg.

the class UtkastModuleApiControllerTest method getDraftShouldPatchIfNewAddressExist.

@Test
public void getDraftShouldPatchIfNewAddressExist() throws Exception {
    // Given
    String intygsTyp = "gdspinae-intygsTyp";
    String intygsId = "gdspinae-intygsId";
    setupUser(AuthoritiesConstants.PRIVILEGE_SKRIVA_INTYG, intygsTyp, false, AuthoritiesConstants.FEATURE_HANTERA_INTYGSUTKAST);
    when(utkastService.getDraft(CERTIFICATE_ID, intygsTyp)).thenReturn(buildUtkast(intygsTyp, intygsId));
    when(certificateRelationService.getRelations(eq(intygsId))).thenReturn(new Relations());
    String postadress = "gdspinae-postadress";
    String postort = "gdspinae-postort";
    String postnummer = "gdspinae-postnummer";
    Patient patientWithIncompleteAddress = buildPatient();
    patientWithIncompleteAddress.setPostadress(postadress);
    patientWithIncompleteAddress.setPostort(postort);
    patientWithIncompleteAddress.setPostnummer(postnummer);
    when(patientDetailsResolver.resolvePatient(any(Personnummer.class), anyString())).thenReturn(patientWithIncompleteAddress);
    // When
    Response response = moduleApiController.getDraft(intygsTyp, CERTIFICATE_ID, request);
    // Then
    ArgumentCaptor<Patient> argumentCaptor = ArgumentCaptor.forClass(Patient.class);
    verify(moduleApi).updateBeforeSave(anyString(), argumentCaptor.capture());
    assertEquals(postadress, argumentCaptor.getValue().getPostadress());
    assertEquals(postort, argumentCaptor.getValue().getPostort());
    assertEquals(postnummer, argumentCaptor.getValue().getPostnummer());
}
Also used : Personnummer(se.inera.intyg.schemas.contract.Personnummer) Response(javax.ws.rs.core.Response) SaveDraftResponse(se.inera.intyg.webcert.web.service.utkast.dto.SaveDraftResponse) Patient(se.inera.intyg.common.support.model.common.internal.Patient) Relations(se.inera.intyg.webcert.web.web.controller.api.dto.Relations) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) Test(org.junit.Test)

Example 43 with Patient

use of se.inera.intyg.common.support.model.common.internal.Patient in project webcert by sklintyg.

the class PatientDetailsResolverTest method testFKIntygIntegrationWithPuOk.

// - START FK-intyg - //
/**
 * Standardfallet för FK-intyg är namn + sekr + avliden från PU, alltid nullad address.
 */
@Test
public void testFKIntygIntegrationWithPuOk() {
    when(puService.getPerson(any(Personnummer.class))).thenReturn(buildPersonSvar());
    when(webCertUserService.getUser()).thenReturn(integratedWebCertUser);
    Patient patient = testee.resolvePatient(PNR, "luae_fs");
    assertEquals(PNR, patient.getPersonId());
    assertEquals(FNAMN, patient.getFornamn());
    assertEquals(MNAMN, patient.getMellannamn());
    assertEquals(LNAMN, patient.getEfternamn());
    assertNull(patient.getPostadress());
    assertNull(patient.getPostnummer());
    assertNull(patient.getPostort());
    assertEquals(PU_AVLIDEN || INTEGR_AVLIDEN, patient.isAvliden());
    assertEquals(false, patient.isSekretessmarkering());
}
Also used : Personnummer(se.inera.intyg.schemas.contract.Personnummer) Patient(se.inera.intyg.common.support.model.common.internal.Patient) Test(org.junit.Test)

Example 44 with Patient

use of se.inera.intyg.common.support.model.common.internal.Patient in project webcert by sklintyg.

the class PatientDetailsResolverTest method testSOSDBIntygIntegrationWithPuOkShouldIgnoreIntegrationParameters.

// - START Dödsbevis - //
// (DB har nästan exakt samma regler som TS)
/**
 * Dödsbevis - integration - PU: Namn + meta från PU == allt hämtas från PU
 */
@Test
public void testSOSDBIntygIntegrationWithPuOkShouldIgnoreIntegrationParameters() {
    when(puService.getPerson(any(Personnummer.class))).thenReturn(buildPersonSvar());
    when(webCertUserService.getUser()).thenReturn(integratedWebCertUser);
    Patient patient = testee.resolvePatient(PNR, "db");
    assertEquals(PNR, patient.getPersonId());
    assertEquals(FNAMN, patient.getFornamn());
    assertEquals(MNAMN, patient.getMellannamn());
    assertEquals(LNAMN, patient.getEfternamn());
    assertEquals(POST_ADDR, patient.getPostadress());
    assertEquals(POST_NR, patient.getPostnummer());
    assertEquals(POST_ORT, patient.getPostort());
    assertEquals(PU_AVLIDEN, patient.isAvliden());
    assertEquals(false, patient.isSekretessmarkering());
}
Also used : Personnummer(se.inera.intyg.schemas.contract.Personnummer) Patient(se.inera.intyg.common.support.model.common.internal.Patient) Test(org.junit.Test)

Example 45 with Patient

use of se.inera.intyg.common.support.model.common.internal.Patient in project webcert by sklintyg.

the class PatientDetailsResolverTest method testSOSDBIntygFristaendeWithPuOk.

/**
 * Dödsbevis + fristående + PU == Allt från PU
 */
@Test
public void testSOSDBIntygFristaendeWithPuOk() {
    when(puService.getPerson(any(Personnummer.class))).thenReturn(buildPersonSvar());
    when(webCertUserService.getUser()).thenReturn(freeWebCertUser);
    Patient patient = testee.resolvePatient(PNR, "db");
    assertEquals(PNR, patient.getPersonId());
    assertEquals(FNAMN, patient.getFornamn());
    assertEquals(MNAMN, patient.getMellannamn());
    assertEquals(LNAMN, patient.getEfternamn());
    assertEquals(POST_ADDR, patient.getPostadress());
    assertEquals(POST_NR, patient.getPostnummer());
    assertEquals(POST_ORT, patient.getPostort());
    assertEquals(PU_AVLIDEN, patient.isAvliden());
    assertEquals(false, patient.isSekretessmarkering());
}
Also used : Personnummer(se.inera.intyg.schemas.contract.Personnummer) Patient(se.inera.intyg.common.support.model.common.internal.Patient) Test(org.junit.Test)

Aggregations

Patient (se.inera.intyg.common.support.model.common.internal.Patient)62 Test (org.junit.Test)28 Personnummer (se.inera.intyg.schemas.contract.Personnummer)28 Utkast (se.inera.intyg.webcert.persistence.utkast.model.Utkast)12 HoSPersonal (se.inera.intyg.common.support.model.common.internal.HoSPersonal)11 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)7 Utlatande (se.inera.intyg.common.support.model.common.internal.Utlatande)7 Vardenhet (se.inera.intyg.common.support.model.common.internal.Vardenhet)6 ModuleApi (se.inera.intyg.common.support.modules.support.api.ModuleApi)6 ArrayList (java.util.ArrayList)5 Before (org.junit.Before)5 Vardgivare (se.inera.intyg.common.support.model.common.internal.Vardgivare)5 Vardgivare (se.inera.intyg.infra.integration.hsa.model.Vardgivare)5 IntygContentHolder (se.inera.intyg.webcert.web.service.intyg.dto.IntygContentHolder)5 Relations (se.inera.intyg.webcert.web.web.controller.api.dto.Relations)5 IOException (java.io.IOException)4 GrundData (se.inera.intyg.common.support.model.common.internal.GrundData)4 ModuleNotFoundException (se.inera.intyg.common.support.modules.registry.ModuleNotFoundException)4 ModuleException (se.inera.intyg.common.support.modules.support.api.exception.ModuleException)4 PersonSvar (se.inera.intyg.infra.integration.pu.model.PersonSvar)4