use of se.inera.intyg.common.support.modules.registry.ModuleNotFoundException in project webcert by sklintyg.
the class UtkastServiceImpl method updateUtkastModel.
private void updateUtkastModel(Utkast utkast, String modelJson) {
WebCertUser user = webCertUserService.getUser();
try {
ModuleApi moduleApi = moduleRegistry.getModuleApi(utkast.getIntygsTyp());
GrundData grundData = moduleApi.getUtlatandeFromJson(modelJson).getGrundData();
Vardenhet vardenhetFromJson = grundData.getSkapadAv().getVardenhet();
HoSPersonal hosPerson = IntygConverterUtil.buildHosPersonalFromWebCertUser(user, vardenhetFromJson);
utkast.setSenastSparadAv(UpdateUserUtil.createVardpersonFromWebCertUser(user));
utkast.setPatientPersonnummer(grundData.getPatient().getPersonId());
String updatedInternal = moduleApi.updateBeforeSave(modelJson, hosPerson);
// String updatedInternalWithResolvedPatient = moduleApi.updateBeforeSave(updatedInternal,
// updatedPatientForSaving);
utkast.setModel(updatedInternal);
updatePatientNameFromModel(utkast, grundData.getPatient());
} catch (ModuleException | ModuleNotFoundException | IOException e) {
if (e.getCause() != null && e.getCause().getCause() != null) {
// This error message is helpful when debugging save problems.
LOG.debug(e.getCause().getCause().getMessage());
}
throw new WebCertServiceException(WebCertServiceErrorCodeEnum.MODULE_PROBLEM, "Could not update with HoS personal", e);
}
}
use of se.inera.intyg.common.support.modules.registry.ModuleNotFoundException in project webcert by sklintyg.
the class UtkastServiceImpl method validateDraft.
@Override
public DraftValidation validateDraft(String intygId, String intygType, String draftAsJson) {
LOG.debug("Validating Intyg '{}' with type '{}'", intygId, intygType);
try {
ModuleApi moduleApi = moduleRegistry.getModuleApi(intygType);
ValidateDraftResponse validateDraftResponse = moduleApi.validateDraft(draftAsJson);
return convertToDraftValidation(validateDraftResponse);
} catch (ModuleException | ModuleNotFoundException me) {
throw new WebCertServiceException(WebCertServiceErrorCodeEnum.MODULE_PROBLEM, me);
}
}
use of se.inera.intyg.common.support.modules.registry.ModuleNotFoundException in project webcert by sklintyg.
the class UtkastApiController method createUtkast.
/**
* Create a new draft.
*/
@POST
@Path("/{intygsTyp}")
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON + UTF_8_CHARSET)
public Response createUtkast(@PathParam("intygsTyp") String intygsTyp, CreateUtkastRequest request) {
try {
if (moduleRegistry.getIntygModule(intygsTyp).isDeprecated()) {
LOG.error("Request for deprecated module {}", intygsTyp);
return Response.status(Status.BAD_REQUEST).build();
}
} catch (ModuleNotFoundException e) {
LOG.error("Request for unknown module {}", intygsTyp);
return Response.status(Status.BAD_REQUEST).build();
}
authoritiesValidator.given(getWebCertUserService().getUser(), intygsTyp).features(AuthoritiesConstants.FEATURE_HANTERA_INTYGSUTKAST).privilege(AuthoritiesConstants.PRIVILEGE_SKRIVA_INTYG).orThrow();
final SekretessStatus sekretessStatus = patientDetailsResolver.getSekretessStatus(request.getPatientPersonnummer());
if (SekretessStatus.UNDEFINED.equals(sekretessStatus)) {
throw new WebCertServiceException(WebCertServiceErrorCodeEnum.PU_PROBLEM, "Could not fetch sekretesstatus for patient from PU service");
}
// INTYG-4086: If the patient is sekretessmarkerad, we need an additional check.
boolean sekr = sekretessStatus == SekretessStatus.TRUE;
if (sekr) {
authoritiesValidator.given(getWebCertUserService().getUser(), intygsTyp).privilege(AuthoritiesConstants.PRIVILEGE_HANTERA_SEKRETESSMARKERAD_PATIENT).orThrow(new WebCertServiceException(WebCertServiceErrorCodeEnum.AUTHORIZATION_PROBLEM_SEKRETESSMARKERING, "User missing required privilege or cannot handle sekretessmarkerad patient"));
}
if (!request.isValid()) {
LOG.error("Request is invalid: " + request.toString());
return Response.status(Status.BAD_REQUEST).build();
}
LOG.debug("Attempting to create draft of type '{}'", intygsTyp);
if (authoritiesValidator.given(getWebCertUserService().getUser(), intygsTyp).features(AuthoritiesConstants.FEATURE_UNIKT_INTYG, AuthoritiesConstants.FEATURE_UNIKT_INTYG_INOM_VG, AuthoritiesConstants.FEATURE_UNIKT_UTKAST_INOM_VG).isVerified()) {
Map<String, Map<String, Boolean>> intygstypToStringToBoolean = utkastService.checkIfPersonHasExistingIntyg(request.getPatientPersonnummer(), getWebCertUserService().getUser());
Boolean utkastExists = intygstypToStringToBoolean.get("utkast").get(intygsTyp);
Boolean intygExists = intygstypToStringToBoolean.get("intyg").get(intygsTyp);
if (utkastExists != null && utkastExists) {
if (authoritiesValidator.given(getWebCertUserService().getUser(), intygsTyp).features(AuthoritiesConstants.FEATURE_UNIKT_UTKAST_INOM_VG).isVerified()) {
return Response.status(Status.BAD_REQUEST).build();
}
}
if (intygExists != null) {
if (authoritiesValidator.given(getWebCertUserService().getUser(), intygsTyp).features(AuthoritiesConstants.FEATURE_UNIKT_INTYG).isVerified()) {
return Response.status(Status.BAD_REQUEST).build();
} else if (intygExists && authoritiesValidator.given(getWebCertUserService().getUser(), intygsTyp).features(AuthoritiesConstants.FEATURE_UNIKT_INTYG_INOM_VG).isVerified()) {
return Response.status(Status.BAD_REQUEST).build();
}
}
}
CreateNewDraftRequest serviceRequest = createServiceRequest(request);
Utkast utkast = utkastService.createNewDraft(serviceRequest);
LOG.debug("Created a new draft of type '{}' with id '{}'", intygsTyp, utkast.getIntygsId());
return Response.ok().entity(utkast).build();
}
use of se.inera.intyg.common.support.modules.registry.ModuleNotFoundException in project webcert by sklintyg.
the class UtkastModelToXmlConverterServiceImpl method utkastToJAXBObject.
private Intyg utkastToJAXBObject(String intygsTyp, String json) {
try {
ModuleApi moduleApi = intygModuleRegistry.getModuleApi(intygsTyp);
Utlatande utlatandeFromJson = moduleApi.getUtlatandeFromJson(json);
return moduleApi.getIntygFromUtlatande(utlatandeFromJson);
} catch (ModuleNotFoundException | IOException | ModuleException e) {
LOG.error("Error building Intyg JAXB object from Utkast. Message: {}", e.getMessage());
throw new IllegalArgumentException(e.getMessage());
}
}
use of se.inera.intyg.common.support.modules.registry.ModuleNotFoundException in project webcert by sklintyg.
the class UtkastBootstrapBean method init.
@PostConstruct
public void init() throws IOException {
for (Resource resource : getResourceListing("classpath*:module-bootstrap-certificate/*.xml")) {
try {
String moduleName = resource.getFilename().split("__")[0];
LOG.info("Bootstrapping certificate '{}' from module ", resource.getFilename(), moduleName);
Utlatande utlatande = buildUtlatande(resource, moduleName);
if (utkastRepo.findOne(utlatande.getId()) == null) {
utkastRepo.save(createUtkast(utlatande));
switch(utlatande.getTyp()) {
case Fk7263EntryPoint.MODULE_ID:
fragaRepo.save(createFragaSvar(utlatande, FrageStallare.FORSAKRINGSKASSAN, true, false));
fragaRepo.save(createFragaSvar(utlatande, FrageStallare.WEBCERT, false, false));
fragaRepo.save(createFragaSvar(utlatande, FrageStallare.FORSAKRINGSKASSAN, false, true));
fragaRepo.save(createFragaSvar(utlatande, FrageStallare.FORSAKRINGSKASSAN, false, false));
break;
case TsBasEntryPoint.MODULE_ID:
case TsDiabetesEntryPoint.MODULE_ID:
// These certificates does not support arende or fragaSvar
break;
default:
// SIT certificates
setupArende(utlatande, true, true, FrageStallare.FORSAKRINGSKASSAN);
setupArende(utlatande, false, false, FrageStallare.WEBCERT);
setupArende(utlatande, false, false, FrageStallare.FORSAKRINGSKASSAN);
break;
}
}
} catch (ModuleException | ModuleNotFoundException | IOException e) {
LOG.error("Could not bootstrap {}", resource.getFilename(), e);
}
}
}
Aggregations