use of se.inera.intyg.common.support.model.common.internal.Utlatande in project webcert by sklintyg.
the class IntygServiceImpl method sendIntyg.
@Override
public IntygServiceResult sendIntyg(String intygsId, String typ, String recipient, boolean delay) {
Utlatande intyg = getUtlatandeForIntyg(intygsId, typ);
verifyEnhetsAuth(intyg, true);
if (isRevoked(intygsId, typ, false)) {
LOG.debug("Cannot send certificate with id '{}', the certificate is revoked", intygsId);
throw new WebCertServiceException(WebCertServiceErrorCodeEnum.INVALID_STATE, "Certificate is revoked");
}
verifyNotReplacedBySignedIntyg(intygsId, "send");
// WC-US-SM-001 - vi får ej skicka FK-intyg för sekretessmarkerad patient som innehåller personuppgifter.
verifyNoExposureOfSekretessmarkeradPatient(intyg);
SendIntygConfiguration sendConfig = new SendIntygConfiguration(recipient, webCertUserService.getUser());
monitoringService.logIntygSent(intygsId, recipient);
// send PDL log event
LogRequest logRequest = LogRequestFactory.createLogRequestFromUtlatande(intyg);
logRequest.setAdditionalInfo(sendConfig.getPatientConsentMessage());
logService.logSendIntygToRecipient(logRequest);
markUtkastWithSendDateAndRecipient(intygsId, recipient);
return sendIntygToCertificateSender(sendConfig, intyg, delay);
}
use of se.inera.intyg.common.support.model.common.internal.Utlatande in project webcert by sklintyg.
the class ArendeViewConverter method convertToMedicinsktArendeView.
private List<MedicinsktArendeView> convertToMedicinsktArendeView(List<MedicinsktArende> medicinskaArenden, String intygsId, String intygsTyp) {
List<MedicinsktArendeView> medicinskaArendenViews = new ArrayList<>();
if (CollectionUtils.isEmpty(medicinskaArenden)) {
return medicinskaArendenViews;
}
List<String> frageIds = medicinskaArenden.stream().map(MedicinsktArende::getFrageId).distinct().collect(Collectors.toList());
ModuleApi moduleApi = null;
try {
moduleApi = moduleRegistry.getModuleApi(intygsTyp);
} catch (ModuleNotFoundException e) {
LOG.error("Module not found for certificate of type {}", intygsTyp);
Throwables.propagate(e);
}
Utlatande utlatande = intygService.fetchIntygData(intygsId, intygsTyp, false).getUtlatande();
Map<String, List<String>> arendeParameters = moduleApi.getModuleSpecificArendeParameters(utlatande, frageIds);
for (MedicinsktArende arende : medicinskaArenden) {
Integer position = getListPositionForInstanceId(arende);
String jsonPropertyHandle = getJsonPropertyHandle(arende, position, arendeParameters);
MedicinsktArendeView view = MedicinsktArendeView.builder().setFrageId(arende.getFrageId()).setInstans(arende.getInstans()).setText(arende.getText()).setPosition(Math.max(position - 1, 0)).setJsonPropertyHandle(jsonPropertyHandle).build();
medicinskaArendenViews.add(view);
}
return medicinskaArendenViews;
}
use of se.inera.intyg.common.support.model.common.internal.Utlatande in project webcert by sklintyg.
the class UtkastServiceImplTest method testSaveDraftSecondSave.
@Test
public void testSaveDraftSecondSave() throws Exception {
ValidationMessage valMsg = new ValidationMessage("a.category", "a.field.somewhere", ValidationMessageType.OTHER, "This is soooo wrong!");
ValidateDraftResponse validationResponse = new ValidateDraftResponse(ValidationStatus.INVALID, Collections.singletonList(valMsg));
WebCertUser user = createUser();
Utlatande utlatande = mock(Utlatande.class);
GrundData grunddata = new GrundData();
grunddata.setSkapadAv(new HoSPersonal());
grunddata.setPatient(defaultPatient);
when(utlatande.getGrundData()).thenReturn(grunddata);
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(mockModuleApi.shouldNotify(any(String.class), any(String.class))).thenReturn(true);
when(userService.getUser()).thenReturn(user);
when(mockModuleApi.updateBeforeSave(anyString(), any(HoSPersonal.class))).thenReturn("{}");
SaveDraftResponse res = draftService.saveDraft(INTYG_ID, UTKAST_VERSION, INTYG_JSON, false);
verify(mockUtkastRepository).save(any(Utkast.class));
// Assert notification message
verify(notificationService).sendNotificationForDraftChanged(any(Utkast.class));
// Assert that no logs are called
verifyZeroInteractions(logService);
verifyZeroInteractions(mockMonitoringService);
assertNotNull("An DraftValidation should be returned", res);
assertEquals("Validation should fail", UtkastStatus.DRAFT_INCOMPLETE, res.getStatus());
}
use of se.inera.intyg.common.support.model.common.internal.Utlatande in project webcert by sklintyg.
the class UtkastServiceImplTest method setupReferensMocks.
private void setupReferensMocks() throws ModuleNotFoundException, ModuleException, IOException {
ValidationMessage valMsg = new ValidationMessage("a.category", "a.field.somewhere", ValidationMessageType.OTHER, "This is soooo wrong!");
ValidateDraftResponse validationResponse = new ValidateDraftResponse(ValidationStatus.INVALID, Collections.singletonList(valMsg));
Utlatande utlatande = mock(Utlatande.class);
when(moduleRegistry.getModuleApi(INTYG_TYPE)).thenReturn(mockModuleApi);
when(mockUtkastRepository.save(any(Utkast.class))).then(invocation -> invocation.getArguments()[0]);
}
use of se.inera.intyg.common.support.model.common.internal.Utlatande in project webcert by sklintyg.
the class UtkastServiceImplTest method testUpdatePatientOnDraftSamePatientId.
@Test
public void testUpdatePatientOnDraftSamePatientId() throws Exception {
utkast.setEnhetsId(UTKAST_ENHETS_ID);
UpdatePatientOnDraftRequest request = new UpdatePatientOnDraftRequest(defaultPatient.getPersonId(), utkast.getIntygsId(), utkast.getVersion());
WebCertUser user = createUser();
Utlatande utlatande = mock(Utlatande.class);
GrundData grunddata = new GrundData();
grunddata.setPatient(defaultPatient);
grunddata.setSkapadAv(new HoSPersonal());
when(utlatande.getGrundData()).thenReturn(grunddata);
// 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.getUtlatandeFromJson(anyString())).thenReturn(utlatande);
when(userService.getUser()).thenReturn(user);
draftService.updatePatientOnDraft(request);
verify(mockUtkastRepository, never()).save(any(Utkast.class));
verify(notificationService, never()).sendNotificationForDraftChanged(any(Utkast.class));
verify(utkast, never()).setPatientPersonnummer(any(Personnummer.class));
assertEquals(defaultPatient.getPersonId().getPersonnummer(), user.getParameters().getBeforeAlternateSsn());
}
Aggregations