Search in sources :

Example 1 with Utdatafilter

use of se.inera.intyg.clinicalprocess.healthcond.srs.getsrsinformation.v1.Utdatafilter 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();
    }
}
Also used : InvalidPersonNummerException(se.inera.intyg.schemas.contract.InvalidPersonNummerException) Utdatafilter(se.inera.intyg.clinicalprocess.healthcond.srs.getsrsinformation.v1.Utdatafilter) SrsResponse(se.inera.intyg.infra.integration.srs.model.SrsResponse) Path(javax.ws.rs.Path) POST(javax.ws.rs.POST) Produces(javax.ws.rs.Produces) ApiOperation(io.swagger.annotations.ApiOperation) ApiResponses(io.swagger.annotations.ApiResponses)

Example 2 with Utdatafilter

use of se.inera.intyg.clinicalprocess.healthcond.srs.getsrsinformation.v1.Utdatafilter in project webcert by sklintyg.

the class SrsApiController method buildUtdatafilter.

private Utdatafilter buildUtdatafilter(boolean prediktion, boolean atgard, boolean statistik) {
    Utdatafilter filter = new Utdatafilter();
    filter.setPrediktion(prediktion);
    filter.setAtgardsrekommendation(atgard);
    filter.setStatistik(statistik);
    return filter;
}
Also used : Utdatafilter(se.inera.intyg.clinicalprocess.healthcond.srs.getsrsinformation.v1.Utdatafilter)

Aggregations

Utdatafilter (se.inera.intyg.clinicalprocess.healthcond.srs.getsrsinformation.v1.Utdatafilter)2 ApiOperation (io.swagger.annotations.ApiOperation)1 ApiResponses (io.swagger.annotations.ApiResponses)1 POST (javax.ws.rs.POST)1 Path (javax.ws.rs.Path)1 Produces (javax.ws.rs.Produces)1 SrsResponse (se.inera.intyg.infra.integration.srs.model.SrsResponse)1 InvalidPersonNummerException (se.inera.intyg.schemas.contract.InvalidPersonNummerException)1