Search in sources :

Example 1 with ArendeAmne

use of se.inera.intyg.webcert.persistence.arende.model.ArendeAmne in project webcert by sklintyg.

the class ArendeConverterTest method testCreateArendeAnswerFromQuestion.

@Test
public void testCreateArendeAnswerFromQuestion() throws CertificateSenderException {
    final String nyttMeddelande = "nytt meddelande";
    final String meddelandeId = "meddelandeId";
    final ArendeAmne amne = ArendeAmne.KONTKT;
    final String enhetsId = "enhetsId";
    final String intygsId = "intygsId";
    final String intygsTyp = "luse";
    final String meddelande = "meddelande";
    final String patientPersonId = "191212121212";
    final String rubrik = "rubrik";
    final String signeratAv = "hsa123";
    final String signeratAvName = "givenname surname";
    final String referensId = "referensId";
    final String vardaktorName = "vardaktor namn";
    final String enhetName = "enhet namn";
    final String vardgivareName = "vardgivare namn";
    final LocalDateTime now = LocalDateTime.now();
    Arende arende = new Arende();
    arende.setMeddelandeId(meddelandeId);
    arende.setEnhetId(enhetsId);
    arende.setEnhetName(enhetName);
    arende.setVardgivareName(vardgivareName);
    arende.setIntygsId(intygsId);
    arende.setIntygTyp(intygsTyp);
    arende.setPatientPersonId(patientPersonId);
    arende.setSigneratAv(signeratAv);
    arende.setSigneratAvName(signeratAvName);
    arende.setRubrik(rubrik);
    arende.setMeddelande(meddelande);
    arende.setAmne(amne);
    arende.setReferensId(referensId);
    arende.setStatus(Status.PENDING_INTERNAL_ACTION);
    Arende res = ArendeConverter.createAnswerFromArende(nyttMeddelande, arende, now, vardaktorName);
    assertNotNull(res);
    assertEquals(amne, res.getAmne());
    assertEquals(enhetsId, res.getEnhetId());
    assertEquals(enhetName, res.getEnhetName());
    assertEquals(vardgivareName, res.getVardgivareName());
    assertEquals(intygsId, res.getIntygsId());
    assertEquals(intygsTyp, res.getIntygTyp());
    assertEquals(nyttMeddelande, res.getMeddelande());
    assertNotNull(res.getMeddelandeId());
    assertNull(res.getPaminnelseMeddelandeId());
    assertEquals(patientPersonId, res.getPatientPersonId());
    assertNull(res.getReferensId());
    assertEquals(rubrik, res.getRubrik());
    assertEquals(now, res.getSenasteHandelse());
    assertEquals(now, res.getSkickatTidpunkt());
    assertEquals(now, res.getTimestamp());
    assertEquals(signeratAv, res.getSigneratAv());
    assertEquals(signeratAvName, res.getSigneratAvName());
    assertNull(res.getSistaDatumForSvar());
    assertEquals(FrageStallare.WEBCERT.getKod(), res.getSkickatAv());
    assertEquals(Status.CLOSED, res.getStatus());
    assertEquals(meddelandeId, res.getSvarPaId());
    assertEquals(referensId, res.getSvarPaReferens());
    assertEquals(Boolean.FALSE, res.getVidarebefordrad());
    assertNotEquals(meddelandeId, res.getMeddelandeId());
    assertEquals(vardaktorName, res.getVardaktorName());
}
Also used : LocalDateTime(java.time.LocalDateTime) ArendeAmne(se.inera.intyg.webcert.persistence.arende.model.ArendeAmne) Arende(se.inera.intyg.webcert.persistence.arende.model.Arende) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) Test(org.junit.Test)

Example 2 with ArendeAmne

use of se.inera.intyg.webcert.persistence.arende.model.ArendeAmne in project webcert by sklintyg.

the class ArendeConverterTest method testCreateArendeQuestionFromUtkast.

@Test
public void testCreateArendeQuestionFromUtkast() throws CertificateSenderException {
    final ArendeAmne amne = ArendeAmne.OVRIGT;
    final String enhetsId = "enhetsId";
    final String intygsId = "intygsId";
    final String intygsTyp = "luse";
    final String meddelande = "meddelande";
    final String patientPersonId = "191212121212";
    final String rubrik = "rubrik";
    final String signeratAv = "hsa123";
    final String givenName = "givenname";
    final String surname = "surname";
    final String vardaktorName = "vardaktor namn";
    final String enhetName = "enhet namn";
    final String vardgivareName = "vardgivare namn";
    final LocalDateTime now = LocalDateTime.now();
    Utkast utkast = new Utkast();
    utkast.setEnhetsId(enhetsId);
    utkast.setEnhetsNamn(enhetName);
    utkast.setVardgivarNamn(vardgivareName);
    utkast.setIntygsId(intygsId);
    utkast.setIntygsTyp(intygsTyp);
    utkast.setPatientPersonnummer(Personnummer.createPersonnummer(patientPersonId).get());
    utkast.setSignatur(mock(Signatur.class));
    when(utkast.getSignatur().getSigneradAv()).thenReturn(signeratAv);
    when(hsaEmployeeService.getEmployee(signeratAv, null)).thenReturn(createHsaResponse(givenName, surname));
    Arende res = ArendeConverter.createArendeFromUtkast(amne, rubrik, meddelande, utkast, now, vardaktorName, hsaEmployeeService);
    assertNotNull(res);
    assertEquals(amne, res.getAmne());
    assertEquals(enhetsId, res.getEnhetId());
    assertEquals(enhetName, res.getEnhetName());
    assertEquals(vardgivareName, res.getVardgivareName());
    assertEquals(intygsId, res.getIntygsId());
    assertEquals(intygsTyp, res.getIntygTyp());
    assertEquals(meddelande, res.getMeddelande());
    assertNotNull(res.getMeddelandeId());
    assertNull(res.getPaminnelseMeddelandeId());
    assertEquals(patientPersonId, res.getPatientPersonId());
    assertNull(res.getReferensId());
    assertEquals(rubrik, res.getRubrik());
    assertEquals(now, res.getSenasteHandelse());
    assertEquals(now, res.getSkickatTidpunkt());
    assertEquals(now, res.getTimestamp());
    assertEquals(signeratAv, res.getSigneratAv());
    assertEquals(givenName + " " + surname, res.getSigneratAvName());
    assertNull(res.getSistaDatumForSvar());
    assertEquals(FrageStallare.WEBCERT.getKod(), res.getSkickatAv());
    assertEquals(Status.PENDING_EXTERNAL_ACTION, res.getStatus());
    assertNull(res.getSvarPaId());
    assertNull(res.getSvarPaReferens());
    assertEquals(Boolean.FALSE, res.getVidarebefordrad());
    assertEquals(vardaktorName, res.getVardaktorName());
}
Also used : LocalDateTime(java.time.LocalDateTime) Signatur(se.inera.intyg.webcert.persistence.utkast.model.Signatur) Utkast(se.inera.intyg.webcert.persistence.utkast.model.Utkast) ArendeAmne(se.inera.intyg.webcert.persistence.arende.model.ArendeAmne) Arende(se.inera.intyg.webcert.persistence.arende.model.Arende) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) Test(org.junit.Test)

Example 3 with ArendeAmne

use of se.inera.intyg.webcert.persistence.arende.model.ArendeAmne in project webcert by sklintyg.

the class UtkastBootstrapBean method setupArende.

private void setupArende(Utlatande utlatande, boolean komplettering, boolean paminnelse, FrageStallare fragestallare) {
    ArendeAmne amne;
    if (komplettering) {
        amne = ArendeAmne.KOMPLT;
    } else {
        amne = arendeAmnen.get(rand.nextInt(arendeAmnen.size()));
    }
    String meddelandeId = createArende(utlatande, komplettering, null, fragestallare, amne);
    if (paminnelse) {
        createArende(utlatande, false, meddelandeId, fragestallare, ArendeAmne.PAMINN);
    }
}
Also used : ArendeAmne(se.inera.intyg.webcert.persistence.arende.model.ArendeAmne)

Example 4 with ArendeAmne

use of se.inera.intyg.webcert.persistence.arende.model.ArendeAmne in project webcert by sklintyg.

the class ArendeListItemConverter method convert.

public static ArendeListItem convert(FragaSvar fragaSvar) {
    if (fragaSvar.getIntygsReferens() == null || fragaSvar.getVardperson() == null) {
        return null;
    }
    ArendeListItem res = new ArendeListItem();
    res.setFragestallare(fragaSvar.getFrageStallare());
    res.setIntygId(fragaSvar.getIntygsReferens().getIntygsId());
    res.setIntygTyp(fragaSvar.getIntygsReferens().getIntygsTyp());
    res.setMeddelandeId(Long.toString(fragaSvar.getInternReferens()));
    res.setReceivedDate(fragaSvar.getSenasteHandelseDatum());
    res.setPatientId(fragaSvar.getIntygsReferens().getPatientId().getPersonnummer());
    res.setSigneratAvNamn(fragaSvar.getVardperson().getNamn());
    res.setStatus(fragaSvar.getStatus());
    res.setVidarebefordrad(fragaSvar.getVidarebefordrad());
    res.setAmne(ArendeAmne.fromAmne(fragaSvar.getAmne()).map(ArendeAmne::name).orElse(fragaSvar.getAmne().name()));
    res.setEnhetsnamn(fragaSvar.getVardperson().getEnhetsnamn());
    res.setVardgivarnamn(fragaSvar.getVardperson().getVardgivarnamn());
    return res;
}
Also used : ArendeListItem(se.inera.intyg.webcert.web.web.controller.api.dto.ArendeListItem) ArendeAmne(se.inera.intyg.webcert.persistence.arende.model.ArendeAmne)

Example 5 with ArendeAmne

use of se.inera.intyg.webcert.persistence.arende.model.ArendeAmne in project webcert by sklintyg.

the class ArendeConverterTest method testConvertArende.

@Test
public void testConvertArende() {
    final ArendeAmne amneskod = ArendeAmne.AVSTMN;
    final String intygId = "intygId";
    final String kontaktInfo = "kontaktInfo";
    final String skickatAv = PARTKOD_FKASSA;
    final String frageId = "frageId";
    final Integer instans = 1;
    final String kompletteringsText = "kompletteringsText";
    final String meddelande = "meddelande";
    final String meddelandeId = "meddelandeId";
    final String paminnelseMeddelandeId = "paminnelseMeddelandeId";
    final String personId = "personId";
    final String referensId = "referensId";
    final String rubrik = "rubrik";
    final LocalDate sistaDatum = LocalDate.now();
    final LocalDateTime skickatTidpunkt = LocalDateTime.now();
    final String svarPa = "svarPa";
    final String svarReferensId = "svarReferensId";
    SendMessageToCareType input = createSendMessageToCare(amneskod.name(), intygId, kontaktInfo, skickatAv, frageId, instans, kompletteringsText, meddelande, meddelandeId, paminnelseMeddelandeId, personId, referensId, rubrik, sistaDatum, skickatTidpunkt, svarPa, svarReferensId);
    Arende res = ArendeConverter.convert(input);
    assertEquals(amneskod, res.getAmne());
    assertEquals(intygId, res.getIntygsId());
    assertEquals(kontaktInfo, res.getKontaktInfo().get(0));
    assertEquals(FRAGESTALLARKOD_FORSAKRINGSKASSA, res.getSkickatAv());
    assertEquals(frageId, res.getKomplettering().get(0).getFrageId());
    assertEquals(instans, res.getKomplettering().get(0).getInstans());
    assertEquals(kompletteringsText, res.getKomplettering().get(0).getText());
    assertEquals(meddelande, res.getMeddelande());
    assertEquals(meddelandeId, res.getMeddelandeId());
    assertEquals(paminnelseMeddelandeId, res.getPaminnelseMeddelandeId());
    assertEquals(personId, res.getPatientPersonId());
    assertEquals(referensId, res.getReferensId());
    assertEquals(rubrik, res.getRubrik());
    assertEquals(sistaDatum, res.getSistaDatumForSvar());
    assertEquals(skickatTidpunkt, res.getSkickatTidpunkt());
    assertEquals(svarPa, res.getSvarPaId());
    assertEquals(svarReferensId, res.getSvarPaReferens());
}
Also used : LocalDateTime(java.time.LocalDateTime) SendMessageToCareType(se.riv.clinicalprocess.healthcond.certificate.sendMessageToCare.v2.SendMessageToCareType) ArendeAmne(se.inera.intyg.webcert.persistence.arende.model.ArendeAmne) Arende(se.inera.intyg.webcert.persistence.arende.model.Arende) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) LocalDate(java.time.LocalDate) Test(org.junit.Test)

Aggregations

ArendeAmne (se.inera.intyg.webcert.persistence.arende.model.ArendeAmne)6 LocalDateTime (java.time.LocalDateTime)4 Test (org.junit.Test)4 Arende (se.inera.intyg.webcert.persistence.arende.model.Arende)4 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)3 ArendeListItem (se.inera.intyg.webcert.web.web.controller.api.dto.ArendeListItem)2 LocalDate (java.time.LocalDate)1 Status (se.inera.intyg.webcert.persistence.model.Status)1 Signatur (se.inera.intyg.webcert.persistence.utkast.model.Signatur)1 Utkast (se.inera.intyg.webcert.persistence.utkast.model.Utkast)1 SendMessageToCareType (se.riv.clinicalprocess.healthcond.certificate.sendMessageToCare.v2.SendMessageToCareType)1