Search in sources :

Example 1 with Arenden

use of se.riv.clinicalprocess.healthcond.certificate.v3.Arenden in project webcert by sklintyg.

the class CertificateStatusUpdateForCareResponderStub method certificateStatusUpdateForCare.

@Override
public CertificateStatusUpdateForCareResponseType certificateStatusUpdateForCare(String logicalAddress, CertificateStatusUpdateForCareType request) {
    Intyg intyg = request.getIntyg();
    String handelseKod = request.getHandelse().getHandelsekod().getCode();
    String intygsId = intyg.getIntygsId().getExtension();
    StringBuilder sb = new StringBuilder();
    if (intyg.getSigneringstidpunkt() != null) {
        sb.append(" Signeringstidpunkt: " + intyg.getSigneringstidpunkt());
        sb.append("\n");
    }
    if (intyg.getPatient() != null) {
        sb.append(" Patient: " + intyg.getPatient().getPersonId().getExtension());
        sb.append("\n");
    }
    Arenden skickadeFragor = request.getSkickadeFragor();
    sb.append(" Skickade fragor totalt: " + skickadeFragor.getTotalt());
    sb.append(" Skickade fragor hanterade: " + skickadeFragor.getHanterade());
    sb.append(" Skickade fragor besvarade: " + skickadeFragor.getBesvarade());
    sb.append(" Skickade fragor ej besvarade: " + skickadeFragor.getEjBesvarade());
    sb.append("\n");
    Arenden mottagnaFragor = request.getMottagnaFragor();
    sb.append(" Mottagna fragor totalt: " + mottagnaFragor.getTotalt());
    sb.append(" Mottagna fragor hanterade: " + mottagnaFragor.getHanterade());
    sb.append(" Mottagna fragor besvarade: " + mottagnaFragor.getBesvarade());
    sb.append(" Mottagna fragor ej besvarade: " + mottagnaFragor.getEjBesvarade());
    sb.append("\n");
    LOG.info("\n*********************************************************************************\n" + " Request to address '{}' recieved for intyg: {} handelse: {}.\n" + "{}" + "*********************************************************************************", logicalAddress, intygsId, handelseKod, sb.toString());
    notificationStoreV3.put(request);
    CertificateStatusUpdateForCareResponseType response = new CertificateStatusUpdateForCareResponseType();
    response.setResult(ResultTypeUtil.okResult());
    LOG.debug("Request set to 'OK'");
    return response;
}
Also used : Arenden(se.riv.clinicalprocess.healthcond.certificate.v3.Arenden) Intyg(se.riv.clinicalprocess.healthcond.certificate.v3.Intyg)

Example 2 with Arenden

use of se.riv.clinicalprocess.healthcond.certificate.v3.Arenden in project webcert by sklintyg.

the class NotificationTypeConverter method toArenden.

public static Arenden toArenden(ArendeCount source) {
    Arenden target = new Arenden();
    target.setTotalt(source.getTotalt());
    target.setBesvarade(source.getBesvarade());
    target.setEjBesvarade(source.getEjBesvarade());
    target.setHanterade(source.getHanterade());
    return target;
}
Also used : Arenden(se.riv.clinicalprocess.healthcond.certificate.v3.Arenden)

Example 3 with Arenden

use of se.riv.clinicalprocess.healthcond.certificate.v3.Arenden in project webcert by sklintyg.

the class IntygServiceImpl method listCertificatesForCareWithQA.

@Override
public List<IntygWithNotificationsResponse> listCertificatesForCareWithQA(IntygWithNotificationsRequest request) {
    List<Utkast> utkastList;
    if (request.shouldUseEnhetId()) {
        utkastList = utkastRepository.findDraftsByPatientAndEnhetAndStatus(DaoUtil.formatPnrForPersistence(request.getPersonnummer()), request.getEnhetId(), Arrays.asList(UtkastStatus.values()), moduleRegistry.listAllModules().stream().map(IntygModule::getId).collect(Collectors.toSet()));
    } else {
        utkastList = utkastRepository.findDraftsByPatientAndVardgivareAndStatus(DaoUtil.formatPnrForPersistence(request.getPersonnummer()), request.getVardgivarId(), Arrays.asList(UtkastStatus.values()), moduleRegistry.listAllModules().stream().map(IntygModule::getId).collect(Collectors.toSet()));
    }
    List<IntygWithNotificationsResponse> res = new ArrayList<>();
    for (Utkast utkast : utkastList) {
        List<Handelse> notifications = notificationService.getNotifications(utkast.getIntygsId());
        String ref = referensService.getReferensForIntygsId(utkast.getIntygsId());
        notifications = notifications.stream().filter(handelse -> {
            if (request.getStartDate() != null && handelse.getTimestamp().isBefore(request.getStartDate())) {
                return false;
            }
            if (request.getEndDate() != null && handelse.getTimestamp().isAfter(request.getEndDate())) {
                return false;
            }
            return true;
        }).collect(Collectors.toList());
        // this time span
        if ((request.getStartDate() != null || request.getEndDate() != null) && notifications.isEmpty()) {
            continue;
        }
        try {
            ModuleApi api = moduleRegistry.getModuleApi(utkast.getIntygsTyp());
            Intyg intyg = api.getIntygFromUtlatande(api.getUtlatandeFromJson(utkast.getModel()));
            Pair<ArendeCount, ArendeCount> arenden = fragorOchSvarCreator.createArenden(utkast.getIntygsId(), utkast.getIntygsTyp());
            res.add(new IntygWithNotificationsResponse(intyg, notifications, arenden.getLeft(), arenden.getRight(), ref));
        } catch (ModuleNotFoundException | ModuleException | IOException e) {
            LOG.error("Could not convert intyg {} to external format", utkast.getIntygsId());
        }
    }
    return res;
}
Also used : ModuleApi(se.inera.intyg.common.support.modules.support.api.ModuleApi) ModuleNotFoundException(se.inera.intyg.common.support.modules.registry.ModuleNotFoundException) Intyg(se.riv.clinicalprocess.healthcond.certificate.v3.Intyg) ArendeCount(se.inera.intyg.common.support.modules.support.api.notification.ArendeCount) ArrayList(java.util.ArrayList) IOException(java.io.IOException) Utkast(se.inera.intyg.webcert.persistence.utkast.model.Utkast) IntygWithNotificationsResponse(se.inera.intyg.webcert.web.service.intyg.dto.IntygWithNotificationsResponse) ModuleException(se.inera.intyg.common.support.modules.support.api.exception.ModuleException) Handelse(se.inera.intyg.webcert.persistence.handelse.model.Handelse)

Aggregations

Arenden (se.riv.clinicalprocess.healthcond.certificate.v3.Arenden)2 Intyg (se.riv.clinicalprocess.healthcond.certificate.v3.Intyg)2 IOException (java.io.IOException)1 ArrayList (java.util.ArrayList)1 ModuleNotFoundException (se.inera.intyg.common.support.modules.registry.ModuleNotFoundException)1 ModuleApi (se.inera.intyg.common.support.modules.support.api.ModuleApi)1 ModuleException (se.inera.intyg.common.support.modules.support.api.exception.ModuleException)1 ArendeCount (se.inera.intyg.common.support.modules.support.api.notification.ArendeCount)1 Handelse (se.inera.intyg.webcert.persistence.handelse.model.Handelse)1 Utkast (se.inera.intyg.webcert.persistence.utkast.model.Utkast)1 IntygWithNotificationsResponse (se.inera.intyg.webcert.web.service.intyg.dto.IntygWithNotificationsResponse)1