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();
}
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);
}
}
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();
}
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();
}
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;
}
Aggregations