source: WorldVistAEHR/trunk/r/CLINICAL_REMINDERS-PXRM/PXRMEXID.m@ 1806

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

revised back to 6/30/08 version

File size: 7.2 KB
Line 
1PXRMEXID ;SLC/PJH - Reminder Dialog Exchange Install Routine.;11/14/2003
2 ;;2.0;CLINICAL REMINDERS;;Feb 04, 2005
3 ;
4 ;==================================================
5 ;
6 ;Install all dialog components in an exchange file entry
7 ;------------------------------------------------
8INSALL N ALL,DIROUT,DIRUT,DTOUT,DUOUT,IND,PXRMDONE
9 K ^TMP("PXRMEXIA",$J)
10 ;
11 ;Set the install date and time.
12 S IND="",PXRMDONE=0,^TMP("PXRMEXIA",$J,"DT")=$$NOW^XLFDT
13 ;
14 ;Go to full screen mode.
15 D FULL^VALM1
16 ;
17 ;Check if all or none exists - option to install all unchanged
18 N DNAME
19 S DNAME=$G(^TMP("PXRMEXTMP",$J,"PXRMDNAM"))
20 D EXIST^PXRMEXIX(.ALL,DNAME,"reminder dialog","")
21 ;
22 ;Lock the entire file
23 Q:'$$LOCK
24 ;
25 ;Install all components
26 F S IND=$O(^TMP("PXRMEXLD",$J,"SEL",IND),-1) Q:(+IND=0)!(PXRMDONE) D
27 .D INSCOM(IND,1)
28 ;
29 ;Clear lock
30 D UNLOCK
31 ;
32 ;Rebuild display workfile
33 D DISP^PXRMEXLD(PXRMMODE)
34 ;
35 K PXRMNMCH
36 Q
37 ;
38 ;Build list of descendents names
39 ;-------------------------------
40INSBLD(NAME,INAME) ;
41 N DNAME,IDATA,ISEQ
42 S ISEQ=0
43 F S ISEQ=$O(^TMP("PXRMEXTMP",$J,"DMAP",NAME,ISEQ)) Q:'ISEQ D
44 .S IDATA=$G(^TMP("PXRMEXTMP",$J,"DMAP",NAME,ISEQ)) Q:IDATA=""
45 .S DNAME=$P(IDATA,U) Q:DNAME="" Q:$$PXRM(DNAME) S INAME(DNAME)=""
46 .;Check for descendants
47 .I $D(^TMP("PXRMEXTMP",$J,"DMAP",DNAME)) D INSBLD(DNAME,.INAME)
48 Q
49 ;
50 ;Install component IND
51 ;---------------------
52INSCOM(IND,SILENT) ;
53 N ACTION,ATTR,DTYP,EXIEN,END,EXISTS,FILENUM,IND120,JND120
54 N NEWPT01,PT01,START,TEMP
55 S TEMP=^TMP("PXRMEXLD",$J,"SEL",IND),FILENUM=$P(TEMP,U,1)
56 S EXISTS=$P(TEMP,U,4),START=$P(TEMP,U,2),END=$P(TEMP,U,3) Q:START=""
57 S JND120=$P(TEMP,U,6) Q:'JND120
58 S IND120=$P(TEMP,U,5) Q:'IND120
59 S TEMP=^PXD(811.8,PXRMRIEN,100,START,0),PT01=$P(TEMP,"~",2) Q:PT01=""
60 S DTYP=$G(^TMP("PXRMEXTMP",$J,"DTYP",PT01))
61 I DTYP="dialog" S DTYP="reminder dialog"
62 ;
63 ;Go to full screen mode.
64 D FULL^VALM1
65 ;
66 ;Check for descendents
67 I 'SILENT,$$INSDSC(PT01) D Q:PXRMDONE
68 .N ANS,INDS,TEXT
69 .S TEXT(1)=PT01_" ("_DTYP_") contains sub-components."
70 .S TEXT="Install all sub-components with the "_DTYP_": "
71 .;Give option to install all descendents
72 .D ASK^PXRMEXIX(.ANS,.TEXT,1) Q:PXRMDONE
73 .I $G(ANS)="Y" D
74 ..S INDS=IND
75 ..N IDATA,INAME,IND
76 ..;Build list of decendents to install
77 ..D INSBLD(PT01,.INAME)
78 ..;Check if all or none exists - option to install all unchanged
79 ..D EXIST^PXRMEXIX(.ALL,PT01,DTYP,.INAME) Q:PXRMDONE
80 ..;Start at the end of the list
81 ..S IND=""
82 ..F S IND=$O(^TMP("PXRMEXLD",$J,"SEL",IND),-1) Q:PXRMDONE!(IND=INDS) D
83 ...N PT01,START,TEMP
84 ...S TEMP=^TMP("PXRMEXLD",$J,"SEL",IND),START=$P(TEMP,U,2) Q:START=""
85 ...S PT01=$P(^PXD(811.8,PXRMRIEN,100,START,0),"~",2) Q:PT01=""
86 ...;Ignore namechanges
87 ...I $D(PXRMNMCH(801.41,PT01)) Q
88 ...;Only install descendents
89 ...I $D(INAME(PT01)) D INSCOM(IND,1)
90 ;
91 D SETATTR^PXRMEXFI(.ATTR,FILENUM)
92 ;Double check that it hasn't been installed
93 S EXIEN=$$EXISTS^PXRMEXIU(801.41,PT01)
94 I EXIEN,'EXISTS S EXISTS=1
95 ;If all components installed the default is 'Install or Overwrite'
96 S:ALL ACTION=$S(EXISTS:"O",1:"I"),(ATTR("NAME"),ATTR("PT01"))=PT01,PXRMNMCH="",NEWPT01=""
97 S:'ALL ACTION=$$GETFACT^PXRMEXFI(PT01,.ATTR,.NEWPT01,.PXRMNMCH,EXISTS)
98 ;Save what was done for the installation summary.
99 S ^TMP("PXRMEXIA",$J,IND,ATTR("FILE NAME"),ATTR("PT01"),ACTION)=NEWPT01
100 ;Clear heading
101 S VALMHDR(2)=""
102 ;If the ACTION is Quit then quit the entire install.
103 I ACTION="Q" S PXRMDONE=1 S VALMHDR(2)="Install not completed" Q
104 ;If the ACTION is Skip then skip this component.
105 I ACTION="S" S VALMBCK="R" Q
106 ;If the ACTION is Replace then skip this component.
107 I ACTION="P" S VALMBCK="R",VALMHDR(2)=PT01_" replaced with "_NEWPT01 Q
108 ;Install this component.
109 D FILE^PXRMEXIC(PXRMRIEN,EXIEN,IND120,JND120,ACTION,.ATTR,.PXRMNMCH)
110 S VALMBCK="R"
111 I PXRMDONE S VALMHDR(2)="Install aborted" Q
112 I NEWPT01="" S VALMHDR(2)=PT01_" ("_DTYP_") installed from exchange file."
113 I NEWPT01'="" S VALMHDR(2)=PT01_" installed as "_NEWPT01_"."
114 ;If reminder dialog - disable and give option to link
115 I DTYP="reminder dialog" D
116 .N DNAME
117 .S DNAME=PT01
118 .I NEWPT01'="" S DNAME=NEWPT01
119 .D INSLNK(DNAME)
120 Q
121 ;
122 ;Check for descendents (either elements or prompts)
123 ;--------------------------------------------------
124INSDSC(NAME) ;
125 N DATA,DFOUND,SUB
126 S DFOUND=0,SUB=0
127 F S SUB=$O(^TMP("PXRMEXTMP",$J,"DMAP",NAME,SUB)) Q:'SUB D Q:DFOUND
128 .S DATA=$G(^TMP("PXRMEXTMP",$J,"DMAP",NAME,SUB)) Q:DATA=""
129 .I '$$PXRM($P(DATA,U)) S DFOUND=1
130 Q DFOUND
131 ;
132 ;Option to link dialog to a reminder
133 ;-----------------------------------
134INSLNK(DNAME) ;
135 N DIEN,DISABLE,DSRC,RNAME
136 N DA,DIE,DR
137 ;Disable
138 S DIEN=$O(^PXRMD(801.41,"B",DNAME,"")) Q:'DIEN
139 ;Set dialog as disabled
140 S DISABLE="DISABLED IN EXCHANGE"
141 ;Except for National dialogs
142 I $P(^PXRMD(801.41,DIEN,100),U)="N" S DISABLE=""
143 ;
144 S DR="3///^S X=DISABLE",DIE="^PXRMD(801.41,",DA=$P(DIEN,U)
145 D ^DIE
146 ;
147 ;Quit if already linked
148 I $D(^PXD(811.9,"AG",DIEN)) Q
149 ;
150 S RNAME=""
151 ;If reminder was renamed use as default
152 I $D(PXRMNMCH(811.9)) D
153 .S RNAME=$O(PXRMNMCH(811.9,"")) Q:RNAME=""
154 .S RNAME=$G(PXRMNMCH(811.9,RNAME))
155 ;Otherwise use original reminder name as default
156 I RNAME="" D
157 .N DATA,FOUND,RIEN,SUB
158 .;Rebuild ^TMP("PXRMEXLC",$J
159 .D CDISP^PXRMEXLC(PXRMRIEN)
160 .;
161 .S SUB="",FOUND=0
162 .F S SUB=$O(^TMP("PXRMEXLC",$J,"SEL",SUB),-1) Q:'SUB Q:FOUND D
163 ..S DATA=$G(^TMP("PXRMEXLC",$J,"SEL",SUB)) Q:$P(DATA,U)'=811.9
164 ..S RIEN=$P(DATA,U,4),FOUND=1 Q:'RIEN
165 ..S RNAME=$P($G(^PXD(811.9,RIEN,0)),U)
166 ;
167TAG W !!,"Reminder Dialog "_DNAME_" is not linked to a reminder.",!
168 ;Select reminder to link
169 S IEN=$$SELECT^PXRMINQ("^PXD(811.9,","Select Reminder to Link: ",RNAME)
170 ;Update reminder link in #811.9
171 I $P(IEN,U)'=-1 D
172 .N DA,DIE,DIK,DR
173 .;Set reminder to dialog pointer
174 .S DR="51///^S X=DNAME",DIE="^PXD(811.9,",DA=$P(IEN,U)
175 .D ^DIE
176 .;If source reminder is null replace with linked reminder
177 .S DSRC=$P($G(^PXRMD(801.41,DIEN,0)),U,2) Q:DSRC
178 .S DSRC=$P(IEN,U)
179 .S DR="2///^S X=DSRC",DIE="^PXRMD(801.41,",DA=$P(DIEN,U)
180 .D ^DIE
181 Q
182 ;
183 ;Install Selected Components
184 ;---------------------------
185INSSEL N ALL,IND,PXRMDONE,VALMY
186 N DIROUT,DIRUT,DTOUT,DUOUT
187 N VALMBG,VALMLST
188 S VALMBG=1,VALMLST=+$O(^TMP("PXRMEXLD",$J,"IDX",""),-1)
189 ;Get the list to install.
190 D EN^VALM2(XQORNOD(0))
191 ;
192 K ^TMP("PXRMEXIA",$J)
193 ;Set the install date and time.
194 S ALL="",PXRMDONE=0,^TMP("PXRMEXIA",$J,"DT")=$$NOW^XLFDT
195 ;
196 ;Lock the entire file
197 Q:'$$LOCK
198 ;
199 S IND=0
200 F S IND=$O(VALMY(IND)) Q:(+IND=0)!(PXRMDONE) D
201 .D INSCOM(IND,0)
202 ;
203 ;Clear locks
204 D UNLOCK
205 ;
206 ;Rebuild workfile
207 D DISP^PXRMEXLD(PXRMMODE)
208 Q
209 ;
210 ;Install the exchange entry PXRMRIEN
211 ;-----------------------------------
212INSTALL N IEN,IND,VALMY
213 ;Make sure the component list exists for this entry. PXRMRIEN is
214 ;set in INSTALL^PXRMEXLR.
215 I '$D(^PXD(811.8,PXRMRIEN,120)) D CLIST^PXRMEXU1(.PXRMRIEN)
216 I PXRMRIEN=-1 Q
217 ;Format the component list for display.
218 D CDISP^PXRMEXLC(PXRMRIEN)
219 S VALMBCK="R",VALMCNT=$O(^TMP("PXRMEXLD",$J,"IDX"),-1)
220 Q
221 ;
222PXRM(NAME) ;Validate prompts
223 ;
224 ;Ignore non-PXRM
225 I $E(NAME,1,4)'="PXRM" Q 0
226 ;
227 ;Check if this is a national code
228 N DIEN
229 S DIEN=$O(^PXRMD(801.41,"B",NAME,""))
230 ;If not found abort
231 I 'DIEN Q 0
232 ;Check class
233 I $P($G(^PXRMD(801.41,DIEN,100)),U)="N" Q 1
234 ;Otherwise local
235 Q 0
236 ;
237 ;Lock the dialog file
238LOCK() ;
239 L +^PXRMD(801.41):0 I Q 1
240 E W !,"Another user is editing this file, try later" H 2
241 Q 0
242 ;
243 ;Clear lock
244UNLOCK L -^PXRMD(801.41)
245 Q
Note: See TracBrowser for help on using the repository browser.