source: WorldVistAEHR/trunk/r/PHARMACY_BENEFITS_MANAGEMENT-PSU/PSUTL.m@ 901

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

initial load of WorldVistAEHR

File size: 5.0 KB
Line 
1PSUTL ;BIR/PDW - Utilities for AR/WS extracts ;12 AUG 1999
2 ;;4.0;PHARMACY BENEFITS MANAGEMENT;;MARCH, 2005
3 ;
4 ; Reference to DOLRO^%ZOSV supported by DBIA 2500
5 ;
6 ; Entry Points
7 ;
8 ; D GETS^PSUTL(,,,,)
9 ; D GETM^PSUTL(,,,,)
10 ; $$VAL^PSUTL(,,)
11 ; $$VALI^PSUTL(,,)
12 ; ---------------------
13 ; D MOVEI^PSUTL("ref") Moves @ref@(Fld,"I") Value to (Fld) node
14 ; D MOVEMI^PSUTL("ref") Moves @ref@(da,Fld,"I") value to (da,Fld) node
15 ; ---------------------
16 ; ---------------------
17 ; Details & Parameters
18 ; D GETS^PSUTL(,,,,) Returns @root@(Field Number(s)) = Value(s)
19 ; Multiples NO
20 ;
21 ; D GETM^PSUTL(,,,,) Returns @root@(DA,Field Number(s)) = Value(s)
22 ; Multiples YES & ONLY
23 ;
24 ; S X=$$VAL^PSUTL(,,) X = External Value
25 ; S X=$$VALI^PSUTL(,,) X = Interanl Value
26 ;
27 ; [ Variables for Parameter Passing ]
28 ; PSUFILE = file number or subfile number as described in GETS^DIQ()
29 ; PSUDA = List or array of IENS NOT as described in GETS^DIQ()
30 ;
31 ; A .DA array or a list of IENS left to right as they are in the
32 ; global data arrays D0,D1,D2 as within a FM Global map
33 ; This Iens list can be constructed with variables.
34 ; Example: as reaching into file 200 division subfile 200.02
35 ; "DUZ,SITE"
36 ;
37 ; PSUDR = DR string as described in GETS^DIQ()
38 ; PSUROOT = closed array as described in GETS^DIQ()
39 ; PSUFORM = format control as described in GETS^DIQ()
40 ;
41GETS(PSUFILE,PSUDA,PSUDR,PSUROOT,PSUFORM) ;
42 ; Example S PSUSITE=6025
43 ; D GETS^PSUTL(200.02,"DUZ,PSUSITE",".01","DIV")
44 ; returns
45 ; DIV(.01)="HINES DEVELOPMENT"
46 ;
47 N PSUIEN,DA
48 I $D(PSUFILE),$D(PSUDA),$D(PSUDR),$D(PSUROOT)
49 E Q
50 I '$D(PSUFORM) S PSUFORM=""
51 D PARSE(PSUDA)
52 S PSUIEN=$$IENS^DILF(.DA)
53 K ^TMP("PSUDIQ",$J)
54 D GETS^DIQ(PSUFILE,PSUIEN,PSUDR,PSUFORM,"^TMP(""PSUDIQ"",$J)")
55 ;
56 I $G(PSUMTUL) Q
57 ;
58 M @PSUROOT=^TMP("PSUDIQ",$J,PSUFILE,PSUIEN)
59 K ^TMP("PSUDIQ",$J)
60 Q
61 ;
62VAL(PSUFILE,PSUDA,PSUFLD) ; Returns External Value
63 N PSUTMP
64 I $D(PSUFILE),$D(PSUDA),$D(PSUFLD)
65 E Q ""
66 D GETS(PSUFILE,PSUDA,PSUFLD,"PSUTMP")
67 Q $G(PSUTMP(PSUFLD))
68VALI(PSUFILE,PSUDA,PSUFLD) ; Returns Internal Value
69 N PSUTMP
70 I $D(PSUFILE),$D(PSUDA),$D(PSUFLD)
71 E Q ""
72 D GETS(PSUFILE,PSUDA,PSUFLD,"PSUTMP","I")
73 Q $G(PSUTMP(PSUFLD,"I"))
74 ;
75GETM(PSUFILE,PSUDA,PSUFLD,PSUROOT,PSUFORM) ;EP RETURN MULTIPLES
76 ; PSUFILE is the immediate upper level file number of the one desired
77 ; PSUDA is the "DO,D1,Dx .." IENS to get to the immediate upper level
78 ; PSUFLD is the field notation for the multiple at the upper level
79 ; "3*"
80 ; appended with "^" and the list of fields ".01;.02;9.3;..."
81 ; resulting in "3*^.01;.02;9.3;..."
82 ; PSUROOT is the target closed array reference
83 ; PSUFORM is the format as in GET^DIQ
84 ; return form is @PSUROOT@(da,fld)=VALUE
85 ;
86 ; example: pulls multiple divisions from file 200
87 ; D GETM^PSUTL(200,DUZ,"16*^.01","DIV")
88 ; Returns DIV(578,.01) ="HINES, IL"
89 ; DIV(6020,.01)="HINES ISC"
90 ; DIV(6025,.01)="HINES DEVELOPMENT"
91 ;
92 N PSUMTUL,PSUSUB,PSUDID
93 I $D(PSUFILE),$D(PSUDA),$D(PSUFLD),$D(PSUROOT)
94 E Q
95 S PSUMTUL=1
96 I '$D(PSUFORM) S PSUFORM=""
97 I PSUFLD'["^" Q
98 K PSUFLDL
99 S PSUFLDL=$P(PSUFLD,U,2),PSUFLD=$P(PSUFLD,U)
100 I +PSUFLDL,+PSUFLD
101 E Q
102 D FIELD^DID(PSUFILE,+PSUFLD,"","SPECIFIER","PSUDID")
103 S PSUSUB=+PSUDID("SPECIFIER")
104 D GETS(PSUFILE,PSUDA,PSUFLD,PSUROOT,PSUFORM)
105 ; load multiple into target array
106 S PSUIEN=0 F S PSUIEN=$O(^TMP("PSUDIQ",$J,PSUSUB,PSUIEN)) Q:+PSUIEN'>0 M @PSUROOT@(+PSUIEN)=^TMP("PSUDIQ",$J,PSUSUB,PSUIEN)
107 K ^TMP("PSUDIQ",$J)
108 Q:'$D(PSUFLDL)
109 ;
110 ; process individual fields
111 N I,FLD
112 S FLD=+PSUFLDL,PSUFLDL(FLD)=0
113 F I=2:1 S FLD=$P(PSUFLDL,";",I) Q:FLD'>0 S PSUFLDL(FLD)=""
114 S PSUIEN=0 F S PSUIEN=$O(@PSUROOT@(PSUIEN)) Q:PSUIEN'>0 D
115 . S FLD=0
116 . F S FLD=$O(@PSUROOT@(PSUIEN,FLD)) Q:FLD'>0 I '$D(PSUFLDL(FLD)) K @PSUROOT@(PSUIEN,FLD)
117 K PSUFLDL
118 Q
119PARSE(XBDA) ;PEP - parse DA literal into da array
120 I XBDA="",$D(XBDA)=1 S DA=0 Q
121 NEW D,I,J
122 F I=1:1 S D(I)=$P(XBDA,",",I) Q:D(I)=""
123 S I=I-1
124 F J=0:1:I-1 S DA(J)=D(I-J)
125 F J=0:1:I-1 F Q:(DA(J)=+DA(J)) S DA(J)=@(DA(J)) S:DA(J)="" DA(J)=0
126 S DA=DA(0)
127 KILL DA(0)
128 Q
129MOVEI(PSUREF) ;EP Move @PSUREF@(Fld,"I") values to @PSUREF@(Fld)
130 N PSUFLD
131 S PSUFLD=0 F S PSUFLD=$O(@PSUREF@(PSUFLD)) Q:PSUFLD'>0 S @PSUREF@(PSUFLD)=$G(@PSUREF@(PSUFLD,"I")) K @PSUREF@(PSUFLD,"I")
132 Q
133 ;
134MOVEMI(PSUREF) ;EP Move @PSUREF@(da,Fld,"I") values to @PSUREF@(da,Fld)
135 N PSUDA,PSUFLD
136 S PSUDA=0 F S PSUDA=$O(@PSUREF@(PSUDA)) Q:PSUDA'>0 D
137 . S PSUFLD=0 F S PSUFLD=$O(@PSUREF@(PSUDA,PSUFLD)) Q:PSUFLD'>0 S @PSUREF@(PSUDA,PSUFLD)=@PSUREF@(PSUDA,PSUFLD,"I") K @PSUREF@(PSUDA,PSUFLD,"I")
138 Q
139 ;
140UPPER(PSUX) ;Convert lower case to upper case
141 Q $TR(PSUX,"abcdefghijklmnopqrstuvwxyz","ABCDEFGHIJKLMNOPQRSTUVWXYZ")
142 ;
143VARKILL ;PEP Kill variable PSU* namespace
144 ;Kills off all PSU Variables
145 S X="^TMP(""PSUVAR"",$J,"
146 D DOLRO^%ZOSV ; load symbols into ^TMP(,,var)=..
147 ; (preserve PSU,PSUXMY*)
148 S X="" F S X=$O(^TMP("PSUVAR",$J,X)) Q:X="" I $E(X,1,3)="PSU",X'="PSU",($E(X,1,6)'="PSUXMY"),X'="PSUJOB" K @X
149 K ^TMP("PSUVAR",$J)
150 ;
151 ;
Note: See TracBrowser for help on using the repository browser.