Search in sources :

Example 1 with MedicinsktArende

use of se.inera.intyg.webcert.persistence.arende.model.MedicinsktArende in project webcert by sklintyg.

the class ArendeViewConverterTest method buildArende.

private Arende buildArende(String intygstyp) {
    Arende arende = new Arende();
    arende.setAmne(ArendeAmne.OVRIGT);
    arende.setIntygsId(intygsId);
    arende.setStatus(se.inera.intyg.webcert.persistence.model.Status.PENDING_INTERNAL_ACTION);
    arende.setMeddelandeId("meddelandeId");
    arende.setPatientPersonId("191212121212");
    arende.setTimestamp(LocalDateTime.now());
    arende.setIntygTyp(intygstyp);
    arende.setVardaktorName(VARDAKTOR_NAMN);
    arende.setEnhetId(ENHETS_ID);
    arende.setEnhetName(ENHETS_NAMN);
    arende.setVardgivareName(VARDGIVARE_NAMN);
    arende.setSkickatAv("Fragestallare");
    arende.setRubrik("rubrik");
    arende.setSistaDatumForSvar(LocalDateTime.now().plusDays(4).toLocalDate());
    MedicinsktArende medArende1 = buildMedicinsktArende("1", 1, "arende1");
    MedicinsktArende medArende2 = buildMedicinsktArende("2", 1, "arende1");
    MedicinsktArende medArende4 = buildMedicinsktArende("4", 2, "arende1");
    arende.setKomplettering(Arrays.asList(medArende1, medArende2, medArende4));
    return arende;
}
Also used : MedicinsktArende(se.inera.intyg.webcert.persistence.arende.model.MedicinsktArende) MedicinsktArende(se.inera.intyg.webcert.persistence.arende.model.MedicinsktArende) Arende(se.inera.intyg.webcert.persistence.arende.model.Arende)

Example 2 with MedicinsktArende

use of se.inera.intyg.webcert.persistence.arende.model.MedicinsktArende in project webcert by sklintyg.

the class ArendeViewConverterTest method buildMedicinsktArende.

private MedicinsktArende buildMedicinsktArende(String frageId, Integer instansId, String text) {
    MedicinsktArende med1 = new MedicinsktArende();
    med1.setFrageId(frageId);
    med1.setInstans(instansId);
    med1.setText(text);
    return med1;
}
Also used : MedicinsktArende(se.inera.intyg.webcert.persistence.arende.model.MedicinsktArende)

Example 3 with MedicinsktArende

use of se.inera.intyg.webcert.persistence.arende.model.MedicinsktArende in project webcert by sklintyg.

the class UtkastBootstrapBean method createArende.

private String createArende(Utlatande utlatande, boolean komplettering, String paminnelseMeddelandeId, FrageStallare fragestallare, ArendeAmne amne) {
    Arende arende = new Arende();
    arende.setAmne(amne);
    arende.setEnhetId(utlatande.getGrundData().getSkapadAv().getVardenhet().getEnhetsid());
    arende.setEnhetName(utlatande.getGrundData().getSkapadAv().getVardenhet().getEnhetsnamn());
    arende.setIntygsId(utlatande.getId());
    arende.setIntygTyp(utlatande.getTyp());
    if (komplettering) {
        MedicinsktArende ma = new MedicinsktArende();
        // This question always exist.
        ma.setFrageId("1");
        ma.setInstans(1);
        ma.setText("Kompletteringstext");
        arende.setKomplettering(Arrays.asList(ma));
    }
    arende.setMeddelande("Meddelandetext");
    String meddelandeId = UUID.randomUUID().toString();
    arende.setMeddelandeId(meddelandeId);
    arende.setPaminnelseMeddelandeId(paminnelseMeddelandeId);
    arende.setPatientPersonId(utlatande.getGrundData().getPatient().getPersonId().getPersonnummer());
    arende.setReferensId("referens");
    arende.setRubrik(arende.getAmne().getDescription());
    arende.setSenasteHandelse(LocalDateTime.now());
    arende.setSigneratAv(utlatande.getGrundData().getSkapadAv().getPersonId());
    arende.setSigneratAvName(utlatande.getGrundData().getSkapadAv().getFullstandigtNamn());
    arende.setSkickatAv(fragestallare.getKod());
    arende.setSkickatTidpunkt(LocalDateTime.now());
    if (fragestallare.equals(FrageStallare.WEBCERT)) {
        arende.setStatus(Status.PENDING_EXTERNAL_ACTION);
    } else {
        arende.setStatus(Status.PENDING_INTERNAL_ACTION);
        arende.setSistaDatumForSvar(LocalDate.now().plusWeeks(2));
    }
    arende.setSvarPaId(null);
    arende.setSvarPaReferens(null);
    arende.setTimestamp(LocalDateTime.now());
    arende.setVardaktorName(utlatande.getGrundData().getSkapadAv().getFullstandigtNamn());
    arende.setVardgivareName(utlatande.getGrundData().getSkapadAv().getVardenhet().getVardgivare().getVardgivarnamn());
    arende.setVidarebefordrad(false);
    arendeRepo.save(arende);
    return meddelandeId;
}
Also used : MedicinsktArende(se.inera.intyg.webcert.persistence.arende.model.MedicinsktArende) MedicinsktArende(se.inera.intyg.webcert.persistence.arende.model.MedicinsktArende) Arende(se.inera.intyg.webcert.persistence.arende.model.Arende)

Example 4 with MedicinsktArende

use of se.inera.intyg.webcert.persistence.arende.model.MedicinsktArende in project webcert by sklintyg.

the class ArendeServiceImpl method processIncomingMessage.

@Override
public Arende processIncomingMessage(Arende arende) {
    if (arendeRepository.findOneByMeddelandeId(arende.getMeddelandeId()) != null) {
        throw new WebCertServiceException(WebCertServiceErrorCodeEnum.INVALID_STATE, "meddelandeId not unique");
    }
    Utkast utkast = utkastRepository.findOne(arende.getIntygsId());
    validateArende(arende.getIntygsId(), utkast);
    ArendeConverter.decorateArendeFromUtkast(arende, utkast, LocalDateTime.now(systemClock), hsaEmployeeService);
    updateRelated(arende);
    monitoringLog.logArendeReceived(arende.getIntygsId(), utkast.getIntygsTyp(), utkast.getEnhetsId(), arende.getAmne(), arende.getKomplettering().stream().map(MedicinsktArende::getFrageId).collect(Collectors.toList()), arende.getSvarPaId() != null);
    Arende saved = arendeRepository.save(arende);
    if (ArendeAmne.PAMINN == saved.getAmne() || saved.getSvarPaId() == null) {
        notificationService.sendNotificationForQuestionReceived(saved);
    } else {
        notificationService.sendNotificationForAnswerRecieved(saved);
    }
    return saved;
}
Also used : MedicinsktArende(se.inera.intyg.webcert.persistence.arende.model.MedicinsktArende) Utkast(se.inera.intyg.webcert.persistence.utkast.model.Utkast) MedicinsktArende(se.inera.intyg.webcert.persistence.arende.model.MedicinsktArende) Arende(se.inera.intyg.webcert.persistence.arende.model.Arende) WebCertServiceException(se.inera.intyg.webcert.common.service.exception.WebCertServiceException)

Example 5 with MedicinsktArende

use of se.inera.intyg.webcert.persistence.arende.model.MedicinsktArende in project webcert by sklintyg.

the class ArendeConverter method convert.

private static MedicinsktArende convert(Komplettering k) {
    MedicinsktArende res = new MedicinsktArende();
    res.setFrageId(k.getFrageId());
    res.setText(k.getText());
    res.setInstans(k.getInstans());
    return res;
}
Also used : MedicinsktArende(se.inera.intyg.webcert.persistence.arende.model.MedicinsktArende)

Aggregations

MedicinsktArende (se.inera.intyg.webcert.persistence.arende.model.MedicinsktArende)8 Arende (se.inera.intyg.webcert.persistence.arende.model.Arende)4 ImmutableList (com.google.common.collect.ImmutableList)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 Utlatande (se.inera.intyg.common.support.model.common.internal.Utlatande)1 ModuleNotFoundException (se.inera.intyg.common.support.modules.registry.ModuleNotFoundException)1 ModuleApi (se.inera.intyg.common.support.modules.support.api.ModuleApi)1 WebCertServiceException (se.inera.intyg.webcert.common.service.exception.WebCertServiceException)1 Utkast (se.inera.intyg.webcert.persistence.utkast.model.Utkast)1 MedicinsktArendeView (se.inera.intyg.webcert.web.web.controller.api.dto.MedicinsktArendeView)1