med: add ad lib flag
This commit is contained in:
parent
b93f3915b7
commit
933d67e9af
4 changed files with 50 additions and 8 deletions
|
@ -132,6 +132,13 @@ func (c ComplianceLogList) ComputeDoseOffset(dir Direction, newLog *ComplianceLo
|
|||
}
|
||||
}
|
||||
|
||||
// ad lib ignore negative offsets
|
||||
if util.Contain(dir.Flags, DirectionFlagAdLib) {
|
||||
if offset < 0 {
|
||||
offset = 0
|
||||
}
|
||||
}
|
||||
|
||||
if math.Abs(offset) > 2 {
|
||||
// stop counting if three or more doses are missed
|
||||
return 0, false, nil
|
||||
|
|
|
@ -37,6 +37,7 @@ const (
|
|||
DirectionFlagAM DirectionFlag = "qam"
|
||||
DirectionFlagHS DirectionFlag = "qhs"
|
||||
DirectionFlagPRN DirectionFlag = "prn"
|
||||
DirectionFlagAdLib DirectionFlag = "ad lib"
|
||||
OptScheduleDefault OptSchedule = "default"
|
||||
OptScheduleWholeDose OptSchedule = "whole"
|
||||
)
|
||||
|
@ -86,12 +87,23 @@ func ParseShorthand(shorthand string) (*Direction, error) {
|
|||
words[i] = words[i] + words[i+1]
|
||||
words[i+1] = ""
|
||||
}
|
||||
if strings.ToLower(words[i]) == "ad" && strings.ToLower(words[i+1]) == "lib" {
|
||||
res.Flags = append(res.Flags, DirectionFlagAdLib)
|
||||
words[i] = ""
|
||||
words[i+1] = ""
|
||||
} else if strings.ToLower(words[i]) == "adlib" {
|
||||
res.Flags = append(res.Flags, DirectionFlagAdLib)
|
||||
words[i] = ""
|
||||
}
|
||||
}
|
||||
words = util.AntiJoin(words, []string{""})
|
||||
|
||||
// find prn keyword
|
||||
for i := len(words) - 1; i >= 0; i-- {
|
||||
if strings.EqualFold(words[i], "prn") {
|
||||
if util.Contain(res.Flags, DirectionFlagAdLib) {
|
||||
return nil, fmt.Errorf("cannot use 'ad lib' and 'prn' together")
|
||||
}
|
||||
res.Flags = append(res.Flags, DirectionFlagPRN)
|
||||
words = append(words[:i], words[i+1:]...)
|
||||
break
|
||||
|
@ -214,6 +226,8 @@ func (d *Direction) ShortHand() (name string, direction string) {
|
|||
}
|
||||
if util.Contain(d.Flags, DirectionFlagPRN) {
|
||||
builder.WriteString(" PRN")
|
||||
} else if util.Contain(d.Flags, DirectionFlagAdLib) {
|
||||
builder.WriteString(" ad lib")
|
||||
}
|
||||
if d.OptSchedule != "" && d.OptSchedule != OptScheduleDefault {
|
||||
if d.OptSchedule == OptScheduleWholeDose {
|
||||
|
|
|
@ -46,6 +46,15 @@ func TestShortHandParser(t *testing.T) {
|
|||
OptSchedule: OptScheduleDefault,
|
||||
Disclaimer: DirectionDisclaimer,
|
||||
}},
|
||||
{"Something 10mg tid ad lib", &Direction{
|
||||
Name: "Something",
|
||||
PeriodHours: 8,
|
||||
Dosage: 10,
|
||||
DosageUnit: "mg",
|
||||
Flags: []DirectionFlag{DirectionFlagAdLib},
|
||||
OptSchedule: OptScheduleDefault,
|
||||
Disclaimer: DirectionDisclaimer,
|
||||
}},
|
||||
{"Hydroxyzine 50mg qid prn sched(whole)", &Direction{
|
||||
Name: "Hydroxyzine",
|
||||
PeriodHours: 6,
|
||||
|
|
|
@ -130,6 +130,11 @@
|
|||
<input type="checkbox" class="form-check-input" id="flags-prn" name="PRN" value="prn">
|
||||
<label for="flags-prn" class="form-check-label">PRN</label>
|
||||
</div>
|
||||
<div class="form-check form-check-inline">
|
||||
<input type="checkbox" class="form-check-input" id="flags-adlib" name="adlib"
|
||||
value="ad lib">
|
||||
<label for="flags-adlib" class="form-check-label">ad lib</label>
|
||||
</div>
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label for="flags" class="form-label">Schedule:</label>
|
||||
|
@ -162,6 +167,7 @@
|
|||
$("#addMed #flags-qam").prop("checked", data.flags.includes("qam"));
|
||||
$("#addMed #flags-qhs").prop("checked", data.flags.includes("qhs"));
|
||||
$("#addMed #flags-prn").prop("checked", data.flags.includes("prn"));
|
||||
$("#addMed #flags-adlib").prop("checked", data.flags.includes("ad lib"));
|
||||
$("#addMed #schedule-default").prop("checked", data.schedule == "default");
|
||||
$("#addMed #schedule-whole").prop("checked", data.schedule == "whole");
|
||||
}
|
||||
|
@ -186,6 +192,9 @@
|
|||
if ($("#addMed #flags-prn").prop("checked")) {
|
||||
flags.push("prn");
|
||||
}
|
||||
if ($("#addMed #flags-adlib").prop("checked")) {
|
||||
flags.push("ad lib");
|
||||
}
|
||||
let schedule = $("#addMed input[name=schedule]:checked").val();
|
||||
$.ajax({
|
||||
url: "/api/health/meds/directions",
|
||||
|
@ -229,6 +238,7 @@
|
|||
medList.map(med => new Promise((resolve, reject) => {
|
||||
{
|
||||
const prn = med.flags.includes("prn");
|
||||
const adlib = med.flags.includes("ad lib");
|
||||
let id = "med-direction-accordion-" + med.name
|
||||
let accEl = document.getElementById(id)
|
||||
if (!accEl) {
|
||||
|
@ -291,17 +301,17 @@
|
|||
let available = false
|
||||
icon.setAttribute("class", "accordion-icon")
|
||||
if (data.dose_offset < -0.2 || dayjs().isAfter(dayjs(data.expected.time).add(1, "day"))) {
|
||||
accEl.setAttribute("data-weight", prn ? 5 : 15)
|
||||
accEl.setAttribute("data-weight", (prn || adlib) ? 5 : 10)
|
||||
icon.classList.add("trima-procedure-ineligible")
|
||||
} else if (data.dose_offset >= 0 && !prn) {
|
||||
} else if (data.dose_offset < 0 || adlib || (prn && data.dose_offset == 0)) {
|
||||
available = true
|
||||
accEl.setAttribute("data-weight", 50)
|
||||
important = true
|
||||
icon.classList.add("trima-procedure-optimal")
|
||||
accEl.setAttribute("data-weight", (prn || adlib) ? 15 : 20)
|
||||
icon.classList.add("trima-procedure-valid")
|
||||
} else {
|
||||
available = true
|
||||
accEl.setAttribute("data-weight", prn ? 10 : 20)
|
||||
icon.classList.add("trima-procedure-valid")
|
||||
accEl.setAttribute("data-weight", 50)
|
||||
important = !adlib
|
||||
icon.classList.add("trima-procedure-optimal")
|
||||
}
|
||||
if (initial) {
|
||||
accEl.querySelector(".accordion-collapse").classList[important ? "add" : "remove"]("show")
|
||||
|
@ -324,7 +334,7 @@
|
|||
projectedTr.classList.add("table-primary");
|
||||
projectedTr.innerHTML = `<th scope="row"></th><td></td><td></td><td></td>`;
|
||||
labelTimeElement(projectedTr.children[0], data.expected.time);
|
||||
projectedTr.children[1].innerText = `${data.expected.dose} ${med.dosage_unit} (${prn ? "available" : "scheduled"})`;
|
||||
projectedTr.children[1].innerText = `${data.expected.dose} ${med.dosage_unit} (${(prn || adlib) ? "available" : "scheduled"})`;
|
||||
tbody.appendChild(projectedTr);
|
||||
|
||||
logs.forEach(log => {
|
||||
|
@ -383,6 +393,8 @@
|
|||
|
||||
if (prn)
|
||||
$(medTimeline).find(".bar").attr("fill", "#B19693");
|
||||
else if (adlib)
|
||||
$(medTimeline).find(".bar").attr("fill", "#F596AA");
|
||||
|
||||
timelineDoses = timelineDoses.map(dose => {
|
||||
dose.time = dayjs(dose.time)
|
||||
|
|
Loading…
Reference in a new issue