Search in sources :

Example 41 with FragaSvar

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

the class FragaSvarResource method insertFragaSvar.

@POST
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
public Response insertFragaSvar(FragaSvar fragaSvar) {
    FragaSvar saved = fragasvarRepository.save(fragaSvar);
    LOG.info("Created FragaSvar with id {} using testability API", saved.getInternReferens());
    return Response.ok(saved).build();
}
Also used : FragaSvar(se.inera.intyg.webcert.persistence.fragasvar.model.FragaSvar) POST(javax.ws.rs.POST) Consumes(javax.ws.rs.Consumes) Produces(javax.ws.rs.Produces)

Example 42 with FragaSvar

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

the class FragaSvarResource method answer.

@PUT
@Path("/svara/{vardgivare}/{enhet}/{id}")
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON + ";charset=utf-8")
public Response answer(@PathParam("vardgivare") final String vardgivarId, @PathParam("enhet") final String enhetsId, @PathParam("id") final Long frageSvarId, String svarsText) {
    SecurityContext originalContext = SecurityContextHolder.getContext();
    SecurityContextHolder.setContext(getSecurityContext(vardgivarId, enhetsId));
    try {
        FragaSvar fragaSvarResponse = fragaSvarService.saveSvar(frageSvarId, svarsText);
        return Response.ok(fragaSvarResponse).build();
    } finally {
        SecurityContextHolder.setContext(originalContext);
    }
}
Also used : SecurityContext(org.springframework.security.core.context.SecurityContext) FragaSvar(se.inera.intyg.webcert.persistence.fragasvar.model.FragaSvar) Path(javax.ws.rs.Path) Consumes(javax.ws.rs.Consumes) Produces(javax.ws.rs.Produces) PUT(javax.ws.rs.PUT)

Example 43 with FragaSvar

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

the class FragaSvarRepositoryImpl method filterFragaSvar.

@Override
public List<FragaSvar> filterFragaSvar(Filter filter) {
    CriteriaBuilder builder = entityManager.getCriteriaBuilder();
    CriteriaQuery<FragaSvar> cq = builder.createQuery(FragaSvar.class);
    Root<FragaSvar> root = cq.from(FragaSvar.class);
    cq.where(createPredicate(filter, builder, root));
    cq.orderBy(builder.desc(root.get("senasteHandelse")));
    TypedQuery<FragaSvar> query = entityManager.createQuery(cq);
    if (filter.hasPageSizeAndStartFrom()) {
        query.setMaxResults(filter.getPageSize());
        query.setFirstResult(filter.getStartFrom());
    }
    return query.getResultList();
}
Also used : CriteriaBuilder(javax.persistence.criteria.CriteriaBuilder) FragaSvar(se.inera.intyg.webcert.persistence.fragasvar.model.FragaSvar)

Example 44 with FragaSvar

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

the class FragaSvarRepositoryImpl method filterCountFragaSvar.

@Override
public int filterCountFragaSvar(Filter filter) {
    CriteriaBuilder cb = entityManager.getCriteriaBuilder();
    CriteriaQuery<Long> cq = cb.createQuery(Long.class);
    Root<FragaSvar> root = cq.from(FragaSvar.class);
    cq.select(cb.count(root));
    cq.where(createPredicate(filter, cb, root));
    Query query = entityManager.createQuery(cq);
    return ((Long) query.getSingleResult()).intValue();
}
Also used : CriteriaBuilder(javax.persistence.criteria.CriteriaBuilder) CriteriaQuery(javax.persistence.criteria.CriteriaQuery) TypedQuery(javax.persistence.TypedQuery) Query(javax.persistence.Query) FragaSvar(se.inera.intyg.webcert.persistence.fragasvar.model.FragaSvar)

Example 45 with FragaSvar

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

the class FragaSvarServiceImplTest method buildFraga.

private FragaSvar buildFraga(Long id, String frageText, Amne amne, LocalDateTime fragaSkickadDatum) {
    FragaSvar f = new FragaSvar();
    f.setStatus(Status.PENDING_INTERNAL_ACTION);
    f.setAmne(amne);
    f.setExternReferens("<fk-extern-referens>");
    f.setInternReferens(id);
    f.setFrageSkickadDatum(fragaSkickadDatum);
    f.setFrageText(frageText);
    f.setVardAktorHsaId("vardaktor-hsa-id");
    IntygsReferens intygsReferens = new IntygsReferens();
    intygsReferens.setIntygsId(INTYG_ID);
    intygsReferens.setIntygsTyp("fk7263");
    intygsReferens.setPatientId(PNR);
    f.setIntygsReferens(intygsReferens);
    f.setKompletteringar(new HashSet<>());
    f.setVardperson(new Vardperson());
    f.getVardperson().setEnhetsId("enhet");
    return f;
}
Also used : Vardperson(se.inera.intyg.webcert.persistence.fragasvar.model.Vardperson) IntygsReferens(se.inera.intyg.webcert.persistence.fragasvar.model.IntygsReferens) FragaSvar(se.inera.intyg.webcert.persistence.fragasvar.model.FragaSvar)

Aggregations

FragaSvar (se.inera.intyg.webcert.persistence.fragasvar.model.FragaSvar)71 Test (org.junit.Test)42 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)14 IntygsReferens (se.inera.intyg.webcert.persistence.fragasvar.model.IntygsReferens)11 Vardperson (se.inera.intyg.webcert.persistence.fragasvar.model.Vardperson)11 Produces (javax.ws.rs.Produces)7 AttributedURIType (org.w3.wsaddressing10.AttributedURIType)7 Path (javax.ws.rs.Path)6 Filter (se.inera.intyg.webcert.persistence.model.Filter)6 LocalDateTime (java.time.LocalDateTime)5 Consumes (javax.ws.rs.Consumes)5 WebCertUser (se.inera.intyg.webcert.web.service.user.dto.WebCertUser)5 ArendeListItem (se.inera.intyg.webcert.web.web.controller.api.dto.ArendeListItem)5 ArrayList (java.util.ArrayList)4 SOAPFaultException (javax.xml.ws.soap.SOAPFaultException)4 SendMedicalCertificateAnswerResponseType (se.inera.ifv.insuranceprocess.healthreporting.sendmedicalcertificateanswerresponder.v1.SendMedicalCertificateAnswerResponseType)4 SendMedicalCertificateAnswerType (se.inera.ifv.insuranceprocess.healthreporting.sendmedicalcertificateanswerresponder.v1.SendMedicalCertificateAnswerType)4 SendMedicalCertificateQuestionType (se.inera.ifv.insuranceprocess.healthreporting.sendmedicalcertificatequestionresponder.v1.SendMedicalCertificateQuestionType)4 WebCertServiceException (se.inera.intyg.webcert.common.service.exception.WebCertServiceException)4 Amne (se.inera.intyg.webcert.persistence.fragasvar.model.Amne)4