Search in sources :

Example 16 with Vardenhet

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

the class CreateUtkastFromTemplateBuilderTest method setup.

@Before
public void setup() {
    hoSPerson = new HoSPersonal();
    hoSPerson.setPersonId(HOSPERSON_ID);
    hoSPerson.setFullstandigtNamn(HOSPERSON_NAME);
    Vardgivare vardgivare = new Vardgivare();
    vardgivare.setVardgivarid(VARDGIVARE_ID);
    vardgivare.setVardgivarnamn(VARDGIVARE_NAME);
    Vardenhet vardenhet = new Vardenhet();
    vardenhet.setEnhetsid(VARDENHET_ID);
    vardenhet.setEnhetsnamn(VARDENHET_NAME);
    vardenhet.setVardgivare(vardgivare);
    hoSPerson.setVardenhet(vardenhet);
    patient = new Patient();
    patient.setPersonId(PATIENT_SSN);
}
Also used : HoSPersonal(se.inera.intyg.common.support.model.common.internal.HoSPersonal) Patient(se.inera.intyg.common.support.model.common.internal.Patient) Vardgivare(se.inera.intyg.common.support.model.common.internal.Vardgivare) AbstractVardenhet(se.inera.intyg.infra.integration.hsa.model.AbstractVardenhet) Vardenhet(se.inera.intyg.common.support.model.common.internal.Vardenhet) Before(org.junit.Before)

Example 17 with Vardenhet

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

the class AbstractUtkastBuilder method populateUtkastWithVardenhetAndHoSPerson.

private void populateUtkastWithVardenhetAndHoSPerson(Utkast utkast, AbstractCreateCopyRequest copyRequest) {
    Vardenhet vardenhet = copyRequest.getHosPerson().getVardenhet();
    utkast.setEnhetsId(vardenhet.getEnhetsid());
    utkast.setEnhetsNamn(vardenhet.getEnhetsnamn());
    Vardgivare vardgivare = vardenhet.getVardgivare();
    utkast.setVardgivarId(vardgivare.getVardgivarid());
    utkast.setVardgivarNamn(vardgivare.getVardgivarnamn());
    VardpersonReferens creator = UpdateUserUtil.createVardpersonFromHosPerson(copyRequest.getHosPerson());
    utkast.setSenastSparadAv(creator);
    utkast.setSkapadAv(creator);
}
Also used : Vardenhet(se.inera.intyg.common.support.model.common.internal.Vardenhet) Vardgivare(se.inera.intyg.common.support.model.common.internal.Vardgivare) VardpersonReferens(se.inera.intyg.webcert.persistence.utkast.model.VardpersonReferens)

Example 18 with Vardenhet

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

the class CreateDraftCertificateResponderImplTest method createVardenhet.

private Vardenhet createVardenhet(Vardgivare vardgivare) {
    Vardenhet vardenhet = new Vardenhet();
    vardenhet.setEnhetsid("SE1234567890-1A01");
    vardenhet.setEnhetsnamn("Vardenheten");
    vardenhet.setVardgivare(vardgivare);
    return vardenhet;
}
Also used : Vardenhet(se.inera.intyg.common.support.model.common.internal.Vardenhet)

Example 19 with Vardenhet

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

the class CreateDraftCertificateResponderImplTest method whenNewCertificateDraftSuccessResponse.

/**
 * When a new certificate draft is being created the caller
 * should get a success response returned and any stakeholder
 * should be notified with a notification message.
 */
@Test
public void whenNewCertificateDraftSuccessResponse() {
    // Given
    ResultValidator resultsValidator = new ResultValidator();
    Vardgivare vardgivare = createVardgivare();
    Vardenhet vardenhet = createVardenhet(vardgivare);
    CreateNewDraftRequest draftRequest = createCreateNewDraftRequest(vardenhet);
    CreateDraftCertificateType certificateType = createCertificateType();
    VardpersonReferens vardperson = createVardpersonReferens(certificateType.getUtlatande().getSkapadAv().getPersonalId().getRoot(), certificateType.getUtlatande().getSkapadAv().getFullstandigtNamn());
    Utkast utkast = createUtkast(UTKAST_ID, Long.parseLong(UTKAST_VERSION), UTKAST_TYPE, UtkastStatus.DRAFT_INCOMPLETE, UTKAST_JSON, vardperson);
    // When
    when(mockValidator.validate(any(Utlatande.class))).thenReturn(resultsValidator);
    when(mockRequestBuilder.buildCreateNewDraftRequest(any(Utlatande.class), any(IntygUser.class))).thenReturn(draftRequest);
    when(mockUtkastService.createNewDraft(any(CreateNewDraftRequest.class))).thenReturn(utkast);
    when(takService.verifyTakningForCareUnit(any(String.class), any(String.class), any(SchemaVersion.class), any(IntygUser.class))).thenReturn(new TakResult(true, Lists.emptyList()));
    // Then
    CreateDraftCertificateResponseType response = responder.createDraftCertificate(LOGICAL_ADDR, certificateType);
    verify(mockUtkastService).createNewDraft(any(CreateNewDraftRequest.class));
    verify(mockIntegreradeEnheterService).putIntegreradEnhet(any(IntegreradEnhetEntry.class), eq(true), eq(false));
    verify(takService).verifyTakningForCareUnit(any(String.class), any(String.class), any(SchemaVersion.class), any(IntygUser.class));
    // Assert response content
    assertNotNull(response);
    assertEquals(response.getResult().getResultCode(), ResultCodeType.OK);
    assertEquals(response.getUtlatandeId().getExtension(), UTKAST_ID);
}
Also used : IntegreradEnhetEntry(se.inera.intyg.webcert.web.integration.registry.dto.IntegreradEnhetEntry) CreateNewDraftRequest(se.inera.intyg.webcert.web.service.utkast.dto.CreateNewDraftRequest) CreateDraftCertificateType(se.riv.clinicalprocess.healthcond.certificate.createdraftcertificateresponder.v1.CreateDraftCertificateType) SchemaVersion(se.inera.intyg.common.support.modules.support.api.notification.SchemaVersion) TakResult(se.inera.intyg.webcert.integration.tak.model.TakResult) Vardgivare(se.inera.intyg.common.support.model.common.internal.Vardgivare) Vardenhet(se.inera.intyg.common.support.model.common.internal.Vardenhet) IntygUser(se.inera.intyg.infra.security.common.model.IntygUser) CreateDraftCertificateResponseType(se.riv.clinicalprocess.healthcond.certificate.createdraftcertificateresponder.v1.CreateDraftCertificateResponseType) ResultValidator(se.inera.intyg.webcert.web.integration.validators.ResultValidator) Utkast(se.inera.intyg.webcert.persistence.utkast.model.Utkast) TypAvUtlatande(se.riv.clinicalprocess.healthcond.certificate.types.v1.TypAvUtlatande) Utlatande(se.riv.clinicalprocess.healthcond.certificate.createdraftcertificateresponder.v1.Utlatande) VardpersonReferens(se.inera.intyg.webcert.persistence.utkast.model.VardpersonReferens) BaseCreateDraftCertificateTest(se.inera.intyg.webcert.web.integration.interactions.createdraftcertificate.BaseCreateDraftCertificateTest) Test(org.junit.Test)

Example 20 with Vardenhet

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

the class IntygServiceImpl method verifyEnhetsAuth.

protected void verifyEnhetsAuth(Utlatande utlatande, boolean isReadOnlyOperation) {
    Vardenhet vardenhet = utlatande.getGrundData().getSkapadAv().getVardenhet();
    if (!webCertUserService.isAuthorizedForUnit(vardenhet.getVardgivare().getVardgivarid(), vardenhet.getEnhetsid(), isReadOnlyOperation)) {
        String msg = "User not authorized for enhet " + vardenhet.getEnhetsid();
        LOG.debug(msg);
        throw new WebCertServiceException(WebCertServiceErrorCodeEnum.AUTHORIZATION_PROBLEM, msg);
    }
}
Also used : Vardenhet(se.inera.intyg.common.support.model.common.internal.Vardenhet) WebCertServiceException(se.inera.intyg.webcert.common.service.exception.WebCertServiceException)

Aggregations

Vardenhet (se.inera.intyg.common.support.model.common.internal.Vardenhet)20 Vardgivare (se.inera.intyg.common.support.model.common.internal.Vardgivare)13 AbstractVardenhet (se.inera.intyg.infra.integration.hsa.model.AbstractVardenhet)8 Patient (se.inera.intyg.common.support.model.common.internal.Patient)6 HoSPersonal (se.inera.intyg.common.support.model.common.internal.HoSPersonal)5 Before (org.junit.Before)4 Utkast (se.inera.intyg.webcert.persistence.utkast.model.Utkast)4 VardpersonReferens (se.inera.intyg.webcert.persistence.utkast.model.VardpersonReferens)4 WebCertUser (se.inera.intyg.webcert.web.service.user.dto.WebCertUser)4 CopyUtkastBuilderResponse (se.inera.intyg.webcert.web.service.utkast.dto.CopyUtkastBuilderResponse)4 ValidateDraftResponse (se.inera.intyg.common.support.modules.support.api.dto.ValidateDraftResponse)3 IntegreradEnhetEntry (se.inera.intyg.webcert.web.integration.registry.dto.IntegreradEnhetEntry)3 IOException (java.io.IOException)2 ModuleApi (se.inera.intyg.common.support.modules.support.api.ModuleApi)2 ModuleException (se.inera.intyg.common.support.modules.support.api.exception.ModuleException)2 WebCertServiceException (se.inera.intyg.webcert.common.service.exception.WebCertServiceException)2 LocalDateTime (java.time.LocalDateTime)1 Consumes (javax.ws.rs.Consumes)1 POST (javax.ws.rs.POST)1 Produces (javax.ws.rs.Produces)1