const tables_to_print = [ { title: 'Allergien', table: i_allergies }, { title: 'Aktuelle Medikamente', table: i_current_medication }, { title: 'Vergangene Medikamente', table: i_past_medication }, { title: 'Aktuelle Diagnose', table: i_current_problems }, { title: 'Vergangene Diagnosen', table: i_past_problems }, { title: 'Familienanamnese', table: i_family_problems }, { title: 'Operationen', table: i_procedures }, { title: 'Lebensstil', table: i_socialhistory }, { title: 'Durchgeführte Tests', table: i_results }, { title: 'Laborwerte', table: i_vitalsigns }, ]; document.querySelector(".btn-print").addEventListener("click", function(){ // need to load all tables into the DOM expandAll(); printTables(); }); function printTables() { const print_area = document.createElement("div"); // Static header and patient information const header_html = `

IPS von Max Mustermann (m) - 11.12.1950

Adresse: Am Schulweg 5, Hainfeld, 3100, AUT

Identifikationsnummer:0000121150

`; // Append the header to print_area print_area.innerHTML += header_html; // Loop through tables and add them to print_area for (const table_to_print of tables_to_print) { table_to_print.table.redraw(true); // Ensure table is redrawn const title_html = "
" + `

${table_to_print.title}

`; const table_html = table_to_print.table.getHtml(); const sum_html = title_html + table_html ; print_area.innerHTML += sum_html; } // Create print window with header, patient info, and tables const printWindow = window.open('', '_blank'); printWindow.document.open(); printWindow.document.write(` Print Multiple Tables ${print_area.innerHTML} `); printWindow.document.close(); printWindow.print(); }