source: FOIAVistA/trunk/r/ORDER_ENTRY_RESULTS_REPORTING-OR-OCX--ORRC--ORRJ/ORWPCE1.m@ 1678

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

initial load of FOIAVistA 6/30/08 version

File size: 8.3 KB
Line 
1ORWPCE1 ;SLC/KCM - PCE Calls from CPRS GUI; 10/26/04
2 ;;3.0;ORDER ENTRY/RESULTS REPORTING;**10,85,116,132,148,187,190,215**;Dec 17, 1997
3 ;
4 ; DBIA 1365 DSELECT^GMPLENFM ^TMP("IB",$J)
5 ;
6GETVSIT(VSTR,DFN) ; lookup a visit
7 N PKG,SRC,ORPXAPI,OK,ORVISIT
8 S PKG=$O(^DIC(9.4,"B","ORDER ENTRY/RESULTS REPORTING",0))
9 S SRC="TEXT INTEGRATION UTILITIES"
10 S ORPXAPI("ENCOUNTER",1,"ENC D/T")=$P(VSTR,";",2)
11 S ORPXAPI("ENCOUNTER",1,"PATIENT")=DFN
12 S ORPXAPI("ENCOUNTER",1,"HOS LOC")=+VSTR
13 S ORPXAPI("ENCOUNTER",1,"SERVICE CATEGORY")=$P(VSTR,";",3)
14 S ORPXAPI("ENCOUNTER",1,"ENCOUNTER TYPE")="P"
15 S OK=$$DATA2PCE^PXAPI("ORPXAPI",PKG,SRC,.ORVISIT)
16 Q ORVISIT
17DQDEL ; background call to DATA2PCE and DELVFILE
18 N VISIT,VAL
19 I $D(ZTQUEUED) S ZTREQ="@"
20 S VISIT=$$GETVSIT(VSTR,DFN)
21 S VAL=$$DELVFILE^PXAPI("ALL",VISIT,"","TEXT INTEGRATION UTILITIES")
22 S ZTSTAT=0 ; clear sync flag
23 Q
24DQSAVE ; Background Call to DATA2PCE
25 N PKG,SRC,TYP,CODE,IEN,OK,I,X,ORPXAPI,ORPXDEL
26 N CAT,NARR,ROOT,ROOT2,ORAVST
27 N PRV,CPT,ICD,IMM,SK,PED,HF,XAM,TRT,MOD,MODCNT,MODIDX,MODS
28 N COM,COMMENT,COMMENTS
29 N DFN,PROBLEMS,PXAPREDT,ORCPTDEL
30 I $D(ZTQUEUED) S ZTREQ="@"
31 S PKG=$O(^DIC(9.4,"B","ORDER ENTRY/RESULTS REPORTING",0))
32 S SRC="TEXT INTEGRATION UTILITIES"
33 S (PRV,CPT,ICD,IMM,SK,PED,HF,XAM,TRT)=0
34 S I="" F S I=$O(PCELIST(I)) Q:'I S X=PCELIST(I) D
35 . S X=PCELIST(I),TYP=$P(X,U),CODE=$P(X,U,2),CAT=$P(X,U,3),NARR=$P(X,U,4)
36 . I $E(TYP,1,3)="PRV" D Q
37 . . Q:'$L(CODE)
38 . . S PRV=PRV+1
39 . . S ROOT="ORPXAPI(""PROVIDER"","_PRV_")"
40 . . S ROOT2="ORPXDEL(""PROVIDER"","_PRV_")"
41 . . I $E(TYP,4)'="-" D
42 . . . S @ROOT@("NAME")=CODE
43 . . . S @ROOT@("PRIMARY")=$P(X,U,6)
44 . . S @ROOT2@("NAME")=CODE
45 . . S @ROOT2@("DELETE")=1
46 . . S PXAPREDT=1 ;Allow edit of primary flag
47 . I TYP="VST" D Q
48 . . S ROOT="ORPXAPI(""ENCOUNTER"",1)"
49 . . I CODE="DT" S @ROOT@("ENC D/T")=$P(X,U,3) Q
50 . . I CODE="PT" S @ROOT@("PATIENT")=$P(X,U,3),DFN=$P(X,U,3) Q
51 . . I CODE="HL" S @ROOT@("HOS LOC")=$P(X,U,3) Q
52 . . I CODE="PR" S @ROOT@("PARENT")=$P(X,U,3) Q
53 . . ;prevents checkout!
54 . . I CODE="VC" S @ROOT@("SERVICE CATEGORY")=$P(X,U,3) Q
55 . . I CODE="SC" S @ROOT@("SC")=$P(X,U,3) Q
56 . . I CODE="AO" S @ROOT@("AO")=$P(X,U,3) Q
57 . . I CODE="IR" S @ROOT@("IR")=$P(X,U,3) Q
58 . . I CODE="EC" S @ROOT@("EC")=$P(X,U,3) Q
59 . . I CODE="MST" S @ROOT@("MST")=$P(X,U,3) Q
60 . . I CODE="HNC" S @ROOT@("HNC")=$P(X,U,3) Q
61 . . I CODE="CV" S @ROOT@("CV")=$P(X,U,3) Q
62 . . I CODE="OL" D Q
63 . . . I +$P(X,U,3) S @ROOT@("INSTITUTION")=$P(X,U,3)
64 . . . E I $P(X,U,4)'="",$P(X,U,4)'="0" D
65 . . . . I $$PATCH^XPDUTL("PX*1.0*96") S @ROOT@("OUTSIDE LOCATION")=$P(X,U,4)
66 . . . . E S @ROOT@("COMMENT")="OUTSIDE LOCATION: "_$P(X,U,4)
67 . I $E(TYP,1,3)="CPT" D Q
68 . . Q:'$L(CODE)
69 . . S CPT=CPT+1,ROOT="ORPXAPI(""PROCEDURE"","_CPT_")"
70 . . S IEN=+$O(^ICPT("B",CODE,0))
71 . . S @ROOT@("PROCEDURE")=IEN
72 . . I +$P(X,U,9) D
73 . . . S MODS=$P(X,U,9),MODCNT=+MODS
74 . . . F MODIDX=1:1:MODCNT D
75 . . . . S MOD=$P($P(MODS,";",MODIDX+1),"/")
76 . . . . S @ROOT@("MODIFIERS",MOD)=""
77 . . S:$L(CAT) @ROOT@("CATEGORY")=CAT
78 . . S:$L(NARR) @ROOT@("NARRATIVE")=NARR
79 . . S:$L($P(X,U,5)) @ROOT@("QTY")=$P(X,U,5)
80 . . S:$P(X,U,6)>0 @ROOT@("ENC PROVIDER")=$P(X,U,6)
81 . . S:$L($P(X,U,10))>0 COMMENT($P(X,U,10))="PROCEDURE^"_CPT
82 . . I $E(TYP,4)="-" S @ROOT@("DELETE")=1,@ROOT@("QTY")=0,ORCPTDEL=CPT
83 . I $E(TYP,1,3)="POV" D Q
84 . . Q:'$L(CODE)
85 . . S ICD=ICD+1,ROOT="ORPXAPI(""DX/PL"","_ICD_")"
86 . . S IEN=+$O(^ICD9("AB",CODE_" ",0))
87 . . S @ROOT@("DIAGNOSIS")=IEN
88 . . S @ROOT@("PRIMARY")=$P(X,U,5)
89 . . S:$L(CAT) @ROOT@("CATEGORY")=CAT
90 . . S:$L(NARR) @ROOT@("NARRATIVE")=NARR
91 . . S:$P(X,U,6)>0 @ROOT@("ENC PROVIDER")=$P(X,U,6)
92 . . I $L($P(X,U,7)),$P(X,U,7)=1 S @ROOT@("PL ADD")=$P(X,U,7),PROBLEMS(ICD)=NARR_U_CODE
93 . . S:$L($P(X,U,10))>0 COMMENT($P(X,U,10))="DX/PL^"_ICD
94 . . I $E(TYP,4)="-" S @ROOT@("DELETE")=1
95 . I $E(TYP,1,3)="IMM" D Q
96 . . Q:'$L(CODE)
97 . . S IMM=IMM+1,ROOT="ORPXAPI(""IMMUNIZATION"","_IMM_")"
98 . . S @ROOT@("IMMUN")=CODE
99 . . S:$L($P(X,U,5)) @ROOT@("SERIES")=$P(X,U,5)
100 . . S:$L($P(X,U,5)) @ROOT@("REACTION")=$P(X,U,7)
101 . . S:$L($P(X,U,8)) @ROOT@("CONTRAINDICATED")=$P(X,U,8)
102 . . S:$L($P(X,U,9)) @ROOT@("REFUSED")=$P(X,U,9)
103 . . S:$P(X,U,6)>0 @ROOT@("ENC PROVIDER")=$P(X,U,6)
104 . . S:$L($P(X,U,10))>0 COMMENT($P(X,U,10))="IMMUNIZATION^"_IMM
105 . . I $E(TYP,4)="-" S @ROOT@("DELETE")=1
106 . I $E(TYP,1,2)="SK" D Q
107 . . Q:'$L(CODE)
108 . . S SK=SK+1,ROOT="ORPXAPI(""SKIN TEST"","_SK_")"
109 . . S @ROOT@("TEST")=CODE
110 . . S:$L($P(X,U,5)) @ROOT@("RESULT")=$P(X,U,5)
111 . . S:$L($P(X,U,7)) @ROOT@("READING")=$P(X,U,7)
112 . . S:$L($P(X,U,8)) @ROOT@("D/T READ")=$P(X,U,8)
113 . . S:$L($P(X,U,9)) @ROOT@("EVENT D/T")=$P(X,U,9)
114 . . S:$P(X,U,6)>0 @ROOT@("ENC PROVIDER")=$P(X,U,6)
115 . . S:$L($P(X,U,10))>0 COMMENT($P(X,U,10))="SKIN TEST^"_SK
116 . . I $E(TYP,3)="-" S @ROOT@("DELETE")=1
117 . I $E(TYP,1,3)="PED" D Q
118 . . Q:'$L(CODE)
119 . . S PED=PED+1,ROOT="ORPXAPI(""PATIENT ED"","_PED_")"
120 . . S @ROOT@("TOPIC")=CODE
121 . . S:$L($P(X,U,5)) @ROOT@("UNDERSTANDING")=$P(X,U,5)
122 . . S:$P(X,U,6)>0 @ROOT@("ENC PROVIDER")=$P(X,U,6)
123 . . S:$L($P(X,U,10))>0 COMMENT($P(X,U,10))="PATIENT ED^"_PED
124 . . I $E(TYP,4)="-" S @ROOT@("DELETE")=1
125 . I $E(TYP,1,2)="HF" D Q
126 . . Q:'$L(CODE)
127 . . S HF=HF+1,ROOT="ORPXAPI(""HEALTH FACTOR"","_HF_")"
128 . . S @ROOT@("HEALTH FACTOR")=CODE
129 . . S:$L($P(X,U,5)) @ROOT@("LEVEL/SEVERITY")=$P(X,U,5)
130 . . S:$P(X,U,6)'>0 $P(X,U,6)=$G(ORPXAPI("PROVIDER",1,"NAME"))
131 . . S:$P(X,U,6)>0 @ROOT@("ENC PROVIDER")=$P(X,U,6)
132 . . S:$L($P(X,U,11)) @ROOT@("EVENT D/T")=$P($P(X,U,11),";",1)
133 . . S:$L($P(X,U,11)) SRC=$P($P(X,U,11),";",2)
134 . . S:$L($P(X,U,10))>0 COMMENT($P(X,U,10))="HEALTH FACTOR^"_HF
135 . . I $E(TYP,3)="-" S @ROOT@("DELETE")=1
136 . I $E(TYP,1,3)="XAM" D Q
137 . . Q:'$L(CODE)
138 . . S XAM=XAM+1,ROOT="ORPXAPI(""EXAM"","_XAM_")"
139 . . S @ROOT@("EXAM")=CODE
140 . . S:$L($P(X,U,5)) @ROOT@("RESULT")=$P(X,U,5)
141 . . S:$P(X,U,6)>0 @ROOT@("ENC PROVIDER")=$P(X,U,6)
142 . . S:$L($P(X,U,10))>0 COMMENT($P(X,U,10))="EXAM^"_XAM
143 . . I $E(TYP,4)="-" S @ROOT@("DELETE")=1
144 . I $E(TYP,1,3)="TRT" D Q
145 . . Q:'$L(CODE)
146 . . S TRT=TRT+1,ROOT="ORPXAPI(""TREATMENT"","_TRT_")"
147 . . S @ROOT@("IMMUN")=CODE
148 . . S:$L(CAT) @ROOT@("CATEGORY")=CAT
149 . . S:$L(NARR) @ROOT@("NARRATIVE")=NARR
150 . . S:$L($P(X,U,5)) @ROOT@("QTY")=$P(X,U,5)
151 . . S:$P(X,U,6)>0 @ROOT@("ENC PROVIDER")=$P(X,U,6)
152 . . S:$L($P(X,U,10))>0 COMMENT($P(X,U,10))="TREATMENT^"_TRT
153 . . I $E(TYP,4)="-" S @ROOT@("DELETE")=1,@ROOT@("QTY")=0
154 . I $E(TYP,1,3)="COM" D Q
155 . . Q:'$L(CODE)
156 . . Q:'$L(CAT)
157 . . S COMMENTS(CODE)=$P(X,U,3,999)
158 ;Store the comments
159 S COM=""
160 F S COM=$O(COMMENT(COM)) Q:COM="" S:$D(COMMENTS(COM)) ORPXAPI($P(COMMENT(COM),"^",1),$P(COMMENT(COM),"^",2),"COMMENT")=COMMENTS(COM)
161 ;
162 ;Remove any problems to add that the patient already has as active problems
163 I $D(PROBLEMS),$D(DFN) D
164 . N ORWPROB,ORPROBIX
165 . K ^TMP("IB",$J,"INTERFACES","GMP SELECT PATIENT ACTIVE PROBLEMS")
166 . D DSELECT^GMPLENFM ;DBIA 1365
167 . S ORPROBIX=0
168 . F S ORPROBIX=$O(^TMP("IB",$J,"INTERFACES","GMP SELECT PATIENT ACTIVE PROBLEMS",ORPROBIX)) Q:'ORPROBIX D ;DBIA 1365
169 .. S ORWPROB=$P(^TMP("IB",$J,"INTERFACES","GMP SELECT PATIENT ACTIVE PROBLEMS",ORPROBIX),"^",2,3)
170 .. S ORWPROB($S($E(ORWPROB,1)="$":$E(ORWPROB,2,255),1:ORWPROB))=""
171 . K ^TMP("IB",$J,"INTERFACES","GMP SELECT PATIENT ACTIVE PROBLEMS")
172 . Q:'$D(ORWPROB)
173 . S ORPROBIX=""
174 . F S ORPROBIX=$O(PROBLEMS(ORPROBIX)) Q:'ORPROBIX D
175 .. S:$D(ORWPROB(PROBLEMS(ORPROBIX))) ORPXAPI("DX/PL",ORPROBIX,"PL ADD")=0
176 ;
177 I $$MDS(.ORPXAPI,$G(ORLOC)) S ORPXAPI("ENCOUNTER",1,"CHECKOUT D/T")=$$NOW^XLFDT
178 S ORPXAPI("ENCOUNTER",1,"ENCOUNTER TYPE")="P"
179DATA2PCE ;
180 I $G(PXAPREDT)!($G(ORCPTDEL)) D
181 . M ORPXDEL("ENCOUNTER")=ORPXAPI("ENCOUNTER")
182 . I $G(ORCPTDEL) M ORPXDEL("PROCEDURE",ORCPTDEL)=ORPXAPI("PROCEDURE",ORCPTDEL)
183 . S OK=$$DATA2PCE^PXAPI("ORPXDEL",PKG,SRC,.ORAVST)
184 S OK=$$DATA2PCE^PXAPI("ORPXAPI",PKG,SRC,.ORAVST)
185 I OK>0,+NOTEIEN,+ORAVST D ; NOTEIEN only set on inpatient encounters
186 .N OROK,ORX
187 .S ORX(1207)=ORAVST
188 .D FILE^TIUSRVP(.OROK,NOTEIEN,.ORX,1)
189 S ZTSTAT=0 ; clear sync flag
190 Q
191 ;
192MDS(X,ORLOC) ; return TRUE if checkout is needed
193 I $$CHKOUT^ORWPCE2(ORLOC) Q 1
194 N I,ORAUTO,OROK
195 S (OROK,I)=0
196 F S I=$O(X("DX/PL",I)) Q:'I D Q:OROK
197 . I $G(X("DX/PL",I,"DIAGNOSIS")) S OROK=1
198 I 'OROK D
199 .S I=0 F S I=$O(X("PROCEDURE",I)) Q:'I D Q:OROK
200 .. I $G(X("PROCEDURE",I,"PROCEDURE")) S OROK=1
201 I $D(X("PROVIDER",1,"NAME")) S OROK=1
202 Q OROK
203NONCOUNT(ORY,ORLOC) ; Is the location a non-count clinic? (DBIA #964)
204 Q:'ORLOC
205 S ORY=$S($P($G(^SC(ORLOC,0)),U,17)="Y":1,1:0)
206 Q
Note: See TracBrowser for help on using the repository browser.