Search in sources :

Example 6 with Person

use of se.inera.intyg.infra.integration.pu.model.Person in project webcert by sklintyg.

the class CopyUtkastServiceImplTest method expectCallToPUService.

@Before
public void expectCallToPUService() throws Exception {
    PersonSvar personSvar = new PersonSvar(new Person(PATIENT_SSN, false, false, "Adam", "Bertilsson", "Cedergren", "Testgatan 12", "12345", "Testberga"), PersonSvar.Status.FOUND);
    when(mockPUService.getPerson(PATIENT_SSN)).thenReturn(personSvar);
}
Also used : PersonSvar(se.inera.intyg.infra.integration.pu.model.PersonSvar) Person(se.inera.intyg.infra.integration.pu.model.Person) Before(org.junit.Before)

Example 7 with Person

use of se.inera.intyg.infra.integration.pu.model.Person in project webcert by sklintyg.

the class CreateRenewalCopyUtkastBuilderImplTest method testPopulateRenewalUtkastFromSignedIntygEnforceVardenhet.

@Test(expected = WebCertServiceException.class)
public void testPopulateRenewalUtkastFromSignedIntygEnforceVardenhet() throws Exception {
    IntygContentHolder ich = createIntygContentHolder();
    when(mockIntygService.fetchIntygData(INTYG_ID, INTYG_TYPE, true)).thenReturn(ich);
    CreateRenewalCopyRequest renewalRequest = buildRenewalRequest();
    Person patientDetails = new Person(PATIENT_SSN, false, false, PATIENT_FNAME, PATIENT_MNAME, PATIENT_LNAME, "Postadr", "12345", "postort");
    renewalBuilder.populateCopyUtkastFromSignedIntyg(renewalRequest, patientDetails, false, true, true);
}
Also used : CreateRenewalCopyRequest(se.inera.intyg.webcert.web.service.utkast.dto.CreateRenewalCopyRequest) IntygContentHolder(se.inera.intyg.webcert.web.service.intyg.dto.IntygContentHolder) Person(se.inera.intyg.infra.integration.pu.model.Person) Test(org.junit.Test)

Example 8 with Person

use of se.inera.intyg.infra.integration.pu.model.Person in project webcert by sklintyg.

the class CreateRenewalCopyUtkastBuilderImplTest method testPopulateRenewalUtkastFromOriginal.

@Test
public void testPopulateRenewalUtkastFromOriginal() throws Exception {
    Utkast orgUtkast = createOriginalUtkast();
    when(mockUtkastRepository.findOne(INTYG_ID)).thenReturn(orgUtkast);
    CreateRenewalCopyRequest renewalRequest = buildRenewalRequest();
    Person patientDetails = new Person(PATIENT_SSN, false, false, PATIENT_FNAME, PATIENT_MNAME, PATIENT_LNAME, "Postadr", "12345", "postort");
    when(mockModuleApi.createRenewalFromTemplate(any(CreateDraftCopyHolder.class), any())).thenReturn(INTYG_JSON);
    ValidateDraftResponse vdr = new ValidateDraftResponse(ValidationStatus.VALID, new ArrayList<>());
    when(mockModuleApi.validateDraft(anyString())).thenReturn(vdr);
    CopyUtkastBuilderResponse builderResponse = renewalBuilder.populateCopyUtkastFromOrignalUtkast(renewalRequest, patientDetails, false, false, false);
    assertNotNull(builderResponse.getUtkastCopy());
    assertNotNull(builderResponse.getUtkastCopy().getModel());
    assertEquals(INTYG_TYPE, builderResponse.getUtkastCopy().getIntygsTyp());
    assertEquals(PATIENT_SSN, builderResponse.getUtkastCopy().getPatientPersonnummer());
    assertEquals(PATIENT_FNAME, builderResponse.getUtkastCopy().getPatientFornamn());
    assertNotNull(builderResponse.getUtkastCopy().getPatientMellannamn());
    assertEquals(PATIENT_LNAME, builderResponse.getUtkastCopy().getPatientEfternamn());
}
Also used : CreateRenewalCopyRequest(se.inera.intyg.webcert.web.service.utkast.dto.CreateRenewalCopyRequest) CopyUtkastBuilderResponse(se.inera.intyg.webcert.web.service.utkast.dto.CopyUtkastBuilderResponse) Utkast(se.inera.intyg.webcert.persistence.utkast.model.Utkast) CreateDraftCopyHolder(se.inera.intyg.common.support.modules.support.api.dto.CreateDraftCopyHolder) ValidateDraftResponse(se.inera.intyg.common.support.modules.support.api.dto.ValidateDraftResponse) Person(se.inera.intyg.infra.integration.pu.model.Person) Test(org.junit.Test)

Example 9 with Person

use of se.inera.intyg.infra.integration.pu.model.Person in project webcert by sklintyg.

the class CreateRenewalCopyUtkastBuilderImplTest method testPopulateRenewalUtkastFromOriginalEnforceVardenhet.

@Test(expected = WebCertServiceException.class)
public void testPopulateRenewalUtkastFromOriginalEnforceVardenhet() throws Exception {
    Utkast orgUtkast = createOriginalUtkast();
    orgUtkast.setEnhetsId("OTHER_ID");
    when(mockUtkastRepository.findOne(INTYG_ID)).thenReturn(orgUtkast);
    CreateRenewalCopyRequest renewalRequest = buildRenewalRequest();
    Person patientDetails = new Person(PATIENT_SSN, false, false, PATIENT_FNAME, PATIENT_MNAME, PATIENT_LNAME, "Postadr", "12345", "postort");
    renewalBuilder.populateCopyUtkastFromOrignalUtkast(renewalRequest, patientDetails, false, true, true);
}
Also used : CreateRenewalCopyRequest(se.inera.intyg.webcert.web.service.utkast.dto.CreateRenewalCopyRequest) Utkast(se.inera.intyg.webcert.persistence.utkast.model.Utkast) Person(se.inera.intyg.infra.integration.pu.model.Person) Test(org.junit.Test)

Example 10 with Person

use of se.inera.intyg.infra.integration.pu.model.Person in project webcert by sklintyg.

the class CreateUtkastFromTemplateBuilderTest method testPopulateRenewalUtkastFromSignedIntyg.

@Test
public void testPopulateRenewalUtkastFromSignedIntyg() throws Exception {
    IntygContentHolder ich = createIntygContentHolder();
    when(mockIntygService.fetchIntygData(INTYG_ID, INTYG_TYPE_1, false)).thenReturn(ich);
    CreateUtkastFromTemplateRequest createUtkastFromTemplateRequest = buildCreateUtkastFromTemplateRequest();
    Person patientDetails = new Person(PATIENT_SSN, false, false, PATIENT_FNAME, PATIENT_MNAME, PATIENT_LNAME, "Postadr", "12345", "postort");
    when(mockModuleApi2.createNewInternalFromTemplate(any(CreateDraftCopyHolder.class), any())).thenReturn(INTYG_JSON);
    ValidateDraftResponse vdr = new ValidateDraftResponse(ValidationStatus.VALID, new ArrayList<>());
    when(mockModuleApi2.validateDraft(anyString())).thenReturn(vdr);
    CopyUtkastBuilderResponse builderResponse = createUtkastFromTemplateBuilder.populateCopyUtkastFromSignedIntyg(createUtkastFromTemplateRequest, patientDetails, false, false, false);
    assertNotNull(builderResponse.getUtkastCopy());
    assertNotNull(builderResponse.getUtkastCopy().getModel());
    assertEquals(INTYG_TYPE_2, builderResponse.getUtkastCopy().getIntygsTyp());
    assertEquals(PATIENT_SSN, builderResponse.getUtkastCopy().getPatientPersonnummer());
    assertEquals(PATIENT_FNAME, builderResponse.getUtkastCopy().getPatientFornamn());
    assertEquals(PATIENT_MNAME, builderResponse.getUtkastCopy().getPatientMellannamn());
    assertEquals(PATIENT_LNAME, builderResponse.getUtkastCopy().getPatientEfternamn());
    ArgumentCaptor<CreateDraftCopyHolder> requestCaptor = ArgumentCaptor.forClass(CreateDraftCopyHolder.class);
    verify(mockModuleApi2).createNewInternalFromTemplate(requestCaptor.capture(), any());
    // verify full name is set
    assertNotNull(requestCaptor.getValue().getPatient().getFullstandigtNamn());
    assertEquals(PATIENT_FNAME + " " + PATIENT_MNAME + " " + PATIENT_LNAME, requestCaptor.getValue().getPatient().getFullstandigtNamn());
}
Also used : CopyUtkastBuilderResponse(se.inera.intyg.webcert.web.service.utkast.dto.CopyUtkastBuilderResponse) IntygContentHolder(se.inera.intyg.webcert.web.service.intyg.dto.IntygContentHolder) CreateDraftCopyHolder(se.inera.intyg.common.support.modules.support.api.dto.CreateDraftCopyHolder) CreateUtkastFromTemplateRequest(se.inera.intyg.webcert.web.service.utkast.dto.CreateUtkastFromTemplateRequest) ValidateDraftResponse(se.inera.intyg.common.support.modules.support.api.dto.ValidateDraftResponse) Person(se.inera.intyg.infra.integration.pu.model.Person) Test(org.junit.Test)

Aggregations

Person (se.inera.intyg.infra.integration.pu.model.Person)18 Test (org.junit.Test)12 CopyUtkastBuilderResponse (se.inera.intyg.webcert.web.service.utkast.dto.CopyUtkastBuilderResponse)10 ValidateDraftResponse (se.inera.intyg.common.support.modules.support.api.dto.ValidateDraftResponse)8 CreateDraftCopyHolder (se.inera.intyg.common.support.modules.support.api.dto.CreateDraftCopyHolder)7 PersonSvar (se.inera.intyg.infra.integration.pu.model.PersonSvar)4 Utkast (se.inera.intyg.webcert.persistence.utkast.model.Utkast)4 IntygContentHolder (se.inera.intyg.webcert.web.service.intyg.dto.IntygContentHolder)4 CreateCompletionCopyRequest (se.inera.intyg.webcert.web.service.utkast.dto.CreateCompletionCopyRequest)4 CreateRenewalCopyRequest (se.inera.intyg.webcert.web.service.utkast.dto.CreateRenewalCopyRequest)4 Personnummer (se.inera.intyg.schemas.contract.Personnummer)3 ArrayList (java.util.ArrayList)2 Response (javax.ws.rs.core.Response)2 Arende (se.inera.intyg.webcert.persistence.arende.model.Arende)2 CreateUtkastFromTemplateRequest (se.inera.intyg.webcert.web.service.utkast.dto.CreateUtkastFromTemplateRequest)2 PersonuppgifterResponse (se.inera.intyg.webcert.web.web.controller.api.dto.PersonuppgifterResponse)2 Before (org.junit.Before)1