source: WorldVistAEHR/trunk/r/SPINAL_CORD_DYSFUNCTION-SPN/SPNAHOCW.m@ 767

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

initial load of WorldVistAEHR

File size: 4.6 KB
Line 
1SPNAHOCW ;HISC/DAD-AD HOC REPORTS: MACRO EXPORT COMPILER ; [ 06/15/95 8:24 PM ]
2 ;;2.0;Spinal Cord Dysfunction;;01/02/1997
3 ;
4 W !,"=== Ad Hoc Report Macro Export Compiler ==="
5 I $$VFILE^DILFD(154.8)=0 D G EXIT
6 . W $C(7),!!?3,"The Ad Hoc Macro file does not exist !!"
7 . Q
8 D DT^DICRW,HOME^%ZIS,NOW^%DTC
9 S X=$J(%,0,6),SPNTODAY=$E(X,4,5)_"/"_$E(X,6,7)_"/"_$E(X,2,3)
10 S SPNTODAY=SPNTODAY_" "_$E(X,9,10)_":"_$E(X,11,12)
11 S SPNYESNO="Please answer Y(es) or N(o)."
12ROUTINE ; *** Macro routine
13 K DIR S DIR(0)="FAO^2:8^K:X'?1U1.7UN X",DIR("?")="^D EN^SPNAHOCH(""H6"")"
14 S DIR("A")="Ad Hoc Report Macro Routine: "
15 D ^DIR G:$D(DIRUT) EXIT S (SPNPROG,X)=Y
16 X ^%ZOSF("TEST") I D G EXIT:SPNREPLC=-1 I SPNREPLC=2 W ! G ROUTINE
17 . W !!?5,"*** ",SPNPROG," already exists !! ***",$C(7)
18 . F D Q:%
19 .. W !!?5,"Do you want to replace it"
20 .. S %=2 D YN^DICN S SPNREPLC=% I '% W !!?10,SPNYESNO
21 .. Q
22 . I SPNREPLC=1 F D Q:%
23 .. W !!?5,"Replace ",SPNPROG,", are you sure"
24 .. S %=2 D YN^DICN S SPNREPLC=% I '% W !!?10,SPNYESNO
25 .. Q
26 . Q
27MACRO ; *** Select macros
28 S SPNNUM=1,SPNQUIT=0 K ^TMP($J,"SPNMACRO")
29 F D Q:X=""!SPNQUIT
30 . W !!,$S(SPNNUM>1:"Another macro",1:"Select MACRO TO EXPORT")_": "
31 . R X:DTIME S:('$T)!($E(X)=U) SPNQUIT=1 Q:X=""!SPNQUIT
32 . I X?1"?".E D
33 .. W !
34 .. W !?5,"Select a macro name or number, to deselect a macro"
35 .. W !?5,"type a minus sign (-) in front of it, e.g., -MACRO."
36 .. W !?5,"Enter ALL to select all macros. ALL may be followed by"
37 .. W !?5,"SORT or PRINT to select only sort/print macros. ALL"
38 .. W !?5,"may also be followed by FILE to select macros for a"
39 .. W !?5,"particular file. Or, use any combination of the above."
40 .. W !?5,"Use an asterisk (*) to do a wildcard selection, e.g., MACRO*"
41 .. W !
42 .. I $O(^TMP($J,"SPNMACRO",""))]"" D
43 ... W !,"You have already selected:"
44 ... N SPNQUIT,X S SPNLN=$Y,SPNQUIT=0,SPNMACRO=""
45 ... F S SPNMACRO=$O(^TMP($J,"SPNMACRO",SPNMACRO)) Q:SPNMACRO=""!SPNQUIT S SPND0=0 F S SPND0=$O(^TMP($J,"SPNMACRO",SPNMACRO,SPND0)) Q:SPND0'>0!SPNQUIT W !?3,SPND0," ",SPNMACRO D ID^SPNAHOCV(SPND0) I $Y>(IOSL+SPNLN-3) D
46 .... K DIR S DIR(0)="E" D ^DIR S SPNQUIT=$S(Y'>0:1,1:0),SPNLN=$Y
47 .... Q
48 ... Q
49 .. Q
50 . S SPNDSEL=$S(X?1"-".E:1,1:0) S:SPNDSEL X=$E(X,2,$L(X))
51 . I $E($$U^SPNAHOCY(X),1,3)="ALL"!(X["*") S SPNALL=0 D ASKALL I SPNALL Q
52 . K DIC S DIC="^SPNL(154.8,",DIC(0)="EMNQZ",DIC("W")="D ID^SPNAHOCV(+Y)"
53 . D ^DIC K DIC Q:+Y'>0
54 . I 'SPNDSEL,'$D(^TMP($J,"SPNMACRO",Y(0,0),+Y)) D TMP(Y(0,0),+Y,1)
55 . I SPNDSEL,$D(^TMP($J,"SPNMACRO",Y(0,0),+Y)) D TMP(Y(0,0),+Y,0)
56 . Q
57 I $O(^TMP($J,"SPNMACRO",""))=""!SPNQUIT G EXIT
58 W !
59BUILD ; *** Build the macro export routine(s)
60 D BUILD^SPNAHOCV
61EXIT ; *** Exit
62 K %,DIC,DIE,DIR,DIROUT,DIRUT,DTOUT,SP,SPN,SPNAFLAG,SPNALL,SPND0,SPND1
63 K SPNDIC,SPNDONE,SPNDSEL,SPNFFLAG,SPNLEN,SPNLN,SPNMACRO,SPNNAME,SPNNUM
64 K SPNPATRN,SPNPFILE,SPNPFLAG,SPNPROG,SPNQUIT,SPNREPLC,SPNRTN,SPNRTNNO
65 K SPNRTNXT,SPNSFLAG,SPNTAB,SPNTODAY,SPNTYPE,SPNUTIL,SPNWFLAG,SPNYESNO
66 K X,XCN,Y,^TMP($J,"SPNROU")
67 Q
68ASKALL ; *** All macros?
69 S SP=X N X S X=$$U^SPNAHOCY(SP),SPNWFLAG=(X["*")
70 S SPNAFLAG=(X="ALL"),SPNFFLAG=(X["FILE")
71 S SPNSFLAG=(X["SORT"),SPNPFLAG=(X["PRINT")
72 I 'SPNWFLAG D W:%=2 !!,SP Q:%'=1
73 . F D Q:%
74 .. W !!?5,"By '",X,"' do you mean all "
75 .. W:SPNSFLAG "sort" W:SPNSFLAG&SPNPFLAG " & " W:SPNPFLAG "print"
76 .. W !?5,"macros" W:SPNFFLAG " for a particular file"
77 .. S %=2 D YN^DICN I '% W !!?10,SPNYESNO
78 .. Q
79 . Q
80 E D
81 . S SPNPATRN="SPNNAME?",SPN=""
82 . F Y=1:1:$L(SP,"*") D
83 .. S SPN=$P(SP,"*",Y) I SPN]"" S SPNPATRN=SPNPATRN_"1"""_SPN_""""
84 .. S X=$E(SP,$L($P(SP,"*",1,Y))+1),SPN=$L(SPNPATRN)
85 .. I X="*",$E(SPNPATRN,SPN-1,SPN)'=".E" S SPNPATRN=SPNPATRN_".E"
86 .. Q
87 . Q
88 S SPNPFILE=""
89 I SPNFFLAG,'SPNWFLAG D I SPNPFILE'>0 W !!,SP Q
90 . K DIC S DIC="^DIC(",DIC(0)="AEMNQZ",DIC("A")="Select FILE: "
91 . W ! D ^DIC S SPNPFILE=+Y
92 . Q
93 S SPND0=0,SPNALL=1
94 F S SPND0=$O(^SPNL(154.8,SPND0)) Q:SPND0'>0 D
95 . S SPN=$G(^SPNL(154.8,SPND0,0)) Q:SPN=""
96 . S SPNNAME=$P(SPN,U),SPNTYPE=$P(SPN,U,2),SPNPFILE(0)=$P(SPN,U,3)
97 . I SPNWFLAG,@SPNPATRN D TMP(SPNNAME,SPND0,'SPNDSEL)
98 . I SPNWFLAG Q
99 . I SPNAFLAG D TMP(SPNNAME,SPND0,'SPNDSEL) Q
100 . I SPNFFLAG,SPNPFILE=SPNPFILE(0) D Q
101 .. I SPNSFLAG,SPNTYPE="s" D TMP(SPNNAME,SPND0,'SPNDSEL)
102 .. I SPNPFLAG,SPNTYPE="p" D TMP(SPNNAME,SPND0,'SPNDSEL)
103 .. I 'SPNSFLAG,'SPNPFLAG D TMP(SPNNAME,SPND0,'SPNDSEL)
104 .. Q
105 . I 'SPNFFLAG,SPNSFLAG,SPNTYPE="s" D TMP(SPNNAME,SPND0,'SPNDSEL)
106 . I 'SPNFFLAG,SPNPFLAG,SPNTYPE="p" D TMP(SPNNAME,SPND0,'SPNDSEL)
107 . Q
108 Q
109TMP(X,Y,Z) ; *** Set/Kill ^TMP
110 I Z,'$D(^TMP($J,"SPNMACRO",X,Y)) D
111 . S ^TMP($J,"SPNMACRO",X,Y)="",SPNNUM=SPNNUM+1
112 . Q
113 I 'Z,$D(^TMP($J,"SPNMACRO",X,Y)) D
114 . K ^TMP($J,"SPNMACRO",X,Y) S SPNNUM=SPNNUM-$S(SPNNUM>0:1,1:0)
115 . Q
116 Q
Note: See TracBrowser for help on using the repository browser.