Search in sources :

Example 41 with WebCertUser

use of se.inera.intyg.webcert.web.service.user.dto.WebCertUser in project webcert by sklintyg.

the class UserApiController method godkannAvtal.

/**
 * Retrieves the security context of the logged in user as JSON.
 *
 * @return
 */
@PUT
@Path("/godkannavtal")
@Produces(MediaType.APPLICATION_JSON + UTF_8_CHARSET)
public Response godkannAvtal() {
    WebCertUser user = getWebCertUserService().getUser();
    if (user != null) {
        avtalService.approveLatestAvtal(user.getHsaId(), user.getPersonId());
        user.setPrivatLakareAvtalGodkand(true);
    }
    return Response.ok().build();
}
Also used : WebCertUser(se.inera.intyg.webcert.web.service.user.dto.WebCertUser) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) PUT(javax.ws.rs.PUT)

Example 42 with WebCertUser

use of se.inera.intyg.webcert.web.service.user.dto.WebCertUser in project webcert by sklintyg.

the class UserApiController method changeSelectedUnitOnUser.

/**
 * Changes the selected care unit in the security context for the logged in user.
 *
 * @param request
 * @return
 */
@POST
@Path("/andraenhet")
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON + UTF_8_CHARSET)
public Response changeSelectedUnitOnUser(ChangeSelectedUnitRequest request) {
    WebCertUser user = getWebCertUserService().getUser();
    LOG.debug("Attempting to change selected unit for user '{}', currently selected unit is '{}'", user.getHsaId(), user.getValdVardenhet() != null ? user.getValdVardenhet().getId() : "(none)");
    boolean changeSuccess = user.changeValdVardenhet(request.getId());
    if (!changeSuccess) {
        LOG.error("Unit '{}' is not present in the MIUs for user '{}'", request.getId(), user.getHsaId());
        return Response.status(Status.BAD_REQUEST).entity("Unit change failed").build();
    }
    user.setFeatures(commonAuthoritiesResolver.getFeatures(Arrays.asList(user.getValdVardenhet().getId(), user.getValdVardgivare().getId())));
    LOG.debug("Seleced vardenhet is now '{}'", user.getValdVardenhet().getId());
    return Response.ok(user.getAsJson()).build();
}
Also used : 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) Produces(javax.ws.rs.Produces)

Example 43 with WebCertUser

use of se.inera.intyg.webcert.web.service.user.dto.WebCertUser in project webcert by sklintyg.

the class UtkastApiController method getLakareWithDraftsByEnheter.

/**
 * Returns a list of doctors that have one or more unsigned utkast.
 *
 * @return a list of {@link se.inera.intyg.webcert.web.service.dto.Lakare} objects.
 */
@GET
@Path("/lakare")
@Produces(MediaType.APPLICATION_JSON + UTF_8_CHARSET)
public Response getLakareWithDraftsByEnheter() {
    authoritiesValidator.given(getWebCertUserService().getUser()).features(AuthoritiesConstants.FEATURE_HANTERA_INTYGSUTKAST).orThrow();
    WebCertUser user = getWebCertUserService().getUser();
    String selectedUnitHsaId = user.getValdVardenhet().getId();
    List<Lakare> lakareWithDraftsByEnhet = utkastService.getLakareWithDraftsByEnhet(selectedUnitHsaId);
    return Response.ok().entity(lakareWithDraftsByEnhet).build();
}
Also used : Lakare(se.inera.intyg.webcert.web.service.dto.Lakare) WebCertUser(se.inera.intyg.webcert.web.service.user.dto.WebCertUser) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET)

Example 44 with WebCertUser

use of se.inera.intyg.webcert.web.service.user.dto.WebCertUser in project webcert by sklintyg.

the class StatisticsGroupByUtil method toSekretessFilteredMap.

/**
 * Takes a list of object[] where each object[] is one of utkast, fraga/svar or arende represented as:
 *
 * [0] id (unique, this is what we want to count per enhetsId)
 * [1] enhetsId
 * [2] personnummer
 *
 * This method will filter out any items belonging to a patient having sekretessmarkering and return the result as a
 * map: EnhetsId -> number of id for that unit.
 *
 * @param groupableItems
 *            Each item is an array of: id, enhetsId, personnummer, intygsTyp.
 * @return
 *         Map with enhetsId -> count, with personummer being sekretessmarkerade has been removed.
 */
public Map<String, Long> toSekretessFilteredMap(List<GroupableItem> groupableItems) {
    if (groupableItems == null || groupableItems.size() == 0) {
        return new HashMap<>();
    }
    List<GroupableItem> filteredGroupableItems = getFilteredGroupableItemList(groupableItems);
    WebCertUser user = webCertUserService.getUser();
    Map<Personnummer, SekretessStatus> sekretessStatusMap = patientDetailsResolver.getSekretessStatusForList(getPersonummerList(filteredGroupableItems));
    // update sekretess status
    filteredGroupableItems.forEach(item -> item.setSekretessStatus(sekretessStatusMap.get(createPnr(item.getPersonnummer()))));
    return filteredGroupableItems.stream().filter(item -> item.getSekretessStatus() != SekretessStatus.UNDEFINED).filter(item -> authoritiesValidator.given(user, item.getIntygsTyp()).privilegeIf(AuthoritiesConstants.PRIVILEGE_HANTERA_SEKRETESSMARKERAD_PATIENT, item.getSekretessStatus() == SekretessStatus.TRUE).isVerified()).collect(Collectors.groupingBy(GroupableItem::getEnhetsId, Collectors.counting()));
}
Also used : Personnummer(se.inera.intyg.schemas.contract.Personnummer) AuthoritiesValidator(se.inera.intyg.infra.security.authorities.validation.AuthoritiesValidator) SekretessStatus(se.inera.intyg.webcert.common.model.SekretessStatus) PatientDetailsResolver(se.inera.intyg.webcert.web.service.patient.PatientDetailsResolver) Personnummer(se.inera.intyg.schemas.contract.Personnummer) Autowired(org.springframework.beans.factory.annotation.Autowired) HashMap(java.util.HashMap) WebCertUserService(se.inera.intyg.webcert.web.service.user.WebCertUserService) Collectors(java.util.stream.Collectors) GroupableItem(se.inera.intyg.webcert.common.model.GroupableItem) Component(org.springframework.stereotype.Component) List(java.util.List) Map(java.util.Map) WebCertUser(se.inera.intyg.webcert.web.service.user.dto.WebCertUser) AuthoritiesConstants(se.inera.intyg.infra.security.common.model.AuthoritiesConstants) GroupableItem(se.inera.intyg.webcert.common.model.GroupableItem) SekretessStatus(se.inera.intyg.webcert.common.model.SekretessStatus) HashMap(java.util.HashMap) WebCertUser(se.inera.intyg.webcert.web.service.user.dto.WebCertUser)

Example 45 with WebCertUser

use of se.inera.intyg.webcert.web.service.user.dto.WebCertUser 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)

Aggregations

WebCertUser (se.inera.intyg.webcert.web.service.user.dto.WebCertUser)217 Test (org.junit.Test)123 IntegrationParameters (se.inera.intyg.webcert.web.web.controller.integration.dto.IntegrationParameters)32 Utkast (se.inera.intyg.webcert.persistence.utkast.model.Utkast)31 Personnummer (se.inera.intyg.schemas.contract.Personnummer)24 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)23 WebCertServiceException (se.inera.intyg.webcert.common.service.exception.WebCertServiceException)23 Role (se.inera.intyg.infra.security.common.model.Role)18 HoSPersonal (se.inera.intyg.common.support.model.common.internal.HoSPersonal)16 Arende (se.inera.intyg.webcert.persistence.arende.model.Arende)15 CopyIntygRequest (se.inera.intyg.webcert.web.web.controller.api.dto.CopyIntygRequest)15 Utlatande (se.inera.intyg.common.support.model.common.internal.Utlatande)14 Vardenhet (se.inera.intyg.infra.integration.hsa.model.Vardenhet)14 CopyUtkastBuilderResponse (se.inera.intyg.webcert.web.service.utkast.dto.CopyUtkastBuilderResponse)14 Vardgivare (se.inera.intyg.infra.integration.hsa.model.Vardgivare)13 Feature (se.inera.intyg.infra.security.common.model.Feature)13 HashMap (java.util.HashMap)12 MedicinsktArende (se.inera.intyg.webcert.persistence.arende.model.MedicinsktArende)12 Transactional (org.springframework.transaction.annotation.Transactional)11 Path (javax.ws.rs.Path)10