Search in sources :

Example 6 with CreateDraftCopyHolder

use of se.inera.intyg.common.support.modules.support.api.dto.CreateDraftCopyHolder in project webcert by sklintyg.

the class CreateRenewalCopyUtkastBuilderImplTest method testPopulateRenewalUtkastFromSignedIntyg.

@Test
public void testPopulateRenewalUtkastFromSignedIntyg() throws Exception {
    IntygContentHolder ich = createIntygContentHolder();
    when(mockIntygService.fetchIntygData(INTYG_ID, INTYG_TYPE, false)).thenReturn(ich);
    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.populateCopyUtkastFromSignedIntyg(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());
    assertEquals(PATIENT_MNAME, builderResponse.getUtkastCopy().getPatientMellannamn());
    assertEquals(PATIENT_LNAME, builderResponse.getUtkastCopy().getPatientEfternamn());
    ArgumentCaptor<CreateDraftCopyHolder> requestCaptor = ArgumentCaptor.forClass(CreateDraftCopyHolder.class);
    verify(mockModuleApi).createRenewalFromTemplate(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 : CreateRenewalCopyRequest(se.inera.intyg.webcert.web.service.utkast.dto.CreateRenewalCopyRequest) 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) 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 7 with CreateDraftCopyHolder

use of se.inera.intyg.common.support.modules.support.api.dto.CreateDraftCopyHolder in project webcert by sklintyg.

the class AbstractUtkastBuilder method createModuleRequestForCopying.

protected CreateDraftCopyHolder createModuleRequestForCopying(AbstractCreateCopyRequest copyRequest, Person person, Relation relation, String newDraftCopyId) {
    LOG.debug("Created id '{}' for the new copy", newDraftCopyId);
    CreateDraftCopyHolder newDraftCopyHolder = new CreateDraftCopyHolder(newDraftCopyId, copyRequest.getHosPerson(), relation);
    if (person != null) {
        Patient patient = new Patient();
        patient.setFornamn(person.getFornamn());
        patient.setMellannamn(person.getMellannamn());
        patient.setEfternamn(person.getEfternamn());
        patient.setPersonId(person.getPersonnummer());
        patient.setPostadress(person.getPostadress());
        patient.setPostnummer(person.getPostnummer());
        patient.setPostort(person.getPostort());
        patient.setFullstandigtNamn(IntygConverterUtil.concatPatientName(patient.getFornamn(), patient.getMellannamn(), patient.getEfternamn()));
        newDraftCopyHolder.setPatient(patient);
        LOG.debug("Added new patient data to CreateDraftCopyHolder");
    }
    if (copyRequest.containsNyttPatientPersonnummer()) {
        newDraftCopyHolder.setNewPersonnummer(copyRequest.getNyttPatientPersonnummer());
        LOG.debug("Added new personnummer to CreateDraftCopyHolder");
    }
    return newDraftCopyHolder;
}
Also used : CreateDraftCopyHolder(se.inera.intyg.common.support.modules.support.api.dto.CreateDraftCopyHolder) Patient(se.inera.intyg.common.support.model.common.internal.Patient)

Aggregations

CreateDraftCopyHolder (se.inera.intyg.common.support.modules.support.api.dto.CreateDraftCopyHolder)7 Test (org.junit.Test)5 ValidateDraftResponse (se.inera.intyg.common.support.modules.support.api.dto.ValidateDraftResponse)5 Person (se.inera.intyg.infra.integration.pu.model.Person)5 CreateCompletionCopyRequest (se.inera.intyg.webcert.web.service.utkast.dto.CreateCompletionCopyRequest)4 IntygContentHolder (se.inera.intyg.webcert.web.service.intyg.dto.IntygContentHolder)3 CopyUtkastBuilderResponse (se.inera.intyg.webcert.web.service.utkast.dto.CopyUtkastBuilderResponse)3 ArrayList (java.util.ArrayList)2 Arende (se.inera.intyg.webcert.persistence.arende.model.Arende)2 Patient (se.inera.intyg.common.support.model.common.internal.Patient)1 CreateRenewalCopyRequest (se.inera.intyg.webcert.web.service.utkast.dto.CreateRenewalCopyRequest)1 CreateUtkastFromTemplateRequest (se.inera.intyg.webcert.web.service.utkast.dto.CreateUtkastFromTemplateRequest)1