Search in sources :

Example 66 with FragaSvar

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

Example 67 with FragaSvar

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);
}
Also used : ArendeListItem(se.inera.intyg.webcert.web.web.controller.api.dto.ArendeListItem) IntygsReferens(se.inera.intyg.webcert.persistence.fragasvar.model.IntygsReferens) FragaSvar(se.inera.intyg.webcert.persistence.fragasvar.model.FragaSvar) Test(org.junit.Test)

Example 68 with FragaSvar

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);
}
Also used : FragaSvar(se.inera.intyg.webcert.persistence.fragasvar.model.FragaSvar)

Example 69 with 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;
}
Also used : FragaSvar(se.inera.intyg.webcert.persistence.fragasvar.model.FragaSvar) NotificationEvent(se.inera.intyg.webcert.web.service.notification.NotificationEvent) WebCertServiceException(se.inera.intyg.webcert.common.service.exception.WebCertServiceException)

Example 70 with FragaSvar

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;
}
Also used : FragaSvar(se.inera.intyg.webcert.persistence.fragasvar.model.FragaSvar) NotificationEvent(se.inera.intyg.webcert.web.service.notification.NotificationEvent)

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