source: FOIAVistA/trunk/r/SPINAL_CORD_DYSFUNCTION-SPN/SPNAHOC3.m@ 1352

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

initial load of FOIAVistA 6/30/08 version

File size: 4.9 KB
Line 
1SPNAHOC3 ;HISC/DAD-AD HOC REPORTS: MACRO MANAGEMENT ;9/9/96 08:42
2 ;;2.0;Spinal Cord Dysfunction;;01/02/1997
3 ;
4 S SPNSELOP=$E(SPNSELOP,2,$L(SPNSELOP))
5 S:SPNSELOP?1L SPNSELOP=$C($A(SPNSELOP)-32)
6 I "^S^L^I^D^O^"'[(U_SPNSELOP_U) S SPNSELOP=-1 Q
7 W $P($P("^Save^Load^Inquire^Delete^Output^",U_SPNSELOP,2),U)
8 W $S(SPNSELOP'="O":" "_SPNTYPE(0),1:"")," macro]"
9 I $$VFILE^DILFD(154.8)=0 D Q
10 . W $C(7),!!?3,"The Ad Hoc Macro file does not exist !!"
11 . S SPNSELOP=0 R SP:SPNDTIME
12 . Q
13 I SPNSELOP="S" D SETSAVE^SPNAHOC5 Q
14 I SPNSELOP="O" D EN1^SPNAHOC4 Q
15 D LOAD:SPNSELOP="L"
16 D INQUIRE:SPNSELOP="I"
17 D DELETE:SPNSELOP="D"
18 D UNLOCK(SPND0)
19 Q
20SAVE ; *** Save macro
21 D SAV,UNLOCK(SPND0)
22 Q
23SAV K DIC,SPNMACRO(SPNTYPE) S DIC(0)="AELMNQZ",DIC("A")="Save"
24 D ASKMAC Q:Y'>0
25 I $P(Y,U,3)'>0 W $C(7) D G SAVE:SPNREPLC=2 Q:SPNREPLC=-1
26 . F D Q:%
27 .. W !!?3,SPNTEMP," already exists, OK to replace"
28 .. S %=2 D YN^DICN S SPNREPLC=% I '% W !!?5,SPNYESNO
29 .. Q
30 . Q:%'=1
31 . S SPND1=0 F S SPND1=$O(^SPNL(154.8,SPND0,"FLD",SPND1)) Q:SPND1'>0 D
32 .. S (D0,DA(1))=SPND0,(D1,DA)=SPND1,DIK="^SPNL(154.8,"_SPND0_",""FLD"","
33 .. D ^DIK
34 .. Q
35 . Q
36 S (SPNFLDNO,SPNORDER,SPNOK)=0
37 F S SPNORDER=$O(SPNOPTN(SPNTYPE,SPNORDER)) Q:(SPNORDER'>0)!(SPNOK<0) S SPNFIELD=0 F S SPNFIELD=$O(SPNOPTN(SPNTYPE,SPNORDER,SPNFIELD)) Q:(SPNFIELD'>0)!(SPNOK<0) D
38 . I SPNTYPE="S" F D Q:SPNOK
39 .. W !!?3,"Ask user BEGINNING/ENDING values for "
40 .. W $P(SPNMENU(SPNFIELD),U,2) S %=2 D YN^DICN S SPNOK=%
41 .. I 'SPNOK W !!?5,SPNYESNO
42 .. Q
43 . Q:SPNOK<0
44 . S X=SPNPREFX(SPNTYPE,SPNORDER)_SPNFIELD_SPNSUFFX(SPNTYPE,SPNORDER)_U_SPNOPTN(SPNTYPE,SPNORDER,SPNFIELD)_U_$S(SPNTYPE="S":(SPNOK=1),1:"")
45 . S ^SPNL(154.8,SPND0,"FLD",SPNORDER,0)=X,SPNFLDNO=SPNFLDNO+1
46 . I SPNTYPE="S" S ^SPNL(154.8,SPND0,"FLD",SPNORDER,"FRTO")=$S(SPNOK=2:FR(SPNORDER)_U_TO(SPNORDER),1:U)
47 . E K ^SPNL(154.8,SPND0,"FLD",SPNORDER,"FRTO")
48 . Q
49 I SPNOK<0 D Q
50 . S DIK="^SPNL(154.8,",DA=SPND0 D ^DIK S SPNMSAVE=0
51 . W !!?3,"Sort macro ",SPNTEMP," not saved !! ",$C(7) R SP:SPNDTIME
52 . Q
53 S $P(^SPNL(154.8,SPND0,0),U,2,4)=$TR(SPNTYPE,"SP","sp")_U_SPNDIC_U_SPNCHKSM
54 S ^SPNL(154.8,SPND0,"FLD",0)=U_$$GET1^DID(154.8,1,"","SPECIFIER")_U_SPNFLDNO_U_SPNFLDNO
55 S DIK="^SPNL(154.8,",DA=SPND0 D IX1^DIK
56 S SPNMACRO(SPNTYPE)=SPNTEMP(SPNTYPE)
57 S $P(SPNMACRO(SPNTYPE),U,4)="SAVE"
58 Q
59LOAD ; *** Load macro
60 S SPNMLOAD=0 I SPNSEQ>1 D Q
61 . W !!?3,SPNTYPE(1)," macros may only be loaded at the first "
62 . W SPNTYPE(0)," selection prompt !! ",$C(7) R SP:SPNDTIME
63 . Q
64 K DIC,SPNMACRO(SPNTYPE) S DIC(0)="AEMNQZ",DIC("A")="Load"
65 D ASKMAC Q:Y'>0
66 S (SPNQUIT,SPNNEXT,SPNORDER)=0,SPNMLOAD=1 K:SPNTYPE="S" FR,TO
67 F S SPNORDER=$O(^SPNL(154.8,SPND0,"FLD",SPNORDER)) Q:SPNORDER'>0!SPNQUIT!SPNNEXT D
68 . S X=^SPNL(154.8,SPND0,"FLD",SPNORDER,0),X("FRTO")=$G(^("FRTO"))
69 . S X(1)=$P($P(X,U),";"),SPNFIELD=$TR(X(1),"&!+#-@'")
70 . S SP=$G(SPNMENU(+SPNFIELD))
71 . I SP=""!((SPNTYPE="S")&(SP'>0)) D Q
72 .. W !!?3,"Corrupted ",SPNTYPE(0)," macro !! ",$C(7)
73 .. R SP:SPNDTIME S SPNQUIT=1
74 .. Q
75 . S SPNOPTN(SPNTYPE,SPNSEQ,SPNFIELD)=$P(X,U,2)
76 . I SPNTYPE="S" D
77 .. I $P(X,U,3)'>0 D Q
78 ... S FR(SPNSEQ)=$P(X("FRTO"),U),TO(SPNSEQ)=$P(X("FRTO"),U,2)
79 ... Q
80 .. W !!?3,"Sort by: ",$P(SPNMENU(SPNFIELD),U,2)
81 .. S SPNDIR(0)=$P($P(SPNMENU(SPNFIELD),U,4,99),"|")
82 .. S SPNDIR("S")=$P(SPNMENU(SPNFIELD),"|",2)
83 .. D ^SPNAHOC2
84 .. Q
85 . S SPNSEQ=SPNSEQ+1
86 . Q
87 S SPNMACRO(SPNTYPE)=SPNTEMP(SPNTYPE)
88 S $P(SPNMACRO(SPNTYPE),U,4)="LOAD"
89 I SPNQUIT!SPNNEXT D
90 . S (SPNQUIT,SPNNEXT,SPNMLOAD)=0,SPNSEQ=1
91 . K SPNCHOSN,SPNMACRO(SPNTYPE),SPNOPTN(SPNTYPE) K:SPNTYPE="S" FR,TO
92 . Q
93 Q
94INQUIRE ; *** Inquire macro
95 K DIC S DIC(0)="AEMNQZ",DIC("A")="Inquire" D ASKMAC Q:Y'>0
96 S SPNORDER=0,SPNTYP=SPNTYPE,X=SPNTYPE(1)_" macro: "_SPNTEMP
97 W !!,X,!,$TR($E(SPNUNDL,1,$L(X)),"_","-")
98 S SPND1=0 F S SPND1=$O(^SPNL(154.8,SPND0,"FLD",SPND1)) Q:SPND1'>0 D
99 . S SP=^SPNL(154.8,SPND0,"FLD",SPND1,0),SPN=$G(^("FRTO"))
100 . S SPNORDER=SPNORDER+1,X(1)=$P(SP,U),SPNFIELD=$P(X(1),";")
101 . S SPNFIELD=$TR(SPNFIELD,"&!+#-@'") S:SPNFIELD'?1.N SPNFIELD=0
102 . F SPI=1,2 S X(SPI+1)=$S(SPNTYPE="P":"",$P(SP,U,3):"Ask User",$P(SPN,U,SPI)]"":$P(SPN,U,SPI),SPI=1:"Beginning",1:"Ending")
103 . D PRNTFLD^SPNAHOC4
104 . Q
105 I SPNTYPE="S" D SORTHDR^SPNAHOC4(SPND0)
106 I SPNTYPE="P" D PRNTHDR^SPNAHOC4(SPND0)
107 R !,SP:(2*SPNDTIME)
108 Q
109DELETE ; *** Delete macro
110 K DIC S DIC(0)="AEMNQZ",DIC("A")="Delete" D ASKMAC Q:Y'>0
111 F D Q:%
112 . W !!?3,"Delete ",SPNTEMP,", are you sure"
113 . S %=2 D YN^DICN I '% W !!?5,SPNYESNO
114 . Q
115 I %=1 S DIK="^SPNL(154.8,",DA=SPND0 D ^DIK K SPNMACRO(SPNTYPE)
116 Q
117ASKMAC ; *** Prompt for a macro name
118 S DIC="^SPNL(154.8,",DLAYGO=154.8
119 S DIC("A")=" "_DIC("A")_" "_SPNTYPE(0)_" macro name: "
120 S DIC("S")="I $P(^(0),U,2,4)="""
121 S DIC("S")=DIC("S")_$TR(SPNTYPE,"SP","sp")_U_SPNDIC_U_SPNCHKSM_""""
122 F D Q:SPND0
123 . W ! D ^DIC S SPND0=+Y Q:SPND0'>0
124 . S SPNTEMP=Y(0,0),SPNTEMP(SPNTYPE)=Y
125 . L +^SPNL(154.8,SPND0):0 I '$T D S SPND0=0
126 .. W !!?10,"Someone else is currently using this macro !!",$C(7)
127 .. Q
128 . Q
129 Q
130UNLOCK(Y) ; *** Unlock macro
131 I $G(Y) L -^SPNL(154.8,Y)
132 Q
Note: See TracBrowser for help on using the repository browser.