use of se.inera.intyg.common.support.modules.support.api.dto.ValidateDraftResponse in project webcert by sklintyg.
the class UtkastServiceImpl method validateDraft.
@Override
public DraftValidation validateDraft(String intygId, String intygType, String draftAsJson) {
LOG.debug("Validating Intyg '{}' with type '{}'", intygId, intygType);
try {
ModuleApi moduleApi = moduleRegistry.getModuleApi(intygType);
ValidateDraftResponse validateDraftResponse = moduleApi.validateDraft(draftAsJson);
return convertToDraftValidation(validateDraftResponse);
} catch (ModuleException | ModuleNotFoundException me) {
throw new WebCertServiceException(WebCertServiceErrorCodeEnum.MODULE_PROBLEM, me);
}
}
use of se.inera.intyg.common.support.modules.support.api.dto.ValidateDraftResponse 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());
}
use of se.inera.intyg.common.support.modules.support.api.dto.ValidateDraftResponse 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());
}
use of se.inera.intyg.common.support.modules.support.api.dto.ValidateDraftResponse in project webcert by sklintyg.
the class CreateRenewalCopyUtkastBuilderImplTest method testPopulateRenewalUtkastFromSignedIntygWithNoPatientDetails.
@Test
public void testPopulateRenewalUtkastFromSignedIntygWithNoPatientDetails() throws Exception {
IntygContentHolder ich = createIntygContentHolder();
when(mockIntygService.fetchIntygData(INTYG_ID, INTYG_TYPE, false)).thenReturn(ich);
CreateRenewalCopyRequest renewalRequest = buildRenewalRequest();
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, null, false, false, false);
assertNotNull(builderResponse.getUtkastCopy());
assertNotNull(builderResponse.getUtkastCopy().getModel());
assertEquals(INTYG_TYPE, builderResponse.getUtkastCopy().getIntygsTyp());
assertEquals(PATIENT_SSN, builderResponse.getUtkastCopy().getPatientPersonnummer());
assertEquals("Test", builderResponse.getUtkastCopy().getPatientFornamn());
assertNull(builderResponse.getUtkastCopy().getPatientMellannamn());
assertEquals("Testorsson", builderResponse.getUtkastCopy().getPatientEfternamn());
}
use of se.inera.intyg.common.support.modules.support.api.dto.ValidateDraftResponse 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());
}
Aggregations