source: WorldVistAEHR/trunk/r/QUALITY_ASSURANCE_INTEGRATION-QAQ/QAQAHOC3.m@ 1710

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

initial load of WorldVistAEHR

File size: 7.7 KB
RevLine 
[613]1QAQAHOC3 ;HISC/DAD-AD HOC REPORTS: MACRO MANAGEMENT ;7/12/93 14:35
2 ;;1.7;QM Integration Module;**1,2,5**;07/25/1995
3 ;
4 S QAQSELOP=$E(QAQSELOP,2,999) S:QAQSELOP?1L QAQSELOP=$C($A(QAQSELOP)-32)
5 I "^S^L^I^D^O^"'[("^"_QAQSELOP_"^") S QAQSELOP=-1 Q
6 W $P($P("^Save^Load^Inquire^Delete^Output^","^"_QAQSELOP,2),"^")," ",$S(QAQSELOP'="O":QAQTYPE(0)_" ",1:""),"macro"
7 I $D(^QA(740.1,0))[0 W *7,!!?3,"The Ad Hoc Macro file does not exist !!" S QAQSELOP=0 R QA:QAQDTIME Q
8 D SETSAVE:QAQSELOP="S",LOAD:QAQSELOP="L",INQUIRE:QAQSELOP="I",DELETE:QAQSELOP="D",EN1^QAQAHOC4:QAQSELOP="O"
9 Q
10SETSAVE ; *** Set the save macro flag
11 S QAQMSAVE=1 W !!?3,"The macro will be saved when you exit the ",QAQTYPE(0)," menu. ",*7 I QAQSEQ=1 R QA:QAQDTIME Q
12SAVEOUT W !!?3,"OK to exit now" S %=1 D YN^DICN I '% W !!?5,QAQYESNO G SAVEOUT
13 S:%=1 QAQNEXT=1 S:%=-1 (QAQNEXT,QAQQUIT)=1
14 Q
15SAVE ; *** Save a sort/print macro
16 K DIC,QAQMACRO(QAQTYPE) S DIC(0)="AELMNQZ",DIC("A")="Save" D ASKMAC Q:Y'>0
17 I $P(Y,"^",3)'>0 W *7 D G SAVE:QAQREPLC=2 Q:QAQREPLC=-1
18REPLACE . W !!?3,QAQTEMP," already exists, OK to replace"
19 . S %=2 D YN^DICN S QAQREPLC=% I '% W !!?5,QAQYESNO G REPLACE
20 . Q:%'=1
21 . F QAQD1=0:0 S QAQD1=$O(^QA(740.1,QAQD0,"FLD",QAQD1)) Q:QAQD1'>0 D
22 .. S (D0,DA(1))=QAQD0,(D1,DA)=QAQD1,DIK="^QA(740.1,"_QAQD0_",""FLD"","
23 .. D ^DIK
24 .. Q
25 . Q
26 S (QAQFLDNO,%)=0
27 F QAQORDER=0:0 S QAQORDER=$O(QAQOPTN(QAQTYPE,QAQORDER)) Q:(QAQORDER'>0)!(%=-1) F QAQFIELD=0:0 S QAQFIELD=$O(QAQOPTN(QAQTYPE,QAQORDER,QAQFIELD)) Q:(QAQFIELD'>0)!(%=-1) D
28SV . I QAQTYPE="S" W !!?3,"Ask user BEGINNING/ENDING values for ",$P(QAQMENU(QAQFIELD),"^",2) S %=2 D YN^DICN Q:%=-1 I '% W !!?5,QAQYESNO G SV
29 . S X=QAQPREFX(QAQTYPE,QAQORDER)_QAQFIELD_QAQSUFFX(QAQTYPE,QAQORDER)_"^"_QAQOPTN(QAQTYPE,QAQORDER,QAQFIELD)_"^"_$S(QAQTYPE="S":(%=1),1:"")
30 . S ^QA(740.1,QAQD0,"FLD",QAQORDER,0)=X,QAQFLDNO=QAQFLDNO+1
31 . I QAQTYPE="S" S ^QA(740.1,QAQD0,"FLD",QAQORDER,"FRTO")=$S(%=2:QAQBEGIN(QAQORDER)_"^"_QAQEND(QAQORDER),1:"^")
32 . E K ^QA(740.1,QAQD0,"FLD",QAQORDER,"FRTO")
33 . Q
34 I %=-1 S DIK="^QA(740.1,",DA=QAQD0 D ^DIK S QAQMSAVE=0 W !!?3,"Sort macro ",QAQTEMP," not saved !! ",*7 R QA:QAQDTIME Q
35 S $P(^QA(740.1,QAQD0,0),"^",2,4)=$TR(QAQTYPE,"SP","sp")_"^"_QAQDIC_"^"_QAQCHKSM
36 S ^QA(740.1,QAQD0,"FLD",0)="^"_$P(^DD(740.1,1,0),"^",2)_"^"_QAQFLDNO_"^"_QAQFLDNO,DIK="^QA(740.1,",DA=QAQD0 D IX1^DIK
37 S QAQMACRO(QAQTYPE)=QAQTEMP(QAQTYPE)
38 Q
39LOAD ; *** Load a sort/print macro
40 S QAQMLOAD=0 I QAQSEQ>1 W !!?3,QAQTYPE(1)," macros may only be loaded at the first ",QAQTYPE(0)," selection prompt !! ",*7 R QA:QAQDTIME Q
41 K DIC,QAQMACRO(QAQTYPE) S DIC(0)="AEMNQZ",DIC("A")="Load" D ASKMAC Q:Y'>0
42 S (QAQQUIT,QAQNEXT)=0,QAQMLOAD=1
43 F QAQORDER=0:0 S QAQORDER=$O(^QA(740.1,QAQD0,"FLD",QAQORDER)) Q:QAQORDER'>0!QAQQUIT!QAQNEXT D
44 . S X=^QA(740.1,QAQD0,"FLD",QAQORDER,0),X("FRTO")=$G(^("FRTO"))
45 . S X(1)=$P($P(X,"^"),";"),QAQFIELD=$TR(X(1),"&!+#-@'")
46 . S QA=$G(QAQMENU(+QAQFIELD))
47 . I (QA="")!((QAQTYPE="S")&(QA'>0)) D Q
48 .. W !!?3,"Corrupted ",QAQTYPE(0)," macro !! ",*7
49 .. R QA:QAQDTIME S QAQQUIT=1
50 .. Q
51 . S QAQOPTN(QAQTYPE,QAQSEQ,QAQFIELD)=$P(X,"^",2)
52 . I QAQTYPE="S" D
53 .. I $P(X,"^",3)'>0 S FR(QAQSEQ)=$P(X("FRTO"),"^"),TO(QAQSEQ)=$P(X("FRTO"),"^",2) Q
54 .. W !!?3,"Sort by: ",$P(QAQMENU(QAQFIELD),"^",2)
55 .. S QAQDIR(0)=$P(QAQMENU(QAQFIELD),"^",4,99) D ^QAQAHOC2
56 .. Q
57 . S QAQSEQ=QAQSEQ+1
58 I QAQQUIT!QAQNEXT D Q
59 . S (QAQQUIT,QAQNEXT,QAQMLOAD)=0,QAQSEQ=1 K QAQCHOSN,QAQOPTN(QAQTYPE)
60 . I QAQTYPE="S" K QAQBEGIN,QAQEND
61 . Q
62 S QAQMACRO(QAQTYPE)=QAQTEMP(QAQTYPE)
63 Q
64INQUIRE ; *** Inquire a sort/print macro
65 K DIC S DIC(0)="AEMNQZ",DIC("A")="Inquire" D ASKMAC Q:Y'>0
66INQ2 ;entry point from DISPMAC
67 K QAQUNDL S $P(QAQUNDL,"_",81)="",QAQORDER=0
68 S X=QAQTYPE(1)_" macro: "_QAQTEMP W !!,X,!,$E(QAQUNDL,1,$L(X))
69 F QAQD1=0:0 S QAQD1=$O(^QA(740.1,QAQD0,"FLD",QAQD1)) Q:QAQD1'>0 D
70 . S QA=^QA(740.1,QAQD0,"FLD",QAQD1,0),QAQ=$G(^("FRTO"))
71 . S QAQORDER=QAQORDER+1,X(1)=$P(QA,"^"),QAQFIELD=$P(X(1),";")
72 . S QAQFIELD=$TR(QAQFIELD,"&!+#-@'") S:QAQFIELD'?1.N QAQFIELD=0
73 . F QAI=1,2 S X(QAI+1)=$S(QAQTYPE="P":"",$P(QA,"^",3):"Ask User",$P(QAQ,"^",QAI)]"":$P(QAQ,"^",QAI),QAI=1:"Beginning",1:"Ending")
74 . D PS1^QAQAHOC4:QAQTYPE="S",PP1^QAQAHOC4:QAQTYPE="P"
75 . Q
76 R !,QA:(2*QAQDTIME)
77 Q
78DELETE ; *** Delete a sort/print macro
79 K DIC S DIC(0)="AEMNQZ",DIC("A")="Delete" D ASKMAC Q:Y'>0
80DEL W !!?3,"Delete ",QAQTEMP,", are you sure" S %=2 D YN^DICN I '% W !!?5,QAQYESNO G DEL
81 I %=1 S DIK="^QA(740.1,",DA=QAQD0 D ^DIK
82 Q
83ASKMAC ; *** Prompt user for the name of a sort/print macro
84 S DIC="^QA(740.1,",DIC("A")=" "_DIC("A")_" "_QAQTYPE(0)_" macro name: ",DLAYGO=740.1
85 S DIC("S")="I $P(^(0),""^"",2,3)="""_$TR(QAQTYPE,"SP","sp")_"^"_QAQDIC_""""
86 W ! D ^DIC
87 I Y>0 S QAQD0=+Y,QAQTEMP=Y(0,0),QAQTEMP(QAQTYPE)=Y
88 I Y>0 I "^I^D^O^"[QAQSELOP Q
89 I Y>0 I $P(^QA(740.1,+Y,0),U,4)=QAQCHKSM Q ;S QAQD0=+Y,QAQTEMP=Y(0,0),QAQTEMP(QAQTYPE)=Y Q
90 I Y>0 I $P(^QA(740.1,+Y,0),U,4)'=QAQCHKSM D
91 . ;if the menu for the ad hoc report has been altered, the old checksum
92 . ;values in file 740.1 will not be the same as those calculated at
93 . ;the beginning of ^QAQAHOC0.
94 . I $P(^QA(740.1,+Y,0),U,4)']""!($G(QAQMSAVE)=1) Q ;S QAQD0=+Y,QAQTEMP=Y(0,0),QAQTEMP(QAQTYPE)=Y Q
95 . N DIRUT
96 . S DIR(0)="YAO"
97 . S DIR("A")="This macro is not current, would you like to review it? "
98 . S DIR("B")="YES"
99 . S DIR("?")="Enter 'Y' if you want to review this macro now."
100 . D ^DIR I Y=0!($D(DIRUT)) S Y=0 Q
101 . I Y=1 D DISPMAC
102 . Q
103 ;I Y'>0 Q
104 Q
105DISPMAC ;if user wants to review macro, display existing macro,
106 ; allow user to say it's okay, then update the checksum value
107 ; (set it to QAQCHKSM) or edit or start over
108 D INQ2
109 W !!
110 S DIR(0)="NAO^1:2"
111 S DIR("A")="Enter the number of your choice: "
112 S DIR("A",1)="Review the menu line"_$S("Pp"[QAQTYPE:" and ",1:", ")_"field name"_$S("Pp"[QAQTYPE:".",1:" and sort range.")
113 S DIR("A",2)=" Enter '1' if the macro displayed still reflects the desired report."
114 S DIR("A",3)=" Enter '2'if the macro is no longer valid."
115 K DIR("B")
116 S DIR("?",1)="Check the display of the macro. If it is still valid enter '1'."
117 S DIR("?",2)="If the macro is no longer valid enter '2'."
118 D ^DIR K DIR
119 I $D(DIRUT) S Y=0 Q
120 I Y=1 D UPDMAC
121 I Y=2 D EDITMAC^QAQAHOC5
122 Q
123UPDMAC ;ask user if want to update the macro, if yes, set piece 4 of the
124 ;macro's zero node to QAQCHKSM and check piece 2 of the "FLD" zero node
125 N QAQEE,QAQFLD
126 S DIR(0)="YOA"
127 S DIR("A")="Are you ready to update the "_QAQTEMP_" macro? "
128 S DIR("B")="YES"
129 S DIR=("?")="Enter 'Y' if the macro is valid and ready for updating."
130 D ^DIR K DIR
131 I $D(DIRUT)!(Y'=1) S Y=0 W !!,"Macro '"_QAQTEMP_"' not updated.",!! R X:5 Q
132 S $P(^QA(740.1,QAQD0,0),U,4)=QAQCHKSM ;update the checksum
133 ;then update the macro for field, sub-field settings
134 S QAQEE=0
135 F S QAQEE=$O(^QA(740.1,QAQD0,"FLD",QAQEE)) Q:QAQEE'>0 D
136 . S (QAQOUT,QAQPF,QAQPF1,QAQPF2,QAQPFALL,QAQPFEND,QAQPM,QAQPFQUL,QAQPM1,QAQPM2)=""
137 . S QAQFLD=$P($P(^QA(740.1,QAQD0,"FLD",QAQEE,0),U),";")
138 . I "'!@#&+-"[$E($G(QAQFLD)) D STRIP^QAQAHOC5
139 . ;will set several variables to compare the field setings in QAQMENU
140 . ;to the field settings in the macro, disregarding qualifiers
141 . ;QAQPF is the piece of the "FLD" node from file 740.1
142 . ;QAQPFEND is the format part of the field from 740.1 (2nd ";" piece)
143 . ;QAQPM is the is the field's piece from QAQMENU
144 . ;QAQPM1 is the 1st "~" piece of the "~" character in the QAQMENU line
145 . ;QAQPM2 is the 2nd "~ piece from QAQMENU
146 . ;QAQPF1 is the piece of QAQPF up to any qualifiers
147 . ;QAQPF2 is the piece of QAQPF after any qualifiers
148 . S QAQPF=$P($P(^QA(740.1,QAQD0,"FLD",QAQEE,0),U,2),";")
149 . S QAQPFEND=$P($P(^QA(740.1,QAQD0,"FLD",QAQEE,0),U,2),";",2,999)
150 . S QAQPM=$P($P(QAQMENU(QAQFLD),U,3),";")
151 . I $G(QAQPF)']""!($G(QAQPM)']"") S QAQOUT=1 Q
152 . S QAQPM1=$P(QAQPM,"~"),QAQPM2=$P(QAQPM,"~",2)
153 . D STRIP2^QAQAHOC5
154 I $G(QAQOUT)=1 W !!,"Macro incomplete, cannot update." Q
155 W !!,"Macro '"_QAQTEMP_"' updated.",!!
156 Q
Note: See TracBrowser for help on using the repository browser.