source: cprs/branches/tmg-cprs/m_files/TMGRPC3E.m@ 825

Last change on this file since 825 was 796, checked in by Kevin Toppenberg, 14 years ago

Initial upload

File size: 8.9 KB
Line 
1TMGRPC3E ;TMG/kst/Support Functions for GUI_Config ;08/31/08
2 ;;1.0;TMG-LIB;**1**;08/31/08
3 ;
4 ;"TMG RPC FUNCTIONS for a GUI config program
5 ;
6 ;"Kevin Toppenberg MD
7 ;"GNU Lessor General Public License (LGPL) applies
8 ;"7/20/08
9 ;
10 ;"=======================================================================
11 ;" RPC -- Public Functions.
12 ;"=======================================================================
13 ;" <none>
14 ;"=======================================================================
15 ;"PRIVATE API FUNCTIONS
16 ;"=======================================================================
17 ;"GETEMPTY(TMGOUT,TMGPARAMS) -- get stub entries for a file (typically a subfile)
18 ;"GETHELPM(TMGOUT,TMGPARAMS) -- retrieve the help message for a given field.
19 ;"STUBNEWR(TMGFILE,NewValue,TMGOUT) -- create a stub entry in the file (200), to be filled in elsewhere
20 ;"GETIFWP(TMGOUT,TMGPARAMS) -- return if filenumber is a WP subfile
21 ;"GETWPFLD(TMGOUT,TMGPARAMS) -- retrieve on word processing (WP) field entry
22 ;"PSTWPFLD(TMGOUT,TMGPARAMS,INPUT) -- store a word processing (WP) field entry
23 ;
24 ;"=======================================================================
25 ;"=======================================================================
26 ;"Dependencies:
27 ;" TMGRPC3* only
28 ;
29 ;"=======================================================================
30 ;"=======================================================================
31 ;
32GETEMPTY(TMGOUT,TMGPARAMS) ;"GET EMPTY ENTRY
33 ;"Purpose: to get stub entries for a file (typically a subfile)
34 ;" "GET EMPTY ENTRY" -- getting stub entries for subfiles typically
35 ;" TMGPARAMS: file entry (file or subfile number)
36 ;"Input: TMGOUT --an OUT ARRAY, filled as follows:
37 ;" TMGOUT(0)="1^Success" or "-1^Message"
38 ;" TMGOUT(1)=File^^FieldNum^^DDInfo...
39 ;" TMGOUT(2)=File^^FieldNum^^DDInfo...
40 ;" Etc ...
41 ;" Params: filenumber (typically a subfilenumber)
42 ;"Result: None
43 ;
44 SET TMGOUT(0)="1^Success"
45 NEW TMGCOUNT SET TMGCOUNT=1
46 NEW TMGFNUM SET TMGFNUM=+$GET(TMGPARAMS)
47 NEW TMGFLDNUM SET TMGFLDNUM=0
48 FOR SET TMGFLDNUM=$ORDER(^DD(TMGFNUM,TMGFLDNUM)) QUIT:(+TMGFLDNUM'>0) DO
49 . NEW TMGDDINFO SET TMGDDINFO=$PIECE($GET(^DD(TMGFNUM,TMGFLDNUM,0)),"^",1,4)
50 . SET TMGOUT(TMGCOUNT)=TMGFNUM_"^^"_TMGFLDNUM_"^^"_TMGDDINFO
51 . SET TMGCOUNT=TMGCOUNT+1
52 ;
53 QUIT
54 ;
55 ;
56GETHELPM(TMGOUT,TMGPARAMS) ;
57 ;"Purpose: to retrieve the help message for a given field.
58 ;"Input: TMGOUT -- an OUT PARAMETER, PASS BY REFERENCE.
59 ;" TMGPARAMS -- file^field^HelpType
60 ;"Output: TMGOUT is filled as follows:
61 ;" TMGOUT(0)="1^Success" or "-1^Message"
62 ;" TMGOUT(1...?)=Help Message
63 ;
64 NEW TMGMSG
65 NEW TMGINDEX SET TMGINDEX=1
66 NEW TMGFILE SET TMGFILE=+$PIECE(TMGPARAMS,"^",1)
67 NEW TMGFIELD SET TMGFIELD=+$PIECE(TMGPARAMS,"^",2)
68 NEW TMGHELPTYPE SET TMGHELPTYPE=$PIECE(TMGPARAMS,"^",3)
69 IF TMGFILE'>0 DO GOTO GHMDONE
70 . SET TMGOUT(0)="-1^No file number supplied"
71 IF TMGFIELD'>0 DO GOTO GHMDONE
72 . SET TMGOUT(0)="-1^No Field Number supplied"
73 DO HELP^DIE(TMGFILE,,TMGFIELD,TMGHELPTYPE,"TMGMSG")
74 NEW TMGI SET TMGI=""
75 FOR SET TMGI=$ORDER(TMGMSG("DIHELP",TMGI)) QUIT:(TMGI="") DO
76 . SET TMGOUT(TMGINDEX)=TMGMSG("DIHELP",TMGI)
77 . SET TMGINDEX=TMGINDEX+1
78 ;
79 SET TMGOUT(0)="1^Success"
80 ;
81GHMDONE ;
82 QUIT
83 ;
84 ;
85STUBNEWR(TMGFILE,TMGNEWVALUE,TMGOUT) ;"STUB NEW RECORD
86 ;"Purpose: to create a stub entry in the file (200), to be filled in elsewhere
87 ;"Input: TMGNEWVALUE -- a value for the .01 field
88 ;" TMGOUT -- PASS BY REFERENCE, an OUT PARAMETER.
89 ;"Output: A new record will be added to file, if no errors
90 ;" TMGOUT(0): 1^Success^NewIEN or -1^See Fileman message
91 ;" TMGOUT(1) will contain Fileman error, if any
92 ;"Results: none
93 ;"NOTICE: This function makes no promise that the creation of the
94 ;" new record will succeed. For example, if there are required
95 ;" fields, the creation will fail. So users should check for success
96 ;" result and error feedback.
97 ;"Results: none
98 ;
99 NEW TMGFDA,TMGIEN,TMGMSG,DIC
100 SET DIC(0)="" ;"I get a crash without this, for some reason...
101 SET TMGFDA(TMGFILE,"+1,",.01)=TMGNEWVALUE
102 DO UPDATE^DIE("S","TMGFDA","TMGIEN","TMGMSG")
103 ;
104 IF $DATA(TMGMSG("DIERR")) DO GOTO SNPDONE
105 . SET TMGOUT(0)="-1^See Fileman message"
106 . SET TMGOUT(1)=$$GETERSTR^TMGRPC3G(.TMGMSG)
107 ;
108 SET TMGOUT(0)="1^Success^"_$GET(TMGIEN(1))
109 ;
110SNPDONE ;
111 QUIT
112 ;
113 ;
114GETIFWP(TMGOUT,TMGPARAMS) ;"GET IF WP FIELD
115 ;"Purpose: to return if filenumber is a WP subfile
116 ;"Input: TMGOUT -- an OUT PARAMETER, PASS BY REFERENCE.
117 ;" TMGPARAMS -- file^field
118 ;"Output:
119 ;" TMGOUT(0): "1^Success^YES/NO" or "-1^Message"
120 ;" "YES" if is a WP subfile, otherwise "NO"
121 ;" TMGOUT(1) will contain Fileman error, if any
122 ;"Results: none
123 ;
124 NEW TMGRESULT
125 NEW TMGFILE SET TMGFILE=+$PIECE(TMGPARAMS,"^",1)
126 NEW TMGFIELD SET TMGFIELD=+$PIECE(TMGPARAMS,"^",2)
127 IF TMGFILE'>0 DO GOTO GWPSDONE
128 . SET TMGOUT(0)="-1^No file number supplied"
129 IF TMGFIELD'>0 DO GOTO GWPSDONE
130 . SET TMGOUT(0)="-1^No Field Number supplied"
131 ;
132 DO FIELD^DID(TMGFILE,TMGFIELD,"","TYPE","TMGARRAY","TMGMSG")
133 ;
134 IF $DATA(TMGMSG("DIERR")) DO GOTO GWPSDONE
135 . SET TMGOUT(0)="-1^See Fileman message"
136 . SET TMGOUT(1)=$$GETERSTR^TMGRPC3G(.TMGMSG)
137 ;
138 IF $GET(TMGARRAY("TYPE"))="WORD-PROCESSING" DO
139 . SET TMGRESULT="YES"
140 ELSE DO
141 . SET TMGRESULT="NO"
142 ;
143 SET TMGOUT(0)="1^Success^"_TMGRESULT
144 ;
145GWPSDONE ;
146 QUIT
147 ;
148 ;
149GETWPFLD(TMGOUT,TMGPARAMS) ;"GET WP FIELD
150 ;"Purpose: To retrieve on word processing (WP) field entry
151 ;"Input: TMGOUT -- an OUT PARAMETER, PASS BY REFERENCE.
152 ;" TMGPARAMS -- FileNum^Field^IENS (e.g. 'GET ONE WP FIELD^200^73,')
153 ;"Output:
154 ;" TMGOUT(0): "1^Success" or "-1^Message"
155 ;" TMGOUT(1) will contain Fileman error, if any
156 ;" - or to return WP array -
157 ;" TMGOUT(1)=1st line of text
158 ;" TMGOUT(2)=2nd line of text
159 ;" etc..
160 ;"Results: None
161 ;
162 NEW TMGFILE SET TMGFILE=+$PIECE(TMGPARAMS,"^",1)
163 NEW TMGFIELD SET TMGFIELD=+$PIECE(TMGPARAMS,"^",2)
164 NEW TMGIENS SET TMGIENS=+$PIECE(TMGPARAMS,"^",3)
165 IF TMGFILE'>0 DO GOTO GWPDONE
166 . SET TMGOUT(0)="-1^No file number supplied"
167 IF TMGFIELD'>0 DO GOTO GWPDONE
168 . SET TMGOUT(0)="-1^No Field Number supplied"
169 IF TMGIENS="" DO GOTO GWPDONE
170 . SET TMGOUT(0)="-1^No IENS supplied"
171 ;
172 NEW TMGTEMP
173 SET TMGTEMP=$$GET1^DIQ(TMGFILE,TMGIENS,TMGFIELD,"","TMGARRAY","TMGMSG")
174 IF $DATA(TMGMSG("DIERR")) DO GOTO GWPDONE
175 . SET TMGOUT(0)="-1^See Fileman message"
176 . SET TMGOUT(1)=$$GETERSTR^TMGRPC3G(.TMGMSG)
177 ;
178 SET TMGOUT(0)="1^Success"
179 NEW TMGINDEX SET TMGINDEX=1
180 NEW TMGI SET TMGI=0
181 FOR SET TMGI=$ORDER(TMGARRAY(TMGI)) QUIT:(TMGI="") DO
182 . SET TMGOUT(TMGINDEX)=TMGARRAY(TMGI)
183 . SET TMGINDEX=TMGINDEX+1
184 ;
185GWPDONE ;
186 QUIT
187 ;
188 ;
189PSTWPFLD(TMGOUT,TMGPARAMS,INPUT) ;"POST WP FIELD
190 ;"Purpose: To store a word processing (WP) field entry
191 ;"Input: TMGOUT -- an OUT PARAMETER, PASS BY REFERENCE.
192 ;" TMGPARAMS -- FileNum^FieldNum^IENS (e.g. 'GET ONE WP FIELD^200^73,')
193 ;" INPUT -- holds the WP itself to be stored:
194 ;" INPUT(0)=0TH line
195 ;" INPUT(1)=1st line
196 ;" INPUT(2)=2nd line
197 ;" ...
198 ;"Output:
199 ;" TMGOUT(0): "1^Success" or "-1^Message"
200 ;" TMGOUT(1) will contain Fileman error, if any
201 ;"Results: None
202 ;
203 NEW TMGFILE SET TMGFILE=+$PIECE(TMGPARAMS,"^",1)
204 NEW TMGFIELD SET TMGFIELD=+$PIECE(TMGPARAMS,"^",2)
205 NEW TMGIENS SET TMGIENS=+$PIECE(TMGPARAMS,"^",3)
206 IF TMGFILE'>0 DO GOTO PWPDONE
207 . SET TMGOUT(0)="-1^No file number supplied"
208 IF TMGFIELD'>0 DO GOTO PWPDONE
209 . SET TMGOUT(0)="-1^No Field Number supplied"
210 IF TMGIENS="" DO GOTO PWPDONE
211 . SET TMGOUT(0)="-1^No IENS supplied"
212 IF $LENGTH(TMGIENS,",")=1 SET TMGIENS=TMGIENS_","
213 ;
214 DO WP^DIE(TMGFILE,TMGIENS,TMGFIELD,"K","INPUT","TMGMSG")
215 ;
216 IF $DATA(TMGMSG("DIERR")) DO GOTO GWPDONE
217 . SET TMGOUT(0)="-1^See Fileman message"
218 . SET TMGOUT(1)=$$GETERSTR^TMGRPC3G(.TMGMSG)
219 ;
220 SET TMGOUT(0)="1^Success"
221 ;
222PWPDONE ;
223 QUIT
224 ;
225 ;
Note: See TracBrowser for help on using the repository browser.