use of se.inera.intyg.infra.integration.srs.model.SrsResponse 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();
}
}
Aggregations