Blood pressure formula

Is it possible to create a formula or something that can analyze my blood pressure readings and return the category, Normal, High, etc. based on the number? I would love for it to also either be highlighted in color or have the font be in a color like green for normal, read for high. Any help would be appreciated.

Hi.
I think it’s possible (not an easy but feasible task). I can suggest Dataview plugin.
But first, how do you register your values? Do you use daily and weekly notes?

I am using daily notes . Right now I have a quick add that I activate using a button. The category information that I have came from the American Heart Association. I wasn’t sure it if would be better to separate the Systolic and Diastolic and add them each individually. It would also be nice to be able to have each category have a color either highlighted or written in a specific color, but that might be asking too much.

Time:: {{DATE: h:mmA}}
Blood Pressure:: 115/75

These are the Categories NORMAL (S-🠋80, D-🠋80),
ELEVATED (120-129, D-80-90),
HIGH (Stage 2(S-140 or 🠉, D- 90 or 🠉),
HYPERTENSIVE CRISIS (S-🠉 than 180, D-🠉 than 120)}

Before your last post I made this test (using Dataview), using different categories for test purposes.

## Categories
Normal: S < 120 and D < 80
Elevated: 120 ≤ S ≤ 139 or 80 ≤ D ≤ 89
High: S ≥ 140 or D ≥ 90

## Blood pressure - 2022-W01

```dataview
TABLE systolic, diastolic, choice(systolic < 120 and diastolic < 80, "🟢 normal", choice((systolic < 120 and diastolic >= 80 and diastolic <= 89) or (systolic >= 120 and diastolic < 80) or (systolic >= 120 and systolic <= 139 and diastolic >= 80 and diastolic <= 89), "🟡 elevated", choice((systolic <= 139 and diastolic >= 90) or (systolic >= 140 and diastolic <= 89) or (systolic >= 140 and diastolic >= 90), "🔴 high", "error"))) AS level
WHERE systolic
WHERE file.day.weekyear = number(split(this.file.name, "W")[1]) 
SORT file.name ASC
```

In this example the logic was:

  1. In daily notes (with title in format “YYYY-MM-DD”) added two fields:
    systolic:: 132
    diastolic:: 86
  2. The query was created in weekly notes with the title in format “YYYY-[W]ww”, i.e., year and week number (example: 2022-W01)
  3. I only added one measurement per day. To multiple measurements per day this approach doesn’t work.

But after read your post, I’m not sure if this is the best approach for your intents.

1 Like

Thank you! That looks great. Is there anyway to do it using an inline query? That might fix the problem of multiple times per day, because then I could just have the table query the individual results.

Can you explain, with an example, the idea of inline queries?
Multiples entries in same day for the same field has a basic problem about arrays/list…
Simplifying with an example:

Pressure 1
Time:: 2022-01-10, 2:30PM
fieldA:: value A1
fieldB:: value B1

---
Pressure 2
Time:: 2022-01-10, 5:30PM
fieldA:: value A2
fieldB:: value B2

---
Pressure 3
Time:: 2022-01-10, 10:30PM
fieldA:: value A3
fieldB:: value B3

You can group all this elements, thinking they are related between them: A1 <-> B1, A2 <-> B2, A3 <-> B3, … But it’s a false idea.
Each field is related with the page/note. So, each field has a list of values:

Time:
  - 2022-01-10, 2:30PM
  - 2022-01-10, 5:30PM
  - 2022-01-10, 10:30PM

fieldA:
  - value A1
  - value A2
  - value A3

fieldB:
  - value B1
  - value B2
  - value B3

The apparent relationship between them seems to be the order, nothing more. If, for example, I decide to sort by descending “Time”, the values in other fields don’t follow the new order, just because they aren’t related.

For now, with my limitations in dataview (don’t know js), to your case, working with multiple entries per day, I only found one way: working with only one field.

Taking this example (field sysdias for everything: systolic/diastolic / time):

# 2022-01-08

sysdias:: 140/89 / 09:15AM
sysdias:: 133/79 / 05:45PM

---
# 2022-01-09

sysdias:: 142/90 / 10:10AM
sysdias:: 128/82 / 07:22PM

---
etc.

Now the “weird” dataview query:

```dataview
TABLE WITHOUT ID Days, map(rows.sysdias, (s) => split(s, "/")[2]) AS time, map(rows.sysdias, (s) => split(s, "/")[0]) AS systolic, map(rows.sysdias, (s) => split(s, "/")[1]) AS diastolic, map(rows.sysdias, (s) =>choice(number(split(s, "/")[0]) < 120 and number(split(s, "/")[1]) < 80, "🟢 normal", choice((number(split(s, "/")[0]) < 120 and number(split(s, "/")[1]) >= 80 and number(split(s, "/")[1]) <= 89) or (number(split(s, "/")[0]) >= 120 and number(split(s, "/")[1]) < 80) or (number(split(s, "/")[0]) >= 120 and number(split(s, "/")[0]) <= 139 and number(split(s, "/")[1]) >= 80 and number(split(s, "/")[1]) <= 89), "🟡 elevated", choice((number(split(s, "/")[0]) <= 139 and number(split(s, "/")[1]) >= 90) or (number(split(s, "/")[0]) >= 140 and number(split(s, "/")[1]) <= 89) or (number(split(s, "/")[0]) >= 140 and number(split(s, "/")[1]) >= 90), "🔴 high", "error")))) AS level
WHERE sysdias
WHERE file.day.weekyear = number(split(this.file.name, "W")[1])
FLATTEN sysdias
GROUP BY file.link AS Days
SORT file.name ASC
```

And the test result in weekly note:

1 Like

Wow, that look great! It’s exactly what I was hoping for. I could never have figured it out on my own. Thank you so much!

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.