Search in sources :

Example 21 with Intyg

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

the class NotificationTransformer method process.

public void process(Message message) throws ModuleException, IOException, ModuleNotFoundException, TemporaryException {
    LOG.debug("Receiving message: {}", message.getMessageId());
    NotificationMessage notificationMessage = message.getBody(NotificationMessage.class);
    message.setHeader(NotificationRouteHeaders.LOGISK_ADRESS, notificationMessage.getLogiskAdress());
    message.setHeader(NotificationRouteHeaders.INTYGS_ID, notificationMessage.getIntygsId());
    // Note that this header have been set already by the original sender to accommodate header-based routing
    // in the aggreagatorRoute. It is 100% safe to overwrite it at this point.
    message.setHeader(NotificationRouteHeaders.HANDELSE, notificationMessage.getHandelse().value());
    if (notificationMessage.getVersion() != null) {
        message.setHeader(NotificationRouteHeaders.VERSION, notificationMessage.getVersion().name());
    } else {
        message.setHeader(NotificationRouteHeaders.VERSION, SchemaVersion.VERSION_1.name());
    }
    if (SchemaVersion.VERSION_3.equals(notificationMessage.getVersion())) {
        ModuleApi moduleApi = moduleRegistry.getModuleApi(notificationMessage.getIntygsTyp());
        Utlatande utlatande = moduleApi.getUtlatandeFromJson(notificationMessage.getUtkast());
        Intyg intyg = moduleApi.getIntygFromUtlatande(utlatande);
        notificationPatientEnricher.enrichWithPatient(intyg);
        message.setBody(NotificationTypeConverter.convert(notificationMessage, intyg));
    } else if (Fk7263EntryPoint.MODULE_ID.equals(notificationMessage.getIntygsTyp())) {
        message.setBody(fk7263Transform.createCertificateStatusUpdateForCareType(notificationMessage));
    } else {
        throw new IllegalArgumentException("Unsupported combination of version '" + notificationMessage.getVersion() + "' and type '" + notificationMessage.getIntygsTyp() + "'");
    }
}
Also used : ModuleApi(se.inera.intyg.common.support.modules.support.api.ModuleApi) NotificationMessage(se.inera.intyg.common.support.modules.support.api.notification.NotificationMessage) Intyg(se.riv.clinicalprocess.healthcond.certificate.v3.Intyg) Utlatande(se.inera.intyg.common.support.model.common.internal.Utlatande)

Example 22 with Intyg

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

the class CreateNewDraftRequestBuilderTest method createIntyg.

private Intyg createIntyg() {
    Intyg intyg = new Intyg();
    TypAvIntyg intygTyp = new TypAvIntyg();
    intygTyp.setCode(CERT_TYPE);
    intyg.setTypAvIntyg(intygTyp);
    HosPersonal hosPerson = new HosPersonal();
    HsaId userHsaId = new HsaId();
    userHsaId.setExtension(USER_HSAID);
    userHsaId.setRoot("USERHSAID");
    hosPerson.setPersonalId(userHsaId);
    hosPerson.setFullstandigtNamn(FULLSTANDIGT_NAMN);
    Enhet hosEnhet = new Enhet();
    HsaId unitHsaId = new HsaId();
    unitHsaId.setExtension(UNIT_HSAID);
    unitHsaId.setRoot("UNITHSAID");
    hosEnhet.setEnhetsId(unitHsaId);
    hosPerson.setEnhet(hosEnhet);
    intyg.setSkapadAv(hosPerson);
    Patient patType = new Patient();
    PersonId personId = new PersonId();
    personId.setRoot("PERSNR");
    personId.setExtension(PERSONNUMMER);
    patType.setPersonId(personId);
    patType.setFornamn(FORNAMN);
    patType.setMellannamn(MELLANNAMN);
    patType.setEfternamn(EFTERNAMN);
    patType.setPostadress(PATIENT_POSTADRESS);
    patType.setPostnummer(PATIENT_POSTNUMMER);
    patType.setPostort(PATIENT_POSTORT);
    intyg.setPatient(patType);
    return intyg;
}
Also used : HosPersonal(se.riv.clinicalprocess.healthcond.certificate.createdraftcertificateresponder.v3.HosPersonal) Enhet(se.riv.clinicalprocess.healthcond.certificate.createdraftcertificateresponder.v3.Enhet) TypAvIntyg(se.riv.clinicalprocess.healthcond.certificate.types.v3.TypAvIntyg) PersonId(se.riv.clinicalprocess.healthcond.certificate.types.v3.PersonId) TypAvIntyg(se.riv.clinicalprocess.healthcond.certificate.types.v3.TypAvIntyg) Intyg(se.riv.clinicalprocess.healthcond.certificate.createdraftcertificateresponder.v3.Intyg) Patient(se.riv.clinicalprocess.healthcond.certificate.v3.Patient) HsaId(se.riv.clinicalprocess.healthcond.certificate.types.v3.HsaId)

Example 23 with Intyg

use of se.riv.clinicalprocess.healthcond.certificate.v3.Intyg 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

Intyg (se.riv.clinicalprocess.healthcond.certificate.v3.Intyg)15 TypAvIntyg (se.riv.clinicalprocess.healthcond.certificate.types.v3.TypAvIntyg)7 Test (org.junit.Test)6 Patient (se.riv.clinicalprocess.healthcond.certificate.v3.Patient)6 NotificationMessage (se.inera.intyg.common.support.modules.support.api.notification.NotificationMessage)5 ArendeCount (se.inera.intyg.common.support.modules.support.api.notification.ArendeCount)4 CertificateStatusUpdateForCareType (se.riv.clinicalprocess.healthcond.certificate.certificatestatusupdateforcareresponder.v3.CertificateStatusUpdateForCareType)4 Intyg (se.riv.clinicalprocess.healthcond.certificate.createdraftcertificateresponder.v3.Intyg)4 HsaId (se.riv.clinicalprocess.healthcond.certificate.types.v3.HsaId)4 Enhet (se.riv.clinicalprocess.healthcond.certificate.v3.Enhet)4 LocalDateTime (java.time.LocalDateTime)3 HandelsekodEnum (se.inera.intyg.common.support.common.enumerations.HandelsekodEnum)3 ModuleApi (se.inera.intyg.common.support.modules.support.api.ModuleApi)3 Personnummer (se.inera.intyg.schemas.contract.Personnummer)3 PermanentException (se.inera.intyg.webcert.common.sender.exception.PermanentException)3 TemporaryException (se.inera.intyg.webcert.common.sender.exception.TemporaryException)3 Enhet (se.riv.clinicalprocess.healthcond.certificate.createdraftcertificateresponder.v3.Enhet)3 HosPersonal (se.riv.clinicalprocess.healthcond.certificate.createdraftcertificateresponder.v3.HosPersonal)3 ArbetsplatsKod (se.riv.clinicalprocess.healthcond.certificate.types.v3.ArbetsplatsKod)3 PersonId (se.riv.clinicalprocess.healthcond.certificate.types.v3.PersonId)3