source: WorldVistAEHR/trunk/r/HEALTH_SUMMARY-GMTS/GMTSRS1.m@ 1005

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

initial load of WorldVistAEHR

File size: 5.9 KB
Line 
1GMTSRS1 ; SLC/KER - Component Structure Resequence ; 02/11/2003
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 Health Summary Components
13 ; in the structure (sub-file 142.01) of a Health Summary
14 ; Type (file 142)
15 ;
16EN ; Main Entry Point
17 N DA,DIK,GMTST,GMTSS,GMTSERR,X,Y
18 W !,"Resequence the Components of a Health Summary Type.",!
19 D LKT I +Y'>0 W !,"Health Summary Type not selected ",! Q
20 S GMTST=+Y,DA(1)=GMTST D RCS K DA S DA=GMTST,DIK="^GMT(142," D IX1^DIK
21 Q
22 ;
23RCS ; Resequence Component Structure - Needs DA array
24 N ARY,INA,OPA,GMTST,GMTSINM,GMTSMAX K ARY,INA,OPA D INA^GMTSRS1B(DA(1),.ARY)
25 S GMTSINM=$$MAX(.ARY) I +GMTSINM'>0 W !,"Can not resequence, no components found." Q
26 I +GMTSINM'>1 W !,"Resequencing not required (1 component)" Q
27 F D RESEQ(.ARY) Q:'$D(ARY)
28 S GMTSMAX=$$MAX(.OPA) I +GMTSINM'=+GMTSMAX W !,"Component structure not resequenced (sequence not fully specified)" Q
29 D:+GMTSMAX>0 VER(.INA,.OPA,DA(1))
30 Q
31 ;
32RESEQ(ARY) ; Resequence - .ARY
33 N GMTSNXT,GMTSI,GMTSIN,GMTSOP,GMTS,GMTS0,GMTS1,GMTSS,GMTSC,GMTSMAX
34 D RES^GMTSRS1B(.ARY) S GMTSMAX=$$MAX(.ARY)
35 I '$D(GMTSRO)!($D(GMTSRO)&(+($G(GMTSRO))>0)) W:+GMTSMAX>1 !,"Resequence Components:",!
36 I '$D(GMTSRO)!($D(GMTSRO)&(+($G(GMTSRO))>0)) D:+GMTSMAX>1 DIS^GMTSRS1B(.ARY)
37 S GMTSNXT=$$ASK(.ARY)
38 F Q:$E(GMTSNXT,$L(GMTSNXT))'="," S GMTSNXT=$E(GMTSNXT,1,($L(GMTSNXT)-1))
39 K:+GMTSNXT'>0 ARY Q:+GMTSNXT'>0 S GMTSI=0 F GMTSI=1:1 Q:+($P(GMTSNXT,",",GMTSI))'>0 D
40 . N GMTSIN,GMTSOP,GMTS0,GMTS1 S GMTSIN=+($P(GMTSNXT,",",GMTSI))
41 . S GMTS=$G(ARY(GMTSIN)) Q:'$L(GMTS) S GMTS0=$G(ARY(GMTSIN,0)) Q:'$L(GMTS0)
42 . S GMTSOP=+($O(OPA(" "),-1))+1,OPA(GMTSOP)=GMTS,OPA(GMTSOP,0)=GMTS0
43 . S (GMTSC,GMTSS)=0 F S GMTSS=$O(ARY(GMTSIN,GMTSS)) Q:+GMTSS=0 D
44 . . I $L($G(ARY(GMTSIN,GMTSS))) D
45 . . . S GMTSC=+GMTSC+1,OPA(GMTSOP,GMTSC)=ARY(GMTSIN,GMTSS)
46 . K ARY(GMTSIN)
47 Q
48 ;
49ASK(ARY,X) ; Ask for order of Components
50 N DIR,DTOUT,DUOUT,DIRUT,DIROUT,GMTSMAX,Y,GMTSF,GMTSI
51 S GMTSMAX=$$MAX(.ARY) Q:+GMTSMAX=1 1 Q:+GMTSMAX'>0 ""
52 F GMTSI=1:1:GMTSMAX S GMTSF=$G(GMTSF)_GMTSI_","
53 I $D(GMTSRO),+GMTSRO=0 S X=GMTSF Q X
54 S DIR(0)="LAO^1:"_GMTSMAX_":0"
55 S DIR("A")="Select next component(s)" S:GMTSMAX>1 DIR("A")=DIR("A")_" 1-"_GMTSMAX
56 S DIR("A")=DIR("A")_": ",DIR("B")=1 W ! D ^DIR
57 I $D(DTOUT)!($D(DUOUT))!($D(DIRUT))!($D(DIROUT)) K ARY S X=-1 Q X
58 S X=Y Q X
59 ;
60MAX(ARY,X) ; Maximum # Components
61 N GMTSI S (GMTSI,X)=0 F S GMTSI=$O(ARY(GMTSI)) Q:+GMTSI=0 S X=X+1
62 Q X
63 ;
64VER(INA,OPA,GMTST) ; Verify Resequence
65 I $D(GMTSRO),+GMTSRO=0 G VER2
66 N GMTSI1,GMTSI2,GMTSI,GMTSC,GMTSON,GMTSNN,GMTSCHG,GMTSVAL,GMTSEX
67 N GMTS3,GMTS4,X,Y,DIR,DTOUT,DUOUT,DIRUT,DIROUT,DA,DIK
68 S GMTSI1=+($G(GMTST)) Q:+GMTSI1=0 S (GMTSI,GMTSC,GMTSCHG)=0,(GMTSI,GMTSC)=0
69 F S GMTSI=$O(INA(GMTSI)) Q:+GMTSI=0 D
70 . S GMTSON=$P($G(INA(GMTSI,0)),"^",3),GMTSNN=$P($G(OPA(GMTSI,0)),"^",3) S:GMTSON'=GMTSNN GMTSCHG=1
71 I 'GMTSCHG,'$D(GMTSRO) W !,"No changes in the Health Summary Component sequence." G VER2
72 S GMTSI=0 F S GMTSI=$O(INA(GMTSI)) Q:+GMTSI=0 D
73 . S GMTSON=$G(INA(GMTSI)),GMTSNN=$G(OPA(GMTSI)) Q:'$L(GMTSON) Q:'$L(GMTSNN)
74 . S GMTSC=GMTSC+1 W:GMTSC=1 !!,?8,"Old Sequence",?40,"New Sequence",!,?8,"------------------------",?40,"------------------------"
75 . W !,$J(GMTSC,5),?8,GMTSON,?40,GMTSNN
76 S DIR(0)="YAO",DIR("A")="Is this Correct: (Y/N) ",DIR("B")="Y" W ! D ^DIR
77 I +($G(Y))'>0 W !,"Components not resequenced" Q
78VER2 S DA(2)=+($G(GMTST)) K ^GMT(142,DA(2),1)
79 S GMTSI1=0 F S GMTSI1=$O(OPA(GMTSI1)) Q:+GMTSI1=0 D
80 . S DA(1)=(+($G(GMTSI1)))*5,DA=0 S GMTSEX="S "_$G(OPA(GMTSI1,0)) X GMTSEX
81 . K ^GMT(142,"AE",+($P($G(OPA(GMTSI1,0)),"^",3)),GMTST)
82 . S GMTSI2=0 F S GMTSI2=$O(OPA(GMTSI1,GMTSI2)) Q:+GMTSI2=0 D
83 . . S DA=GMTSI2-1 S GMTSEX="S "_$G(OPA(GMTSI1,GMTSI2)) X GMTSEX
84 S (DA,GMTS3,GMTS4)=0 F S DA=$O(^GMT(142,DA(2),1,DA)) Q:+DA=0 S GMTS4=+($G(GMTS4))+1,GMTS3=DA
85 S ^GMT(142,DA(2),1,0)="^142.01IA^"_GMTS3_"^"_GMTS4
86 K DA S DA=+($G(GMTST)),DIK="^GMT(142," D IX1^DIK
87 Q
88 ; K ^GMT(142,"AE",GMTSCMP,GMTST)
89 ;
90LKT ; Lookup HS Type
91 N DIC,DIR,DTOUT,DUOUT,DIRUT,DIROUT,GMTSERR
92 ;
93LKT2 ; Re-prompt for Type
94 S GMTSERR=0,DIC="^GMT(142,",DIC("S")="I +($$ST^GMTSRS1)>0",DIC(0)="AEMQZF"
95 S DIC("A")="Select a Health Summary Type: "
96 D ^DIC I $D(DTOUT)!($D(DUOUT))!($D(DIRUT))!($D(DIROUT)) S Y=-1 Q
97 I +($G(GMTSERR))>0 D DTE(+($G(GMTSERR))) G LKT2
98 I +Y>0 D
99 . N X,DIC S X=$P(Y,"^",2),DIC="^GMT(142,",DIC(0)="M" D ^DIC
100 Q
101 ;
102ST(X) ; Screen for Type - Assumes Y
103 N GMTSY,GMTSO,GMTSS,GMTSU,GMTSKEY,GMTSLOCK,GMTSN0,GMTSMGR
104 S GMTSO=0,GMTSY=+($G(Y)) S:+GMTSY'>0 GMTSERR=1 Q:+GMTSY'>0 1
105 S GMTSN0=$G(^GMT(142,+GMTSY,0)) S:'$L(GMTSN0) GMTSERR=2 Q:'$L(GMTSN0) 1
106 S GMTSKEY=$P(GMTSN0,"^",2),GMTSU=$P(GMTSN0,"^",3)
107 S GMTSMGR=$S($D(^XUSEC("GMTSMGR",+($G(DUZ)))):1,1:0) S GMTSLOCK=0
108 S:$L(GMTSKEY) GMTSLOCK=$S($D(^XUSEC(GMTSKEY,+($G(DUZ)))):0,1:1)
109 S:$P(GMTSN0,"^",1)="GMTS HS ADHOC OPTION" GMTSERR=3 Q:$P(GMTSN0,"^",1)="GMTS HS ADHOC OPTION" 1
110 S:+($G(^GMT(142,+GMTSY,"VA")))>0 GMTSERR=6 Q:+($G(^GMT(142,+GMTSY,"VA")))>0 1
111 S (GMTSO,GMTSS)=0 F S GMTSS=$O(^GMT(142,+GMTSY,1,GMTSS)) Q:+GMTSS=0 D Q:GMTSO>1
112 . S GMTSO=+($G(GMTSO))+1
113 S X=GMTSO S:+X'>0 GMTSERR=7 S:+X=1 GMTSERR=8
114 Q 1
115 ;
116DTE(X) ; Display Type Error
117 I +($G(X))=1 W !!," No Health Summary Type selected.",! Q
118 I +($G(X))=2 W !!," Health Summary Type not found.",! Q
119 I +($G(X))=3 W !!," Can not resequence AD HOC Health Summary Type.",! Q
120 I +($G(X))=4 W !!," Health Summary Type LOCKED",! Q
121 I +($G(X))=5 W !!," Can not resequence a Health Summary Type you do not own.",! Q
122 I +($G(X))=6 W !!," Can not resequence a Nationally exported Health Summary Type.",! Q
123 I +($G(X))=7 W !!," Health Summary Type does not have any components." Q
124 I +($G(X))=8 W !!," Can not resequence, selected Health Summary Type only has",!," one (1) component.",! Q
125 Q
Note: See TracBrowser for help on using the repository browser.