GMTSRS1 ; SLC/KER - Component Structure Resequence ; 02/11/2003
;;2.7;Health Summary;**62**;Oct 20, 1995
;
; External References
; DBIA 10076 ^XUSEC(
; DBIA 10076 ^XUSEC("GMTSMGR"
; DBIA 10026 ^DIR
; DBIA 10006 ^DIC (file #142)
; DBIA 2054 $$CREF^DILF
; DBIA 10013 IX1^DIK
;
; This routine will resequence the Health Summary Components
; in the structure (sub-file 142.01) of a Health Summary
; Type (file 142)
;
EN ; Main Entry Point
N DA,DIK,GMTST,GMTSS,GMTSERR,X,Y
W !,"Resequence the Components of a Health Summary Type.",!
D LKT I +Y'>0 W !,"Health Summary Type not selected ",! Q
S GMTST=+Y,DA(1)=GMTST D RCS K DA S DA=GMTST,DIK="^GMT(142," D IX1^DIK
Q
;
RCS ; Resequence Component Structure - Needs DA array
N ARY,INA,OPA,GMTST,GMTSINM,GMTSMAX K ARY,INA,OPA D INA^GMTSRS1B(DA(1),.ARY)
S GMTSINM=$$MAX(.ARY) I +GMTSINM'>0 W !,"Can not resequence, no components found." Q
I +GMTSINM'>1 W !,"Resequencing not required (1 component)" Q
F D RESEQ(.ARY) Q:'$D(ARY)
S GMTSMAX=$$MAX(.OPA) I +GMTSINM'=+GMTSMAX W !,"Component structure not resequenced (sequence not fully specified)" Q
D:+GMTSMAX>0 VER(.INA,.OPA,DA(1))
Q
;
RESEQ(ARY) ; Resequence - .ARY
N GMTSNXT,GMTSI,GMTSIN,GMTSOP,GMTS,GMTS0,GMTS1,GMTSS,GMTSC,GMTSMAX
D RES^GMTSRS1B(.ARY) S GMTSMAX=$$MAX(.ARY)
I '$D(GMTSRO)!($D(GMTSRO)&(+($G(GMTSRO))>0)) W:+GMTSMAX>1 !,"Resequence Components:",!
I '$D(GMTSRO)!($D(GMTSRO)&(+($G(GMTSRO))>0)) D:+GMTSMAX>1 DIS^GMTSRS1B(.ARY)
S GMTSNXT=$$ASK(.ARY)
F Q:$E(GMTSNXT,$L(GMTSNXT))'="," S GMTSNXT=$E(GMTSNXT,1,($L(GMTSNXT)-1))
K:+GMTSNXT'>0 ARY Q:+GMTSNXT'>0 S GMTSI=0 F GMTSI=1:1 Q:+($P(GMTSNXT,",",GMTSI))'>0 D
. N GMTSIN,GMTSOP,GMTS0,GMTS1 S GMTSIN=+($P(GMTSNXT,",",GMTSI))
. S GMTS=$G(ARY(GMTSIN)) Q:'$L(GMTS) S GMTS0=$G(ARY(GMTSIN,0)) Q:'$L(GMTS0)
. S GMTSOP=+($O(OPA(" "),-1))+1,OPA(GMTSOP)=GMTS,OPA(GMTSOP,0)=GMTS0
. S (GMTSC,GMTSS)=0 F S GMTSS=$O(ARY(GMTSIN,GMTSS)) Q:+GMTSS=0 D
. . I $L($G(ARY(GMTSIN,GMTSS))) D
. . . S GMTSC=+GMTSC+1,OPA(GMTSOP,GMTSC)=ARY(GMTSIN,GMTSS)
. K ARY(GMTSIN)
Q
;
ASK(ARY,X) ; Ask for order of Components
N DIR,DTOUT,DUOUT,DIRUT,DIROUT,GMTSMAX,Y,GMTSF,GMTSI
S GMTSMAX=$$MAX(.ARY) Q:+GMTSMAX=1 1 Q:+GMTSMAX'>0 ""
F GMTSI=1:1:GMTSMAX S GMTSF=$G(GMTSF)_GMTSI_","
I $D(GMTSRO),+GMTSRO=0 S X=GMTSF Q X
S DIR(0)="LAO^1:"_GMTSMAX_":0"
S DIR("A")="Select next component(s)" S:GMTSMAX>1 DIR("A")=DIR("A")_" 1-"_GMTSMAX
S DIR("A")=DIR("A")_": ",DIR("B")=1 W ! D ^DIR
I $D(DTOUT)!($D(DUOUT))!($D(DIRUT))!($D(DIROUT)) K ARY S X=-1 Q X
S X=Y Q X
;
MAX(ARY,X) ; Maximum # Components
N GMTSI S (GMTSI,X)=0 F S GMTSI=$O(ARY(GMTSI)) Q:+GMTSI=0 S X=X+1
Q X
;
VER(INA,OPA,GMTST) ; Verify Resequence
I $D(GMTSRO),+GMTSRO=0 G VER2
N GMTSI1,GMTSI2,GMTSI,GMTSC,GMTSON,GMTSNN,GMTSCHG,GMTSVAL,GMTSEX
N GMTS3,GMTS4,X,Y,DIR,DTOUT,DUOUT,DIRUT,DIROUT,DA,DIK
S GMTSI1=+($G(GMTST)) Q:+GMTSI1=0 S (GMTSI,GMTSC,GMTSCHG)=0,(GMTSI,GMTSC)=0
F S GMTSI=$O(INA(GMTSI)) Q:+GMTSI=0 D
. S GMTSON=$P($G(INA(GMTSI,0)),"^",3),GMTSNN=$P($G(OPA(GMTSI,0)),"^",3) S:GMTSON'=GMTSNN GMTSCHG=1
I 'GMTSCHG,'$D(GMTSRO) W !,"No changes in the Health Summary Component sequence." G VER2
S GMTSI=0 F S GMTSI=$O(INA(GMTSI)) Q:+GMTSI=0 D
. S GMTSON=$G(INA(GMTSI)),GMTSNN=$G(OPA(GMTSI)) Q:'$L(GMTSON) Q:'$L(GMTSNN)
. S GMTSC=GMTSC+1 W:GMTSC=1 !!,?8,"Old Sequence",?40,"New Sequence",!,?8,"------------------------",?40,"------------------------"
. W !,$J(GMTSC,5),?8,GMTSON,?40,GMTSNN
S DIR(0)="YAO",DIR("A")="Is this Correct: (Y/N) ",DIR("B")="Y" W ! D ^DIR
I +($G(Y))'>0 W !,"Components not resequenced" Q
VER2 S DA(2)=+($G(GMTST)) K ^GMT(142,DA(2),1)
S GMTSI1=0 F S GMTSI1=$O(OPA(GMTSI1)) Q:+GMTSI1=0 D
. S DA(1)=(+($G(GMTSI1)))*5,DA=0 S GMTSEX="S "_$G(OPA(GMTSI1,0)) X GMTSEX
. K ^GMT(142,"AE",+($P($G(OPA(GMTSI1,0)),"^",3)),GMTST)
. S GMTSI2=0 F S GMTSI2=$O(OPA(GMTSI1,GMTSI2)) Q:+GMTSI2=0 D
. . S DA=GMTSI2-1 S GMTSEX="S "_$G(OPA(GMTSI1,GMTSI2)) X GMTSEX
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
S ^GMT(142,DA(2),1,0)="^142.01IA^"_GMTS3_"^"_GMTS4
K DA S DA=+($G(GMTST)),DIK="^GMT(142," D IX1^DIK
Q
; K ^GMT(142,"AE",GMTSCMP,GMTST)
;
LKT ; Lookup HS Type
N DIC,DIR,DTOUT,DUOUT,DIRUT,DIROUT,GMTSERR
;
LKT2 ; Re-prompt for Type
S GMTSERR=0,DIC="^GMT(142,",DIC("S")="I +($$ST^GMTSRS1)>0",DIC(0)="AEMQZF"
S DIC("A")="Select a Health Summary Type: "
D ^DIC I $D(DTOUT)!($D(DUOUT))!($D(DIRUT))!($D(DIROUT)) S Y=-1 Q
I +($G(GMTSERR))>0 D DTE(+($G(GMTSERR))) G LKT2
I +Y>0 D
. N X,DIC S X=$P(Y,"^",2),DIC="^GMT(142,",DIC(0)="M" D ^DIC
Q
;
ST(X) ; Screen for Type - Assumes Y
N GMTSY,GMTSO,GMTSS,GMTSU,GMTSKEY,GMTSLOCK,GMTSN0,GMTSMGR
S GMTSO=0,GMTSY=+($G(Y)) S:+GMTSY'>0 GMTSERR=1 Q:+GMTSY'>0 1
S GMTSN0=$G(^GMT(142,+GMTSY,0)) S:'$L(GMTSN0) GMTSERR=2 Q:'$L(GMTSN0) 1
S GMTSKEY=$P(GMTSN0,"^",2),GMTSU=$P(GMTSN0,"^",3)
S GMTSMGR=$S($D(^XUSEC("GMTSMGR",+($G(DUZ)))):1,1:0) S GMTSLOCK=0
S:$L(GMTSKEY) GMTSLOCK=$S($D(^XUSEC(GMTSKEY,+($G(DUZ)))):0,1:1)
S:$P(GMTSN0,"^",1)="GMTS HS ADHOC OPTION" GMTSERR=3 Q:$P(GMTSN0,"^",1)="GMTS HS ADHOC OPTION" 1
S:+($G(^GMT(142,+GMTSY,"VA")))>0 GMTSERR=6 Q:+($G(^GMT(142,+GMTSY,"VA")))>0 1
S (GMTSO,GMTSS)=0 F S GMTSS=$O(^GMT(142,+GMTSY,1,GMTSS)) Q:+GMTSS=0 D Q:GMTSO>1
. S GMTSO=+($G(GMTSO))+1
S X=GMTSO S:+X'>0 GMTSERR=7 S:+X=1 GMTSERR=8
Q 1
;
DTE(X) ; Display Type Error
I +($G(X))=1 W !!," No Health Summary Type selected.",! Q
I +($G(X))=2 W !!," Health Summary Type not found.",! Q
I +($G(X))=3 W !!," Can not resequence AD HOC Health Summary Type.",! Q
I +($G(X))=4 W !!," Health Summary Type LOCKED",! Q
I +($G(X))=5 W !!," Can not resequence a Health Summary Type you do not own.",! Q
I +($G(X))=6 W !!," Can not resequence a Nationally exported Health Summary Type.",! Q
I +($G(X))=7 W !!," Health Summary Type does not have any components." Q
I +($G(X))=8 W !!," Can not resequence, selected Health Summary Type only has",!," one (1) component.",! Q
Q
--- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HGMTSRS1 6212 printed Dec 13, 2024@02:00:18 Page 2
GMTSRS1 ; SLC/KER - Component Structure Resequence ; 02/11/2003
+1 ;;2.7;Health Summary;**62**;Oct 20, 1995
+2 ;
+3 ; External References
+4 ; DBIA 10076 ^XUSEC(
+5 ; DBIA 10076 ^XUSEC("GMTSMGR"
+6 ; DBIA 10026 ^DIR
+7 ; DBIA 10006 ^DIC (file #142)
+8 ; DBIA 2054 $$CREF^DILF
+9 ; DBIA 10013 IX1^DIK
+10 ;
+11 ; This routine will resequence the Health Summary Components
+12 ; in the structure (sub-file 142.01) of a Health Summary
+13 ; Type (file 142)
+14 ;
EN ; Main Entry Point
+1 NEW DA,DIK,GMTST,GMTSS,GMTSERR,X,Y
+2 WRITE !,"Resequence the Components of a Health Summary Type.",!
+3 DO LKT
IF +Y'>0
WRITE !,"Health Summary Type not selected ",!
QUIT
+4 SET GMTST=+Y
SET DA(1)=GMTST
DO RCS
KILL DA
SET DA=GMTST
SET DIK="^GMT(142,"
DO IX1^DIK
+5 QUIT
+6 ;
RCS ; Resequence Component Structure - Needs DA array
+1 NEW ARY,INA,OPA,GMTST,GMTSINM,GMTSMAX
KILL ARY,INA,OPA
DO INA^GMTSRS1B(DA(1),.ARY)
+2 SET GMTSINM=$$MAX(.ARY)
IF +GMTSINM'>0
WRITE !,"Can not resequence, no components found."
QUIT
+3 IF +GMTSINM'>1
WRITE !,"Resequencing not required (1 component)"
QUIT
+4 FOR
DO RESEQ(.ARY)
if '$DATA(ARY)
QUIT
+5 SET GMTSMAX=$$MAX(.OPA)
IF +GMTSINM'=+GMTSMAX
WRITE !,"Component structure not resequenced (sequence not fully specified)"
QUIT
+6 if +GMTSMAX>0
DO VER(.INA,.OPA,DA(1))
+7 QUIT
+8 ;
RESEQ(ARY) ; Resequence - .ARY
+1 NEW GMTSNXT,GMTSI,GMTSIN,GMTSOP,GMTS,GMTS0,GMTS1,GMTSS,GMTSC,GMTSMAX
+2 DO RES^GMTSRS1B(.ARY)
SET GMTSMAX=$$MAX(.ARY)
+3 IF '$DATA(GMTSRO)!($DATA(GMTSRO)&(+($GET(GMTSRO))>0))
if +GMTSMAX>1
WRITE !,"Resequence Components:",!
+4 IF '$DATA(GMTSRO)!($DATA(GMTSRO)&(+($GET(GMTSRO))>0))
if +GMTSMAX>1
DO DIS^GMTSRS1B(.ARY)
+5 SET GMTSNXT=$$ASK(.ARY)
+6 FOR
if $EXTRACT(GMTSNXT,$LENGTH(GMTSNXT))'=","
QUIT
SET GMTSNXT=$EXTRACT(GMTSNXT,1,($LENGTH(GMTSNXT)-1))
+7 if +GMTSNXT'>0
KILL ARY
if +GMTSNXT'>0
QUIT
SET GMTSI=0
FOR GMTSI=1:1
if +($PIECE(GMTSNXT,",",GMTSI))'>0
QUIT
Begin DoDot:1
+8 NEW GMTSIN,GMTSOP,GMTS0,GMTS1
SET GMTSIN=+($PIECE(GMTSNXT,",",GMTSI))
+9 SET GMTS=$GET(ARY(GMTSIN))
if '$LENGTH(GMTS)
QUIT
SET GMTS0=$GET(ARY(GMTSIN,0))
if '$LENGTH(GMTS0)
QUIT
+10 SET GMTSOP=+($ORDER(OPA(" "),-1))+1
SET OPA(GMTSOP)=GMTS
SET OPA(GMTSOP,0)=GMTS0
+11 SET (GMTSC,GMTSS)=0
FOR
SET GMTSS=$ORDER(ARY(GMTSIN,GMTSS))
if +GMTSS=0
QUIT
Begin DoDot:2
+12 IF $LENGTH($GET(ARY(GMTSIN,GMTSS)))
Begin DoDot:3
+13 SET GMTSC=+GMTSC+1
SET OPA(GMTSOP,GMTSC)=ARY(GMTSIN,GMTSS)
End DoDot:3
End DoDot:2
+14 KILL ARY(GMTSIN)
End DoDot:1
+15 QUIT
+16 ;
ASK(ARY,X) ; Ask for order of Components
+1 NEW DIR,DTOUT,DUOUT,DIRUT,DIROUT,GMTSMAX,Y,GMTSF,GMTSI
+2 SET GMTSMAX=$$MAX(.ARY)
if +GMTSMAX=1
QUIT 1
if +GMTSMAX'>0
QUIT ""
+3 FOR GMTSI=1:1:GMTSMAX
SET GMTSF=$GET(GMTSF)_GMTSI_","
+4 IF $DATA(GMTSRO)
IF +GMTSRO=0
SET X=GMTSF
QUIT X
+5 SET DIR(0)="LAO^1:"_GMTSMAX_":0"
+6 SET DIR("A")="Select next component(s)"
if GMTSMAX>1
SET DIR("A")=DIR("A")_" 1-"_GMTSMAX
+7 SET DIR("A")=DIR("A")_": "
SET DIR("B")=1
WRITE !
DO ^DIR
+8 IF $DATA(DTOUT)!($DATA(DUOUT))!($DATA(DIRUT))!($DATA(DIROUT))
KILL ARY
SET X=-1
QUIT X
+9 SET X=Y
QUIT X
+10 ;
MAX(ARY,X) ; Maximum # Components
+1 NEW GMTSI
SET (GMTSI,X)=0
FOR
SET GMTSI=$ORDER(ARY(GMTSI))
if +GMTSI=0
QUIT
SET X=X+1
+2 QUIT X
+3 ;
VER(INA,OPA,GMTST) ; Verify Resequence
+1 IF $DATA(GMTSRO)
IF +GMTSRO=0
GOTO VER2
+2 NEW GMTSI1,GMTSI2,GMTSI,GMTSC,GMTSON,GMTSNN,GMTSCHG,GMTSVAL,GMTSEX
+3 NEW GMTS3,GMTS4,X,Y,DIR,DTOUT,DUOUT,DIRUT,DIROUT,DA,DIK
+4 SET GMTSI1=+($GET(GMTST))
if +GMTSI1=0
QUIT
SET (GMTSI,GMTSC,GMTSCHG)=0
SET (GMTSI,GMTSC)=0
+5 FOR
SET GMTSI=$ORDER(INA(GMTSI))
if +GMTSI=0
QUIT
Begin DoDot:1
+6 SET GMTSON=$PIECE($GET(INA(GMTSI,0)),"^",3)
SET GMTSNN=$PIECE($GET(OPA(GMTSI,0)),"^",3)
if GMTSON'=GMTSNN
SET GMTSCHG=1
End DoDot:1
+7 IF 'GMTSCHG
IF '$DATA(GMTSRO)
WRITE !,"No changes in the Health Summary Component sequence."
GOTO VER2
+8 SET GMTSI=0
FOR
SET GMTSI=$ORDER(INA(GMTSI))
if +GMTSI=0
QUIT
Begin DoDot:1
+9 SET GMTSON=$GET(INA(GMTSI))
SET GMTSNN=$GET(OPA(GMTSI))
if '$LENGTH(GMTSON)
QUIT
if '$LENGTH(GMTSNN)
QUIT
+10 SET GMTSC=GMTSC+1
if GMTSC=1
WRITE !!,?8,"Old Sequence",?40,"New Sequence",!,?8,"------------------------",?40,"------------------------"
+11 WRITE !,$JUSTIFY(GMTSC,5),?8,GMTSON,?40,GMTSNN
End DoDot:1
+12 SET DIR(0)="YAO"
SET DIR("A")="Is this Correct: (Y/N) "
SET DIR("B")="Y"
WRITE !
DO ^DIR
+13 IF +($GET(Y))'>0
WRITE !,"Components not resequenced"
QUIT
VER2 SET DA(2)=+($GET(GMTST))
KILL ^GMT(142,DA(2),1)
+1 SET GMTSI1=0
FOR
SET GMTSI1=$ORDER(OPA(GMTSI1))
if +GMTSI1=0
QUIT
Begin DoDot:1
+2 SET DA(1)=(+($GET(GMTSI1)))*5
SET DA=0
SET GMTSEX="S "_$GET(OPA(GMTSI1,0))
XECUTE GMTSEX
+3 KILL ^GMT(142,"AE",+($PIECE($GET(OPA(GMTSI1,0)),"^",3)),GMTST)
+4 SET GMTSI2=0
FOR
SET GMTSI2=$ORDER(OPA(GMTSI1,GMTSI2))
if +GMTSI2=0
QUIT
Begin DoDot:2
+5 SET DA=GMTSI2-1
SET GMTSEX="S "_$GET(OPA(GMTSI1,GMTSI2))
XECUTE GMTSEX
End DoDot:2
End DoDot:1
+6 SET (DA,GMTS3,GMTS4)=0
FOR
SET DA=$ORDER(^GMT(142,DA(2),1,DA))
if +DA=0
QUIT
SET GMTS4=+($GET(GMTS4))+1
SET GMTS3=DA
+7 SET ^GMT(142,DA(2),1,0)="^142.01IA^"_GMTS3_"^"_GMTS4
+8 KILL DA
SET DA=+($GET(GMTST))
SET DIK="^GMT(142,"
DO IX1^DIK
+9 QUIT
+10 ; K ^GMT(142,"AE",GMTSCMP,GMTST)
+11 ;
LKT ; Lookup HS Type
+1 NEW DIC,DIR,DTOUT,DUOUT,DIRUT,DIROUT,GMTSERR
+2 ;
LKT2 ; Re-prompt for Type
+1 SET GMTSERR=0
SET DIC="^GMT(142,"
SET DIC("S")="I +($$ST^GMTSRS1)>0"
SET DIC(0)="AEMQZF"
+2 SET DIC("A")="Select a Health Summary Type: "
+3 DO ^DIC
IF $DATA(DTOUT)!($DATA(DUOUT))!($DATA(DIRUT))!($DATA(DIROUT))
SET Y=-1
QUIT
+4 IF +($GET(GMTSERR))>0
DO DTE(+($GET(GMTSERR)))
GOTO LKT2
+5 IF +Y>0
Begin DoDot:1
+6 NEW X,DIC
SET X=$PIECE(Y,"^",2)
SET DIC="^GMT(142,"
SET DIC(0)="M"
DO ^DIC
End DoDot:1
+7 QUIT
+8 ;
ST(X) ; Screen for Type - Assumes Y
+1 NEW GMTSY,GMTSO,GMTSS,GMTSU,GMTSKEY,GMTSLOCK,GMTSN0,GMTSMGR
+2 SET GMTSO=0
SET GMTSY=+($GET(Y))
if +GMTSY'>0
SET GMTSERR=1
if +GMTSY'>0
QUIT 1
+3 SET GMTSN0=$GET(^GMT(142,+GMTSY,0))
if '$LENGTH(GMTSN0)
SET GMTSERR=2
if '$LENGTH(GMTSN0)
QUIT 1
+4 SET GMTSKEY=$PIECE(GMTSN0,"^",2)
SET GMTSU=$PIECE(GMTSN0,"^",3)
+5 SET GMTSMGR=$SELECT($DATA(^XUSEC("GMTSMGR",+($GET(DUZ)))):1,1:0)
SET GMTSLOCK=0
+6 if $LENGTH(GMTSKEY)
SET GMTSLOCK=$SELECT($DATA(^XUSEC(GMTSKEY,+($GET(DUZ)))):0,1:1)
+7 if $PIECE(GMTSN0,"^",1)="GMTS HS ADHOC OPTION"
SET GMTSERR=3
if $PIECE(GMTSN0,"^",1)="GMTS HS ADHOC OPTION"
QUIT 1
+8 if +($GET(^GMT(142,+GMTSY,"VA")))>0
SET GMTSERR=6
if +($GET(^GMT(142,+GMTSY,"VA")))>0
QUIT 1
+9 SET (GMTSO,GMTSS)=0
FOR
SET GMTSS=$ORDER(^GMT(142,+GMTSY,1,GMTSS))
if +GMTSS=0
QUIT
Begin DoDot:1
+10 SET GMTSO=+($GET(GMTSO))+1
End DoDot:1
if GMTSO>1
QUIT
+11 SET X=GMTSO
if +X'>0
SET GMTSERR=7
if +X=1
SET GMTSERR=8
+12 QUIT 1
+13 ;
DTE(X) ; Display Type Error
+1 IF +($GET(X))=1
WRITE !!," No Health Summary Type selected.",!
QUIT
+2 IF +($GET(X))=2
WRITE !!," Health Summary Type not found.",!
QUIT
+3 IF +($GET(X))=3
WRITE !!," Can not resequence AD HOC Health Summary Type.",!
QUIT
+4 IF +($GET(X))=4
WRITE !!," Health Summary Type LOCKED",!
QUIT
+5 IF +($GET(X))=5
WRITE !!," Can not resequence a Health Summary Type you do not own.",!
QUIT
+6 IF +($GET(X))=6
WRITE !!," Can not resequence a Nationally exported Health Summary Type.",!
QUIT
+7 IF +($GET(X))=7
WRITE !!," Health Summary Type does not have any components."
QUIT
+8 IF +($GET(X))=8
WRITE !!," Can not resequence, selected Health Summary Type only has",!," one (1) component.",!
QUIT
+9 QUIT