use of se.inera.intyg.webcert.persistence.fragasvar.model.FragaSvar in project webcert by sklintyg.
the class FragaSvarServiceImpl method getFragaSvar.
@Override
@Transactional(value = "jpaTransactionManager", readOnly = true)
public List<FragaSvarView> getFragaSvar(String intygId) {
List<FragaSvar> fragaSvarList = fragaSvarRepository.findByIntygsReferensIntygsId(intygId);
WebCertUser user = webCertUserService.getUser();
validateSekretessmarkering(intygId, fragaSvarList, user);
List<String> hsaEnhetIds = user.getIdsOfSelectedVardenhet();
// Filter questions to that current user only sees questions issued to
// units with active employment role
fragaSvarList.removeIf(fragaSvar -> fragaSvar.getVardperson() != null && !hsaEnhetIds.contains(fragaSvar.getVardperson().getEnhetsId()));
// Finally sort by senasteHandelseDatum
// We do the sorting in code, since we need to sort on a derived
// property and not a direct entity persisted
// property in which case we could have used an order by in the query.
fragaSvarList.sort(SENASTE_HANDELSE_DATUM_COMPARATOR);
List<ArendeDraft> drafts = arendeDraftService.listAnswerDrafts(intygId);
List<AnsweredWithIntyg> bmi = AnsweredWithIntygUtil.findAllKomplementForGivenIntyg(intygId, utkastRepository);
List<FragaSvarView> fragaSvarWithBesvaratMedIntygInfo = fragaSvarList.stream().map(fs -> FragaSvarView.create(fs, fs.getFrageSkickadDatum() == null ? null : AnsweredWithIntygUtil.returnOldestKompltOlderThan(fs.getFrageSkickadDatum(), bmi), drafts.stream().filter(d -> Long.toString(fs.getInternReferens()).equals(d.getQuestionId())).findAny().map(ArendeDraft::getText).orElse(null))).collect(Collectors.toList());
return fragaSvarWithBesvaratMedIntygInfo;
}
use of se.inera.intyg.webcert.persistence.fragasvar.model.FragaSvar in project webcert by sklintyg.
the class ReceiveQuestionResponderImpl method receiveMedicalCertificateQuestion.
@Override
public ReceiveMedicalCertificateQuestionResponseType receiveMedicalCertificateQuestion(AttributedURIType logicalAddress, ReceiveMedicalCertificateQuestionType request) {
ReceiveMedicalCertificateQuestionResponseType response = new ReceiveMedicalCertificateQuestionResponseType();
// Validate incoming request
List<String> validationMessages = QuestionAnswerValidator.validate(request);
if (!validationMessages.isEmpty()) {
response.setResult(ResultOfCallUtil.failResult(Joiner.on(",").join(validationMessages)));
return response;
}
// Transform to a FragaSvar object
FragaSvar fragaSvar = converter.convert(request.getQuestion());
// Notify stakeholders
sendNotification(processQuestion(fragaSvar));
// Set result and send response back to caller
response.setResult(ResultOfCallUtil.okResult());
return response;
}
use of se.inera.intyg.webcert.persistence.fragasvar.model.FragaSvar in project webcert by sklintyg.
the class UtkastBootstrapBean method createFragaSvar.
private FragaSvar createFragaSvar(Utlatande utlatande, FrageStallare fragestallare, boolean komplettering, boolean paminnelse) {
FragaSvar fs = new FragaSvar();
fs.setFrageSigneringsDatum(LocalDateTime.now());
fs.setFrageSkickadDatum(LocalDateTime.now());
if (fragestallare.equals(FrageStallare.FORSAKRINGSKASSAN)) {
fs.setStatus(Status.PENDING_INTERNAL_ACTION);
fs.setExternaKontakter(new HashSet<>(Arrays.asList("Testperson1 FK", "Testperson2 FK")));
fs.setExternReferens("Extern referens");
fs.setSistaDatumForSvar(LocalDate.now().plusWeeks(2));
} else {
fs.setStatus(Status.PENDING_EXTERNAL_ACTION);
}
fs.setFrageStallare(fragestallare.getKod());
fs.setFrageText("Detta är frågan");
fs.setIntygsReferens(new IntygsReferens(utlatande.getId(), utlatande.getTyp(), utlatande.getGrundData().getPatient().getPersonId(), null, utlatande.getGrundData().getSigneringsdatum()));
if (komplettering) {
fs.setAmne(Amne.KOMPLETTERING_AV_LAKARINTYG);
Komplettering kompl1 = new Komplettering();
kompl1.setFalt("fält");
kompl1.setText("kompletteringstext");
fs.setKompletteringar(new HashSet<>(Arrays.asList(kompl1)));
} else if (paminnelse) {
fs.setAmne(Amne.PAMINNELSE);
} else {
fs.setAmne(fsAmnen.get(rand.nextInt(fsAmnen.size())));
}
fs.setMeddelandeRubrik("Rubrik");
fs.setVardAktorHsaId(utlatande.getGrundData().getSkapadAv().getPersonId());
fs.setVardAktorNamn(utlatande.getGrundData().getSkapadAv().getFullstandigtNamn());
fs.setVardperson(FragaSvarConverter.convert(utlatande.getGrundData().getSkapadAv()));
fs.setVidarebefordrad(false);
return fs;
}
use of se.inera.intyg.webcert.persistence.fragasvar.model.FragaSvar in project webcert by sklintyg.
the class FragaSvarModuleApiControllerTest method buildFragaSvarViewList.
private List<FragaSvarView> buildFragaSvarViewList() {
List<FragaSvarView> fragaSvarViewList = new ArrayList<>();
IntygsReferens intygsReferens = mock(IntygsReferens.class);
FragaSvar fs = mock(FragaSvar.class);
FragaSvarView fsw = mock(FragaSvarView.class);
fragaSvarViewList.add(fsw);
return fragaSvarViewList;
}
use of se.inera.intyg.webcert.persistence.fragasvar.model.FragaSvar in project webcert by sklintyg.
the class FragaSvarRepositoryTest method buildFragaSvarFraga.
private FragaSvar buildFragaSvarFraga(String enhetsId, Status status, String hsaid, String hsaNamn) {
FragaSvar f = new FragaSvar();
f.setExternaKontakter(new HashSet<>(Arrays.asList("KONTAKT1", "KONTAKT2", "KONTAKT3")));
f.setAmne(Amne.AVSTAMNINGSMOTE);
f.setExternReferens("externReferens");
f.setFrageSigneringsDatum(FRAGA_SIGN_DATE);
f.setFrageSkickadDatum(FRAGA_SENT_DATE);
f.setFrageStallare("Olle");
Vardperson vardperson = new Vardperson();
vardperson.setEnhetsId(enhetsId);
vardperson.setEnhetsnamn(enhetsId + "-namnet");
vardperson.setHsaId(hsaid);
vardperson.setNamn(hsaNamn);
f.setVardperson(vardperson);
f.setFrageText("Detta var ju otydligt formulerat!");
f.setIntygsReferens(INTYGS_REFERENS);
f.setStatus(status);
return f;
}
Aggregations