Search in sources :

Example 1 with InvalidPersonNummerException

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();
    }
}
Also used : Personnummer(se.inera.intyg.schemas.contract.Personnummer) InvalidPersonNummerException(se.inera.intyg.schemas.contract.InvalidPersonNummerException) IntygModule(se.inera.intyg.common.support.modules.registry.IntygModule) SekretessStatus(se.inera.intyg.webcert.common.model.SekretessStatus) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET)

Example 2 with InvalidPersonNummerException

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();
    }
}
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 3 with InvalidPersonNummerException

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();
    }
}
Also used : Personnummer(se.inera.intyg.schemas.contract.Personnummer) InvalidPersonNummerException(se.inera.intyg.schemas.contract.InvalidPersonNummerException) Samtyckesstatus(se.inera.intyg.clinicalprocess.healthcond.srs.getconsent.v1.Samtyckesstatus) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET) ApiOperation(io.swagger.annotations.ApiOperation)

Example 4 with InvalidPersonNummerException

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();
    }
}
Also used : Personnummer(se.inera.intyg.schemas.contract.Personnummer) InvalidPersonNummerException(se.inera.intyg.schemas.contract.InvalidPersonNummerException) PersonuppgifterResponse(se.inera.intyg.webcert.web.web.controller.api.dto.PersonuppgifterResponse) PersonSvar(se.inera.intyg.infra.integration.pu.model.PersonSvar) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET)

Example 5 with InvalidPersonNummerException

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();
    }
}
Also used : Personnummer(se.inera.intyg.schemas.contract.Personnummer) InvalidPersonNummerException(se.inera.intyg.schemas.contract.InvalidPersonNummerException) ResultCodeEnum(se.riv.clinicalprocess.healthcond.certificate.types.v2.ResultCodeEnum) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) Consumes(javax.ws.rs.Consumes) ApiOperation(io.swagger.annotations.ApiOperation) PUT(javax.ws.rs.PUT)

Aggregations

Path (javax.ws.rs.Path)5 Produces (javax.ws.rs.Produces)5 InvalidPersonNummerException (se.inera.intyg.schemas.contract.InvalidPersonNummerException)5 Personnummer (se.inera.intyg.schemas.contract.Personnummer)4 ApiOperation (io.swagger.annotations.ApiOperation)3 GET (javax.ws.rs.GET)3 ApiResponses (io.swagger.annotations.ApiResponses)1 Consumes (javax.ws.rs.Consumes)1 POST (javax.ws.rs.POST)1 PUT (javax.ws.rs.PUT)1 Samtyckesstatus (se.inera.intyg.clinicalprocess.healthcond.srs.getconsent.v1.Samtyckesstatus)1 Utdatafilter (se.inera.intyg.clinicalprocess.healthcond.srs.getsrsinformation.v1.Utdatafilter)1 IntygModule (se.inera.intyg.common.support.modules.registry.IntygModule)1 PersonSvar (se.inera.intyg.infra.integration.pu.model.PersonSvar)1 SrsResponse (se.inera.intyg.infra.integration.srs.model.SrsResponse)1 SekretessStatus (se.inera.intyg.webcert.common.model.SekretessStatus)1 PersonuppgifterResponse (se.inera.intyg.webcert.web.web.controller.api.dto.PersonuppgifterResponse)1 ResultCodeEnum (se.riv.clinicalprocess.healthcond.certificate.types.v2.ResultCodeEnum)1