use of se.inera.intyg.common.support.modules.registry.ModuleNotFoundException in project webcert by sklintyg.
the class UtkastServiceImpl method getPopulatedModelFromIntygModule.
private String getPopulatedModelFromIntygModule(String intygType, CreateNewDraftHolder draftRequest) {
LOG.debug("Calling module '{}' to get populated model", intygType);
String modelAsJson;
try {
ModuleApi moduleApi = moduleRegistry.getModuleApi(intygType);
modelAsJson = moduleApi.createNewInternal(draftRequest);
} catch (ModuleException | ModuleNotFoundException me) {
throw new WebCertServiceException(WebCertServiceErrorCodeEnum.MODULE_PROBLEM, me);
}
LOG.debug("Got populated model of {} chars from module '{}'", getSafeLength(modelAsJson), intygType);
return modelAsJson;
}
use of se.inera.intyg.common.support.modules.registry.ModuleNotFoundException 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.common.support.modules.registry.ModuleNotFoundException 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);
}
}
use of se.inera.intyg.common.support.modules.registry.ModuleNotFoundException in project webcert by sklintyg.
the class IntygServiceImpl method listCertificatesForCareWithQA.
@Override
public List<IntygWithNotificationsResponse> listCertificatesForCareWithQA(IntygWithNotificationsRequest request) {
List<Utkast> utkastList;
if (request.shouldUseEnhetId()) {
utkastList = utkastRepository.findDraftsByPatientAndEnhetAndStatus(DaoUtil.formatPnrForPersistence(request.getPersonnummer()), request.getEnhetId(), Arrays.asList(UtkastStatus.values()), moduleRegistry.listAllModules().stream().map(IntygModule::getId).collect(Collectors.toSet()));
} else {
utkastList = utkastRepository.findDraftsByPatientAndVardgivareAndStatus(DaoUtil.formatPnrForPersistence(request.getPersonnummer()), request.getVardgivarId(), Arrays.asList(UtkastStatus.values()), moduleRegistry.listAllModules().stream().map(IntygModule::getId).collect(Collectors.toSet()));
}
List<IntygWithNotificationsResponse> res = new ArrayList<>();
for (Utkast utkast : utkastList) {
List<Handelse> notifications = notificationService.getNotifications(utkast.getIntygsId());
String ref = referensService.getReferensForIntygsId(utkast.getIntygsId());
notifications = notifications.stream().filter(handelse -> {
if (request.getStartDate() != null && handelse.getTimestamp().isBefore(request.getStartDate())) {
return false;
}
if (request.getEndDate() != null && handelse.getTimestamp().isAfter(request.getEndDate())) {
return false;
}
return true;
}).collect(Collectors.toList());
// this time span
if ((request.getStartDate() != null || request.getEndDate() != null) && notifications.isEmpty()) {
continue;
}
try {
ModuleApi api = moduleRegistry.getModuleApi(utkast.getIntygsTyp());
Intyg intyg = api.getIntygFromUtlatande(api.getUtlatandeFromJson(utkast.getModel()));
Pair<ArendeCount, ArendeCount> arenden = fragorOchSvarCreator.createArenden(utkast.getIntygsId(), utkast.getIntygsTyp());
res.add(new IntygWithNotificationsResponse(intyg, notifications, arenden.getLeft(), arenden.getRight(), ref));
} catch (ModuleNotFoundException | ModuleException | IOException e) {
LOG.error("Could not convert intyg {} to external format", utkast.getIntygsId());
}
}
return res;
}
use of se.inera.intyg.common.support.modules.registry.ModuleNotFoundException in project webcert by sklintyg.
the class IntygModuleFacadeImpl method convertFromInternalToPdfDocument.
@Override
public IntygPdf convertFromInternalToPdfDocument(String intygType, String internalIntygJsonModel, List<Status> statuses, boolean isEmployer) throws IntygModuleFacadeException {
boolean isUtkast = isUtkast(statuses);
try {
ModuleApi moduleApi = moduleRegistry.getModuleApi(intygType);
PdfResponse pdfResponse;
if (!isEmployer) {
pdfResponse = moduleApi.pdf(internalIntygJsonModel, statuses, ApplicationOrigin.WEBCERT, isUtkast);
} else {
pdfResponse = moduleApi.pdfEmployer(internalIntygJsonModel, statuses, ApplicationOrigin.WEBCERT, Collections.emptyList(), isUtkast);
}
return new IntygPdf(pdfResponse.getPdfData(), pdfResponse.getFilename());
} catch (ModuleException me) {
LOG.error("ModuleException occured when when generating PDF document from internal");
throw new IntygModuleFacadeException("ModuleException occured when generating PDF document from internal", me);
} catch (ModuleNotFoundException e) {
LOG.error("ModuleNotFoundException occured for intygstyp '{}' when generating PDF document from internal", intygType);
throw new IntygModuleFacadeException("ModuleNotFoundException occured when registering certificate", e);
}
}
Aggregations