Skip to main content

Overview

The Expediente API generates comprehensive employee evaluation files that compile all captured data from the evaluation process. Reports are generated using Puppeteer for HTML-to-PDF conversion.
Expediente reports include personal data, family information, academic history, work trajectory, economic data, references, and more. Two report types are supported: Nuevo Ingreso (New Entry) and Permanente (Permanent).

Render Expediente HTML

curl -X GET https://api.vlife-dgo.com/Expediente/RenderExpediente/12345
Generates the HTML view of the complete employee evaluation file.

Endpoint

GET /Expediente/RenderExpediente/:evalID

Authentication

No authentication required (public endpoint for internal PDF generation).

Path Parameters

evalID
integer
required
The evaluation ID to generate the expediente for.

Response

Returns an HTML view without layout (layout: false) optimized for PDF generation. The template used depends on evaluation type:
  • tipoEvalID = 1: expedienteViews/RenderExpedientePerma (Permanent employees)
  • tipoEvalID ≠ 1: expedienteViews/RenderExpedienteNI (New entry employees)

Data Sections Included

personales
object
Personal information of the employee.
datoseva
object
Evaluation metadata.
datosfami
array
Family members information.
datosacad
array
Academic history and education records.
datosredess
array
Social media accounts and online presence.
datostrayecto
object
Work trajectory for new entry employees.
datosTraPerma
object
Work trajectory for permanent employees.
economicos
object
Economic and financial information.
GetCuentas
array
Bank accounts (active records only).
getCredito
array
Credit lines and loans (active records only).
getInmuebles
array
Real estate properties (active records only).
getMuebles
array
Personal property and vehicles (active records only).
referencias
object
Personal and professional references.
getCapaciitaciones
array
Training and certifications (active records only).
datosUltimosEmpleosNI
array
Recent employment history for new entry evaluations.
datosFamiliarProceso
array
Family members involved in legal processes.
datosCorpFamiliar
array
Family members in law enforcement or government.
datosIngresoExtra
array
Additional income sources.
datosAdscripciones
array
Work assignments and postings (Permanente only).

Database Queries

The endpoint executes multiple parallel queries to gather comprehensive data:
-- Personal data
SELECT * FROM tbl_dgo_personalesperma personales
WHERE evalID = ?
ORDER BY personales.personalesCreado DESC LIMIT 1;

-- Evaluation type
SELECT eval.evalID, tip.tipoEvalID, tip.evalTipo
FROM tbl_dgo_evaluaciones eval
INNER JOIN cat_dgo_tipoeval tip ON eval.tipoEvalID = tip.tipoEvalID
WHERE eval.evalID = ?
ORDER BY eval.evalCreado DESC LIMIT 1;

-- Family members (active only)
SELECT eval.evalID, fam.*
FROM tbl_dgo_evaluaciones eval
INNER JOIN tbl_dgo_familiares fam ON eval.evalID = fam.evalID
WHERE eval.evalID = ? AND fam.familiarActivo = 1
ORDER BY fam.familiarCreado DESC;

-- Additional queries for academics, social media, work history,
-- economic data, assets, references, and training records

Error Response

{
  "flash": {
    "message": "Algo salio mal !"
  },
  "redirect": "back"
}
Returns when:
  • Evaluation ID not found
  • Database connection errors
  • Missing required data

Generate Expediente PDF

curl -X GET https://api.vlife-dgo.com/Expediente/ExpedienteViewPdf/12345 \
  --output expediente-12345.pdf
Generates and downloads the expediente as a PDF file.

Endpoint

GET /Expediente/ExpedienteViewPdf/:evalID

Authentication

No authentication required.

Path Parameters

evalID
integer
required
The evaluation ID to generate the PDF for.

Response

Content-Type
string
application/pdf
body
binary
PDF file binary data.

PDF Generation Settings

The PDF is generated using Puppeteer with the following configuration:
let navegador = await puppeteer.launch({
  ignoreHTTPSErrors: true,
  args: ["--no-sandbox", "--disable-setuid-sandbox"],
});

let pagina = await navegador.newPage();
await pagina.goto(url);
await pagina.emulateMediaType("screen");

let pdf = await pagina.pdf({
  format: "A4",
  printBackground: true,
  margin: { 
    left: "1cm", 
    top: "1cm", 
    right: "1cm", 
    bottom: "2.5cm" 
  },
});

PDF Specifications

format
string
default:"A4"
Paper size: A4 (210mm × 297mm)
printBackground
boolean
default:"true"
Includes background colors and images in PDF.
margin.left
string
default:"1cm"
Left margin.
margin.top
string
default:"1cm"
Top margin.
margin.right
string
default:"1cm"
Right margin.
margin.bottom
string
default:"2.5cm"
Bottom margin (larger for footers).

Generation Process

  1. HTML Rendering: Calls /Expediente/RenderExpediente/:evalID internally
  2. Page Load: Puppeteer navigates to HTML view at http://localhost:4001
  3. Media Emulation: Sets media type to “screen” for proper styling
  4. PDF Conversion: Renders HTML to PDF with specified settings
  5. Response: Returns PDF binary with application/pdf content type
  6. Cleanup: Closes Puppeteer browser instance

Performance Considerations

PDF generation is resource-intensive. Consider:
  • Caching generated PDFs for frequently accessed reports
  • Rate limiting to prevent server overload
  • Async job queues for batch generation
  • Timeout settings for large reports

Error Response

{
  "flash": {
    "message": "Algo salio mal !"
  },
  "redirect": "back"
}
Returns when:
  • Evaluation ID not found
  • Puppeteer fails to launch
  • HTML rendering errors
  • PDF generation timeout

Implementation Details

Source Code References

  • Routes: ExpedienteRoutes.js:6-7
  • Controller: ExpedienteController.js:23-191
  • Models: ExpedienteModel.js (15+ SQL queries)
  • Puppeteer Config: ExpedienteController.js:6-21

Template Views

  • expedienteViews/RenderExpedientePerma.hbs - Permanent employee template
  • expedienteViews/RenderExpedienteNI.hbs - New entry employee template

Data Filtering

All data queries filter for active records only (e.g., familiarActivo = 1, academicoActivo = 1) to exclude soft-deleted entries.

Use Cases

  1. Official Records: Generate complete employee evaluation file for HR records
  2. Background Checks: Compile all background investigation data
  3. Audit Compliance: Produce standardized reports for regulatory review
  4. Management Review: Provide comprehensive evaluation summaries
  5. Archive Documentation: Create permanent record of evaluation process

Build docs developers (and LLMs) love