From ed930c754c8a060453206a0cdfdf77ee3746f89d Mon Sep 17 00:00:00 2001
From: alex <alex@pdp7.net>
Date: Sun, 22 Oct 2023 12:15:47 +0200
Subject: Add bp

---
 sql/weight.sql | 13 +++++++++++++
 1 file changed, 13 insertions(+)

(limited to 'sql/weight.sql')

diff --git a/sql/weight.sql b/sql/weight.sql
index e97bf057..e1104342 100644
--- a/sql/weight.sql
+++ b/sql/weight.sql
@@ -10,6 +10,11 @@ create table weight.bp (
        kind                      text check (kind in ('standard', 'home', 'doctor')) default 'standard' not null
 );
 
+create table weight.pressure_medication (
+       taken_at                  timestamp with time zone primary key default now(),
+       dose_mg                   numeric(3, 1) not null
+);
+
 create schema zqxjk;
 
 create view zqxjk.weight as (
@@ -27,6 +32,13 @@ create view zqxjk.bp_standard_measure as (
         from   weight.bp
 );
 
+create view zqxjk.pressure_medication as (
+        select to_char(taken_at, 'YYYY-MM-DD"T"HH24:MI:SSOF') as _id,
+               taken_at || ' ' || dose_mg || 'mg' as _display,
+               dose_mg
+        from   weight.pressure_medication
+);
+
 create view zqxjk.admin_weight as (
         select to_char(measured_at, 'YYYY-MM-DD"T"HH24:MI:SSOF') as _id,
                measured_at || ' ' || value as _display,
@@ -43,3 +55,4 @@ create table zqxjk._tables (
 insert into zqxjk._tables(name, default_sort) values ('weight', '{"_id", "desc"}');
 insert into zqxjk._tables(name, default_sort) values ('admin_weight', '{"_id", "desc"}');
 insert into zqxjk._tables(name, default_sort) values ('bp_standard_measure', '{"_id", "desc"}');
+insert into zqxjk._tables(name, default_sort) values ('pressure_medication', '{"_id", "desc"}');
-- 
cgit v1.2.3

