Search in sources :

Example 6 with LogRequest

use of se.inera.intyg.webcert.web.service.log.dto.LogRequest in project webcert by sklintyg.

the class LogRequestFactoryTest method testPatientNameRemovedForFkIntyg.

@Test
public void testPatientNameRemovedForFkIntyg() {
    Utkast utkast = buildUtkast(intygsId, "luse", patientPersonnummer, patientFornamn, patientMellannamn, patientEfternamn, enhetsid, enhetsnamn, vardgivarid, vardgivarnamn);
    LogRequest res = LogRequestFactory.createLogRequestFromUtkast(utkast);
    assertNotNull(res);
    assertEquals(intygsId, res.getIntygId());
    assertEquals(patientPersonnummer, res.getPatientId());
    assertEquals("", res.getPatientName());
    assertNull(res.getAdditionalInfo());
}
Also used : LogRequest(se.inera.intyg.webcert.web.service.log.dto.LogRequest) Utkast(se.inera.intyg.webcert.persistence.utkast.model.Utkast) Test(org.junit.Test)

Example 7 with LogRequest

use of se.inera.intyg.webcert.web.service.log.dto.LogRequest in project webcert by sklintyg.

the class IntygServiceImpl method whenSuccessfulRevoke.

/**
 * Send a notification message to stakeholders informing that
 * a question related to a revoked certificate has been closed.
 */
private IntygServiceResult whenSuccessfulRevoke(Utlatande intyg, String reason) {
    String intygsId = intyg.getId();
    String hsaId = webCertUserService.getUser().getHsaId();
    monitoringService.logIntygRevoked(intygsId, hsaId, reason);
    // First: send a notification informing stakeholders that this certificate has been revoked
    notificationService.sendNotificationForIntygRevoked(intygsId);
    // Second: send a notification informing stakeholders that all questions related to the revoked
    // certificate has been closed.
    arendeService.closeAllNonClosed(intygsId);
    // Third: create a log event
    LogRequest logRequest = LogRequestFactory.createLogRequestFromUtlatande(intyg);
    logService.logRevokeIntyg(logRequest);
    // Fourth: mark the originating Utkast as REVOKED
    markUtkastWithRevokedDate(intygsId);
    return IntygServiceResult.OK;
}
Also used : LogRequest(se.inera.intyg.webcert.web.service.log.dto.LogRequest)

Example 8 with LogRequest

use of se.inera.intyg.webcert.web.service.log.dto.LogRequest 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);
}
Also used : SendIntygConfiguration(se.inera.intyg.webcert.web.service.intyg.config.SendIntygConfiguration) LogRequest(se.inera.intyg.webcert.web.service.log.dto.LogRequest) Utlatande(se.inera.intyg.common.support.model.common.internal.Utlatande) WebCertServiceException(se.inera.intyg.webcert.common.service.exception.WebCertServiceException)

Example 9 with LogRequest

use of se.inera.intyg.webcert.web.service.log.dto.LogRequest in project webcert by sklintyg.

the class SignaturServiceImpl method clientNiasSignature.

@Override
public SignaturTicket clientNiasSignature(String ticketId, SignatureType signatureType, String niasCertificate, WebCertUser user) {
    // Lookup signature ticket
    SignaturTicket ticket = ticketTracker.getTicket(ticketId);
    if (ticket == null) {
        LOG.warn("Ticket '{}' hittades ej", ticketId);
        throw new WebCertServiceException(WebCertServiceErrorCodeEnum.INVALID_STATE, "Biljett " + ticketId + " hittades ej");
    }
    LOG.debug("Klientsignering ticket '{}' intyg '{}'", ticket.getId(), ticket.getIntygsId());
    // Fetch the draft
    Utkast utkast = getUtkastForSignering(ticket.getIntygsId(), ticket.getVersion(), user);
    // Create and persist the new signature
    StringWriter sw = new StringWriter();
    JAXB.marshal(signatureType, sw);
    String rawSignaturXml = sw.toString();
    ticket = createAndPersistSignature(utkast, ticket, rawSignaturXml, user);
    monitoringService.logIntygSigned(utkast.getIntygsId(), utkast.getIntygsTyp(), user.getHsaId(), user.getAuthenticationScheme(), utkast.getRelationKod());
    // Notify stakeholders when certificate has been signed
    notificationService.sendNotificationForDraftSigned(utkast);
    LogRequest logRequest = LogRequestFactory.createLogRequestFromUtkast(utkast);
    // Note that we explictly supplies the WebCertUser here. The NIAS finalization is not executed in a HTTP
    // request context and thus we need to supply the user instance manually.
    logService.logSignIntyg(logRequest, logService.getLogUser(user));
    intygService.handleAfterSigned(utkast);
    return ticketTracker.updateStatus(ticket.getId(), SignaturTicket.Status.SIGNERAD);
}
Also used : LogRequest(se.inera.intyg.webcert.web.service.log.dto.LogRequest) StringWriter(java.io.StringWriter) Utkast(se.inera.intyg.webcert.persistence.utkast.model.Utkast) SignaturTicket(se.inera.intyg.webcert.web.service.signatur.dto.SignaturTicket) WebCertServiceException(se.inera.intyg.webcert.common.service.exception.WebCertServiceException)

Example 10 with LogRequest

use of se.inera.intyg.webcert.web.service.log.dto.LogRequest in project webcert by sklintyg.

the class LogRequestFactory method createLogRequestFromUser.

public static LogRequest createLogRequestFromUser(WebCertUser user, String patientId) {
    LogRequest request = new LogRequest();
    request.setPatientId(Personnummer.createPersonnummer(patientId).get());
    request.setPatientName("");
    request.setIntygCareUnitId(user.getValdVardenhet().getId());
    request.setIntygCareUnitName(user.getValdVardenhet().getNamn());
    request.setIntygCareGiverId(user.getValdVardgivare().getId());
    request.setIntygCareGiverName(user.getValdVardgivare().getNamn());
    if (user.getParameters() != null && user.getParameters().isSjf()) {
        request.setAdditionalInfo(COHERENT_JOURNALING_LOG_POST);
    }
    return request;
}
Also used : LogRequest(se.inera.intyg.webcert.web.service.log.dto.LogRequest)

Aggregations

LogRequest (se.inera.intyg.webcert.web.service.log.dto.LogRequest)25 Utkast (se.inera.intyg.webcert.persistence.utkast.model.Utkast)11 Test (org.junit.Test)7 Transactional (org.springframework.transaction.annotation.Transactional)5 WebCertServiceException (se.inera.intyg.webcert.common.service.exception.WebCertServiceException)5 SignaturTicket (se.inera.intyg.webcert.web.service.signatur.dto.SignaturTicket)3 OptimisticLockException (javax.persistence.OptimisticLockException)2 MessageCreator (org.springframework.jms.core.MessageCreator)2 Utlatande (se.inera.intyg.common.support.model.common.internal.Utlatande)2 ModuleApi (se.inera.intyg.common.support.modules.support.api.ModuleApi)2 ModuleException (se.inera.intyg.common.support.modules.support.api.exception.ModuleException)2 UtkastStatus (se.inera.intyg.webcert.common.model.UtkastStatus)2 IOException (java.io.IOException)1 StringWriter (java.io.StringWriter)1 Session (javax.jms.Session)1 DestinationResolutionException (org.springframework.jms.support.destination.DestinationResolutionException)1 Relation (se.inera.intyg.common.support.model.common.internal.Relation)1 ModuleNotFoundException (se.inera.intyg.common.support.modules.registry.ModuleNotFoundException)1 PdlLogMessage (se.inera.intyg.infra.logmessages.PdlLogMessage)1 Personnummer (se.inera.intyg.schemas.contract.Personnummer)1