forked from KRMAssociatesInc/JDS-GTM
-
Notifications
You must be signed in to change notification settings - Fork 2
/
VPRJPXA.m
153 lines (153 loc) · 5.52 KB
/
VPRJPXA.m
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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
VPRJPXA ;SLC/KCM -- Attribute Style Indexes for patient (VPR) objects
;;1.0;JSON DATA STORE;;Sep 01, 2012
;
;
; ----- Index Logic: attributes by patient -----
;
ATTRIB ; ATTRIBUTE index (PID,"attr",group,value(s)...,key)
N JPID
S JPID=$$JPID4PID^VPRJPR(PID)
I JPID="" D SETERROR^VPRJRER(222,"Unable to acquire JPID for PID: "_PID) Q
D KATTRIB(.OLDOBJ)
D SATTRIB(.NEWOBJ)
S ^VPRPTI(JPID,PID,"attr",IDXNAME)=$H
Q
SATTRIB(OBJECT) ; Set attribute based index
Q:$D(OBJECT)<10
; SETIF conditional statement is in format "$$TAG^ROUTINE"
N OK,SETIF
S OK=1
I $L(IDXMETA("setif")) S OK=0,SETIF=IDXMETA("setif")_"(.OBJECT)" I @SETIF S OK=1
Q:'OK
I $L(IDXMETA("review")) D
. N REVIEW,REVTM
. S REVIEW="S REVTM="_REVIEW_"(.OBJECT)" X REVIEW
. S ^VPRPTI(JPID,PID,"review",KEY,IDXNAME)=REVTM
. S ^VPRPTX("review",REVTM,PID,KEY,IDXNAME)=""
. S ^VPRPTX("pidReview",PID,REVTM)=""
;
I IDXMETA("levels")=0 D SA0 Q
;
N VALUES,I
D IDXVALS^VPRJCV(.OBJECT,.VALUES,.IDXMETA) Q:'$D(VALUES)
I IDXMETA("levels")=1 D SA1 Q
I IDXMETA("levels")=2 D SA2 Q
I IDXMETA("levels")=3 D SA3 Q
Q
KATTRIB(OBJECT) ; Kill attribute based index
Q:$D(OBJECT)<10
;
I $L(IDXMETA("review")) D
. N REVTM
. S REVTM=$G(^VPRPTI(JPID,PID,"review",KEY,IDXNAME)) Q:'$L(REVTM)
. K:$D(^VPRPTI(JPID,PID,"review",KEY,IDXNAME)) ^VPRPTI(JPID,PID,"review",KEY,IDXNAME)
. K:$D(^VPRPTX("review",REVTM,PID,KEY,IDXNAME)) ^VPRPTX("review",REVTM,PID,KEY,IDXNAME)
. K:$D(^VPRPTX("pidReview",PID,REVTM)) ^VPRPTX("pidReview",PID,REVTM)
;
I IDXMETA("levels")=0 D KA0 Q
;
N VALUES,I
D IDXVALS^VPRJCV(.OBJECT,.VALUES,.IDXMETA) Q:'$D(VALUES)
I IDXMETA("levels")=1 D KA1 Q
I IDXMETA("levels")=2 D KA2 Q
I IDXMETA("levels")=3 D KA3 Q
Q
SA0 ; unsorted list set logic
S ^VPRPTI(JPID,PID,"attr",IDXNAME,KEY)=""
Q
KA0 ; unsorted list kill logic
K:$D(^VPRPTI(JPID,PID,"attr",IDXNAME,KEY)) ^VPRPTI(JPID,PID,"attr",IDXNAME,KEY)
Q
SA1 ; one attribute set logic
S I="" F S I=$O(VALUES(I)) Q:I="" S ^VPRPTI(JPID,PID,"attr",IDXNAME,VALUES(I,1),KEY,I)=""
Q
KA1 ; one attribute kill logic
S I="" F S I=$O(VALUES(I)) Q:I="" K:$D(^VPRPTI(JPID,PID,"attr",IDXNAME,VALUES(I,1),KEY,I)) ^VPRPTI(JPID,PID,"attr",IDXNAME,VALUES(I,1),KEY,I)
Q
SA2 ; two attributes set logic
S I="" F S I=$O(VALUES(I)) Q:I="" S ^VPRPTI(JPID,PID,"attr",IDXNAME,VALUES(I,1),VALUES(I,2),KEY,I)=""
Q
KA2 ; two attributes kill logic
S I="" F S I=$O(VALUES(I)) Q:I="" K:$D(^VPRPTI(JPID,PID,"attr",IDXNAME,VALUES(I,1),VALUES(I,2),KEY,I)) ^VPRPTI(JPID,PID,"attr",IDXNAME,VALUES(I,1),VALUES(I,2),KEY,I)
Q
SA3 ; three attributes set logic
S I="" F S I=$O(VALUES(I)) Q:I="" S ^VPRPTI(JPID,PID,"attr",IDXNAME,VALUES(I,1),VALUES(I,2),VALUES(I,3),KEY,I)=""
Q
KA3 ; three attributes kill logic
S I="" F S I=$O(VALUES(I)) Q:I="" K:$D(^VPRPTI(JPID,PID,"attr",IDXNAME,VALUES(I,1),VALUES(I,2),VALUES(I,3),KEY,I)) ^VPRPTI(JPID,PID,"attr",IDXNAME,VALUES(I,1),VALUES(I,2),VALUES(I,3),KEY,I)
Q
;
; ----- Index Logic: attributes across patients -----
;
XATTR ; ATTRIBUTE index ("xattr",group,value(s)...,key)
N JPID
S JPID=$$JPID4PID^VPRJPR(PID)
I JPID="" D SETERROR^VPRJRER(222,"Unable to acquire JPID for PID: "_PID) Q
D KXATTR(.OLDOBJ)
D SXATTR(.NEWOBJ)
S ^VPRPTX("xattr",IDXNAME)=$H
Q
SXATTR(OBJECT) ; Set attribute based index
Q:$D(OBJECT)<10
; SETIF conditional statement is in format "$$TAG^ROUTINE"
N OK,SETIF
S OK=1
I $L(IDXMETA("setif")) S OK=0,SETIF=IDXMETA("setif")_"(.OBJECT)" I @SETIF S OK=1
Q:'OK
I $L(IDXMETA("review")) D
. N REVIEW,REVTM
. S REVIEW="S REVTM="_REVIEW_"(.OBJECT)" X REVIEW
. S ^VPRPTI(JPID,PID,"review",KEY,IDXNAME)=REVTM
. S ^VPRPTX("review",REVTM,PID,KEY,IDXNAME)=""
. S ^VPRPTX("pidReview",PID,REVTM)=""
;
I IDXMETA("levels")=0 D SXA0 Q
;
N VALUES,I
D IDXVALS^VPRJCV(.OBJECT,.VALUES,.IDXMETA) Q:'$D(VALUES)
I IDXMETA("levels")=1 D SXA1 Q
I IDXMETA("levels")=2 D SXA2 Q
I IDXMETA("levels")=3 D SXA3 Q
Q
KXATTR(OBJECT) ; Set attribute based index
Q:$D(OBJECT)<10
;
I $L(IDXMETA("review")) D
. N REVTM
. S REVTM=$G(^VPRPTI(JPID,PID,"review",KEY,IDXNAME)) Q:'$L(REVTM)
. K ^VPRPTI(JPID,PID,"review",KEY,IDXNAME)
. K:$D(^VPRPTX("review",REVTM,PID,KEY,IDXNAME)) ^VPRPTX("review",REVTM,PID,KEY,IDXNAME)
. K:$D(^VPRPTX("pidReview",PID,REVTM)) ^VPRPTX("pidReview",PID,REVTM)
;
I IDXMETA("levels")=0 D KXA0 Q
;
N VALUES,I
D IDXVALS^VPRJCV(.OBJECT,.VALUES,.IDXMETA) Q:'$D(VALUES)
I IDXMETA("levels")=1 D KXA1 Q
I IDXMETA("levels")=2 D KXA2 Q
I IDXMETA("levels")=3 D KXA3 Q
Q
SXA0 ; unsorted list set logic
S ^VPRPTX("xattr",IDXNAME,KEY)=""
Q
KXA0 ; unsorted list kill logic
K:$D(^VPRPTX("xattr",IDXNAME,KEY)) ^VPRPTX("xattr",IDXNAME,KEY)
Q
SXA1 ; one attribute set logic
S I="" F S I=$O(VALUES(I)) Q:I="" S ^VPRPTX("xattr",IDXNAME,VALUES(I,1),KEY,I)=""
Q
KXA1 ; one attribute kill logic
S I="" F S I=$O(VALUES(I)) Q:I="" K:$D(^VPRPTX("xattr",IDXNAME,VALUES(I,1),KEY,I)) ^VPRPTX("xattr",IDXNAME,VALUES(I,1),KEY,I)
Q
SXA2 ; two attributes set logic
S I="" F S I=$O(VALUES(I)) Q:I="" S ^VPRPTX("xattr",IDXNAME,VALUES(I,1),VALUES(I,2),KEY,I)=""
Q
KXA2 ; two attributes kill logic
S I="" F S I=$O(VALUES(I)) Q:I="" K:$D(^VPRPTX("xattr",IDXNAME,VALUES(I,1),VALUES(I,2),KEY,I)) ^VPRPTX("xattr",IDXNAME,VALUES(I,1),VALUES(I,2),KEY,I)
Q
SXA3 ; three attributes set logic
S I="" F S I=$O(VALUES(I)) Q:I="" S ^VPRPTX("xattr",IDXNAME,VALUES(I,1),VALUES(I,2),VALUES(I,3),KEY,I)=""
Q
KXA3 ; three attributes kill logic
S I="" F S I=$O(VALUES(I)) Q:I="" K:$D(^VPRPTX("xattr",IDXNAME,VALUES(I,1),VALUES(I,2),VALUES(I,3),KEY,I)) ^VPRPTX("xattr",IDXNAME,VALUES(I,1),VALUES(I,2),VALUES(I,3),KEY,I)
Q