Search in sources :

Example 21 with LogRequest

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

the class IntygServiceImpl method logPdfPrinting.

/**
 * Creates log events for PDF printing actions. Creates both PDL and monitoring log events
 * depending the state of the intyg.
 *
 * @param intyg
 */
private void logPdfPrinting(IntygContentHolder intyg, boolean coherentJournaling) {
    final String intygsId = intyg.getUtlatande().getId();
    final String intygsTyp = intyg.getUtlatande().getTyp();
    LogRequest logRequest = LogRequestFactory.createLogRequestFromUtlatande(intyg.getUtlatande(), coherentJournaling);
    // Are we printing a draft?
    if (intyg.getUtlatande().getGrundData().getSigneringsdatum() == null) {
        // Log printing of draft
        logService.logPrintIntygAsDraft(logRequest);
        monitoringService.logUtkastPrint(intygsId, intygsTyp);
    } else {
        // Log printing of intyg
        if (intyg.isRevoked()) {
            logService.logPrintRevokedIntygAsPDF(logRequest);
            monitoringService.logRevokedPrint(intygsId, intygsTyp);
        } else {
            logService.logPrintIntygAsPDF(logRequest);
            monitoringService.logIntygPrintPdf(intygsId, intygsTyp);
        }
    }
}
Also used : LogRequest(se.inera.intyg.webcert.web.service.log.dto.LogRequest)

Example 22 with LogRequest

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

the class SignaturServiceImpl method serverSignature.

@Override
@Transactional("jpaTransactionManager")
public SignaturTicket serverSignature(String intygsId, long version) {
    LOG.debug("Signera utkast '{}'", intygsId);
    // On server side we need to create our own signature ticket
    SignaturTicket ticket = createDraftHash(intygsId, version);
    // Fetch Webcert user
    WebCertUser user = getWebcertUserForSignering();
    // Fetch the certificate
    Utkast utkast = getUtkastForSignering(intygsId, ticket.getVersion(), user);
    // Create and persist signature
    ticket = createAndPersistSignature(utkast, ticket, "Signatur", user);
    // Audit signing
    monitoringService.logIntygSigned(utkast.getIntygsId(), utkast.getIntygsTyp(), user.getHsaId(), user.getAuthenticationScheme(), utkast.getRelationKod());
    // Notify stakeholders when a draft has been signed
    notificationService.sendNotificationForDraftSigned(utkast);
    LogRequest logRequest = LogRequestFactory.createLogRequestFromUtkast(utkast);
    logService.logSignIntyg(logRequest);
    intygService.handleAfterSigned(utkast);
    return ticketTracker.updateStatus(ticket.getId(), SignaturTicket.Status.SIGNERAD);
}
Also used : LogRequest(se.inera.intyg.webcert.web.service.log.dto.LogRequest) Utkast(se.inera.intyg.webcert.persistence.utkast.model.Utkast) SignaturTicket(se.inera.intyg.webcert.web.service.signatur.dto.SignaturTicket) WebCertUser(se.inera.intyg.webcert.web.service.user.dto.WebCertUser) Transactional(org.springframework.transaction.annotation.Transactional)

Example 23 with LogRequest

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

the class SignaturServiceImpl method finalizeClientSignature.

private SignaturTicket finalizeClientSignature(String ticketId, String rawSignatur, 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
    ticket = createAndPersistSignature(utkast, ticket, rawSignatur, 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 BankID 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) 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 24 with LogRequest

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

the class LogRequestFactory method createLogRequestFromUtkast.

public static LogRequest createLogRequestFromUtkast(Utkast utkast, boolean coherentJournaling) {
    LogRequest logRequest = new LogRequest();
    logRequest.setIntygId(utkast.getIntygsId());
    logRequest.setPatientId(utkast.getPatientPersonnummer());
    String intygsTyp = utkast.getIntygsTyp();
    addPatientNameIfNotFK(Joiner.on(" ").skipNulls().join(utkast.getPatientFornamn(), utkast.getPatientMellannamn(), utkast.getPatientEfternamn()), logRequest, intygsTyp);
    logRequest.setIntygCareUnitId(utkast.getEnhetsId());
    logRequest.setIntygCareUnitName(utkast.getEnhetsNamn());
    logRequest.setIntygCareGiverId(utkast.getVardgivarId());
    logRequest.setIntygCareGiverName(utkast.getVardgivarNamn());
    if (coherentJournaling) {
        logRequest.setAdditionalInfo(COHERENT_JOURNALING_LOG_POST);
    }
    return logRequest;
}
Also used : LogRequest(se.inera.intyg.webcert.web.service.log.dto.LogRequest)

Example 25 with LogRequest

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

the class LogRequestFactory method createLogRequestFromUtlatande.

public static LogRequest createLogRequestFromUtlatande(Utlatande utlatande, boolean coherentJournaling) {
    LogRequest logRequest = new LogRequest();
    logRequest.setIntygId(utlatande.getId());
    logRequest.setPatientId(utlatande.getGrundData().getPatient().getPersonId());
    addPatientNameIfNotFK(utlatande.getGrundData().getPatient().getFullstandigtNamn(), logRequest, utlatande.getTyp());
    logRequest.setIntygCareUnitId(utlatande.getGrundData().getSkapadAv().getVardenhet().getEnhetsid());
    logRequest.setIntygCareUnitName(utlatande.getGrundData().getSkapadAv().getVardenhet().getEnhetsnamn());
    logRequest.setIntygCareGiverId(utlatande.getGrundData().getSkapadAv().getVardenhet().getVardgivare().getVardgivarid());
    logRequest.setIntygCareGiverName(utlatande.getGrundData().getSkapadAv().getVardenhet().getVardgivare().getVardgivarnamn());
    if (coherentJournaling) {
        logRequest.setAdditionalInfo(COHERENT_JOURNALING_LOG_POST);
    }
    return logRequest;
}
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