Here you are:
- Add a macro inside file
config.edn
, insidemacros{}
::wetflag " <table id=\"results_table\" class=\"table kit\" data-kit=\"wetflag\" data-age=\"$1\" data-weight=\"$2\"> <thead class=\"table-danger\"> <tr> <th class=\"col1\" scope=\"col\"> </th><th class=\"col2\" scope=\"col\">Formula</th> <th class=\"col3\" scope=\"col\">Result</th> </tr> </thead> <tbody> <tr> <th class=\"col1\">Age</th> <td class=\"col2\"> [given] </td> <td class=\"col3\"><span id=\"age_wetflag\"></span>years</td> </tr> <tr> <th class=\"col1\">Weight</th> <td class=\"col2\"> [given] </td> <td class=\"col3\"><span id=\"weight_wetflag\"></span>kg</td> </tr> <tr> <th class=\"col1\">Energy</th> <td class=\"col2\">4 J x Weight</td> <td class=\"col3\"><span id=\"energy_wetflag\"></span>J</td> </tr> <tr> <th class=\"col1\">Tube</th> <td class=\"col2\"><p>Internal Diameter = Age / 4 + 4</p><p>Length (oral) = Age / 2 + 12</p><p>Length (nasal) = Age /2 + 15</p></td> <td class=\"col3\"><p>Internal Diameter: <span id=\"ETT_ID_wetflag\"></span>cm</p><p>Length (oral): <span id=\"ETT_length_oral_wetflag\"></span>cm</p><p>Length (nasal): <span id=\"ETT_length_nasal_wetflag\"></span>cm</p></td> </tr> <tr> <th class=\"col1\">Fluids</th> <td class=\"col2\"><p>Medical = 20 ml x Weight</p><p>Trauma = 10 ml x Weight</p></td> <td><p>Medical = <span id=\"fluid_medical_wetflag\"></span>mls</p><p>Trauma = <span id=\"fluid_trauma_wetflag\"></span>mls</p></td> </tr> <tr> <th class=\"col1\">Lorazepam</th> <td class=\"col2\"><p>0.1mg x Weight</p></td> <td class=\"col3\"><span id=\"lorazepam_wetflag\"></span>mg</td> </tr> <tr> <th class=\"col1\">Adrenaline</th> <td class=\"col2\"><p>0.1ml x Weight of 1:10,000 Adrenaline</p></td> <td class=\"col3\"><span id=\"adrenaline_wetflag\"></span>mls</td> </tr> <tr> <th class=\"col1\">Glucose</th> <td class=\"col2\"><p>2ml x Weight of 10% Dextrose</p></td> <td class=\"col3\"><span id=\"glucose_wetflag\"></span>mls</td> </tr> </tbody> </table> "
- The code below requires having kits inside file
custom.js
. - Inside page
WetFlag
in Logseq, put the following code in a javascript code-block:function weightFromAge(age){ if (age < 1.5) return 0.5 * age + 4 if (age < 5.5) return 2 * age + 8 if (age < 13.5 ) return 3 * age + 7 if (age < 16.5) return 4 * age + 2 return 70 } logseq.kits.wetflag = function wetflag(table){ const dataAge = Number(table.dataset.age) const age = isNaN(dataAge) ? 1 : dataAge const dataWeight = Number(table.dataset.weight) const weight = isNaN(dataWeight) ? weightFromAge(age) : dataWeight const result = { age, weight, energy: 4 * weight, ETT_ID: age / 4 + 4, ETT_length_oral: age / 2 + 12, ETT_length_nasal: age / 2 + 15, fluid_medical: 20 * weight, fluid_trauma: 10 * weight, lorazepam: 0.1 * weight, adrenaline: 0.1 * weight / 1, glucose: 2 * weight } for (const id in result) { table.querySelector(`#${id}_wetflag`).textContent = result[id] } }
- Now you can use it like
{{wetflag 12, 40}}
- Or omit the weight, e.g.
{{wetflag 12}}
- Or omit the weight, e.g.
- Though the calculations look doubtful.
- It renders like this: