source: FOIAVistA/trunk/r/HEALTH_SUMMARY-GMTS/GMTSRS2.m@ 1499

Last change on this file since 1499 was 628, checked in by George Lilly, 15 years ago

initial load of FOIAVistA 6/30/08 version

File size: 9.4 KB
Line 
1GMTSRS2 ; SLC/KER - Selection Items Resequence ; 02/11/2003 [6/13/03 10:30am]
2 ;;2.7;Health Summary;**62**;Oct 20, 1995
3 ;
4 ; External References
5 ; DBIA 10076 ^XUSEC(
6 ; DBIA 10076 ^XUSEC("GMTSMGR"
7 ; DBIA 10026 ^DIR
8 ; DBIA 10006 ^DIC (file #142)
9 ; DBIA 2054 $$CREF^DILF
10 ; DBIA 10013 IX1^DIK
11 ;
12 ; This routine will resequence the selection items (sub-file
13 ; 142.14) of a Health Component in the structure (sub-file
14 ; 142.01) of a Health Summary Type (file 142)
15 ;
16EN ; Main Entry Point
17 N DA,GMTST,GMTSS,GMTSERR,X,Y D LKT Q:+Y'>0 S GMTST=+Y D LKS Q:+Y'>0 S GMTSS=+Y
18 S DA(2)=GMTST,DA(1)=GMTSS D RSI
19 Q
20RSI ; Resequence Selection Items
21 N ARY,INA,OPA,X,Y,DIC,DIK,DIR,DIROUT,DIRUT,DTOUT,DUOUT,GMTSO,GMTS1
22 N GMTSAC,GMTSAI,GMTSC,GMTSCHG,GMTSCOL,GMTSERR,GMTSF,GMTSHDR,GMTSI
23 N GMTSI1,GMTSI2,GMTSIN,GMTSINM,GMTSKEY,GMTSLOCK,GMTSMAX
24 N GMTSMGR,GMTSO,GMTSON,GMTSOP,GMTSPIE,GMTSRO,GMTSROOT,GMTSS
25 N GMTST,GMTSU,GMTSVAL,GMTSY W ! K ARY,INA,OPA
26 D INA^GMTSRS2B(DA(2),DA(1),.ARY)
27 S GMTSINM=$$MAX(.ARY)
28 I +GMTSINM'>0 D Q
29 . I '$D(GMTSRO)!($D(GMTSRO)&(+($G(GMTSRO))>0)) W !,"Can not resequence, no selection items found."
30 I +GMTSINM'>1 I '$D(GMTSRO)!($D(GMTSRO)&(+($G(GMTSRO))>0)) W !,"Resequencing not required (1 item)"
31 F D RESEQ(.ARY) Q:'$D(ARY)
32 S GMTSMAX=$$MAX(.OPA)
33 I +GMTSINM'=+GMTSMAX I '$D(GMTSRO)!($D(GMTSRO)&(+($G(GMTSRO))>0)) W !,"Selection items not resequenced (sequence not fully specified)" Q
34 D:+GMTSMAX>0 VER(.INA,.OPA,DA(2),DA(1))
35 Q
36 ;
37RESEQ(ARY) ; Resequence - .ARY
38 N GMTSNXT,GMTSI,GMTSIN,GMTSOP,GMTS0,GMTS1,GMTSAC,GMTSAI,GMTSMAX S GMTSMAX=$$MAX(.ARY)
39 S (GMTSAI,GMTSAC)=0 F S GMTSAI=$O(ARY(GMTSAI)) Q:+GMTSAI=0 S GMTSAC=+($G(GMTSAC))+1
40 D RES^GMTSRS2B(.ARY) S (GMTSAI,GMTSAC)=0 F S GMTSAI=$O(ARY(GMTSAI)) Q:+GMTSAI=0 S GMTSAC=+($G(GMTSAC))+1
41 I '$D(GMTSRO)!($D(GMTSRO)&(+($G(GMTSRO))>0))&(GMTSMAX>72) W !,"Resequence selection items:",!
42 I '$D(GMTSRO)!($D(GMTSRO)&(+($G(GMTSRO))>0))&(GMTSMAX>72) D DIS^GMTSRS2B(.ARY)
43 I '$D(GMTSRO)!($D(GMTSRO)&(+($G(GMTSRO))>0))&(GMTSMAX'>72) D
44 . N GMTSROOT,GMTSNODE,GMTSPIE,GMTSHDR,GMTSCOL S ARY(0)=$G(GMTSMAX)
45 . S GMTSROOT="ARY",GMTSHDR="Resequence selection items:",GMTSNODE=1,GMTSPIE=2
46 . S GMTSCOL=1 S:+GMTSMAX>18 GMTSCOL=2 S:+GMTSMAX>36 GMTSCOL=3 S:+GMTSMAX>54 GMTSCOL=4 S:+GMTSMAX>72 GMTSCOL=5 S:+GMTSMAX>90 GMTSCOL=6
47 . D EN^GMTSRS4(GMTSROOT,GMTSNODE,GMTSPIE,GMTSHDR,GMTSCOL)
48 S GMTSNXT=$$ASK(.ARY,.GMTSNXT) F Q:$E(GMTSNXT,$L(GMTSNXT))'="," S GMTSNXT=$E(GMTSNXT,1,($L(GMTSNXT)-1))
49 K:+GMTSNXT'>0 ARY Q:+GMTSNXT'>0
50 S GMTSI=0 F GMTSI=1:1 Q:+($P(GMTSNXT,",",GMTSI))'>0 D
51 . N GMTSIN,GMTSOP,GMTS0,GMTS1 S GMTSIN=+($P(GMTSNXT,",",GMTSI))
52 . S GMTS0=$G(ARY(GMTSIN)) S GMTS1=$G(ARY(GMTSIN,1))
53 . K ARY(GMTSIN) Q:'$L(GMTS0) Q:'$L(GMTS1)
54 . S GMTSOP=+($O(OPA(" "),-1))+1,OPA(GMTSOP)=GMTS0
55 . S OPA(GMTSOP,1)=GMTS1 K ARY(GMTSIN)
56 S GMTSA1=1
57 F S GMTSNXT=$G(GMTSNXT(GMTSA1)) Q:+$G(GMTSNXT)=0 D
58 .S GMTSI=0 F GMTSI=1:1 Q:+($P(GMTSNXT,",",GMTSI))'>0 D
59 .. N GMTSIN,GMTSOP,GMTS0,GMTS1 S GMTSIN=+($P(GMTSNXT,",",GMTSI))
60 .. S GMTS0=$G(ARY(GMTSIN)) S GMTS1=$G(ARY(GMTSIN,1))
61 .. K ARY(GMTSIN) Q:'$L(GMTS0) Q:'$L(GMTS1)
62 .. S GMTSOP=+($O(OPA(" "),-1))+1,OPA(GMTSOP)=GMTS0
63 .. S OPA(GMTSOP,1)=GMTS1 K ARY(GMTSIN)
64 .S GMTSA1=GMTSA1+1
65 Q
66 ;
67ASK(ARY,NEXT,X) ; Ask for order of Selection Items
68 N DIR,DTOUT,DUOUT,DIRUT,DIROUT,GMTSMAX,Y,GMTSF,GMTSI S GMTSMAX=$$MAX(.ARY) Q:+GMTSMAX=1 1 Q:+GMTSMAX'>0 ""
69 F GMTSI=1:1:GMTSMAX S GMTSF=$G(GMTSF)_GMTSI_","
70 I $D(GMTSRO),+GMTSRO=0 S X=GMTSF Q X
71 S DIR(0)="LAO^1:"_GMTSMAX_":0",DIR("A")="Select next item(s)" S:GMTSMAX>1 DIR("A")=DIR("A")_" 1-"_GMTSMAX
72 S DIR("?",1)="Specify a set of Selection Items: eg 2-9,1,10-15"
73 S DIR("?",2)=" You must use every Selection Item in the set"
74 S DIR("?",3)=" For example, if there are 20 Selection Items"
75 S DIR("?",4)=" every number from 1 to 20 must be included"
76 S DIR("?")=" in the resulting set. eg 10-20,5-9,1-4"
77 S DIR("A")=DIR("A")_": ",DIR("B")=1 W ! D ^DIR
78 I $D(DTOUT)!($D(DUOUT))!($D(DIRUT))!($D(DIROUT)) K ARY S X=-1 Q X
79 M NEXT=Y
80 S X=Y Q X
81 ;
82MAX(ARY,X) ; Maximum # Items
83 N GMTSI S (GMTSI,X)=0 F S GMTSI=$O(ARY(GMTSI)) Q:+GMTSI=0 S X=X+1
84 S ARY(0)=X Q X
85 ;
86VER(INA,OPA,GMTST,GMTSS) ; Verify Resequence
87 N GMTSI2,GMTSI1,GMTSI,GMTSC,GMTSON,GMTSNN,GMTSCHG,GMTSVAL,GMTSTR,GMTSCT,X,Y,DIR,DTOUT,DUOUT,DIRUT,DIROUT
88 S GMTSI2=+($G(GMTST)) Q:+GMTSI2=0 S GMTSI1=+($G(GMTSS)) Q:+GMTSI1=0
89 I $D(GMTSRO),+GMTSRO=0 G VER2
90 S (GMTSI,GMTSC,GMTSCHG)=0 F S GMTSI=$O(INA(GMTSI)) Q:+GMTSI=0 D
91 . S GMTSON=$P($G(INA(GMTSI,1)),"^",2)
92 . S GMTSNN=$P($G(OPA(GMTSI,1)),"^",2) S:GMTSON'=GMTSNN GMTSCHG=1
93 I 'GMTSCHG I '$D(GMTSRO)!($D(GMTSRO)&(+($G(GMTSRO))>0)) W !,"No changes in the Selection Item sequence." S GMTSRO=0 G VER2
94 S GMTSCT=0 F S GMTSI=$O(INA(GMTSI)) Q:+GMTSI=0 D
95 . S GMTSON=$P($G(INA(GMTSI,1)),"^",2),GMTSNN=$P($G(OPA(GMTSI,1)),"^",2) Q:'$L(GMTSON) Q:'$L(GMTSNN)
96 . S GMTSC=GMTSC+1 D:GMTSC=1 HDR
97 . S GMTSCT=GMTSCT+1 D:GMTSCT>22 CONT S:GMTSCT>22 GMTSCT=0
98 . S GMTSON=$E(GMTSON,1,31)_" " F Q:$L(GMTSON)>30 S GMTSON=GMTSON_"."
99 . S GMTSTR=$J(GMTSC,5)_" "_GMTSON W !,GMTSTR W ?42,$E(GMTSNN,1,36)
100 S DIR(0)="YAO",DIR("A")="Is this Correct: (Y/N) ",DIR("B")="Y" W ! D ^DIR I +($G(Y))'>0 W !,"Selection items not resequenced" Q
101VER2 ; Verified
102 K ^GMT(142,GMTSI2,1,GMTSI1,1)
103 S (GMTSI,GMTSC)=0 F S GMTSI=$O(OPA(GMTSI)) Q:+GMTSI=0 D
104 . S GMTSVAL=$G(OPA(GMTSI)) Q:'$L(GMTSVAL) S GMTSC=GMTSC+1
105 . S ^GMT(142,GMTSI2,1,GMTSI1,1,GMTSC,0)=GMTSVAL
106 N DIK,DA S DA=GMTSI2,DIK="^GMT(142," D IX1^DIK
107 S ^GMT(142,GMTSI2,1,GMTSI1,1,0)="^142.14VA^"_GMTSC_"^"_GMTSC
108 Q
109 ;
110CONT ; Continue
111 N DIC,DIK,DIR,DIROUT,DIRUT,DTOUT,DUOUT
112 S DIR(0)="EA",DIR("A")=" Press <return> to continue. " W ! D ^DIR
113 S GMTSI=+($G(GMTSI)) D:+($O(INA(GMTSI)))>0 HDR
114 Q
115HDR ; Header
116 W !!,?8,"Old Sequence",?42,"New Sequence",!,?8,"------------------------",?42,"------------------------" S GMTSCT=3
117 Q
118LKT ; Lookup HS Type
119 N DIC,DIR,DTOUT,DUOUT,DIRUT,DIROUT,GMTSERR
120 W !,"Resequence the Selection Items of a Health Summary Type.",!
121 ;
122LKT2 ; Re-prompt
123 S GMTSERR=0,DIC="^GMT(142,",DIC("S")="I +($$ST^GMTSRS2)>0",DIC(0)="AEMQZF"
124 S DIC("A")="Select a Health Summary Type: "
125 D ^DIC I $D(DTOUT)!($D(DUOUT))!($D(DIRUT))!($D(DIROUT)) S Y=-1 Q
126 I +($G(GMTSERR))>0 D DTE(+($G(GMTSERR))) G LKT2
127 I +Y>0 D
128 . N X,DIC S X=$P(Y,"^",2),DIC="^GMT(142,",DIC(0)="M" D ^DIC
129 Q
130 ;
131ST(X) ; Screen for Type
132 N GMTSY,GMTSO,GMTSS,GMTSU,GMTSKEY,GMTSLOCK,GMTSN0,GMTSMGR
133 S GMTSO=0,GMTSY=+($G(Y)) S:+GMTSY'>0 GMTSERR=1 Q:+GMTSY'>0 1
134 S GMTSN0=$G(^GMT(142,+GMTSY,0)) S:'$L(GMTSN0) GMTSERR=2 Q:'$L(GMTSN0) 1
135 S GMTSKEY=$P(GMTSN0,"^",2),GMTSU=$P(GMTSN0,"^",3)
136 S GMTSMGR=$S($D(^XUSEC("GMTSMGR",+($G(DUZ)))):1,1:0) S GMTSLOCK=0
137 S:$L(GMTSKEY) GMTSLOCK=$S($D(^XUSEC(GMTSKEY,+($G(DUZ)))):0,1:1)
138 S:$P(GMTSN0,"^",1)="GMTS HS ADHOC OPTION" GMTSERR=3 Q:$P(GMTSN0,"^",1)="GMTS HS ADHOC OPTION" 1
139 S:+($G(^GMT(142,+GMTSY,"VA")))>0 GMTSERR=6 Q:+($G(^GMT(142,+GMTSY,"VA")))>0 1
140 S (GMTSO,GMTSS)=0 F S GMTSS=$O(^GMT(142,+GMTSY,1,GMTSS)) Q:+GMTSS=0 D Q:GMTSO>1
141 . Q:'$D(^GMT(142,+GMTSY,1,GMTSS,1,"B")) N GMTSI S GMTSI=0
142 . F S GMTSI=$O(^GMT(142,+GMTSY,1,GMTSS,1,GMTSI)) Q:+GMTSI=0 D Q:+GMTSO>1
143 . . S GMTSO=+($G(GMTSO))+1
144 S X=GMTSO S:+X'>0 GMTSERR=7 S:+X=1 GMTSERR=8
145 Q 1
146DTE(X) ; Display Type Error
147 I +($G(X))=1 W !!," No Health Summary Type selected.",! Q
148 I +($G(X))=2 W !!," Health Summary Type not found.",! Q
149 I +($G(X))=3 W !!," Can not resequence AD HOC Health Summary Type.",! Q
150 I +($G(X))=4 W !!," Health Summary Type LOCKED",! Q
151 I +($G(X))=5 W !!," Can not resequence a Health Summary Type you do not own.",! Q
152 I +($G(X))=6 W !!," Can not resequence a Nationally exported Health Summary Type.",! Q
153 I +($G(X))=7 W !!," Health Summary Type does not have selection items." D FMT Q
154 I +($G(X))=8 W !!," Can not resequence, selected Health Summary Type only has",!," one (1) selection item.",! Q
155 Q
156FMT ; Format of Type
157 W !!," <Health Summary Type>"
158 W !," <Health Summary Commponent> i.e., 'PCE HEALTH FACTORS SELECTED'"
159 W !," <Selection Items> i.e., TOBACCO USE",!
160 Q
161LKS ; Lookup HS Component Structure
162 Q:+($G(GMTST))'>0
163 N DIC,DIR,DTOUT,DUOUT,DIRUT,DIROUT,GMTSERR,DA
164LKS2 ; Re-prompt for Component
165 S GMTSERR=0,DA(1)=+($G(GMTST)),DIC="^GMT(142,"_DA(1)_",1,"
166 S DIC("S")="I +($$SS^GMTSRS2)>0",DIC(0)="AEMQZF"
167 S DIC("A")="Select a Health Summary Component: "
168 D ^DIC I $D(DTOUT)!($D(DUOUT))!($D(DIRUT))!($D(DIROUT)) S Y=-1 Q
169 I +($G(GMTSERR))>0 D DCE(+($G(GMTSERR))) G LKS2
170 I +Y>0 D
171 . N X,DIC S X=$P(Y,"^",2),DIC="^GMT(142,"_DA(1)_",1,",DIC(0)="M" D ^DIC
172 Q
173SS(X) ; Screen for Structure
174 S GMTST=+($G(GMTST)) Q:+GMTST'>0 0
175 N GMTSY,GMTSI,GMTSO,GMTSS,GMTSU,GMTSKEY,GMTSLOCK,GMTSN0,GMTSMGR
176 S GMTSO=0,GMTSY=+($G(Y)) S:+GMTSY'>0 GMTSERR=1 Q:+GMTSY'>0 1
177 S GMTSN0=$G(^GMT(142,+GMTST,1,+GMTSY,0)) S:'$L(GMTSN0) GMTSERR=2 Q:'$L(GMTSN0) 1
178 S:'$D(^GMT(142,GMTST,1,+GMTSY,1,"B")) GMTSERR=3 Q:'$D(^GMT(142,GMTST,1,+GMTSY,1,"B"))
179 S (GMTSO,GMTSI)=0
180 F S GMTSI=$O(^GMT(142,GMTST,1,+GMTSY,1,GMTSI)) Q:+GMTSI=0 D Q:+GMTSO>1
181 . S GMTSO=+($G(GMTSO))+1
182 S X=GMTSO S:+X'>0 GMTSERR=3 S:+X=1 GMTSERR=4
183 Q 1
184DCE(X) ; Display Component Error
185 I +($G(X))=1 W !!," No Health Summary Component selected.",! Q
186 I +($G(X))=2 W !!," Health Summary Component not found.",! Q
187 I +($G(X))=3 W !!," Health Summary Component does not have selection items." D FMT Q
188 I +($G(X))=4 W !!," Can not resequence, selected Health Summary Component ",!," only has one (1) selection item.",! Q
189 Q 1
Note: See TracBrowser for help on using the repository browser.