Search in sources :

Example 1 with Amne

use of se.inera.intyg.webcert.persistence.fragasvar.model.Amne in project webcert by sklintyg.

the class FragaSvarRepositoryImpl method createPredicate.

private Predicate createPredicate(Filter filter, CriteriaBuilder builder, Root<FragaSvar> root) {
    Predicate pred = builder.conjunction();
    pred = builder.and(pred, root.get("vardperson").get("enhetsId").in(filter.getEnhetsIds()));
    pred = builder.and(pred, root.get("intygsReferens").get("intygsTyp").in(filter.getIntygsTyper()));
    if (filter.isQuestionFromFK()) {
        pred = builder.and(pred, builder.equal(root.get("frageStallare"), "FK"));
    }
    if (filter.isQuestionFromWC()) {
        pred = builder.and(pred, builder.equal(root.get("frageStallare"), "WC"));
    }
    if (!Strings.isNullOrEmpty(filter.getHsaId())) {
        pred = builder.and(pred, builder.equal(root.get("vardperson").get("hsaId"), filter.getHsaId()));
    }
    if (filter.getVidarebefordrad() != null) {
        pred = builder.and(pred, builder.equal(root.<Boolean>get("vidarebefordrad"), filter.getVidarebefordrad()));
    }
    if (filter.getChangedFrom() != null) {
        pred = builder.and(pred, builder.greaterThanOrEqualTo(root.<LocalDateTime>get("senasteHandelse"), filter.getChangedFrom()));
    }
    if (filter.getChangedTo() != null) {
        pred = builder.and(pred, builder.lessThan(root.<LocalDateTime>get("senasteHandelse"), filter.getChangedTo()));
    }
    if (filter.getReplyLatest() != null) {
        pred = builder.and(pred, builder.lessThanOrEqualTo(root.<LocalDate>get("sistaDatumForSvar"), filter.getReplyLatest()));
    }
    switch(filter.getVantarPa()) {
        case ALLA_OHANTERADE:
            pred = builder.and(pred, builder.notEqual(root.<Status>get("status"), Status.CLOSED));
            break;
        case HANTERAD:
            pred = builder.and(pred, builder.equal(root.<Status>get("status"), Status.CLOSED));
            break;
        case KOMPLETTERING_FRAN_VARDEN:
            pred = builder.and(pred, builder.equal(root.<Status>get("status"), Status.PENDING_INTERNAL_ACTION), builder.equal(root.<Amne>get("amne"), Amne.KOMPLETTERING_AV_LAKARINTYG));
            break;
        case SVAR_FRAN_VARDEN:
            Predicate careReplyAmnePred = builder.or(builder.equal(root.<Amne>get("amne"), Amne.OVRIGT), builder.equal(root.<Amne>get("amne"), Amne.ARBETSTIDSFORLAGGNING), builder.equal(root.<Amne>get("amne"), Amne.AVSTAMNINGSMOTE), builder.equal(root.<Amne>get("amne"), Amne.KONTAKT));
            pred = builder.and(pred, builder.equal(root.<Status>get("status"), Status.PENDING_INTERNAL_ACTION), careReplyAmnePred);
            break;
        case SVAR_FRAN_FK:
            pred = builder.and(pred, builder.equal(root.<Status>get("status"), Status.PENDING_EXTERNAL_ACTION), builder.notEqual(root.<Amne>get("amne"), Amne.MAKULERING_AV_LAKARINTYG));
            break;
        case MARKERA_SOM_HANTERAD:
            Predicate amnePred1;
            amnePred1 = builder.and(builder.equal(root.<Status>get("status"), Status.PENDING_INTERNAL_ACTION), builder.equal(root.<Amne>get("amne"), Amne.MAKULERING_AV_LAKARINTYG));
            Predicate amnePred2;
            amnePred2 = builder.and(builder.equal(root.<Status>get("status"), Status.PENDING_INTERNAL_ACTION), builder.equal(root.<Amne>get("amne"), Amne.PAMINNELSE));
            pred = builder.and(pred, builder.or(amnePred1, amnePred2, builder.equal(root.<Status>get("status"), Status.ANSWERED)));
            break;
        case ALLA:
            break;
    }
    return pred;
}
Also used : Status(se.inera.intyg.webcert.persistence.model.Status) Amne(se.inera.intyg.webcert.persistence.fragasvar.model.Amne) Predicate(javax.persistence.criteria.Predicate)

Example 2 with Amne

use of se.inera.intyg.webcert.persistence.fragasvar.model.Amne in project webcert by sklintyg.

the class ArendeListItemConverterTest method testConvertFragaSvarWithoutCorrespondingArendeAmne.

@Test
public void testConvertFragaSvarWithoutCorrespondingArendeAmne() {
    final Amne amne = Amne.ARBETSTIDSFORLAGGNING;
    FragaSvar fs = createFragaSvar("fragestallare", "intygId", "intygTyp", patientId, (long) 13, LocalDateTime.now(), "signeratAv", "enhetsnamn", "vardgivarnamn", amne, false, Status.PENDING_INTERNAL_ACTION);
    ArendeListItem arende = ArendeListItemConverter.convert(fs);
    assertNotNull(arende);
    assertEquals(amne.name(), arende.getAmne());
}
Also used : ArendeListItem(se.inera.intyg.webcert.web.web.controller.api.dto.ArendeListItem) FragaSvar(se.inera.intyg.webcert.persistence.fragasvar.model.FragaSvar) Amne(se.inera.intyg.webcert.persistence.fragasvar.model.Amne) ArendeAmne(se.inera.intyg.webcert.persistence.arende.model.ArendeAmne) Test(org.junit.Test)

Example 3 with Amne

use of se.inera.intyg.webcert.persistence.fragasvar.model.Amne in project webcert by sklintyg.

the class ArendeListItemConverterTest method testConvert.

@Test
public void testConvert() {
    final String fragestallare = "fragestallare";
    final String intygId = "intygId";
    final String intygTyp = "intygTyp";
    final long internReferens = 13;
    final LocalDateTime senasteHandelse = LocalDateTime.now();
    final String signeratAv = "signeratAv";
    final String enhetsnamn = "enhetsnamn";
    final String vardgivarnamn = "vardgivarnamn";
    final Amne amne = Amne.AVSTAMNINGSMOTE;
    final boolean vidarebefordrad = false;
    final Status status = Status.PENDING_INTERNAL_ACTION;
    FragaSvar fs = createFragaSvar(fragestallare, intygId, intygTyp, patientId, internReferens, senasteHandelse, signeratAv, enhetsnamn, vardgivarnamn, amne, vidarebefordrad, status);
    ArendeListItem arende = ArendeListItemConverter.convert(fs);
    assertNotNull(arende);
    assertEquals(fragestallare, arende.getFragestallare());
    assertEquals(intygId, arende.getIntygId());
    assertEquals(intygTyp, arende.getIntygTyp());
    assertEquals(patientId, arende.getPatientId());
    assertEquals(Long.toString(internReferens), arende.getMeddelandeId());
    assertEquals(senasteHandelse, arende.getReceivedDate());
    assertEquals(signeratAv, arende.getSigneratAvNamn());
    assertEquals(enhetsnamn, arende.getEnhetsnamn());
    assertEquals(vardgivarnamn, arende.getVardgivarnamn());
    assertEquals(ArendeAmne.AVSTMN.name(), arende.getAmne());
    assertEquals(vidarebefordrad, arende.isVidarebefordrad());
    assertEquals(status, arende.getStatus());
}
Also used : LocalDateTime(java.time.LocalDateTime) Status(se.inera.intyg.webcert.persistence.model.Status) ArendeListItem(se.inera.intyg.webcert.web.web.controller.api.dto.ArendeListItem) FragaSvar(se.inera.intyg.webcert.persistence.fragasvar.model.FragaSvar) Amne(se.inera.intyg.webcert.persistence.fragasvar.model.Amne) ArendeAmne(se.inera.intyg.webcert.persistence.arende.model.ArendeAmne) Test(org.junit.Test)

Aggregations

Amne (se.inera.intyg.webcert.persistence.fragasvar.model.Amne)3 Test (org.junit.Test)2 ArendeAmne (se.inera.intyg.webcert.persistence.arende.model.ArendeAmne)2 FragaSvar (se.inera.intyg.webcert.persistence.fragasvar.model.FragaSvar)2 Status (se.inera.intyg.webcert.persistence.model.Status)2 ArendeListItem (se.inera.intyg.webcert.web.web.controller.api.dto.ArendeListItem)2 LocalDateTime (java.time.LocalDateTime)1 Predicate (javax.persistence.criteria.Predicate)1