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());
}
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;
}
Aggregations