Search in sources :

Example 1 with IntegrationParameters

use of se.inera.intyg.webcert.web.web.controller.integration.dto.IntegrationParameters in project webcert by sklintyg.

the class IntygModuleApiController method createReplacementCopyRequest.

private CreateReplacementCopyRequest createReplacementCopyRequest(String orgIntygsId, String intygsTyp, CopyIntygRequest request) {
    HoSPersonal hosPerson = createHoSPersonFromUser();
    Patient patient = createPatientFromCopyIntygRequest(request);
    final WebCertUser user = userService.getUser();
    IntegrationParameters parameters = user.getParameters();
    boolean coherentJournaling = parameters != null && parameters.isSjf();
    CreateReplacementCopyRequest req = new CreateReplacementCopyRequest(orgIntygsId, intygsTyp, patient, hosPerson, coherentJournaling);
    // Add new personnummer to request
    addPersonnummerToRequest(req, parameters);
    // Set djupintegrerad flag on request to true if origin is DJUPINTEGRATION
    setDeepIntegrationFlagOnRequest(req);
    return req;
}
Also used : HoSPersonal(se.inera.intyg.common.support.model.common.internal.HoSPersonal) IntegrationParameters(se.inera.intyg.webcert.web.web.controller.integration.dto.IntegrationParameters) Patient(se.inera.intyg.common.support.model.common.internal.Patient) WebCertUser(se.inera.intyg.webcert.web.service.user.dto.WebCertUser)

Example 2 with IntegrationParameters

use of se.inera.intyg.webcert.web.web.controller.integration.dto.IntegrationParameters in project webcert by sklintyg.

the class IntygIntegrationController method postRedirectToIntyg.

@POST
@Path("/{certType}/{certId}")
@Consumes(MediaType.APPLICATION_FORM_URLENCODED)
public Response postRedirectToIntyg(@Context UriInfo uriInfo, @PathParam(PARAM_CERT_TYPE) String intygTyp, @PathParam(PARAM_CERT_ID) String intygId, @DefaultValue("") @FormParam(PARAM_ENHET_ID) String enhetId, @DefaultValue("") @FormParam(PARAM_PATIENT_ALTERNATE_SSN) String alternatePatientSSn, @DefaultValue("") @FormParam(PARAM_RESPONSIBLE_HOSP_NAME) String responsibleHospName, @FormParam(PARAM_PATIENT_FORNAMN) String fornamn, @FormParam(PARAM_PATIENT_EFTERNAMN) String efternamn, @FormParam(PARAM_PATIENT_MELLANNAMN) String mellannamn, @FormParam(PARAM_PATIENT_POSTADRESS) String postadress, @FormParam(PARAM_PATIENT_POSTNUMMER) String postnummer, @FormParam(PARAM_PATIENT_POSTORT) String postort, @DefaultValue("false") @FormParam(PARAM_COHERENT_JOURNALING) boolean coherentJournaling, @FormParam(PARAM_REFERENCE) String reference, @DefaultValue("false") @FormParam(PARAM_INACTIVE_UNIT) boolean inactiveUnit, @DefaultValue("false") @FormParam(PARAM_PATIENT_DECEASED) boolean deceased, @DefaultValue("true") @FormParam(PARAM_COPY_OK) boolean copyOk) {
    Map<String, Object> params = new HashMap<>();
    params.put(PARAM_CERT_TYPE, intygTyp);
    params.put(PARAM_CERT_ID, intygId);
    // validate the request
    validateRequest(params);
    IntegrationParameters integrationParameters = getIntegrationParameters(reference, responsibleHospName, alternatePatientSSn, fornamn, efternamn, mellannamn, postadress, postnummer, postort, coherentJournaling, inactiveUnit, deceased, copyOk);
    WebCertUser user = getWebCertUser();
    user.setParameters(integrationParameters);
    return handleRedirectToIntyg(uriInfo, intygTyp, intygId, enhetId, user);
}
Also used : IntegrationParameters(se.inera.intyg.webcert.web.web.controller.integration.dto.IntegrationParameters) HashMap(java.util.HashMap) WebCertUser(se.inera.intyg.webcert.web.service.user.dto.WebCertUser) Path(javax.ws.rs.Path) POST(javax.ws.rs.POST) Consumes(javax.ws.rs.Consumes)

Example 3 with IntegrationParameters

use of se.inera.intyg.webcert.web.web.controller.integration.dto.IntegrationParameters in project webcert by sklintyg.

the class IntygServiceRevokeTest method buildWebCertUser.

private WebCertUser buildWebCertUser(HoSPersonal person) {
    Role role = AUTHORITIES_RESOLVER.getRole(AuthoritiesConstants.ROLE_LAKARE);
    WebCertUser user = new WebCertUser();
    user.setRoles(AuthoritiesResolverUtil.toMap(role));
    user.setOrigin(UserOriginType.DJUPINTEGRATION.name());
    user.setParameters(new IntegrationParameters(USER_REFERENCE, "", "", "", "", "", "", "", "", false, false, false, true));
    user.setAuthorities(AuthoritiesResolverUtil.toMap(role.getPrivileges(), Privilege::getName));
    user.setNamn(person.getFullstandigtNamn());
    user.setHsaId(person.getPersonId());
    return user;
}
Also used : Role(se.inera.intyg.infra.security.common.model.Role) IntegrationParameters(se.inera.intyg.webcert.web.web.controller.integration.dto.IntegrationParameters) WebCertUser(se.inera.intyg.webcert.web.service.user.dto.WebCertUser)

Example 4 with IntegrationParameters

use of se.inera.intyg.webcert.web.web.controller.integration.dto.IntegrationParameters in project webcert by sklintyg.

the class IntygServiceSendTest method createUser.

private WebCertUser createUser() {
    Role role = AUTHORITIES_RESOLVER.getRole(AuthoritiesConstants.ROLE_LAKARE);
    WebCertUser user = new WebCertUser();
    user.setOrigin(UserOriginType.DJUPINTEGRATION.name());
    user.setParameters(new IntegrationParameters("", "", "", "", "", "", "", "", "", false, false, false, true));
    user.setRoles(AuthoritiesResolverUtil.toMap(role));
    user.setAuthorities(AuthoritiesResolverUtil.toMap(role.getPrivileges(), Privilege::getName));
    return user;
}
Also used : Role(se.inera.intyg.infra.security.common.model.Role) IntegrationParameters(se.inera.intyg.webcert.web.web.controller.integration.dto.IntegrationParameters) WebCertUser(se.inera.intyg.webcert.web.service.user.dto.WebCertUser)

Example 5 with IntegrationParameters

use of se.inera.intyg.webcert.web.web.controller.integration.dto.IntegrationParameters in project webcert by sklintyg.

the class IntygServiceTest method setupDefaultAuthorization.

@Before
public void setupDefaultAuthorization() {
    Set<String> set = new HashSet<>();
    set.add("fk7263");
    when(webCertUserService.getUser()).thenReturn(webcertUser);
    when(webcertUser.getOrigin()).thenReturn(UserOriginType.NORMAL.name());
    when(webcertUser.getParameters()).thenReturn(new IntegrationParameters(USER_REFERENCE, "", "", "", "", "", "", "", "", false, false, false, true));
    when(webCertUserService.isAuthorizedForUnit(any(String.class), any(String.class), eq(true))).thenReturn(true);
    when(authoritiesHelper.getIntygstyperForPrivilege(any(WebCertUser.class), anyString())).thenReturn(set);
}
Also used : IntegrationParameters(se.inera.intyg.webcert.web.web.controller.integration.dto.IntegrationParameters) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) HashSet(java.util.HashSet) WebCertUser(se.inera.intyg.webcert.web.service.user.dto.WebCertUser) Before(org.junit.Before)

Aggregations

IntegrationParameters (se.inera.intyg.webcert.web.web.controller.integration.dto.IntegrationParameters)36 WebCertUser (se.inera.intyg.webcert.web.service.user.dto.WebCertUser)32 Test (org.junit.Test)25 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)12 CreateRenewalCopyRequest (se.inera.intyg.webcert.web.service.utkast.dto.CreateRenewalCopyRequest)9 CreateRenewalCopyResponse (se.inera.intyg.webcert.web.service.utkast.dto.CreateRenewalCopyResponse)9 Utkast (se.inera.intyg.webcert.persistence.utkast.model.Utkast)8 Response (javax.ws.rs.core.Response)7 CopyUtkastBuilderResponse (se.inera.intyg.webcert.web.service.utkast.dto.CopyUtkastBuilderResponse)7 Personnummer (se.inera.intyg.schemas.contract.Personnummer)6 CreateReplacementCopyResponse (se.inera.intyg.webcert.web.service.utkast.dto.CreateReplacementCopyResponse)6 CreateCompletionCopyResponse (se.inera.intyg.webcert.web.service.utkast.dto.CreateCompletionCopyResponse)5 Person (se.inera.intyg.infra.integration.pu.model.Person)4 LogRequest (se.inera.intyg.webcert.web.service.log.dto.LogRequest)4 CreateUtkastFromTemplateResponse (se.inera.intyg.webcert.web.service.utkast.dto.CreateUtkastFromTemplateResponse)4 CopyIntygRequest (se.inera.intyg.webcert.web.web.controller.api.dto.CopyIntygRequest)4 CopyIntygResponse (se.inera.intyg.webcert.web.web.controller.api.dto.CopyIntygResponse)4 Patient (se.inera.intyg.common.support.model.common.internal.Patient)3 Privilege (se.inera.intyg.infra.security.common.model.Privilege)3 Role (se.inera.intyg.infra.security.common.model.Role)3