source: FOIAVistA/trunk/r/TEXT_INTEGRATION_UTILITIES-GMRP-TIU/TIUPXAPC.m@ 632

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

initial load of FOIAVistA 6/30/08 version

File size: 8.5 KB
Line 
1TIUPXAPC ; SLC/JER - Get CPT stuff ;5/8/03@10:27
2 ;;1.0;TEXT INTEGRATION UTILITIES;**15,24,62,82,161**;Jun 20, 1997
3TEST ; Check it out
4 N TIULOC,CPTARR,CPT,TIUI
5 S TIULOC=+$$SELLOC^TIUVSIT,TIUI=0
6 D GETCPT(TIULOC,.CPTARR)
7 D CPT(.CPT,.CPTARR)
8 W ! F S TIUI=$O(CPT(TIUI)) Q:+TIUI'>0 D
9 . W !,"CPT(",TIUI,")=",CPT(TIUI),!,"CPT(",TIUI,",""QTY"")="
10 . W CPT(TIUI,"QTY")
11 Q
12 ; Pass encounter date from TIUPXAPI to IBDF18A **161**
13GETCPT(TIULOC,CPTARR,TIUVDT) ; Get CPT codes for clinic
14 N TIUI,TIUROW,TIUCOL,ARRY2,TIUITM,TIUPAGE,EMARRY,TIUCAT S TIUCAT=""
15 ; Pass encounter date as 5th parameter to IBDF18A **161**
16 D GETLST^IBDF18A(+TIULOC,"DG SELECT VISIT TYPE CPT PROCEDURES","EMARRY",,,1,TIUVDT)
17 D GETLST^IBDF18A(+TIULOC,"DG SELECT CPT PROCEDURE CODES","ARRY2",,,1,TIUVDT)
18 I $D(EMARRY)>9 D CMBLST^TIUPXAP2(.EMARRY,.ARRY2) K EMARRY
19 S (TIUI,TIUROW,TIUITM)=0,(TIUCOL,TIUPAGE)=1
20 F S TIUI=$O(ARRY2(TIUI)) Q:+TIUI'>0 D
21 . I $P(ARRY2(TIUI),U)]"" D I 1
22 . . S TIUROW=+$G(TIUROW)+1,TIUITM=+$G(TIUITM)+1
23 . . ;Set CPT Display Array: Item #^CPT Code^Description^Group
24 . . S CPTARR(TIUROW,TIUCOL)=TIUITM_U_$P($G(ARRY2(TIUI)),U,1,2)_U_TIUCAT
25 . . S CPTARR("INDEX",TIUITM)=$P($G(ARRY2(TIUI)),U,1,2)_U_TIUCAT
26 . . ;If pre-selected CPT Modifiers are defined, add them to CPT Display Array
27 . . ;Pass encounter date to ADDMOD call to pass to ICPTMOD for CSV *161
28 . . I +$G(ARRY2(TIUI,"MODIFIER",0))>0 D ADDMOD(TIUITM,TIUI,.CPTARR,.ARRY2,.TIUROW,.TIUCOL,.TIUPAGE,TIUVDT)
29 . . K ARRY2(TIUI)
30 . E D
31 . . S TIUROW=+$G(TIUROW)+1
32 . . S TIUCAT=$$UP^XLFSTR($P($G(ARRY2(TIUI)),U,2))
33 . . S CPTARR(TIUROW,TIUCOL)=U_U_TIUCAT
34 . . K ARRY2(TIUI)
35 . ;Update counters for CPT Display Array
36 . D UPDCNT(.TIUROW,.TIUCOL,.TIUPAGE)
37 I +$G(ARRY2(0))>0 D
38 . S TIUROW=+$G(TIUROW)+1,TIUITM=TIUITM+1
39 . S CPTARR(TIUROW,TIUCOL)=TIUITM_"^OTHER CPT^OTHER Procedure"
40 . S CPTARR("INDEX",TIUITM)="OTHER CPT^OTHER Procedure"
41 . S CPTARR(0)=+$G(ARRY2(0))_U_+$G(TIUROW)_U_+$G(TIUPAGE)
42 . ;Update counters for CPT Display Array
43 . D UPDCNT(.TIUROW,.TIUCOL,.TIUPAGE)
44 Q
45 ;
46UPDCNT(TIUROW,TIUCOL,TIUPAGE) ;Update Counters for CPT Display Array
47 ; Input -- TIUROW Row Counter
48 ; TIUCOL Column Counter
49 ; TIUPAGE Page Counter
50 ; Output -- Counters:
51 ; TIUROW Row Counter
52 ; TIUCOL Column Counter
53 ; TIUPAGE Page Counter
54 I TIUROW#20'>0 D
55 . S:TIUCOL=3 TIUPAGE=TIUPAGE+1
56 . S TIUCOL=$S(TIUCOL=3:1,1:TIUCOL+1)
57 . S TIUROW=20*(TIUPAGE-1)
58 Q
59 ;
60 ;Pass in encounter date to pass to ICPTMOD,TIUPXAPM for CSV **161**
61ADDMOD(TIUITM,TIUI,CPTARR,ARRY2,TIUROW,TIUCOL,TIUPAGE,TIUVDT) ;Add Pre-selected CPT Modifiers from AICS to CPT Display Array
62 ; Input -- TIUITM Item Number in CPT Display Array
63 ; TIUI Item Number in Combined AICS Selection List Array
64 ; CPTARR CPT Display Array
65 ; ARRY2 Combined AICS Selection List Array
66 ; TIUROW Row Counter
67 ; TIUCOL Column Counter
68 ; TIUPAGE Page Counter
69 ; Output -- CPTARR CPT Display Array
70 ; (TIUROW,TIUCOL)=
71 ; ^^^^CPT Modifier^CPT Modifier Name
72 ; ("INDEX",TIUITM,"MODIFIER",MODCNT)=
73 ; CPT Modifier IEN^CPT Modifier^CPT Modifier Name
74 ; TIUROW Row Counter
75 ; TIUCOL Column Counter
76 ; TIUPAGE Page Counter
77 ; TIUVDT Encounter Date
78 N MODCNT,MODIFIER,MODINFO
79 ;
80 ;Loop through pre-selected CPT Modifiers
81 S MODCNT=0
82 F S MODCNT=$O(ARRY2(TIUI,"MODIFIER",MODCNT)) Q:'MODCNT D
83 . S MODIFIER=$P(ARRY2(TIUI,"MODIFIER",MODCNT),U) Q:MODIFIER=""
84 . ;Invoke API to get CPT Modifier information
85 . ;Pass encounter date to ICPTMOD for CSV **161**
86 . S MODINFO=$$MOD^ICPTMOD(MODIFIER,,TIUVDT)
87 . I +MODINFO>0 D
88 . . S TIUROW=TIUROW+1
89 . . ;Set CPT Modifier and CPT Modifier Name into CPT Display Array
90 . . S CPTARR(TIUROW,TIUCOL)=U_U_U_U_$P(MODINFO,U,2,3)
91 . . ;Set CPT Modifier IEN, CPT Modifier and CPT Modifier Name into Index for CPT Display Array
92 . . S CPTARR("INDEX",TIUITM,"MODIFIER",MODCNT)=$P(MODINFO,U,1,3)
93 Q
94 ;
95 ;Pass encounter date to CPT to pass to ICPTCOD
96CPT(CPT,CPTARR,TIUVDT) ; Select Procedures
97 N I,J,L,Y,TIUCPT,TIUICNT,TIUPGS,TIUPG,TIUITM,TIULITM,TIUPNM
98 S TIUPNM=$S($L($G(TIU("PNM"))):$G(TIU("PNM")),+$G(DFN):$$PTNAME^TIULC1(DFN),1:"the Patient")
99 W !!,"Please Indicate the Procedure(s) Performed on "_TIUPNM_":"
100 W:+$O(CPTARR(0)) !
101 S TIUICNT=+$G(CPTARR(0)),TIUPGS=$P($G(CPTARR(0)),U,3)
102 S (I,J,L,Y)=0 I +TIUICNT S TIUPG=1
103 F S I=$O(CPTARR(I)) Q:+I'>0 D
104 . S J=0 W ! F S J=$O(CPTARR(I,J)) Q:+J'>0 D
105 . . W ?((J-1)*25) W:+$P(CPTARR(I,J),U) $J($P(CPTARR(I,J),U),2)_" " W $E($P(CPTARR(I,J),U,3),1,20)
106 . . ;Display pre-selected CPT Modifier
107 . . W:$P(CPTARR(I,J),U,5)'="" " -"_$P(CPTARR(I,J),U,5)_" "_$E($P(CPTARR(I,J),U,6),1,14)
108 . . S TIUITM=$S(+$G(CPTARR(I,J)):+$G(CPTARR(I,J)),1:$G(TIUITM))
109 . . S:TIUITM>+$G(TIULITM) TIULITM=TIUITM
110 . I I#20=0 S Y=$S(+Y:Y,1:"")_$P($$PICK^TIUPXAP2(1,+$G(TIULITM),"Select Procedures"_$S(+$G(TIUPG)<TIUPGS:" (<RETURN> to see next page of choices)",1:"")),U),TIUPG=+$G(TIUPG)+1 W !
111 . S L=I S:TIUITM>+$G(TIULITM) TIULITM=TIUITM
112 I L#20 S Y=$S(+Y:Y,1:"")_$P($$PICK^TIUPXAP2(1,TIULITM,"Select Procedures"),U)
113 I +Y,$P(CPTARR("INDEX",+Y),U)'="OTHER CPT" D I 1
114 . N I,ITEM F I=1:1:($L(Y,",")-1) D
115 . . S ITEM=$P(Y,",",I)
116 . . I $P(CPTARR("INDEX",+ITEM),U)'="OTHER CPT" D I 1
117 . . . S CPT(I)=$G(CPTARR("INDEX",+ITEM))
118 . . . S $P(CPT(I),U,4)=$P(CPT(I),U)
119 . . . ;Pass encounter date to CPT to pass to ICDTCOD for CSV **161**
120 . . . S $P(CPT(I),U)=+$$CPT^ICPTCOD($P(CPT(I),U),TIUVDT)
121 . . . I +CPT(I)'>0 D
122 . . . . K CPT(I)
123 . . . ELSE D
124 . . . . ;Merge pre-selected CPT Modifiers from CPT Display Array into CPT Selection Array
125 . . . . M CPT(I,"MOD")=CPTARR("INDEX",ITEM,"MODIFIER")
126 . . ;Pass encounter date to CPTOUT for CSV **161**
127 . . E D CPTOUT(.CPT,.I,TIUVDT)
128 E D CPTOUT(.CPT,,TIUVDT)
129 I +$O(CPT(1)) D I 1
130 . N TIUI S TIUI=0
131 . F S TIUI=$O(CPT(TIUI)) Q:+TIUI'>0 D
132 . . S CPT(TIUI,"QTY")=+$$QTY(.CPT,TIUI)
133 . . K:CPT(TIUI,"QTY")'>0 CPT(TIUI)
134 . . ;Select CPT Modifiers
135 . . ;Pass encounter date to TIUPXAPM to pass to ICPTCOD for CVS **161**
136 . . I $D(CPT(TIUI)) D MOD^TIUPXAPM(.CPT,TIUI,TIUVDT)
137 E I $D(CPT(1)) D
138 . S CPT(1,"QTY")=+$$QTY(.CPT,1)
139 . K:CPT(1,"QTY")'>0 CPT(1)
140 . ;Select CPT Modifiers
141 . ;Pass encounter date to TIUPXAPM to pass to ICPTCOD for CSV **161**
142 . I $D(CPT(1)) D MOD^TIUPXAPM(.CPT,1,TIUVDT)
143 Q
144QTY(CPT,TIUI) ; How many times was the procedure performed?
145 N PROMPT,HELP
146 S PROMPT="How many times was the procedure performed? "
147 S HELP="^D QTYHLP^TIUPXAPC"
148 W !!!,$$UP^XLFSTR($P(CPT(TIUI),U,2)),":",!
149 Q +$$READ^TIUU("NA^1:99",PROMPT,1,HELP)
150QTYHLP ; Help for QTY read
151 W !,"Please specify the number of repetitions for this procedure"
152 W !,"performed during this visit with the patient (1-99)."
153 Q
154 ; Pass in encounter date to pass to LEXSET for CSV **161**
155CPTOUT(CPT,TIUI,TIUVDT) ; Go off-list for Procedure(s)
156 N DIC,X,Y,TIUOUT
157 F D Q:+$G(TIUOUT)
158 . I $L($T(CONFIG^LEXSET)) D I 1
159 . .; Pass encounter date to LEXSET for CSV **161**
160 . . D CONFIG^LEXSET("CHP","CHP",TIUVDT) ; PCH 24
161 . E S DIC="^ICPT("
162 . S DIC(0)="AEMQ"
163 . S DIC("A")="Select "_$S(+$G(CPTARR(0))'>0:"Procedure: ",1:"Another Procedure"_$S($D(CPTARR):" (NOT from Above List)",1:"")_": ")
164 . N X
165 . D ^DIC
166 . I +$D(DTOUT)!+$D(DUOUT)!(X="") S TIUOUT=1 Q
167 . I +Y>0 D Q
168 . . ; Pass encounter date to LEXC to LEXSET for CSV **161**
169 . . I DIC="^LEX(757.01," S Y=$$LEXC(Y,TIUVDT) ; PCH 24
170 . . S:$S(+$G(TIUI)'>0:1,$D(CPT(+$G(TIUI))):1,1:0) TIUI=$G(TIUI)+1
171 . . S CPT(TIUI)=Y
172 . W $C(7),!!,"Nothing found for ",X,"..."
173 . F D Q:(+Y>0)!+$G(TIUOUT)
174 . . N X
175 . . I $L($T(CONFIG^LEXSET)) D I 1
176 . . .; Pass encounter date for CSV **161**
177 . . . D CONFIG^LEXSET("CHP","CHP",TIUVDT) ; PCH 24
178 . . E S DIC="^ICPT("
179 . . S DIC("A")="Please try another expression, or RETURN to continue: "
180 . . D ^DIC
181 . . I +$D(DTOUT)!+$D(DUOUT)!(X="") S TIUOUT=1 Q
182 . . I +Y>0 D Q
183 . . . ; Pass encounter date to LEXC for CSV **161**
184 . . . I DIC="^LEX(757.01," S Y=$$LEXC(Y,TIUVDT) ; PCH 24
185 . . . S:$S(+$G(TIUI)'>0:1,$D(CPT(+$G(TIUI))):1,1:0) TIUI=$G(TIUI)+1
186 . . . S CPT(TIUI)=Y
187 . . W $C(7),!!,"Nothing found for ",X,"..."
188 Q
189 ; Pass in encounter date for CSV **161**
190LEXC(Y,TIUVDT) ; Get CPT IEN from Lexicon returned code PCH 24
191 N TIUC,TIUCODE S Y=$G(Y)
192 ; Pass encounter date for CSV **161**
193 S TIUC=$$CPTONE^LEXU(+Y,TIUVDT) S:'$L(TIUC) TIUC=$$CPCONE^LEXU(+Y,TIUVDT)
194 I '$L(TIUC) S Y="-1"_U_$P(Y,U,2) Q Y
195 S TIUCODE=TIUC
196 ; Pass encounter date instead of current date to ICPTCOD for CSV **161**
197 S TIUC=+$$CPT^ICPTCOD(TIUCODE,TIUVDT) S Y=TIUC_U_$P(Y,U,2)
198 S Y=Y_"^^"_TIUCODE
199 Q Y
Note: See TracBrowser for help on using the repository browser.