source: WorldVistAEHR/trunk/r/ASISTS-OOPS/OOPSGUI8.m@ 1396

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

initial load of WorldVistAEHR

File size: 7.8 KB
Line 
1OOPSGUI8 ;WIOFO/LLH-RPC Broker calls for GUI ;10/23/01
2 ;;2.0;ASISTS;**8,7,11**;Jun 03, 2002
3 ;
4EN1(RESULTS,INPUT) ; Entry point for routine
5 ; Input: INPUT contains the IEN of the ASISTS record and the
6 ; calling menu, in the format IEN^CALLING MENU
7 ; Output: RESULTS contains status messages back to the client.
8 ; RESULTS(0) will = either 1 or 0. 1 if ok for form to be
9 ; signed by calling menu option, 0 if not ok. The RESULTS
10 ; array with status message will start at 1.
11 ;
12 N CALL,CN,DIC,IEN,FORM,PRM1,PRM2,SIGN,Y
13 S CN=1
14 S IEN=$P($G(INPUT),U),CALL=$P($G(INPUT),U,2)
15 S FORM=$$GET1^DIQ(2260,IEN,52,"I")
16 S FORM=$S(FORM=1:"CA1",FORM=2:"CA2",1:"")
17 S PRM1=$S(CALL="O":"Safety Officer",CALL="H":"Occupational Health",1:0)
18 S PRM2=PRM1_" approves the WCP signing for the Employee: "
19 S SIGN=""
20 I '$G(IEN)!($G(FORM)="")!($G(CALL)="") D Q
21 . S RESULTS(0)=0
22 . S RESULTS(1)="Missing Information, Cannot Continue"
23 I CALL="W" G WCPS4E
24 S RESULTS(0)=$$VALID()
25 I RESULTS(0) S RESULTS(CN)=PRM2,CN=CN+1
26 G EXIT
27WCPS4E ; allow WCP to sign for employee if all approvals given
28 N CONT,EHS,SIGN,SOS,VALID,VIEW
29 S SIGN=0,VALID=0,VIEW=1
30 S SOS=$$GET1^DIQ(2260,IEN,76,"I")
31 S EHS=$$GET1^DIQ(2260,IEN,79,"I")
32 S CONT=$S(DUZ=SOS:"S",DUZ=EHS:"H",1:"")
33 I (CONT="S")!(CONT="H") D
34 . S RESULTS(CN)="You have approved as "_$S(CONT="S":"Safety Officer",CONT="H":"Occ Health Rep",1:"")
35 . S RESULTS(CN)=RESULTS(0)_" and cannot sign as Employee.",CN=CN+1
36 . S RESULTS(CN)="Three different individuals must be involved."
37 . S VIEW=0
38 I '$G(SOS) S VIEW=0 D
39 . S RESULTS(CN)="Safety Officer has not approved WCP signing for employee.",CN=CN+1
40 I '$G(EHS) S VIEW=0 D
41 . S RESULTS(CN)="Occupational Health has not approved WCP signing for employee.",CN=CN+1
42 I VIEW D
43 . ; Allow clearing WCP signature, employee may be able to sign
44 . I $$GET1^DIQ(2260,IEN,119,"I") D CLRES^OOPSUTL1(IEN,"E",FORM)
45 . D VALIDATE^OOPSUTL4(IEN,FORM,"E",.VALID)
46 . I 'VALID S RESULTS(CN)="All required fields not completed",CN=CN+1 Q
47 . D EMP^OOPSVAL1
48EXIT ;
49 Q
50VALID() ; make sure same person is not signing for both safety and EH and if
51 ; signed from menu option being called not needed again - so quit
52 N CONT,EHAPP,ERR,SOAPP,VALID
53 S VALID=1,ERR=0
54 S SOAPP=$P($G(^OOPS(2260,IEN,"WCSE")),U)
55 S EHAPP=$P($G(^OOPS(2260,IEN,"WCSE")),U,4)
56 S CONT=$S(DUZ=SOAPP:"S",DUZ=EHAPP:"H",1:"")
57 I CALL="O" D
58 . I CONT="S" S ERR=1
59 . I $G(EHAPP)=DUZ S ERR=2
60 . I $G(SOAPP)&($G(CONT)="") S ERR=3
61 I CALL="H" D
62 . I CONT="H" S ERR=1
63 . I $G(SOAPP)=DUZ S ERR=2
64 . I $G(EHAPP)&($G(CONT)="") S ERR=3
65 I ERR=1 D
66 . S RESULTS(CN)="You have signed as "
67 . S RESULTS(CN)=RESULTS(CN)_PRM1
68 . S RESULTS(CN)=RESULTS(CN)_", Cannot sign."
69 . S CN=CN+1,VALID=0
70 I ERR=2 D
71 . S RESULTS(CN)="You have already signed as "
72 . S RESULTS(CN)=RESULTS(CN)_$S(CALL="O":"Occupational Health",CALL="H":"Safety Officer",1:0)_".",CN=CN+1
73 . S RESULTS(CN)="Both signatures cannot be made by the same person."
74 . S CN=CN+1,VALID=0
75 I ERR=3 D
76 . S RESULTS(CN)=PRM1_" has already signed, re-signing is not required."
77 . S CN=CN+1,VALID=0
78 Q VALID
79CSIGN(RESULTS,IEN,FORM,CALL) ; Clears Signature from form
80 ;
81 ; Input: IEN - IEN of the ASISTS case to have the
82 ; signature cleared from
83 ; FORM - the Form to clear the signature from, 2162,
84 ; CA1 or CA2 or CA7 (CA7 added V2 patch 5)
85 ; CALL - the calling menu
86 ; Output: RESULTS - single value with status message
87 ;
88 S RESULTS="Clearing Signatures"
89 I ('$G(IEN))!($G(FORM)="")!($G(CALL)="") S RESULTS="FAILED"
90 ; V2 Patch 5 llh - added logic for CA7
91 I FORM'="CA7" D CLRES^OOPSUTL1(IEN,CALL,FORM)
92 I FORM="CA7" D CLRES^OOPSGUIS(IEN,CALL,FORM)
93 S RESULTS="CLEARED"
94 Q
95DTFC(RESULTS,DATE,FLAG) ; Reformat Date/Time
96 ; Input - Date to be reformatted
97 ; - Flag to be used
98 ; Output - RESULTS contains the reformatted date
99 ;
100 N X,%DT ; patch 11 - added %DT
101 S FLAG=+$G(FLAG)
102 I DATE=""!(FLAG="") S (RESULTS,RESULTS(1))="" Q
103 S X=DATE,%DT="T" D ^%DT
104 S DATE=Y,X="NOW"
105 D ^%DT
106 I $S(DATE=-1:1,FLAG<0:Y<DATE,FLAG>0:DATE>Y,1:0) S DATE=-1
107 I DATE=-1 S (RESULTS,RESULTS(1))="DATE ERROR" Q
108 S (RESULTS,RESULTS(1))=$$FMTE^XLFDT(DATE,5)
109 Q
110GETNOI(RESULTS,OPT) ; Broker Call to retrieve NOI Codes
111 ; Input: OPT - Either CA1 or CA2 to indicate which codes should be
112 ; retrieved. If CA1 must start with T, otherwise CA2
113 ; Output: RESULTS - NOI Description and Code
114 N NOI,DES,CODE,CN
115 S DES="",CN=0
116 F S DES=$O(^OOPS(2263.3,"B",DES)) Q:DES="" S NOI="" F S NOI=$O(^OOPS(2263.3,"B",DES,NOI)) Q:NOI="" D
117 . S CODE=$P(^OOPS(2263.3,NOI,0),U,2)
118 . I OPT="CA1",($E(CODE,1)="T") S RESULTS(CN)=NOI_":"_DES_" - "_CODE
119 . I OPT="CA2",($E(CODE,1)'="T") S RESULTS(CN)=NOI_":"_DES_" - "_CODE
120 . S CN=CN+1
121 Q
122ZIPCHK(RESULTS,DATA) ; patch 5 - validate zip code against file 5.12
123 ; to ensure zip in file and has correct state.
124 ;
125 ; Input: DATA - contains ZIP CODE^STATE NAME
126 ; Output: RESULTS - returns message with validation results
127 ;
128 N STATE,VALSTATE,VALZIP,ZIP,ZZIP
129 S ZIP=$P($G(DATA),U,1),STATE=$P($G(DATA),U,2)
130 S RESULTS=""
131 I '$G(ZIP)!($G(STATE)="") S RESULTS="MISSING PARAMETERS" Q
132 D POSTAL^XIPUTIL(ZIP,.ZZIP)
133 I $G(ZZIP("ERROR"))'="" S RESULTS="ZIP CODE NOT FOUND" Q
134 I STATE'=ZZIP("STATE") S RESULTS="STATE MISMATCH ON ZIP" Q
135 S RESULTS="VALID ZIP/STATE"
136 Q
137AMEND(RESULTS,OLDIEN) ; File new Amended Case
138 ; Input: OLDIEN - The ASISTS IEN for the case to have an
139 ; amendment created for.
140 ; Output: RESULTS - Single value with the new case number
141 ;
142 N DLAYGO
143 Q:$P(^OOPS(2260,OLDIEN,0),"^",6)'=0 ;defensive code, should not occur
144 S NUM=$P(^OOPS(2260,OLDIEN,0),U,1),SUF=$E(NUM,11)
145 S $P(^OOPS(2260,OLDIEN,0),U,6)=3
146 S NUM=$E(NUM,1,10)_$S(SUF="":"A",1:$CHAR($ASCII(SUF)+1))
147 K DD,DO
148 S DLAYGO=2260,DIC="^OOPS(2260,",DIC(0)="QLZ",X=NUM
149 D FILE^DICN G:Y=-1 DONE
150 S NEWIEN=+Y
151 MERGE ^OOPS(2260,NEWIEN)=^OOPS(2260,OLDIEN)
152 S OOP=^OOPS(2260,NEWIEN,0)
153 S $P(OOP,U,1)=NUM,$P(OOP,U,6)=0,$P(OOP,U,11)="",$P(OOP,U,19)=""
154 S ^OOPS(2260,NEWIEN,0)=OOP,$P(^OOPS(2260,NEWIEN,"CA"),U,6)=""
155 S DIK="^OOPS(2260,",DA=NEWIEN D IX^DIK
156 K ^OOPS(2260,NEWIEN,"2162ES")
157 K ^OOPS(2260,NEWIEN,"CA1ES")
158 K ^OOPS(2260,NEWIEN,"CA2ES")
159 N IEN,X,WCPDUZ,WOK
160 S WCPDUZ=$P($G(^OOPS(2260,NEWIEN,"WCES")),U)
161 I $G(WCPDUZ) S WOK=1,X=WCPDUZ,IEN=OLDIEN D WK^OOPSUTL1
162 K ^OOPS(2260,NEWIEN,"WCES")
163 S RESULTS=NUM
164DONE K DA,DIC,OLDIEN,NEWIEN,NUM,SUF,X,Y,DIK,OOP
165 Q
166SETDLOC(RESULTS,P1,DATA) ; files the detail location records
167 ; Input - P1 is the Location record IEN concatenated with the station
168 ; subrecord IEN. EX. 38^600
169 ; DATA is a # subscripted array containing the detail loc data
170 ; in the format - detail location description^Detail Loc IEN
171 ; Output - RESULTS indicating the success of the filing.
172 N CNT,IENS,FILE,LV1,LV2,LOC,MSG,REC,RECNO,STAFDA,STR
173 S BAD=0,FILE=2261.4,LOC=$P(P1,U),STA=$P(P1,U,2),RESULTS=""
174 I $D(DATA)<10 S RESULTS="NO DATA TO FILE, CANNOT CONTINUE" Q
175 I '$G(STA) S RESULTS="NO STATION SENT, COULDN'T FILE" Q
176 I '$G(LOC) S RESULTS="NO LOCATION SENT, COULDN'T FILE" Q
177 I '$D(^OOPS(FILE,LOC,1,"B",STA)) D I BAD Q
178 .S IENS="+1,"_LOC_",",STAFDA(2261.43,IENS,.01)=STA
179 .D UPDATE^DIE("","STAFDA","IENS","MSG")
180 .I $D(MSG("DIERR")) D
181 ..S RESULTS="PROBLEM FILING NEW STATION SUBRECORD",BAD=1
182 ;KILL THE DETAIL LOCATION REC FOR STATION AND LOCATION PASSED IN
183 S DIENS=$O(^OOPS(FILE,"E",STA,LOC,"")),LV1=$O(^OOPS(FILE,LOC,0))
184 I $G(DIENS) D
185 .S LV2=$O(^OOPS(FILE,LOC,LV1,DIENS,0))
186 .I $G(LV2) K ^OOPS(FILE,LOC,LV1,DIENS,LV2)
187 .I $D(^OOPS(FILE,"F",DIENS,LOC)) K ^OOPS(FILE,"F",DIENS,LOC)
188 ;RE-FILE THE DETAIL LOCATION LEVEL RECORD
189 K STAFDA S CNT=0,RECNO=0,REC=""
190 F S REC=$O(DATA(REC)) Q:REC="" D
191 .S STR=DATA(REC),RECNO=$P(STR,U,2),CNT=CNT+1
192 .I RECNO="" S RECNO=CNT
193 .S IENS="+"_RECNO_","_DIENS_","_LOC_","
194 .S STAFDA(2261.431,IENS,.01)=$P(STR,U,1)
195 D UPDATE^DIE("E","STAFDA","IENS","MSG")
196 I '$D(MSG) S RESULTS="Filing Successful"
197 K MSG,STR,Y,X,%DT
198 Q
Note: See TracBrowser for help on using the repository browser.