source: WorldVistAEHR/trunk/r/ASISTS-OOPS/OOPSUTL4.m@ 1361

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

initial load of WorldVistAEHR

File size: 9.2 KB
RevLine 
[613]1OOPSUTL4 ;HINES/WAA-Utilities Routines ;3/24/98
2 ;;2.0;ASISTS;**7**;Jun 03, 2002
3DTVAL(DATE,FLD1,FLD2) ;
4 ; this subroutine called from ^DD so date error checking on fields
5 ; 143, 144, 145 (if CA1) and 254, 255 (if CA2). returns a valid date
6 ; (one passed in) if a date in FLD2 and is > than date passed in (DATE).
7 ; Inputs: DATE - date entered in prompt
8 ; FLD1 - field of prompt date entered in
9 ; FLD2 - field of date to be checked against
10 ; Outputs: VAL - contains valid date passed in if true & "" if false
11 N DTE2,VAL
12 S VAL=DATE,DTE2=""
13 I '$G(IEN) S IEN=$G(DA)
14 I IEN S DTE2=$$GET1^DIQ(2260,IEN,FLD2,"I")
15 I %DT'["R" S DTE2=DTE2\1
16 I DTE2>DATE!'$G(DTE2) S VAL=""
17 I 'VAL D
18 .I '$G(DTE2) W !!?5,$$GET1^DID(2260,FLD2,"","LABEL")_" cannot be blank if date entered in "_$$GET1^DID(2260,FLD1,"","LABEL"),! Q
19 .W !!?5,$$GET1^DID(2260,FLD1,"","LABEL")_" must be on or after the "_$$GET1^DID(2260,FLD2,"","LABEL"),!
20 Q VAL
21VALIDATE(IEN,FORM,CALLER,VALID) ;
22 ; Input: IEN = Internal Entry Number of entry in file 2260
23 ; FORM = 2162,CA1, or CA2
24 ; CALLER = "E" employee
25 ; = "S" supervisor
26 ; = "O" safety officer
27 ; = "W" worker's comp personnel
28 ; WCEMP = from menu if 1 - need to execute emp validation
29 ; VALID = RESERVED FOR OUTPUT DATA
30 ; Output:VALID = 1 ALL REQUIRED DATA FOR FORM IS COMPLETE
31 ; = 0 DATA IS MISSING
32 N LIST,FLD,CNT,CHK
33 S (FLD,LIST)=""
34 S VALID=1,CHK=0,WCEMP=$G(WCEMP,0)
35 W !,"Validating data on form ",FORM,"."
36 I CALLER="E"!$G(WCEMP) D EMP
37 I CALLER="S" D SUP
38 I CALLER="O" D SOF
39 I CALLER="W" D WCP
40 F CNT=1:1 S FLD=$P(LIST,",",CNT) Q:FLD="" D
41 .N LOC,NODE,PCE,BADFLD,TEXT,WP
42 .S BADFLD=1,WP=0
43 .S LOC=$$GET1^DID(2260,FLD,"","GLOBAL SUBSCRIPT LOCATION")
44 .S NODE=$P(LOC,";"),PCE=$P(LOC,";",2)
45 .I PCE=0 D ;Work processing field
46 ..I '$D(^OOPS(2260,IEN,NODE,1,0)) S (BADFLD,VALID)=0
47 ..S WP=1
48 ..Q
49 .I PCE'=0 I $P($G(^OOPS(2260,IEN,NODE)),U,PCE)="" S (BADFLD,VALID)=0
50 .I 'BADFLD D ; Display error messaged about fields not filled.
51 ..I 'CHK W !!,"The following fields must be completed before the "_FORM_" can be signed.",! S CHK=1
52 ..I WP D ;Is this a wp field and where to get title
53 ...N NODE
54 ...S NODE=2260_".0"_FLD
55 ...; patch 11 - fix bug on fld 40, node '= 2260.040, it's 2260.01
56 ...I FLD=40 S NODE="2260.01"
57 ...S TEXT=$$GET1^DID(NODE,".01","","TITLE")
58 ..I 'WP S TEXT=$$GET1^DID(2260,FLD,"","TITLE") I $G(TEXT)="" S TEXT=$$GET1^DID(2260,FLD,"","LABEL")
59 ..; patch 2.7 - if body part affected - indicate the form
60 ..I FLD=30,(TEXT'="") S TEXT=TEXT_" (FORM 2162)"
61 ..W !,TEXT
62 I FORM="CA1"&(CALLER="E"!$G(WCEMP)) D ; fld 110 check on Emp CA1 only
63 .I $$GET1^DIQ(2260,IEN,110,"I")<($$GET1^DIQ(2260,IEN,4,"I")\1) S VALID=0 D
64 ..W !?5,$$GET1^DID(2260,110,"","LABEL")_" must be on or after the "_$$GET1^DID(2260,4,"","LABEL")
65DTCHK ; Date error checking that may be missed w/input transform
66 ; patch 11 - Additional error checking has been added for CA2 field 214
67 I FORM=2162!(CALLER="O")!$G(WCEMP) Q
68 K CNT,FLD,LIST
69 N DATE,DTE1,DTE2,TITLE,EMPDOB
70 ; patch 11 - need to make sure 215 not before 214 on employee part
71 I CALLER="E",FORM="CA2" D Q
72 .S DTE1=$$GET1^DIQ(2260,IEN,215,"I")
73 .S DTE2=$$GET1^DIQ(2260,IEN,214,"I")
74 .S EMPDOB=$$GET1^DIQ(2260,IEN,6,"I")
75 .I $$FMDIFF^XLFDT(DTE2,EMPDOB,2)<0 S VALID=0 D
76 ..W !?5,$$GET1^DID(2260,214,"","LABEL")_" must be on or after the "_$$GET1^DID(2260,6,"","LABEL")
77 .I $$FMDIFF^XLFDT(DTE1,DTE2,2)<0 S VALID=0 D
78 ..W !?5,$$GET1^DID(2260,215,"","LABEL")_" must be on or after the "_$$GET1^DID(2260,214,"","LABEL")
79 ; End of checks from Employee CA2
80 I FORM="CA1" D
81 .S LIST="142,161,175"
82 .S (DATE,DTE1)=$$GET1^DIQ(2260,IEN,4,"I")
83 .S TITLE=$$GET1^DID(2260,4,"","LABEL")
84 I FORM="CA2" D
85 .S LIST="215,250,252,253,255"
86 .S (DATE,DTE1)=$$GET1^DIQ(2260,IEN,214,"I")
87 .S TITLE=$$GET1^DID(2260,214,"","LABEL")
88 F CNT=1:1 S FLD=$P(LIST,",",CNT) Q:FLD="" D
89 .S DTE2=$$GET1^DIQ(2260,IEN,FLD,"I") I FLD'=142 S DTE2=DTE2\1,DTE1=DATE\1
90 .I $G(DTE2),DTE2<DTE1 D S VALID=0
91 ..W !?5,$$GET1^DID(2260,FLD,"","LABEL")_" must be on or after the "_TITLE
92 ; Need specific check on DATE/TIME STOPPED WORK
93 I FORM="CA1" D
94 .S LIST="143,144,145",DATE=$$GET1^DIQ(2260,IEN,142,"I")
95 .S TITLE=$$GET1^DID(2260,142,"","LABEL")
96 I FORM="CA2" D
97 .S LIST="254,256",DATE=$$GET1^DIQ(2260,IEN,253,"I")
98 .S TITLE=$$GET1^DID(2260,253,"","LABEL")
99 F CNT=1:1 S FLD=$P(LIST,",",CNT) Q:FLD="" D
100 .S DTE2=$$GET1^DIQ(2260,IEN,FLD,"I"),DTE1=DATE D
101 ..I FLD=143!(FLD=144) S DTE1=DATE\1,DTE2=DTE2\1
102 ..I (DTE1>DTE2),$G(DTE2) D S VALID=0
103 ...W !?5,$$GET1^DID(2260,FLD,"","LABEL")_" must be on or after the "_TITLE
104 ..I '$G(DTE1),$G(DTE2) D S VALID=0
105 ...W !?5,TITLE_" cannot be blank if date in "_$$GET1^DID(2260,FLD,"","LABEL")
106 Q
107EMP ; Address fields are now all pulled from the 2162A node
108 ; added fields 126 & 181,183-185 to lists below - patch 8
109 I FORM="CA1" S LIST="8,9,10,11,12,108,109,110,111,112,113,114,126,181,183,184,185"
110 ; added field 213 - ASISTS V2.0
111 I FORM="CA2" S LIST="8,9,10,11,12,126,208,213,209,214,215,216,217"
112 Q
113SUP ;
114 N F165
115 I FORM="2162" D F2162 I $$ISEMP^OOPSUTL4(IEN) S LIST=LIST_",33" Q
116 S LIST="30,"
117 I FORM="CA1" D
118 .S LIST=LIST_"4,60,130,131,132,133,134,138,139,140,146,148,150,"
119 .S LIST=LIST_"162,163,172,173,174,175,176,177,178,179,"
120 .S LIST=LIST_"180,181,183,184,185,"
121 .I $$GET1^DIQ(2260,IEN,150,"I")="Y" S LIST=LIST_"151,152,153,154,155,"
122 .; V2.0 added required fields missed in patch 8
123 .I $$GET1^DIQ(2260,IEN,146)="No" S LIST=LIST_"147,"
124 .I $$GET1^DIQ(2260,IEN,148)="Yes" S LIST=LIST_"149,"
125 .I $$GET1^DIQ(2260,IEN,163)="No" S LIST=LIST_"164,"
126 .S F165=$G(^OOPS(2260,IEN,"CA1K",0))
127 .I $G(F165)'="",($P(F165,U,4)'=0) S LIST=LIST_"165,"
128 I FORM="CA2" D
129 .S LIST=LIST_"230,231,232,233,234,237,238,239,240,241,"
130 .S LIST=LIST_"242,243,244,251,252,255,258,60,268,269,"
131 .; below for ASISTS V2.0, needed for roll and scroll also
132 .; added next line, need to get 3rd party if 258 = y
133 .I $$GET1^DIQ(2260,IEN,258,"I")="Y" S LIST=LIST_"259,260,261,262,263,"
134 ; V2.0 if field 60="other" (3) then 61 required for both CA1 & CA2
135 I $$GET1^DIQ(2260,IEN,60,"I")=3 S LIST=LIST_"61,"
136 ; need to check physician information
137 D PHYCHK^OOPSGUI9
138 Q
139SOF ;
140 I FORM="2162" D F2162 S LIST=LIST_",55,47"
141 Q
142WCP ; Get required fields for Workers Comp
143 I FORM="2162" D F2162 Q
144 S LIST="5,6,7,15,62,70,73,"
145 I FORM="CA1" D
146 . S LIST=LIST_"123,124,"
147 . ; flds 166 & 167 only required if personnel status = 1
148 . I $$GET1^DIQ(2260,IEN,2,"I")=1 S LIST=LIST_"166,167,"
149 I FORM="CA2" D
150 . S LIST=LIST_"226,227,"
151 D SUP
152 Q
153F2162 ; Set required fields for form 2162 - doesn't matter which menu
154 ; coming from, Supervisor, Safety, WC (for EDIT REPORT OF INCIDENT)
155 N TYP,SAF
156 I FORM'="2162" Q
157 S LIST="26,27,28,29,30,31"
158 S TYP=$$GET1^DIQ(2260,IEN,"3:.01","E")
159 I "^Sharps Exposure^Hollow Bore Needlestick^Suture Needlestick^"[TYP D
160 . S LIST=LIST_",34,35,36,37,38,82"
161 I $$GET1^DIQ(2260,IEN,"38:2","I")="N" S LIST=LIST_",83"
162 I "^Exposure to Body Fluids/Splash^"[TYP D
163 . S LIST=LIST_",34,39,40,41"
164 I $$GET1^DIQ(2260,IEN,3,"I")<11 Q
165 I $$GET1^DIQ(2260,IEN,42.5,"I")="Y" S LIST=LIST_",42"
166 S SAF=$$GET1^DIQ(2260,IEN,43,"I")
167 S LIST=$S(SAF="Y":LIST_",84,87",SAF="N":LIST_",85",1:LIST)
168 S LIST=LIST_",47"
169 Q
170UP(IN) ; Translate all lower to upper
171 N OUT
172 S OUT=$TR(IN,"abcdefghijklmnopqrstuvwxyz","ABCDEFGHIJKLMNOPQRSTUVWXYZ")
173 Q OUT
174VCHAR(IN) ; Check to make sure no invalid characters have been used
175 ; input - IN, data entered by user
176 ; output - VALID, if invalid characters used, = 0
177 N VALID
178 S VALID=1
179 I IN'=$TR(IN,"~`@#$%*_|\}{[]><","") S VALID=0
180 Q VALID
181ISEMP(IEN) ; Determine if PERSONNEL STATUS = employee
182 ; Input - IEN = internal Entry Number of case in File 2260
183 ; CAT = Personnel Status of Case in File 2260
184 ; TST = valid Personnel status categories for employee
185 ; Output - EMP = 1 Personnel status indicates employee
186 ; 0 Personnel status indicates non-employee
187 NEW CAT,TST,EMP
188 S EMP=0
189 S CAT=$$GET1^DIQ(2260,IEN,2,"I")
190 ; 12/16/01 V2.0 removed personnel types 7,8,9,10
191 S TST=",1,2,6,"
192 I TST[(","_CAT_",") S EMP=1
193 Q EMP
194FUT(DATE) ; Check for dates prior to Date of Inj/Ill
195 N DAT,VIEW,FORM
196 S VIEW=1
197 S FORM=$$GET1^DIQ(2260,IEN,52,"I")
198 S DAT=$$GET1^DIQ(2260,IEN,4,"I")
199 I (DATE<$P(DAT,".")),FORM=1 D
200 . W !!?6,"This date cannot be prior to DATE/TIME INJURY OCCURRED entered on 2162.",! S VIEW=0
201 Q VIEW
202WP(OPFLD) ; Patch 8 - determine number of characters in WP fields that are
203 ; limited to 532 characters & if invalid characters are present
204 ; Input IEN - Internal Record ID of Case
205 ; OPFLD - Field number of WP field to be calculated
206 ; Output OPT - Total number of characters in all lines of WP field
207 ; concatenated to VALID. ex: 165^1 or 180^0
208 ; VALID - indicates whether invalid characters were detected
209 N DATA,DIWL,DIWR,DIWF,OPGLB,OPI,OPNODE,OPT,OPC,VALID
210 S VALID=1
211 K ^UTILITY($J,"W")
212 S DIWL=1,DIWR="",DIWF="|C264",OPT=0
213 S OPNODE=$P($$GET1^DID(2260,OPFLD,"","GLOBAL SUBSCRIPT LOCATION"),";")
214 S OPI=0 F S OPI=$O(^OOPS(2260,IEN,OPNODE,OPI)) Q:'OPI S X=$G(^OOPS(2260,IEN,OPNODE,OPI,0)) D:X]"" ^DIWP
215 I $G(^UTILITY($J,"W",1))+0 D
216 . S OPI=0 F OPC=1:1 S OPI=$O(^UTILITY($J,"W",1,OPI)) Q:'OPI D
217 .. S DATA=^UTILITY($J,"W",1,OPI,0)
218 .. I DATA'=$TR(DATA,"~`@#$%^*_|\}{[]><","") S VALID=0
219 .. S OPT=OPT+$L(DATA)
220 K ^UTILITY($J,"W"),X
221 Q OPT_U_VALID
Note: See TracBrowser for help on using the repository browser.