use of se.inera.intyg.schemas.contract.InvalidPersonNummerException in project webcert by sklintyg.
the class ModuleApiController method getModulesMap.
/**
* Serving module configuration populating selectors based on user.
*
* @return a JSON object
*/
@GET
@Path("/map/{patientId}")
@Produces(MediaType.APPLICATION_JSON + UTF_8_CHARSET)
public Response getModulesMap(@PathParam("patientId") String patientId) {
try {
Personnummer personnummer = createPnr(patientId);
SekretessStatus sekretessmarkering = patientDetailsResolver.getSekretessStatus(personnummer);
List<IntygModule> intygModules = moduleRegistry.listAllModules();
// If patient has sekretessmarkering or PU-service didn't respond, filter out ts-intyg using privilege.
if (sekretessmarkering == SekretessStatus.TRUE || sekretessmarkering == SekretessStatus.UNDEFINED) {
// INTYG-4086
intygModules = intygModules.stream().filter(module -> authoritiesValidator.given(getWebCertUserService().getUser(), module.getId()).privilege(AuthoritiesConstants.PRIVILEGE_HANTERA_SEKRETESSMARKERAD_PATIENT).isVerified()).collect(Collectors.toList());
}
if (patientDetailsResolver.isAvliden(personnummer)) {
intygModules = intygModules.stream().filter(module -> authoritiesValidator.given(getWebCertUserService().getUser(), module.getId()).features(AuthoritiesConstants.FEATURE_HANTERA_INTYGSUTKAST_AVLIDEN).isVerified()).collect(Collectors.toList());
}
return Response.ok(intygModules).build();
} catch (InvalidPersonNummerException e) {
LOG.error(e.getMessage());
return Response.status(Response.Status.BAD_REQUEST).build();
}
}
use of se.inera.intyg.schemas.contract.InvalidPersonNummerException in project webcert by sklintyg.
the class SrsApiController method getSrs.
@POST
@Path("/{intygId}/{personnummer}/{diagnosisCode}")
@Produces(MediaType.APPLICATION_JSON + UTF_8_CHARSET)
@ApiOperation(value = "Get SRS data", httpMethod = "POST", produces = MediaType.APPLICATION_JSON)
@ApiResponses(value = { @ApiResponse(code = OK, message = "SRS data found", response = SrsResponse.class), @ApiResponse(code = BAD_REQUEST, message = "Bad request"), @ApiResponse(code = NO_CONTENT, message = "No prediction model found") })
public Response getSrs(@ApiParam(value = "Intyg id", required = true) @PathParam("intygId") String intygId, @ApiParam(value = "Personnummer", required = true) @PathParam("personnummer") String personnummer, @ApiParam(value = "Diagnosis Code", required = true) @PathParam("diagnosisCode") String diagnosisCode, @ApiParam(value = "Utdatafilter: Prediktion") @QueryParam("prediktion") @DefaultValue("false") boolean prediktion, @ApiParam(value = "Utdatafilter: AtgardRekommendation") @QueryParam("atgard") @DefaultValue("false") boolean atgard, @ApiParam(value = "Utdatafilter: Statistik") @QueryParam("statistik") @DefaultValue("false") boolean statistik, @ApiParam(value = "Svar på frågor") List<SrsQuestionResponse> questions) {
authoritiesValidator.given(getWebCertUserService().getUser()).features(AuthoritiesConstants.FEATURE_SRS).orThrow();
if (Strings.isNullOrEmpty(personnummer) || Strings.isNullOrEmpty(diagnosisCode)) {
return Response.status(Response.Status.BAD_REQUEST).build();
}
try {
Utdatafilter filter = buildUtdatafilter(prediktion, atgard, statistik);
SrsResponse response = srsService.getSrs(userService.getUser(), intygId, createPnr(personnummer), diagnosisCode, filter, questions);
if (prediktion) {
logService.logShowPrediction(personnummer);
monitoringLog.logSrsInformationRetreived(diagnosisCode, intygId);
}
decorateWithDiagnosisDescription(response);
return Response.ok(response).build();
} catch (InvalidPersonNummerException | IllegalArgumentException e) {
return Response.status(Response.Status.BAD_REQUEST).build();
}
}
use of se.inera.intyg.schemas.contract.InvalidPersonNummerException in project webcert by sklintyg.
the class SrsApiController method getConsent.
@GET
@Path("/consent/{personnummer}/{hsaId}")
@Produces(MediaType.APPLICATION_JSON + UTF_8_CHARSET)
@ApiOperation(value = "Get consent for patient and careunit", httpMethod = "GET", produces = MediaType.APPLICATION_JSON)
public Response getConsent(@ApiParam(value = "Personnummer") @PathParam("personnummer") String personnummer, @ApiParam(value = "HsaId för vårdenhet") @PathParam("hsaId") String hsaId) {
authoritiesValidator.given(getWebCertUserService().getUser()).features(AuthoritiesConstants.FEATURE_SRS).orThrow();
try {
Personnummer p = createPnr(personnummer);
Samtyckesstatus response = srsService.getConsent(hsaId, p);
return Response.ok(response).build();
} catch (InvalidPersonNummerException e) {
return Response.status(Response.Status.BAD_REQUEST).build();
}
}
use of se.inera.intyg.schemas.contract.InvalidPersonNummerException in project webcert by sklintyg.
the class PersonApiController method getPersonuppgifter.
@GET
@Path("/{personnummer}")
@Produces(MediaType.APPLICATION_JSON + UTF_8_CHARSET)
public Response getPersonuppgifter(@PathParam("personnummer") String personnummerIn) {
try {
Personnummer personnummer = createPnr(personnummerIn);
LOG.debug("Hämtar personuppgifter för: {}", personnummer.getPersonnummerHash());
PersonSvar personSvar = puService.getPerson(personnummer);
monitoringService.logPULookup(personnummer, personSvar.getStatus().name());
return Response.ok(new PersonuppgifterResponse(personSvar)).build();
} catch (InvalidPersonNummerException e) {
LOG.error(e.getMessage());
return Response.status(Response.Status.BAD_REQUEST).build();
}
}
use of se.inera.intyg.schemas.contract.InvalidPersonNummerException in project webcert by sklintyg.
the class SrsApiController method setConsent.
@PUT
@Path("/consent/{personnummer}/{hsaId}")
@Produces(MediaType.APPLICATION_JSON + UTF_8_CHARSET)
@Consumes(MediaType.APPLICATION_JSON)
@ApiOperation(value = "Set consent for patient and careunit", httpMethod = "PUT", produces = MediaType.APPLICATION_JSON)
public Response setConsent(@ApiParam(value = "Personnummer") @PathParam("personnummer") String personnummer, @ApiParam(value = "HsaId för vårdenhet") @PathParam("hsaId") String hsaId, boolean consent) {
authoritiesValidator.given(getWebCertUserService().getUser()).features(AuthoritiesConstants.FEATURE_SRS).orThrow();
try {
Personnummer p = createPnr(personnummer);
ResultCodeEnum result = srsService.setConsent(hsaId, p, consent);
monitoringLog.logSetSrsConsent(p, consent);
return Response.ok(result).build();
} catch (InvalidPersonNummerException e) {
return Response.status(Response.Status.BAD_REQUEST).build();
}
}
Aggregations