Search in sources :

Example 1 with IntygsReferens

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

the class ReceiveMedicalCertificateAnswerIT method createQuestion.

private int createQuestion(String typ, String intygId, String personnummer) {
    LocalDateTime now = LocalDateTime.now();
    FragaSvar fs = new FragaSvar();
    fs.setAmne(Amne.ARBETSTIDSFORLAGGNING);
    fs.setFrageText("Frågetext");
    fs.setIntygsReferens(new IntygsReferens(intygId, typ, Personnummer.createPersonnummer(personnummer).get(), "Api Restman", now));
    fs.setStatus(Status.PENDING_INTERNAL_ACTION);
    fs.setFrageSkickadDatum(now);
    fs.setMeddelandeRubrik("Meddelanderubrik");
    fs.setFrageStallare(FrageStallare.WEBCERT.getKod());
    fs.setFrageSigneringsDatum(now);
    fs.setVardAktorNamn("Vardaktor");
    fs.setVardAktorHsaId("Test-hsa-id");
    fs.setExternReferens("FK-REF-1");
    Vardperson vardperson = new Vardperson();
    vardperson.setEnhetsId("IFV1239877878-1042");
    vardperson.setArbetsplatsKod("0000000");
    vardperson.setEnhetsnamn("blub");
    vardperson.setHsaId("IFV1239877878-1049");
    vardperson.setVardgivarId("TESTVG");
    vardperson.setVardgivarnamn("VG TEST SYD");
    vardperson.setNamn("Hr Doktor");
    fs.setVardperson(vardperson);
    Response response = given().log().all().contentType(ContentType.JSON).body(fs).expect().statusCode(200).when().post("testability/fragasvar").then().extract().response();
    JsonPath model = new JsonPath(response.body().asString());
    return model.get("internReferens");
}
Also used : LocalDateTime(java.time.LocalDateTime) Vardperson(se.inera.intyg.webcert.persistence.fragasvar.model.Vardperson) Response(com.jayway.restassured.response.Response) IntygsReferens(se.inera.intyg.webcert.persistence.fragasvar.model.IntygsReferens) FragaSvar(se.inera.intyg.webcert.persistence.fragasvar.model.FragaSvar) JsonPath(com.jayway.restassured.path.json.JsonPath)

Example 2 with IntygsReferens

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

the class ArendeListItemConverterTest method createFragaSvar.

private FragaSvar createFragaSvar(String fragestallare, String intygsId, String intygsTyp, String patientId, Long internReferens, LocalDateTime senasteHandelse, String signeratAv, String enhetsnamn, String vardgivarnamn, Amne amne, Boolean vidarebefordrad, Status status) {
    FragaSvar res = new FragaSvar();
    res.setFrageStallare(fragestallare);
    res.setIntygsReferens(new IntygsReferens(intygsId, intygsTyp, Personnummer.createPersonnummer(patientId).get(), null, null));
    res.setInternReferens(internReferens);
    res.setFrageSkickadDatum(senasteHandelse);
    Vardperson vp = new Vardperson();
    vp.setNamn(signeratAv);
    vp.setEnhetsnamn(enhetsnamn);
    vp.setVardgivarnamn(vardgivarnamn);
    res.setVardperson(vp);
    res.setAmne(amne);
    res.setVidarebefordrad(vidarebefordrad);
    res.setStatus(status);
    return res;
}
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)

Example 3 with IntygsReferens

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

the class NotificationServiceImplTest method createFragaSvar.

private FragaSvar createFragaSvar() {
    FragaSvar fs = new FragaSvar();
    fs.setAmne(Amne.OVRIGT);
    fs.setSistaDatumForSvar(LocalDate.of(2018, 12, 12));
    fs.setInternReferens(FRAGASVAR_ID);
    fs.setIntygsReferens(new IntygsReferens());
    fs.getIntygsReferens().setIntygsId(INTYG_ID);
    fs.getIntygsReferens().setIntygsTyp(INTYG_TYP_FK);
    fs.setVardperson(new Vardperson());
    fs.getVardperson().setEnhetsId(ENHET_ID);
    fs.getVardperson().setEnhetsnamn(ENHET_NAMN);
    fs.getVardperson().setHsaId(SIGNED_BY_HSA_ID);
    return fs;
}
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)

Example 4 with IntygsReferens

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

the class FragaSvarServiceImpl method saveNewQuestion.

@Override
public FragaSvar saveNewQuestion(String intygId, String typ, Amne amne, String frageText) {
    // Argument check
    if (Strings.isNullOrEmpty(frageText)) {
        throw new WebCertServiceException(WebCertServiceErrorCodeEnum.INTERNAL_PROBLEM, "frageText cannot be empty!");
    }
    if (amne == null) {
        throw new WebCertServiceException(WebCertServiceErrorCodeEnum.INTERNAL_PROBLEM, "Amne cannot be null!");
    } else if (!VALID_VARD_AMNEN.contains(amne)) {
        // Businessrule RE-013
        throw new WebCertServiceException(WebCertServiceErrorCodeEnum.INTERNAL_PROBLEM, "Invalid Amne " + amne + " for new question from vard!");
    }
    // Fetch from Intygstjansten. Note that if Intygstjansten is unresponsive, the Intyg will be loaded from WebCert
    // if possible.
    IntygContentHolder intyg = intygService.fetchIntygData(intygId, typ, false);
    WebCertUser user = webCertUserService.getUser();
    // Get vardperson that posed the question
    // Is user authorized to save an answer to this question?
    verifyEnhetsAuth(intyg.getUtlatande().getGrundData().getSkapadAv().getVardenhet().getEnhetsid(), false);
    // Verksamhetsregel FS-001 (Is the certificate sent to FK)
    if (!isCertificateSentToFK(intyg.getStatuses())) {
        throw new WebCertServiceException(WebCertServiceErrorCodeEnum.INTERNAL_PROBLEM, "FS-001: Certificate must be sent to FK first before sending question!");
    }
    // Verify that certificate is not revoked
    if (intyg.isRevoked()) {
        throw new WebCertServiceException(WebCertServiceErrorCodeEnum.INTERNAL_PROBLEM, "FS-XXX: Cannot save Fraga when certificate is revoked!");
    }
    IntygsReferens intygsReferens = FragaSvarConverter.convertToIntygsReferens(intyg.getUtlatande());
    HoSPersonal hoSPersonal = IntygConverterUtil.buildHosPersonalFromWebCertUser(user, null);
    Vardperson vardPerson = FragaSvarConverter.convert(hoSPersonal);
    FragaSvar fraga = new FragaSvar();
    fraga.setFrageStallare(FrageStallare.WEBCERT.getKod());
    fraga.setAmne(amne);
    fraga.setFrageText(frageText);
    LocalDateTime now = LocalDateTime.now();
    fraga.setFrageSkickadDatum(now);
    fraga.setFrageSigneringsDatum(now);
    fraga.setIntygsReferens(intygsReferens);
    fraga.setVardperson(vardPerson);
    fraga.setStatus(Status.PENDING_EXTERNAL_ACTION);
    fraga.setVardAktorHsaId(user.getHsaId());
    fraga.setVardAktorNamn(user.getNamn());
    // Ok, lets save the question
    FragaSvar saved = fragaSvarRepository.save(fraga);
    // Send to external party (FK)
    SendMedicalCertificateQuestionType sendType = new SendMedicalCertificateQuestionType();
    QuestionToFkType question = FKQuestionConverter.convert(saved);
    // Remove ASAP.
    if ("true".equalsIgnoreCase(forceFullstandigtNamn)) {
        question.getLakarutlatande().getPatient().setFullstandigtNamn("---");
    }
    sendType.setQuestion(question);
    AttributedURIType logicalAddress = new AttributedURIType();
    logicalAddress.setValue(sendQuestionToFkLogicalAddress);
    SendMedicalCertificateQuestionResponseType response;
    try {
        response = sendQuestionToFKClient.sendMedicalCertificateQuestion(logicalAddress, sendType);
    } catch (SOAPFaultException e) {
        LOGGER.error("Failed to send question to FK, error was: " + e.getMessage());
        throw new WebCertServiceException(WebCertServiceErrorCodeEnum.EXTERNAL_SYSTEM_PROBLEM, e.getMessage());
    }
    if (!response.getResult().getResultCode().equals(ResultCodeEnum.OK)) {
        LOGGER.error("Failed to send question to FK, result was " + response.getResult().toString());
        throw new WebCertServiceException(WebCertServiceErrorCodeEnum.EXTERNAL_SYSTEM_PROBLEM, response.getResult().getErrorText());
    }
    monitoringService.logQuestionSent(saved.getExternReferens(), saved.getInternReferens(), (saved.getIntygsReferens() == null) ? null : saved.getIntygsReferens().getIntygsId(), saved.getVardAktorHsaId(), saved.getAmne());
    // Notify stakeholders
    sendNotification(saved, NotificationEvent.NEW_QUESTION_FROM_CARE);
    arendeDraftService.delete(intygId, null);
    return saved;
}
Also used : Vardperson(se.inera.intyg.webcert.persistence.fragasvar.model.Vardperson) LocalDateTime(java.time.LocalDateTime) AttributedURIType(org.w3.wsaddressing10.AttributedURIType) SOAPFaultException(javax.xml.ws.soap.SOAPFaultException) QuestionToFkType(se.inera.ifv.insuranceprocess.healthreporting.sendmedicalcertificatequestionresponder.v1.QuestionToFkType) WebCertServiceException(se.inera.intyg.webcert.common.service.exception.WebCertServiceException) HoSPersonal(se.inera.intyg.common.support.model.common.internal.HoSPersonal) IntygContentHolder(se.inera.intyg.webcert.web.service.intyg.dto.IntygContentHolder) IntygsReferens(se.inera.intyg.webcert.persistence.fragasvar.model.IntygsReferens) FragaSvar(se.inera.intyg.webcert.persistence.fragasvar.model.FragaSvar) SendMedicalCertificateQuestionType(se.inera.ifv.insuranceprocess.healthreporting.sendmedicalcertificatequestionresponder.v1.SendMedicalCertificateQuestionType) SendMedicalCertificateQuestionResponseType(se.inera.ifv.insuranceprocess.healthreporting.sendmedicalcertificatequestionresponder.v1.SendMedicalCertificateQuestionResponseType) WebCertUser(se.inera.intyg.webcert.web.service.user.dto.WebCertUser)

Example 5 with IntygsReferens

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

Aggregations

IntygsReferens (se.inera.intyg.webcert.persistence.fragasvar.model.IntygsReferens)12 FragaSvar (se.inera.intyg.webcert.persistence.fragasvar.model.FragaSvar)10 Vardperson (se.inera.intyg.webcert.persistence.fragasvar.model.Vardperson)6 LocalDateTime (java.time.LocalDateTime)4 Test (org.junit.Test)4 LakarutlatandeEnkelType (se.inera.ifv.insuranceprocess.healthreporting.medcertqa.v1.LakarutlatandeEnkelType)2 JsonPath (com.jayway.restassured.path.json.JsonPath)1 Response (com.jayway.restassured.response.Response)1 ArrayList (java.util.ArrayList)1 SOAPFaultException (javax.xml.ws.soap.SOAPFaultException)1 AttributedURIType (org.w3.wsaddressing10.AttributedURIType)1 QuestionToFkType (se.inera.ifv.insuranceprocess.healthreporting.sendmedicalcertificatequestionresponder.v1.QuestionToFkType)1 SendMedicalCertificateQuestionResponseType (se.inera.ifv.insuranceprocess.healthreporting.sendmedicalcertificatequestionresponder.v1.SendMedicalCertificateQuestionResponseType)1 SendMedicalCertificateQuestionType (se.inera.ifv.insuranceprocess.healthreporting.sendmedicalcertificatequestionresponder.v1.SendMedicalCertificateQuestionType)1 HoSPersonal (se.inera.intyg.common.support.model.common.internal.HoSPersonal)1 WebCertServiceException (se.inera.intyg.webcert.common.service.exception.WebCertServiceException)1 Komplettering (se.inera.intyg.webcert.persistence.fragasvar.model.Komplettering)1 IntygContentHolder (se.inera.intyg.webcert.web.service.intyg.dto.IntygContentHolder)1 WebCertUser (se.inera.intyg.webcert.web.service.user.dto.WebCertUser)1 ArendeListItem (se.inera.intyg.webcert.web.web.controller.api.dto.ArendeListItem)1