use of se.inera.intyg.common.support.modules.support.api.ModuleApi 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);
}
}
use of se.inera.intyg.common.support.modules.support.api.ModuleApi in project webcert by sklintyg.
the class PatientDetailsResolverImpl method resolveDoiPatient.
/**
* DOI har en specialregel som säger att namn och adress skall hämtas från ett DB-intyg i det fall sådant finns
* utfärdat inom samma Vårdgivare (Integration) eller Vårdenhet (Fristående).
*/
private Patient resolveDoiPatient(Personnummer personnummer, WebCertUser user) {
PersonSvar personSvar = getPersonSvar(personnummer);
// Find ALL existing intyg for this patient, filter out so we only have DB left.
List<Utkast> utkastList = new ArrayList<>();
if (user.getOrigin().equals(UserOriginType.DJUPINTEGRATION.name())) {
utkastList.addAll(utkastRepository.findDraftsByPatientAndVardgivareAndStatus(personnummer.getPersonnummer(), user.getValdVardgivare().getId(), UTKAST_STATUSES, Sets.newHashSet("db")));
} else {
utkastList.addAll(utkastRepository.findDraftsByPatientAndEnhetAndStatus(personnummer.getPersonnummer(), Arrays.asList(user.getValdVardenhet().getId()), UTKAST_STATUSES, Sets.newHashSet("db")));
}
// Use PU and integration parameters for deceased
if (utkastList.size() > 0) {
Utkast newest = utkastList.stream().sorted((u1, u2) -> u2.getSenastSparadDatum().compareTo(u1.getSenastSparadDatum())).findFirst().orElseThrow(() -> new IllegalStateException("List was > 0 but findFirst() returned no result."));
try {
ModuleApi moduleApi = moduleRegistry.getModuleApi("db");
Utlatande utlatande = moduleApi.getUtlatandeFromJson(newest.getModel());
Patient patient = utlatande.getGrundData().getPatient();
if (personSvar.getStatus() == PersonSvar.Status.FOUND) {
patient.setSekretessmarkering(personSvar.getPerson().isSekretessmarkering());
}
patient.setAvliden((personSvar.getStatus() == PersonSvar.Status.FOUND && personSvar.getPerson().isAvliden()) || (user.getParameters() != null && user.getParameters().isPatientDeceased()) || (personSvar.getStatus() != PersonSvar.Status.FOUND && user.getParameters() == null));
return patient;
} catch (ModuleNotFoundException | IOException e) {
// No usabe DB exist
return handleDoiNoExistingDb(personnummer, personSvar, user);
}
} else {
// No usabe DB exist
return handleDoiNoExistingDb(personnummer, personSvar, user);
}
}
Aggregations