use of se.inera.intyg.webcert.persistence.fragasvar.model.FragaSvar 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());
}
use of se.inera.intyg.webcert.persistence.fragasvar.model.FragaSvar in project webcert by sklintyg.
the class ArendeListItemConverterTest method testConvertEmptyVardperson.
@Test
public void testConvertEmptyVardperson() {
FragaSvar fs = new FragaSvar();
fs.setIntygsReferens(new IntygsReferens());
ArendeListItem arende = ArendeListItemConverter.convert(fs);
assertNull(arende);
}
use of se.inera.intyg.webcert.persistence.fragasvar.model.FragaSvar in project webcert by sklintyg.
the class FragaSvarServiceImpl method processIncomingAnswer.
@Override
public FragaSvar processIncomingAnswer(Long internId, String svarsText, LocalDateTime svarSigneringsDatum) {
// lookup question in database
FragaSvar fragaSvar = fragaSvarRepository.findOne(internId);
if (fragaSvar == null) {
throw new IllegalStateException("No question found with internal ID " + internId);
}
if (FrageStallare.FORSAKRINGSKASSAN.isKodEqual(fragaSvar.getFrageStallare())) {
throw new IllegalStateException("Incoming answer refers to question initiated by Försäkringskassan.");
}
fragaSvar.setSvarsText(svarsText);
fragaSvar.setSvarSigneringsDatum(svarSigneringsDatum);
fragaSvar.setSvarSkickadDatum(LocalDateTime.now());
fragaSvar.setStatus(Status.ANSWERED);
monitoringService.logAnswerReceived(fragaSvar.getExternReferens(), fragaSvar.getInternReferens(), ((fragaSvar.getIntygsReferens() == null) ? null : fragaSvar.getIntygsReferens().getIntygsId()), fragaSvar.getVardAktorHsaId(), fragaSvar.getAmne());
// update the FragaSvar
return fragaSvarRepository.save(fragaSvar);
}
use of se.inera.intyg.webcert.persistence.fragasvar.model.FragaSvar in project webcert by sklintyg.
the class FragaSvarServiceImpl method openQuestionAsUnhandled.
@Override
public FragaSvar openQuestionAsUnhandled(Long frageSvarId) {
FragaSvar fragaSvar = lookupFragaSvar(frageSvarId);
// Enforce business rule FS-011, from FK + answer should remain closed
if (!FrageStallare.WEBCERT.isKodEqual(fragaSvar.getFrageStallare()) && !Strings.isNullOrEmpty(fragaSvar.getSvarsText())) {
throw new WebCertServiceException(WebCertServiceErrorCodeEnum.INVALID_STATE, "FS-011: Cant revert status for question " + frageSvarId);
}
NotificationEvent notificationEvent = determineNotificationEvent(fragaSvar);
if (!Strings.isNullOrEmpty(fragaSvar.getSvarsText())) {
fragaSvar.setStatus(Status.ANSWERED);
} else {
if (FrageStallare.WEBCERT.isKodEqual(fragaSvar.getFrageStallare())) {
fragaSvar.setStatus(Status.PENDING_EXTERNAL_ACTION);
} else {
fragaSvar.setStatus(Status.PENDING_INTERNAL_ACTION);
}
}
FragaSvar openedFragaSvar = fragaSvarRepository.save(fragaSvar);
sendNotification(openedFragaSvar, notificationEvent);
return openedFragaSvar;
}
use of se.inera.intyg.webcert.persistence.fragasvar.model.FragaSvar in project webcert by sklintyg.
the class FragaSvarServiceImpl method closeQuestionAsHandled.
private FragaSvar closeQuestionAsHandled(FragaSvar fragaSvar) {
NotificationEvent notificationEvent = determineNotificationEvent(fragaSvar);
fragaSvar.setStatus(Status.CLOSED);
FragaSvar closedFragaSvar = fragaSvarRepository.save(fragaSvar);
sendNotification(closedFragaSvar, notificationEvent);
if (!fragaSvar.getFrageStallare().equals(FrageStallare.WEBCERT.getKod())) {
arendeDraftService.delete(fragaSvar.getIntygsReferens().getIntygsId(), Long.toString(fragaSvar.getInternReferens()));
}
return closedFragaSvar;
}
Aggregations