use of se.inera.intyg.webcert.common.service.exception.WebCertServiceException in project webcert by sklintyg.
the class WebcertRedirectIntegrationExceptionHandler method handleRuntimeException.
private Response handleRuntimeException(RuntimeException re) {
if (re instanceof WebCertServiceException) {
LOG.warn("WebCertServiceException caught", re.getMessage());
WebCertServiceException we = (WebCertServiceException) re;
if (we.getErrorCode() == WebCertServiceErrorCodeEnum.MISSING_PARAMETER) {
return buildErrorRedirectResponse("missing-parameter", we.getMessage());
} else if (we.getErrorCode() == WebCertServiceErrorCodeEnum.AUTHORIZATION_PROBLEM) {
return buildErrorRedirectResponse("auth-exception", we.getMessage());
} else if (we.getErrorCode() == WebCertServiceErrorCodeEnum.AUTHORIZATION_PROBLEM_SEKRETESSMARKERING) {
return buildErrorRedirectResponse("auth-exception-sekretessmarkering", we.getMessage());
} else if (we.getErrorCode() == WebCertServiceErrorCodeEnum.PU_PROBLEM) {
return buildErrorRedirectResponse("pu-problem", we.getMessage());
}
}
LOG.error("Unhandled RuntimeException occured!", re);
return buildErrorRedirectResponse("unknown", re.getMessage());
}
use of se.inera.intyg.webcert.common.service.exception.WebCertServiceException in project webcert by sklintyg.
the class FragaSvarServiceImpl method openQuestionAsUnhandled.
@Override
public FragaSvar openQuestionAsUnhandled(Long frageSvarId) {
FragaSvar fragaSvar = lookupFragaSvar(frageSvarId);
// Enforce business rule FS-011, from FK + answer should remain closed
if (!FrageStallare.WEBCERT.isKodEqual(fragaSvar.getFrageStallare()) && !Strings.isNullOrEmpty(fragaSvar.getSvarsText())) {
throw new WebCertServiceException(WebCertServiceErrorCodeEnum.INVALID_STATE, "FS-011: Cant revert status for question " + frageSvarId);
}
NotificationEvent notificationEvent = determineNotificationEvent(fragaSvar);
if (!Strings.isNullOrEmpty(fragaSvar.getSvarsText())) {
fragaSvar.setStatus(Status.ANSWERED);
} else {
if (FrageStallare.WEBCERT.isKodEqual(fragaSvar.getFrageStallare())) {
fragaSvar.setStatus(Status.PENDING_EXTERNAL_ACTION);
} else {
fragaSvar.setStatus(Status.PENDING_INTERNAL_ACTION);
}
}
FragaSvar openedFragaSvar = fragaSvarRepository.save(fragaSvar);
sendNotification(openedFragaSvar, notificationEvent);
return openedFragaSvar;
}
use of se.inera.intyg.webcert.common.service.exception.WebCertServiceException in project webcert by sklintyg.
the class FragaSvarServiceImpl method sendFragaSvarToExternalParty.
private void sendFragaSvarToExternalParty(final FragaSvar fragaSvar) {
// Send to external party (FK)
SendMedicalCertificateAnswerType sendType = new SendMedicalCertificateAnswerType();
AnswerToFkType answer = FKAnswerConverter.convert(fragaSvar);
sendType.setAnswer(answer);
// Remove ASAP.
if ("true".equalsIgnoreCase(forceFullstandigtNamn)) {
answer.getLakarutlatande().getPatient().setFullstandigtNamn("---");
}
AttributedURIType logicalAddress = new AttributedURIType();
logicalAddress.setValue(sendAnswerToFkLogicalAddress);
SendMedicalCertificateAnswerResponseType response;
try {
response = sendAnswerToFKClient.sendMedicalCertificateAnswer(logicalAddress, sendType);
} catch (SOAPFaultException e) {
LOGGER.error("Failed to send answer to FK, error was: " + e.getMessage());
throw new WebCertServiceException(WebCertServiceErrorCodeEnum.EXTERNAL_SYSTEM_PROBLEM, e.getMessage());
}
if (!response.getResult().getResultCode().equals(ResultCodeEnum.OK)) {
LOGGER.error("Failed to send answer to FK, result was " + response.getResult().getErrorText());
throw new WebCertServiceException(WebCertServiceErrorCodeEnum.EXTERNAL_SYSTEM_PROBLEM, response.getResult().getErrorText());
}
monitoringService.logAnswerSent(fragaSvar.getExternReferens(), fragaSvar.getInternReferens(), (fragaSvar.getIntygsReferens() == null) ? null : fragaSvar.getIntygsReferens().getIntygsId(), fragaSvar.getVardAktorHsaId(), fragaSvar.getAmne());
// Notify stakeholders
sendNotification(fragaSvar, NotificationEvent.NEW_ANSWER_FROM_CARE);
}
use of se.inera.intyg.webcert.common.service.exception.WebCertServiceException in project webcert by sklintyg.
the class IntygServiceImpl method handleAfterSigned.
/**
* Check if signed certificate is a completion, in that case, send to recipient and close pending completion QA /
* Arende as handled.
* <p>
* Check if signed certificate should be sent directly to default recipient for this intygstyp.
* <p>
* Note that the send operation uses the "delay" boolean to allow the signing operation some time to complete
* in intygstjansten.
*/
@Override
public void handleAfterSigned(Utkast utkast) {
boolean isKomplettering = RelationKod.KOMPLT == utkast.getRelationKod();
boolean isSigneraSkickaDirekt = authoritiesHelper.isFeatureActive(AuthoritiesConstants.FEATURE_SIGNERA_SKICKA_DIREKT, utkast.getIntygsTyp());
if (isKomplettering || isSigneraSkickaDirekt) {
try {
LOG.info("Send intyg '{}' directly to recipient", utkast.getIntygsId());
sendIntyg(utkast.getIntygsId(), utkast.getIntygsTyp(), moduleRegistry.getModuleEntryPoint(utkast.getIntygsTyp()).getDefaultRecipient(), true);
if (isKomplettering) {
LOG.info("Set komplettering QAs as handled for {}", utkast.getRelationIntygsId());
arendeService.closeCompletionsAsHandled(utkast.getRelationIntygsId(), utkast.getIntygsTyp());
}
} catch (ModuleNotFoundException e) {
throw new WebCertServiceException(WebCertServiceErrorCodeEnum.MODULE_PROBLEM, "Could not send intyg directly to recipient", e);
}
}
}
use of se.inera.intyg.webcert.common.service.exception.WebCertServiceException in project webcert by sklintyg.
the class IntygServiceImpl method buildIntygContentHolderForUtkast.
// NOTE! INTYG-4086. This method is used when fetching Intyg/Utkast from WC locally. The question is, should we
// replace the patient on the existing model with a freshly fetched one here or not? In case we're storing patient
// info entered manually for non FK-types here, we may end up overwriting a manually stored name etc...
private IntygContentHolder buildIntygContentHolderForUtkast(Utkast utkast, boolean relations) {
try {
// INTYG-4086: Patient object populated according to ruleset for the intygstyp at hand.
Patient newPatientData = patientDetailsResolver.resolvePatient(utkast.getPatientPersonnummer(), utkast.getIntygsTyp());
// create an "empty" Patient with personnummer only.
if (newPatientData == null) {
newPatientData = new Patient();
newPatientData.setPersonId(utkast.getPatientPersonnummer());
}
// INTYG-5354, INTYG-5380: Don't use incomplete address from external data sources (PU/js).
Utlatande utlatande = modelFacade.getUtlatandeFromInternalModel(utkast.getIntygsTyp(), utkast.getModel());
if (!completeAddressProvided(newPatientData)) {
// Use the old address data.
Patient oldPatientData = utlatande.getGrundData().getPatient();
copyOldAddressToNewPatientData(oldPatientData, newPatientData);
}
String updatedModel = moduleRegistry.getModuleApi(utkast.getIntygsTyp()).updateBeforeSave(utkast.getModel(), newPatientData);
utlatande = modelFacade.getUtlatandeFromInternalModel(utkast.getIntygsTyp(), updatedModel);
List<Status> statuses = IntygConverterUtil.buildStatusesFromUtkast(utkast);
Relations certificateRelations = certificateRelationService.getRelations(utkast.getIntygsId());
final SekretessStatus sekretessStatus = patientDetailsResolver.getSekretessStatus(newPatientData.getPersonId());
if (SekretessStatus.UNDEFINED.equals(sekretessStatus)) {
throw new WebCertServiceException(WebCertServiceErrorCodeEnum.PU_PROBLEM, "Sekretesstatus could not be fetched from the PU service");
}
final boolean sekretessmarkerad = SekretessStatus.TRUE.equals(sekretessStatus);
boolean patientNameChanged = patientDetailsResolver.isPatientNamedChanged(utlatande.getGrundData().getPatient(), newPatientData);
boolean patientAddressChanged = patientDetailsResolver.isPatientAddressChanged(utlatande.getGrundData().getPatient(), newPatientData);
return IntygContentHolder.builder().setContents(updatedModel).setUtlatande(utlatande).setStatuses(statuses).setRevoked(utkast.getAterkalladDatum() != null).setRelations(certificateRelations).setCreated(utkast.getSkapad()).setDeceased(isDeceased(utkast.getPatientPersonnummer())).setSekretessmarkering(sekretessmarkerad).setPatientNameChangedInPU(patientNameChanged).setPatientAddressChangedInPU(patientAddressChanged).build();
} catch (ModuleException | ModuleNotFoundException e) {
throw new WebCertServiceException(WebCertServiceErrorCodeEnum.MODULE_PROBLEM, e);
}
}
Aggregations