Search in sources :

Example 1 with CreateCompletionCopyRequest

use of se.inera.intyg.webcert.web.service.utkast.dto.CreateCompletionCopyRequest in project webcert by sklintyg.

the class CopyCompletionUtkastBuilder method getInternalModel.

@Override
protected String getInternalModel(Utlatande template, ModuleApi moduleApi, AbstractCreateCopyRequest copyRequest, Person person, Relation relation, String newDraftCopyId) throws ModuleException {
    CreateDraftCopyHolder draftCopyHolder = createModuleRequestForCopying(copyRequest, person, relation, newDraftCopyId);
    CreateCompletionCopyRequest retyped = (CreateCompletionCopyRequest) copyRequest;
    return moduleApi.createCompletionFromTemplate(draftCopyHolder, template, retyped.getKommentar());
}
Also used : CreateDraftCopyHolder(se.inera.intyg.common.support.modules.support.api.dto.CreateDraftCopyHolder) CreateCompletionCopyRequest(se.inera.intyg.webcert.web.service.utkast.dto.CreateCompletionCopyRequest)

Example 2 with CreateCompletionCopyRequest

use of se.inera.intyg.webcert.web.service.utkast.dto.CreateCompletionCopyRequest in project webcert by sklintyg.

the class CopyCompletionUtkastBuilderTest method testPopulateCompletionFromSignedIntyg.

@Test
public void testPopulateCompletionFromSignedIntyg() throws Exception {
    IntygContentHolder ich = createIntygContentHolder();
    when(mockIntygService.fetchIntygData(INTYG_ID, INTYG_TYPE, false)).thenReturn(ich);
    CreateCompletionCopyRequest copyRequest = buildCompletionRequest();
    copyRequest.setMeddelandeId("meddelandeId");
    Person patientDetails = new Person(PATIENT_SSN, false, false, PATIENT_FNAME, PATIENT_MNAME, PATIENT_LNAME, "Postadr", "12345", "postort");
    ValidateDraftResponse vdr = new ValidateDraftResponse(ValidationStatus.VALID, new ArrayList<>());
    when(mockModuleApi.validateDraft(isNull())).thenReturn(vdr);
    CopyUtkastBuilderResponse builderResponse = copyCompletionBuilder.populateCopyUtkastFromSignedIntyg(copyRequest, patientDetails, true, 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());
    assertEquals(INTYG_ID, builderResponse.getUtkastCopy().getRelationIntygsId());
    ArgumentCaptor<CreateDraftCopyHolder> requestCaptor = ArgumentCaptor.forClass(CreateDraftCopyHolder.class);
    verify(mockModuleApi).createCompletionFromTemplate(requestCaptor.capture(), any(), eq(KOMMENTAR));
    // 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) CreateCompletionCopyRequest(se.inera.intyg.webcert.web.service.utkast.dto.CreateCompletionCopyRequest) 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 3 with CreateCompletionCopyRequest

use of se.inera.intyg.webcert.web.service.utkast.dto.CreateCompletionCopyRequest in project webcert by sklintyg.

the class CopyCompletionUtkastBuilderTest method testPopulateCompletionFromOriginalDecoratesWithReferensId.

@Test
public void testPopulateCompletionFromOriginalDecoratesWithReferensId() throws Exception {
    final String intygsTyp = "lisjp";
    final String meddelandeId = "meddelandeId";
    final String referensId = UUID.randomUUID().toString();
    Arende arende = new Arende();
    arende.setReferensId(referensId);
    when(moduleRegistry.getModuleApi(intygsTyp)).thenReturn(mockModuleApi);
    when(mockUtkastRepository.findOne(INTYG_ID)).thenReturn(createOriginalUtkast());
    when(mockModuleApi.validateDraft(isNull())).thenReturn(new ValidateDraftResponse(ValidationStatus.VALID, new ArrayList<>()));
    when(arendeService.getArende(meddelandeId)).thenReturn(arende);
    CreateCompletionCopyRequest copyRequest = buildCompletionRequest();
    copyRequest.setMeddelandeId(meddelandeId);
    copyRequest.setTyp(intygsTyp);
    copyRequest.setOriginalIntygTyp(intygsTyp);
    Person patientDetails = new Person(PATIENT_SSN, false, false, PATIENT_FNAME, PATIENT_MNAME, PATIENT_LNAME, "Postadr", "12345", "postort");
    copyCompletionBuilder.populateCopyUtkastFromOrignalUtkast(copyRequest, patientDetails, true, false, false);
    ArgumentCaptor<CreateDraftCopyHolder> createDraftCopyHolderCaptor = ArgumentCaptor.forClass(CreateDraftCopyHolder.class);
    verify(mockModuleApi).createCompletionFromTemplate(createDraftCopyHolderCaptor.capture(), any(), eq(KOMMENTAR));
    assertNotNull(createDraftCopyHolderCaptor.getValue());
    assertEquals(meddelandeId, createDraftCopyHolderCaptor.getValue().getRelation().getMeddelandeId());
    assertEquals(RelationKod.KOMPLT, createDraftCopyHolderCaptor.getValue().getRelation().getRelationKod());
    assertEquals(referensId, createDraftCopyHolderCaptor.getValue().getRelation().getReferensId());
    assertEquals(INTYG_ID, createDraftCopyHolderCaptor.getValue().getRelation().getRelationIntygsId());
}
Also used : ArrayList(java.util.ArrayList) CreateCompletionCopyRequest(se.inera.intyg.webcert.web.service.utkast.dto.CreateCompletionCopyRequest) CreateDraftCopyHolder(se.inera.intyg.common.support.modules.support.api.dto.CreateDraftCopyHolder) Arende(se.inera.intyg.webcert.persistence.arende.model.Arende) 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 4 with CreateCompletionCopyRequest

use of se.inera.intyg.webcert.web.service.utkast.dto.CreateCompletionCopyRequest in project webcert by sklintyg.

the class CopyCompletionUtkastBuilderTest method testPopulateCompletionFromSignedIntygDecoratesWithReferensId.

@Test
public void testPopulateCompletionFromSignedIntygDecoratesWithReferensId() throws Exception {
    final String intygsTyp = "luse";
    final String meddelandeId = "meddelandeId";
    final String referensId = UUID.randomUUID().toString();
    Arende arende = new Arende();
    arende.setReferensId(referensId);
    when(moduleRegistry.getModuleApi(intygsTyp)).thenReturn(mockModuleApi);
    when(mockIntygService.fetchIntygData(INTYG_ID, intygsTyp, false)).thenReturn(createIntygContentHolder());
    when(mockModuleApi.validateDraft(isNull())).thenReturn(new ValidateDraftResponse(ValidationStatus.VALID, new ArrayList<>()));
    when(arendeService.getArende(meddelandeId)).thenReturn(arende);
    CreateCompletionCopyRequest copyRequest = buildCompletionRequest();
    copyRequest.setMeddelandeId(meddelandeId);
    copyRequest.setTyp(intygsTyp);
    copyRequest.setOriginalIntygTyp(intygsTyp);
    Person patientDetails = new Person(PATIENT_SSN, false, false, PATIENT_FNAME, PATIENT_MNAME, PATIENT_LNAME, "Postadr", "12345", "postort");
    copyCompletionBuilder.populateCopyUtkastFromSignedIntyg(copyRequest, patientDetails, true, false, false);
    ArgumentCaptor<CreateDraftCopyHolder> createDraftCopyHolderCaptor = ArgumentCaptor.forClass(CreateDraftCopyHolder.class);
    verify(mockModuleApi).createCompletionFromTemplate(createDraftCopyHolderCaptor.capture(), any(), eq(KOMMENTAR));
    assertNotNull(createDraftCopyHolderCaptor.getValue());
    assertEquals(meddelandeId, createDraftCopyHolderCaptor.getValue().getRelation().getMeddelandeId());
    assertEquals(RelationKod.KOMPLT, createDraftCopyHolderCaptor.getValue().getRelation().getRelationKod());
    assertEquals(referensId, createDraftCopyHolderCaptor.getValue().getRelation().getReferensId());
    assertEquals(INTYG_ID, createDraftCopyHolderCaptor.getValue().getRelation().getRelationIntygsId());
}
Also used : ArrayList(java.util.ArrayList) CreateCompletionCopyRequest(se.inera.intyg.webcert.web.service.utkast.dto.CreateCompletionCopyRequest) CreateDraftCopyHolder(se.inera.intyg.common.support.modules.support.api.dto.CreateDraftCopyHolder) Arende(se.inera.intyg.webcert.persistence.arende.model.Arende) 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 5 with CreateCompletionCopyRequest

use of se.inera.intyg.webcert.web.service.utkast.dto.CreateCompletionCopyRequest in project webcert by sklintyg.

the class CopyCompletionUtkastBuilderTest method testPopulateCompletionFromOriginal.

@Test
public void testPopulateCompletionFromOriginal() throws Exception {
    Utkast orgUtkast = createOriginalUtkast();
    when(mockUtkastRepository.findOne(INTYG_ID)).thenReturn(orgUtkast);
    CreateCompletionCopyRequest copyRequest = buildCompletionRequest();
    copyRequest.setMeddelandeId("meddelandeId");
    Person patientDetails = new Person(PATIENT_SSN, false, false, PATIENT_FNAME, PATIENT_MNAME, PATIENT_LNAME, "Postadr", "12345", "postort");
    ValidateDraftResponse vdr = new ValidateDraftResponse(ValidationStatus.VALID, new ArrayList<>());
    when(mockModuleApi.validateDraft(isNull())).thenReturn(vdr);
    CopyUtkastBuilderResponse builderResponse = copyCompletionBuilder.populateCopyUtkastFromOrignalUtkast(copyRequest, patientDetails, true, 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());
    assertEquals(INTYG_ID, builderResponse.getUtkastCopy().getRelationIntygsId());
}
Also used : CopyUtkastBuilderResponse(se.inera.intyg.webcert.web.service.utkast.dto.CopyUtkastBuilderResponse) Utkast(se.inera.intyg.webcert.persistence.utkast.model.Utkast) CreateCompletionCopyRequest(se.inera.intyg.webcert.web.service.utkast.dto.CreateCompletionCopyRequest) 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

CreateCompletionCopyRequest (se.inera.intyg.webcert.web.service.utkast.dto.CreateCompletionCopyRequest)8 Test (org.junit.Test)7 Person (se.inera.intyg.infra.integration.pu.model.Person)5 CreateDraftCopyHolder (se.inera.intyg.common.support.modules.support.api.dto.CreateDraftCopyHolder)4 ValidateDraftResponse (se.inera.intyg.common.support.modules.support.api.dto.ValidateDraftResponse)4 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 Utkast (se.inera.intyg.webcert.persistence.utkast.model.Utkast)2 WebCertUser (se.inera.intyg.webcert.web.service.user.dto.WebCertUser)2 CreateCompletionCopyResponse (se.inera.intyg.webcert.web.service.utkast.dto.CreateCompletionCopyResponse)2 IntegrationParameters (se.inera.intyg.webcert.web.web.controller.integration.dto.IntegrationParameters)2 Response (javax.ws.rs.core.Response)1 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)1 IntygContentHolder (se.inera.intyg.webcert.web.service.intyg.dto.IntygContentHolder)1 CreateRenewalCopyResponse (se.inera.intyg.webcert.web.service.utkast.dto.CreateRenewalCopyResponse)1 CreateReplacementCopyResponse (se.inera.intyg.webcert.web.service.utkast.dto.CreateReplacementCopyResponse)1 CreateUtkastFromTemplateResponse (se.inera.intyg.webcert.web.service.utkast.dto.CreateUtkastFromTemplateResponse)1 CopyIntygRequest (se.inera.intyg.webcert.web.web.controller.api.dto.CopyIntygRequest)1 CopyIntygResponse (se.inera.intyg.webcert.web.web.controller.api.dto.CopyIntygResponse)1