Search in sources :

Example 36 with HoSPersonal

use of se.inera.intyg.common.support.model.common.internal.HoSPersonal in project webcert by sklintyg.

the class IntygConverterUtilTest method testBuildHosPersonalFromWebCertUser.

@Test
public void testBuildHosPersonalFromWebCertUser() {
    final String forskrivarkod = "forskrivarkod";
    final String hsaId = "hsaid";
    final String namn = "namn";
    final String arbetsplatskod = "arbetsplatskod";
    final String epost = "epost";
    final String enhetsId = "enhetsId";
    final String enhetsnamn = "enhetsnamn";
    final String postadress = "postadress";
    final String postnummer = "postnummer";
    final String postort = "postort";
    final String telefonnummer = "telefonnummer";
    final String vardgivarId = "vardgivarId";
    final String vardgivarnamn = "vardgivarnamn";
    Vardenhet valdVardenhet = new Vardenhet();
    valdVardenhet.setArbetsplatskod(arbetsplatskod);
    valdVardenhet.setEpost(epost);
    valdVardenhet.setId(enhetsId);
    valdVardenhet.setNamn(enhetsnamn);
    valdVardenhet.setPostadress(postadress);
    valdVardenhet.setPostnummer(postnummer);
    valdVardenhet.setPostort(postort);
    valdVardenhet.setTelefonnummer(telefonnummer);
    Vardgivare valdVardgivare = new Vardgivare();
    valdVardgivare.setId(vardgivarId);
    valdVardgivare.setNamn(vardgivarnamn);
    WebCertUser user = new WebCertUser();
    user.setForskrivarkod(forskrivarkod);
    user.setHsaId(hsaId);
    user.setNamn(namn);
    user.setValdVardenhet(valdVardenhet);
    user.setValdVardgivare(valdVardgivare);
    HoSPersonal result = IntygConverterUtil.buildHosPersonalFromWebCertUser(user, null);
    assertEquals(forskrivarkod, result.getForskrivarKod());
    assertEquals(hsaId, result.getPersonId());
    assertEquals(namn, result.getFullstandigtNamn());
    assertEquals(arbetsplatskod, result.getVardenhet().getArbetsplatsKod());
    assertEquals(epost, result.getVardenhet().getEpost());
    assertEquals(enhetsId, result.getVardenhet().getEnhetsid());
    assertEquals(enhetsnamn, result.getVardenhet().getEnhetsnamn());
    assertEquals(postadress, result.getVardenhet().getPostadress());
    assertEquals(postnummer, result.getVardenhet().getPostnummer());
    assertEquals(postort, result.getVardenhet().getPostort());
    assertEquals(telefonnummer, result.getVardenhet().getTelefonnummer());
    assertEquals(vardgivarId, result.getVardenhet().getVardgivare().getVardgivarid());
    assertEquals(vardgivarnamn, result.getVardenhet().getVardgivare().getVardgivarnamn());
}
Also used : HoSPersonal(se.inera.intyg.common.support.model.common.internal.HoSPersonal) Vardenhet(se.inera.intyg.infra.integration.hsa.model.Vardenhet) Vardgivare(se.inera.intyg.infra.integration.hsa.model.Vardgivare) WebCertUser(se.inera.intyg.webcert.web.service.user.dto.WebCertUser) Test(org.junit.Test)

Example 37 with HoSPersonal

use of se.inera.intyg.common.support.model.common.internal.HoSPersonal in project webcert by sklintyg.

the class CreateDraftCertificateResponderImplTest method createCreateNewDraftRequest.

private CreateNewDraftRequest createCreateNewDraftRequest(Vardenhet vardenhet) {
    CreateNewDraftRequest draftRequest = new CreateNewDraftRequest(UTKAST_ID, null, null, new HoSPersonal(), null);
    draftRequest.getHosPerson().setVardenhet(vardenhet);
    return draftRequest;
}
Also used : CreateNewDraftRequest(se.inera.intyg.webcert.web.service.utkast.dto.CreateNewDraftRequest) HoSPersonal(se.inera.intyg.common.support.model.common.internal.HoSPersonal)

Example 38 with HoSPersonal

use of se.inera.intyg.common.support.model.common.internal.HoSPersonal in project webcert by sklintyg.

the class IntygServiceImpl method sendIntygToCertificateSender.

protected IntygServiceResult sendIntygToCertificateSender(SendIntygConfiguration sendConfig, Utlatande intyg, boolean delay) {
    String intygsId = intyg.getId();
    String recipient = sendConfig.getRecipient();
    String intygsTyp = intyg.getTyp();
    HoSPersonal skickatAv = IntygConverterUtil.buildHosPersonalFromWebCertUser(webCertUserService.getUser(), null);
    try {
        LOG.debug("Sending intyg {} of type {} to recipient {}", intygsId, intygsTyp, recipient);
        // Ask the certificateSenderService to post a 'send' message onto the queue.
        certificateSenderService.sendCertificate(intygsId, intyg.getGrundData().getPatient().getPersonId(), objectMapper.writeValueAsString(skickatAv), recipient, delay);
        // Notify stakeholders when a certificate is sent
        notificationService.sendNotificationForIntygSent(intygsId);
        return IntygServiceResult.OK;
    } catch (WebServiceException wse) {
        LOG.error("An WebServiceException occured when trying to send intyg: " + intygsId, wse);
        return IntygServiceResult.FAILED;
    } catch (RuntimeException e) {
        LOG.error("Module problems occured when trying to send intyg " + intygsId, e);
        throw new WebCertServiceException(WebCertServiceErrorCodeEnum.MODULE_PROBLEM, e);
    } catch (JsonProcessingException e) {
        LOG.error("Error writing skickatAv as string when trying to send intyg " + intygsId, e);
        throw new WebCertServiceException(WebCertServiceErrorCodeEnum.MODULE_PROBLEM, e);
    } catch (CertificateSenderException e) {
        throw new WebCertServiceException(WebCertServiceErrorCodeEnum.MODULE_PROBLEM, e);
    }
}
Also used : HoSPersonal(se.inera.intyg.common.support.model.common.internal.HoSPersonal) WebServiceException(javax.xml.ws.WebServiceException) JsonProcessingException(com.fasterxml.jackson.core.JsonProcessingException) WebCertServiceException(se.inera.intyg.webcert.common.service.exception.WebCertServiceException) CertificateSenderException(se.inera.intyg.webcert.web.service.certificatesender.CertificateSenderException)

Aggregations

HoSPersonal (se.inera.intyg.common.support.model.common.internal.HoSPersonal)38 WebCertUser (se.inera.intyg.webcert.web.service.user.dto.WebCertUser)15 Test (org.junit.Test)13 Patient (se.inera.intyg.common.support.model.common.internal.Patient)11 GrundData (se.inera.intyg.common.support.model.common.internal.GrundData)10 Utlatande (se.inera.intyg.common.support.model.common.internal.Utlatande)10 Before (org.junit.Before)8 Utkast (se.inera.intyg.webcert.persistence.utkast.model.Utkast)7 Vardenhet (se.inera.intyg.common.support.model.common.internal.Vardenhet)5 Vardgivare (se.inera.intyg.common.support.model.common.internal.Vardgivare)5 ValidateDraftResponse (se.inera.intyg.common.support.modules.support.api.dto.ValidateDraftResponse)5 Vardenhet (se.inera.intyg.infra.integration.hsa.model.Vardenhet)5 Personnummer (se.inera.intyg.schemas.contract.Personnummer)5 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)4 Vardgivare (se.inera.intyg.infra.integration.hsa.model.Vardgivare)4 VardpersonReferens (se.inera.intyg.webcert.persistence.utkast.model.VardpersonReferens)4 CreateNewDraftRequest (se.inera.intyg.webcert.web.service.utkast.dto.CreateNewDraftRequest)4 UpdatePatientOnDraftRequest (se.inera.intyg.webcert.web.service.utkast.dto.UpdatePatientOnDraftRequest)4 AbstractVardenhet (se.inera.intyg.infra.integration.hsa.model.AbstractVardenhet)3 SaveDraftResponse (se.inera.intyg.webcert.web.service.utkast.dto.SaveDraftResponse)3