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();
}
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();
}
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();
}
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()));
}
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);
}
Aggregations