source: FOIAVistA/trunk/r/HEALTH_SUMMARY-GMTS/GMTSPXOP.m@ 1328

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

initial load of FOIAVistA 6/30/08 version

File size: 7.5 KB
Line 
1GMTSPXOP ; SLC/SBW,KER - PCE Outpatient Encounter comp ; 02/27/2002
2 ;;2.7;Health Summary;**8,10,28,37,47,49,76**;Oct 20, 1995
3 ;
4 ; External References
5 ; DBIA 1238 VISIT^PXRHS01
6 ; DBIA 1996 $$MOD^ICPTMOD
7 ; DBIA 10103 $$DT^XLFDT
8 ; DBIA 10011 ^DIWP
9 ;
10PURPOSE ; Encounters with ICD9 and providers
11 N DTYPE S DTYPE="DP" D MAIN Q
12OUTPT ; Encounters with ICD9, CPT, and providers
13 N DTYPE S DTYPE="CDP" D MAIN Q
14MAIN ; Entry for Purpose of Visit and Outpatient Encounters
15 N GMTSIVD,GMTSDAT,GMTSDTU,GMTSOVT,GMTSLOC,DIWL,GMTAB,GMTSN,GMCKP,GMTSX
16 N GMTSITE,GMTSINS,GMTSEVT,GMTSHIS,GMTSICL,GMTSLOC,GMTSELIG,X,GMTSVDF
17 N GMTSCPTM,GMICL
18 ;
19 ; GMTSCPTM Component uses CPT Modifiers 1 yes 0 no
20 S GMTSCPTM=+($$CPT^GMTSU(+($G(GMTSEGN)))) S:$G(GMPXCMOD)="N" GMTSCPTM=0
21 ; GMTSICL # of blank left columns for support data of a visit
22 S GMTSICL=14
23 ; DIWL Used in TXTFMT call & to print returned data
24 S DIWL=0
25 ; GMTAB Used to offset data from TXTFMT call after 1st line
26 S GMTAB=2
27 ; GMTSOVT This is the set of Service Categories for AICTSORE
28 ;
29 ; A Ambulatory
30 ; I Inpatient
31 ; C Chart Review
32 ; T Telecommunications
33 ; S Day Surgery
34 ; O Observation
35 ; R Nursing Home Encounters
36 ; E Event (Historical)
37 ;
38 ; Note: Hospitalization and Ancillary
39 ; encounters are not included
40 S GMTSOVT="AICTSORE"
41 ;
42 D VISIT^PXRHS01(DFN,GMTSEND,GMTSBEG,GMTSNDM,GMTSOVT,DTYPE,1)
43 Q:'$D(^TMP("PXHSV",$J))
44 S GMTSIVD=0
45 F S GMTSIVD=$O(^TMP("PXHSV",$J,GMTSIVD)) Q:GMTSIVD']"" D Q:$D(GMTSQIT)
46 . S GMTSVDF=0
47 . F S GMTSVDF=$O(^TMP("PXHSV",$J,GMTSIVD,GMTSVDF)) Q:GMTSVDF'>0 D Q:$D(GMTSQIT)
48 . . S GMTSN=$G(^TMP("PXHSV",$J,GMTSIVD,GMTSVDF,0))
49 . . S GMTSEVT=$P(GMTSN,U,4),GMTSHIS=$S(GMTSEVT["HISTORICAL":1,1:0)
50 . . S X=$P(GMTSN,U,1) D REGDT4^GMTSU S GMTSDAT=X
51 . . S GMTSDTU=0,(GMTSITE,GMTSLOC)=""
52 . . S GMTSINS=$S($P(GMTSN,U,3)]"":$E($P(GMTSN,U,3),1,10),$P(GMTSN,U,8)]"":$E($P(GMTSN,U,8),1,10),1:""),GMTSITE=GMTSINS
53 . . I $G(GMPXHLOC)'="N" S GMTSLOC=$E($P(GMTSN,U,6),1,30)
54 . . I '$L(GMTSLOC) S GMTSLOC=$P(GMTSN,U,9)
55 . . S GMTSELIG=$E($P(GMTSN,U,12),1,17)
56 . . S:GMTSITE=""&('GMTSHIS) GMTSLOC=""
57 . . I GMTSHIS D
58 . . . S:GMTSLOC'=""&(GMTSITE'="") GMTSLOC=GMTSLOC_" (Historical Event)"
59 . . . S:GMTSLOC=""&(GMTSITE'="") GMTSITE=GMTSITE_" (Historical Event)"
60 . . . S:GMTSLOC'=""&(GMTSITE="") GMTSITE=GMTSLOC_" (Historical Event)",GMTSLOC=""
61 . . . S:GMTSLOC=""&(GMTSITE="") GMTSITE="Historical Event"
62 . . D CKP^GMTSUP Q:$D(GMTSQIT) D DSPVIS,DSPPROV Q:$D(GMTSQIT)
63 . . D DSPPOV Q:$D(GMTSQIT) D DSPCPT W !
64 K ^TMP("PXHSV",$J)
65 Q
66 ;
67DSPPOV ; Display Purpose of visit
68 Q:$O(^TMP("PXHSV",$J,GMTSIVD,GMTSVDF,"D",""))=""
69 Q:$G(GMPXICDF)="N"&($G(GMPXNARR)="N")
70 N GMTSN,GMTSMOD,GMTSICD,GMTSNARR,GMTSPDN,GMTS,GMTSQTY,GMTSPRI,COMMENT
71 D CKP^GMTSUP Q:$D(GMTSQIT) D DSPVIS W ?3,"Diagnosis:"
72 S GMCKP=0,GMTSPDN="",GMTSQTY=""
73 F S GMTSPDN=$O(^TMP("PXHSV",$J,GMTSIVD,GMTSVDF,"D",GMTSPDN)) Q:GMTSPDN'>0 D Q:$D(GMTSQIT)
74 . S GMTSN=$G(^TMP("PXHSV",$J,GMTSIVD,GMTSVDF,"D",GMTSPDN))
75 . S GMTSMOD=$P(GMTSN,U,2)
76 . S GMTSICD=$P(GMTSN,U) D GETICDDX^GMTSPXU1(.GMTSICD,$G(GMPXICDF),GMTSMOD)
77 . S GMTSNARR=""
78 . S:$G(GMPXNARR)'="N" GMTSNARR=$G(^TMP("PXHSV",$J,GMTSIVD,GMTSVDF,"D",GMTSPDN,"N"))
79 . I $P(GMTSICD,"-",2,10)=$G(GMTSNARR) S GMTSNARR=""
80 . S GMTSPRI="" I $P(GMTSN,U,5)]"",$E($P(GMTSN,U,5),1)="P" S GMTSPRI=" (P)"
81 . D TXTFMT^GMTSPXU1(GMTSICD,$G(GMTSNARR),GMTSICL,GMTAB,DIWL,GMTSQTY,GMTSPRI)
82 . I '$D(^UTILITY($J,"W")) Q
83 . S GMTSX=0
84 . F S GMTSX=$O(^UTILITY($J,"W",DIWL,GMTSX)) Q:GMTSX'>0!$D(GMTSQIT) D
85 . . I GMCKP>0 D CKP^GMTSUP Q:$D(GMTSQIT) D DSPVIS
86 . . S GMCKP=1
87 . . W ?GMTSICL+$S(GMTSX>1:GMTAB,1:0),$G(^UTILITY($J,"W",DIWL,GMTSX,0)),!
88 . S COMMENT="",COMMENT=$P($G(^TMP("PXHSV",$J,GMTSIVD,GMTSVDF,"D",GMTSPDN,"COM")),U)
89 . I COMMENT]"" S GMICL=20,GMTAB=2 D FORMAT I $D(^UTILITY($J,"W")) D
90 . . F GMTSLN=1:1:^UTILITY($J,"W",DIWL) D LINE Q:$D(GMTSQIT)
91 Q
92DSPCPT ; Display Procedures performed during the visit
93 Q:$O(^TMP("PXHSV",$J,GMTSIVD,GMTSVDF,"C",""))=""
94 N GMTSNARR,GMTSPDN,GMTSN,GMTSICD,GMTSNARR,GMTSCPT,GMTSQTY,GMTSPRIM,GMTSPRI,GMTSFLG
95 D CKP^GMTSUP Q:$D(GMTSQIT) D DSPVIS W ?3,"Procedure:"
96 S GMCKP=0,GMTSPDN="",GMTSPRI=""
97 F S GMTSPDN=$O(^TMP("PXHSV",$J,GMTSIVD,GMTSVDF,"C",GMTSPDN)) Q:GMTSPDN'>0 D Q:$D(GMTSQIT)
98 . S GMTSN=$G(^TMP("PXHSV",$J,GMTSIVD,GMTSVDF,"C",GMTSPDN))
99 . S GMTSNARR=$P(GMTSN,U,2),GMTSQTY=$P(GMTSN,U,3),GMTSPRIM=$P(GMTSN,U,4)
100 . S GMTSCPT=$$GETCPT^GMTSPXU1($P(GMTSN,U)) I $P(GMTSCPT,"-",2,10)=GMTSNARR S GMTSNARR=""
101 . S GMTSPRI="" S:$G(GMTSQTY)]"" GMTSQTY=" ("_GMTSQTY_")" S:$G(GMTSPRIM)="Y" GMTSPRI="(P)"
102 . S GMTSFLG=1
103 . D TXTFMT^GMTSPXU1(GMTSCPT,GMTSNARR,GMTSICL,GMTAB,DIWL,GMTSQTY,GMTSPRI)
104 . Q:'$D(^UTILITY($J,"W")) D DCPT
105 Q
106DCPT ; Display CPT Comments
107 N GMTSLN,GMTSMOK,GMTSX S (GMTSMOK,GMTSX)=0
108 F S GMTSX=$O(^UTILITY($J,"W",DIWL,GMTSX)) Q:GMTSX'>0 D Q:$D(GMTSQIT)
109 . I GMCKP>0 D CKP^GMTSUP Q:$D(GMTSQIT) D DSPVIS Q:$D(GMTSQIT)
110 . S (GMTSMOK,GMCKP)=1 W ?GMTSICL+$S(GMTSX>1:GMTAB,1:0)
111 . W $G(^UTILITY($J,"W",DIWL,GMTSX,0))
112 . D CKP^GMTSUP Q:$D(GMTSQIT) W !
113 Q:DTYPE="DP"
114 S COMMENT=$P($G(^TMP("PXHSV",$J,GMTSIVD,GMTSVDF,"C",GMTSPDN,"COM")),U)
115 I COMMENT]"" S GMICL=20,GMTAB=2 D FORMAT I $D(^UTILITY($J,"W")) D
116 . F GMTSLN=1:1:^UTILITY($J,"W",DIWL) D Q:$D(GMTSQIT)
117 . . I GMTSFLG=1 W !,?10,"Comments:" S GMTSFLG=0
118 . . D LINE
119 S:+($G(GMTSCPTM))=0 GMTSMOK=0 D:GMTSMOK DMOD
120 Q
121DMOD ; Display CPT Modifier Comments
122 N GMTSM S GMTSM=""
123 W !
124 F S GMTSM=$O(^TMP("PXHSV",$J,GMTSIVD,GMTSVDF,"C",GMTSPDN,GMTSM)) Q:GMTSM="" D Q:$D(GMTSQIT)
125 . I GMTSM="COM" Q
126 . N COMMENT S COMMENT=$$FCM(GMTSM) Q:'$L(COMMENT)
127 . S GMICL=26,GMTAB=2 D FORMAT I $D(^UTILITY($J,"W")) D
128 . . F GMTSLN=1:1:^UTILITY($J,"W",DIWL) D LINE2 Q:$D(GMTSQIT)
129 Q
130DSPPROV ; Display Providers for visit
131 Q:$O(^TMP("PXHSV",$J,GMTSIVD,GMTSVDF,"P",""))=""
132 N GMCNT,GMPROV
133 D ORDERPRO^GMTSPXU1(.GMPROV,20)
134 D CKP^GMTSUP Q:$D(GMTSQIT) D DSPVIS W ?3," Provider:"
135 S GMCNT=0
136 F S GMCNT=$O(GMPROV(GMCNT)) Q:GMCNT'>0 D Q:GMCNT'>0!$D(GMTSQIT)
137 . I GMCNT>1 D CKP^GMTSUP Q:$D(GMTSQIT) D DSPVIS
138 . W ?GMTSICL,GMPROV(GMCNT) S GMCNT=$O(GMPROV(GMCNT)) Q:GMCNT'>0
139 . W ?37,GMPROV(GMCNT) S GMCNT=$O(GMPROV(GMCNT)) Q:GMCNT'>0
140 . W ?60,GMPROV(GMCNT)
141 . D CKP^GMTSUP Q:$D(GMTSQIT) W:$O(GMPROV(GMCNT)) !
142 D CKP^GMTSUP Q:$D(GMTSQIT) W !
143 Q
144DSPVIS ; Display outpatient visit data
145 Q:GMTSNPG'>0&(GMTSDTU>0) D:GMTSNPG HDR I GMTSNPG!(+GMTSDTU'>0) D
146 . W GMTSDAT,?14,GMTSITE,?29,GMTSLOC,?61,GMTSELIG
147 . D CKP^GMTSUP Q:$D(GMTSQIT) W !
148 . S GMTSDTU=1
149 Q
150HDR ; Display header
151 W ?3,"Date",?14,"Facility",?29,"Hospital Location",?61,"Encounter Elig.",!!
152 Q
153FORMAT ; Formats Diagnosis/Procedure line of text
154 N DIWR,DIWF,X S DIWL=3,DIWR=80-(GMICL+GMTAB) K ^UTILITY($J,"W") S X=COMMENT D ^DIWP
155 Q
156FCM(X) ; Format CPT Modifier comment
157 N Y,%,%H,GMTSIEN,GMTSC,GMTSS,GMTST S GMTSIEN=$G(X) Q:GMTSIEN="" ""
158 S:'$D(DT)!(+($G(DT))=0) DT=$$DT^XLFDT
159 S X=$$MOD^ICPTMOD(GMTSIEN,"E",) Q:'$D(X)
160 S GMTSC=$P(X,"^",2),GMTSS=$P(X,"^",3)
161 S GMTST=$$EN2^GMTSUMX(GMTSS) S Y=""
162 S:$L(GMTST)&($L(GMTSC)) Y=GMTSC_"-"_GMTST
163 S:'$L(GMTST)&($L(GMTSS))&($L(GMTSC)) Y=GMTSC_"-"_GMTSS
164 S:'$L(GMTST)&('$L(GMTSS))&($L(GMTSC)) Y=GMTSC
165 S:Y["-" Y="Modifier "_Y S X=Y
166 Q X
167LINE ; Writes formatted lines
168 D CKP^GMTSUP Q:$D(GMTSQIT) W ?20,^UTILITY($J,"W",DIWL,GMTSLN,0),! Q
169LINE2 ; Writes indented formatted lines
170 D CKP^GMTSUP Q:$D(GMTSQIT) N GMTST S GMTST=20 S:+($G(GMTSLN))>1 GMTST=31 W ?GMTST,^UTILITY($J,"W",DIWL,GMTSLN,0),! Q
Note: See TracBrowser for help on using the repository browser.