~umgeher/utos-usr-local-hcs-exam-ecg

ref: 67b7a6f4e83990d7d5591d5cd8c3f01486a4efa4 utos-usr-local-hcs-exam-ecg/src/utos_usr_local_hcs_exam_ecg_flux_setup.erl -rw-r--r-- 2.7 KiB
67b7a6f4Umgeher Torgersen qt-ai upgraded to 0.2.0 1 year, 23 days ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
-module(utos_usr_local_hcs_exam_ecg_flux_setup).

-export([main/0]).

-define(OP, <<"utos">>).

main() ->
    spawn(utos_usr_local_hcs_exam_ecg_influx, flux_set, ecg_corelead_get()),
    spawn(utos_usr_local_hcs_exam_ecg_influx, flux_set, ecg_corelead_scan()),
    spawn(utos_usr_local_hcs_exam_ecg_influx, flux_set, ecg_corelead_seek()),
    spawn(utos_usr_local_hcs_exam_ecg_influx, flux_set, ecg_corelead_ts_first()),
    spawn(utos_usr_local_hcs_exam_ecg_influx, flux_set, ecg_corelead_ts_last()),
    spawn(utos_usr_local_hcs_exam_ecg_influx, flux_set, ecg_ts_first()),
    spawn(utos_usr_local_hcs_exam_ecg_influx, flux_set, ecg_ts_last()),
    ok.

ecg_corelead_get() ->
    Q = <<"from(bucket: \"{bucket}\") |> range(start: {t0}) |> filter(fn: (r) => r[\"_measurement\"] == \"{corelead}\") |> group(columns: []) |> group(columns: []) |> limit(n: 1000) |> keep(columns: [\"_time\", \"label\", \"_value\"]) |> sort(columns: [\"_time\"])">>,
    [?OP, <<"ecg-corelead-get">>, Q].

ecg_corelead_scan() ->
    Q = <<"from(bucket: \"{bucket}\") |> range(start: {t0}) |> filter(fn: (r) => r[\"_measurement\"] == \"{golden}\" and r[\"_field\"] == \"rr_interval\" and r[\"lead\"] == \"{lead}\") |> group(columns: []) |> limit(n: 10000) |> keep(columns: [\"_time\", \"cluster\" \"label\", \"lead\"]) |> sort(columns: [\"_time\"])">>,
    [?OP, <<"ecg-corelead-scan">>, Q].

ecg_corelead_seek() ->
    Q = <<"from(bucket: \"{bucket}\") |> range(start: {t0}, stop: {t1}) |> filter(fn: (r) => r[\"_measurement\"] == \"{golden}\" and r[\"lead\"] != \"{lead}\" and r[\"_field\"] == \"rr_interval\") |> group(columns: [\"lead\"]) |> limit(n: 1) |> keep(columns: [\"_time\", \"lead\", \"label\", \"cluster\"]) |> sort(columns: [\"_time\"])">>,
    [?OP, <<"ecg-corelead-seek">>, Q].

ecg_corelead_ts_first() ->
    Q = <<"from(bucket: \"{bucket}\") |> range(start: -300d) |> filter(fn: (r) => r._measurement == \"{corelead}\") |> first() \> keep(columns: [\"_time\", \"_value\"])">>,
    [?OP, <<"ecg-corelead-ts-first">>, Q].

ecg_corelead_ts_last() ->
    Q = <<"from(bucket: \"{bucket}\") |> range(start: -300d) |> filter(fn: (r) => r._measurement == \"{corelead}\") |> last() \> keep(columns: [\"_time\", \"_value\"])">>,
    [?OP, <<"ecg-corelead-ts-last">>, Q].

ecg_ts_first() ->
    Q = <<"from(bucket: \"{bucket}\") |> range(start: -300d) |> filter(fn: (r) => r._measurement == \"{ecg}\" and r.lead == \"2\") |> first()">>,
    [?OP, <<"ecg-ts-first">>, Q].

ecg_ts_last() ->
    Q = <<"from(bucket: \"{bucket}\") |> range(start: -300d) |> filter(fn: (r) => r._measurement == \"{ecg}\" and r.lead == \"2\") |> last() |> keep(columns: [\"_time\", \"_value\"]) |> yield(name: \"ecg-ts-last\")">>,
    [?OP, <<"ecg-ts-last">>, Q].