use of se.inera.intyg.common.support.modules.support.api.dto.ValidateDraftResponse in project webcert by sklintyg.
the class UtkastServiceImplTest method testSaveUpdatesChangedPatientName.
@Test
public void testSaveUpdatesChangedPatientName() throws Exception {
ValidateDraftResponse validationResponse = new ValidateDraftResponse(ValidationStatus.VALID, Collections.emptyList());
WebCertUser user = createUser();
Utlatande utlatande = mock(Utlatande.class);
GrundData grunddata = new GrundData();
grunddata.setSkapadAv(new HoSPersonal());
grunddata.setPatient(buildPatient(PERSON_ID, "Tolvan", "Tolvansson"));
when(utlatande.getGrundData()).thenReturn(grunddata);
utkast.setPatientFornamn("Inte Tolvan");
utkast.setPatientEfternamn("Inte Tolvansson");
// Make a spy out of the utkast so we can verify invocations on the setters with proper names further down.
utkast = spy(utkast);
when(mockUtkastRepository.findOne(INTYG_ID)).thenReturn(utkast);
when(moduleRegistry.getModuleApi(INTYG_TYPE)).thenReturn(mockModuleApi);
when(mockModuleApi.validateDraft(anyString())).thenReturn(validationResponse);
when(mockModuleApi.getUtlatandeFromJson(anyString())).thenReturn(utlatande);
when(mockUtkastRepository.save(utkast)).thenReturn(utkast);
when(userService.getUser()).thenReturn(user);
when(mockModuleApi.updateBeforeSave(anyString(), any(HoSPersonal.class))).thenReturn("{}");
draftService.saveDraft(INTYG_ID, UTKAST_VERSION, INTYG_JSON, false);
verify(mockUtkastRepository).save(any(Utkast.class));
verify(utkast).setPatientFornamn("Tolvan");
verify(utkast).setPatientEfternamn("Tolvansson");
verify(utkast).setPatientPersonnummer(any(Personnummer.class));
}
use of se.inera.intyg.common.support.modules.support.api.dto.ValidateDraftResponse 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());
}
use of se.inera.intyg.common.support.modules.support.api.dto.ValidateDraftResponse 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());
}
use of se.inera.intyg.common.support.modules.support.api.dto.ValidateDraftResponse 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());
}
use of se.inera.intyg.common.support.modules.support.api.dto.ValidateDraftResponse in project webcert by sklintyg.
the class CreateUtkastFromTemplateBuilderTest method testPopulateRenewalUtkastFromOriginal.
@Test
public void testPopulateRenewalUtkastFromOriginal() throws Exception {
Utkast orgUtkast = createOriginalUtkast();
when(mockUtkastRepository.findOne(INTYG_ID)).thenReturn(orgUtkast);
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.populateCopyUtkastFromOrignalUtkast(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());
assertNotNull(builderResponse.getUtkastCopy().getPatientMellannamn());
assertEquals(PATIENT_LNAME, builderResponse.getUtkastCopy().getPatientEfternamn());
}
Aggregations