/
query_exec.go
57 lines (52 loc) · 1.29 KB
/
query_exec.go
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
package fakeData
import (
"strings"
"time"
"github.com/bsn-si/IPEHR-gateway/src/pkg/common"
)
func QueryExecRequest(ehrID string) []byte {
req := `{
"q": "SELECT e/ehr_id/value,
c/context/start_time/value as startTime,
c/uid/value as cid,
c/name
FROM EHR e[ehr_id/value=$ehr_id]
CONTAINS COMPOSITION c [openEHR-EHR-COMPOSITION.encounter.v1]
CONTAINS OBSERVATION obs [openEHR-EHR-OBSERVATION.blood_pressure.v1]
WHERE obs/data[at0001]/events[at0006]/data[at0003]/items[at0004]/value/magnitude >= $systolic_bp",
"offset": 0,
"fetch": 10,
"query_parameters": {
"ehr_id": "` + ehrID + `",
"systolic_bp": 140
}
}`
req = strings.ReplaceAll(req, "\n", "")
req = strings.ReplaceAll(req, "\t", "")
return []byte(req)
}
func QueryExecResponse(query string) []byte {
return []byte(`{
"meta": {
"_href": "",
"_type": "RESULTSET",
"_schema_version": "1.0.0",
"_created": "` + time.Now().Format(common.OpenEhrTimeFormat) + `"
},
"q": "` + query + `",
"columns": [
{
"name": "#0",
"path": "/ehr_id/value"
},
{
"name": "systolic",
"path": "/data[at0001]/events[at0006]/data[at0003]/items[at0004]/value/magnitude"
}
],
"rows": [
"41f6fdb5-9ea5-4bb8-b2fa-21131543f82e::piri.ehrscape.com::1",
266.0
]
}`)
}