source: WorldVistAEHR/trunk/r/CPT_HCPCS_CODES-ICPT-DGYA/ICPTMOD.m@ 861

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

initial load of WorldVistAEHR

File size: 9.4 KB
RevLine 
[613]1ICPTMOD ; ALB/DEK/KER - CPT MODIFIER APIS ; 09/06/2006
2 ;;6.0;CPT/HCPCS;**6,12,13,14,19,30**;May 19, 1997;Build 1
3 ;
4 ; External References
5 ; DBIA 10103 $$DT^XLFDT
6 ;
7 Q
8MOD(MOD,MFT,MDT,SRC,DFN) ; returns basic info on CPT MODIFIERs
9 ;
10 ; Input: MOD Modifier, Internal or External (Required)
11 ; MFT Modifier Format "I" = IEN "E" = .01 field (Default)
12 ; MDT Version Date, FileMan format (default = TODAY)
13 ; SRC Source Screen
14 ; If 0 or Null, Level I and II only
15 ; If >0, Level I, II, and III
16 ; DFN Not used
17 ;
18 ; Output: Returns a 10 piece string delimited by the up-arrow (^)
19 ;
20 ; 1 IEN
21 ; 2 Modifier (0;1)
22 ; 3 Versioned Name (61, 0;1)
23 ; 4 Code (0;3)
24 ; 5 Source (0;4)
25 ; 6 Effective Date (60, 0;1)
26 ; 7 Status (60, 0;2) 0:inactive; 1:active
27 ; 8 Inactivation Date (60, 0;1)
28 ; 9 Activation Date (60, 0;1)
29 ; 10 Message
30 ; or
31 ; -1^Error
32 ;
33 N DATA,EFF,EFFX,EFFS,STR,MODN,MODST
34 I $G(MOD)="" S STR="-1^NO MODIFIER SELECTED" G MODQ
35 I $G(MFT)="" S MFT="E"
36 I "E^I"'[MFT S STR="-1^INVALID MODIFIER FORMAT" G MODQ
37 S MDT=$S($G(MDT)="":$$DT^XLFDT,1:$$DTBR^ICPTSUPT(MDT))
38 I MFT="E" S MODN=$O(^DIC(81.3,"B",MOD,0)) I $O(^(MODN)) S STR="-1^Multiple modifiers w/same name. Select IEN: " D MULT G MODQ
39 I MFT="E" S MOD=MODN
40 S MOD=+MOD
41 I 'MOD!'$D(^DIC(81.3,MOD)) S STR="-1^NO SUCH MODIFIER" G MODQ
42 S DATA=$G(^DIC(81.3,MOD,0))
43 S MODST=$$VSTCM(MOD,MDT)
44 I '$L(DATA) S STR="-1^NO DATA" G MODQ
45 S STR=MOD_"^"_$P(DATA,"^",1,4)
46 I '$G(SRC),$P(STR,"^",5)="V" Q "-1^VA LOCAL MODIFIER SELECTED"
47 S EFF=$$EFF^ICPTSUPT(81.3,MOD,MDT)
48 I EFF<1 S $P(EFF,"^",2)=0
49 S STR=STR_"^"_EFF_"^"_$$MSG^ICPTSUPT(MDT)
50 S:$L(MODST) $P(STR,"^",3)=MODST
51MODQ Q STR
52 ;
53MODD(CODE,OUTARR,DFN,CDT) ; returns CPT description in array
54 ;
55 ; Input: CODE CPT Modifier code, internal or external (Required)
56 ; ARY Output Array Name
57 ; e.g. "ABC" or "ABC("TEST")"
58 ; Default = ^TMP("ICPTD",$J)
59 ; DFN Not used
60 ; CDT Versioning Date (default = TODAY)
61 ; If CDT is prior to 1/1/1989, 1/1/1989 will be used
62 ; If CDT is year only, the first of that year will be used
63 ; If CDT is month/year only, the first of month will be used
64 ; If CDT is later than today, TODAY will be used
65 ;
66 ; Output: # Number of lines in description
67 ;
68 ; @ARY(1:n) - Versioned Description (from the 62 multiple)
69 ; @ARY(n+1) - blank
70 ; @ARY(n+1) - a message stating: CODE TEXT MAY BE INACCURATE
71 ; or
72 ; -1^Error
73 ;
74 ; ** User must initialize ^TMP("ICPTD",$J), if used **
75 ;
76 N ARR,END,CTV,I,N
77 I $G(CODE)="" S N="-1^NO CODE SELECTED" G MODDQ
78 I $G(OUTARR)="" S OUTARR="^TMP(""ICPTD"",$J,"
79 I OUTARR'["(" S OUTARR=OUTARR_"("
80 I OUTARR[")" S OUTARR=$P(OUTARR,")")
81 S END=$E(OUTARR,$L(OUTARR)) I END'="("&(END'=",") S OUTARR=OUTARR_","
82 I OUTARR="^TMP(""ICPTD"",$J," K ^TMP("ICPTD",$J)
83 S CODE=$S(CODE?1.N:+CODE,1:$$CODEN(CODE)),I=0,N=0
84 I CODE<1!'$D(^DIC(81.3,CODE)) S N="-1^NO SUCH CODE" G MODDQ
85 S CDT=$S($G(CDT)="":$$DT^XLFDT,1:$$DTBR^ICPTSUPT(CDT))
86 D VLTCM(+CODE,CDT,.CTV)
87 S (N,I)=0 F S I=$O(CTV(I)) Q:+I=0 D
88 . S N=N+1,ARR=OUTARR_N_")",@ARR=$$TRIM($G(CTV(I)))
89 I +N>0 D
90 . S N=N+1,ARR=OUTARR_N_")",@ARR=" "
91 . S N=N+1,ARR=OUTARR_N_")",@ARR=$$MSG^ICPTSUPT(CDT,1)
92 I +N'>0 S N="-1^VERSIONED DESCRIPTION NOT FOUND FOR MODIFIER "_$P($G(^DIC(81.3,+CODE,0)),"^",1)
93MODDQ Q N
94 ;
95MODA(CODE,VDT,ARY) ; Return an array of Modifiers for a CPT Code
96 D MODA^ICPTMOD2 Q
97 ;
98MODP(CODE,MOD,MFT,MDT,SRC,DFN) ; Check if modifier can be used with code
99 ;
100 ; Input:
101 ;
102 ; CODE CPT/HCPCS Code ?7N / ?1A4N / ?4N1A
103 ; MOD Modifier (External or Internal)
104 ; MFT Modifier Format "E" - or "I"
105 ; VDT Date service provided
106 ; SRC Source Screen
107 ; If 0 or Null, Level I and II modifiers
108 ; If >0, Level I, II, and III modifiers
109 ; Output:
110 ;
111 ; If pair is acceptable - Positive 7 Piece "^" Delimited String
112 ;
113 ; 1 - IEN of CPT Modifier
114 ; 2 - Versioned Short Text
115 ; 3 - Beginning Code for Code Range
116 ; 4 - Ending Code for Code Range
117 ; 5 - Code Range Activaiton Date
118 ; 6 - Code Range Inactivation Date
119 ; 7 - Modifier Identifier
120 ;
121 ; If pair is unacceptable
122 ;
123 ; 0
124 ;
125 N ACD,ADT,BEGA,BEGR,CDT,CODEA,CPTS,ENDA,ENDR,ICD,IDT,MIEN,MODEFF,MODI,MODNM,MODST,NEXT,NN,ND,PR,PRN,RIEN,SIEN,SRC,STA,STI,STX,TA,TEFF,TI,TIEN,VDT
126 S:$G(MFT)="" MFT="E" Q:"^E^I^"'[("^"_MFT_"^") "-1^Invalid Modifier Format"
127 S VDT=$P($G(MDT),".",1) Q:+VDT'>0!(VDT'?7N) "-1^Invalid Date"
128 I MFT="E" D I +($G(MIEN))'>0 Q "-1^Multiple Modifiers with the same name, use IEN"
129 . S MIEN=0 S (TIEN,TI)=0 F S TIEN=$O(^DIC(81.3,"B",MOD,TIEN)) Q:+TIEN'>0 D
130 . . S TEFF=$$EFF^ICPTSUPT(81.3,TIEN,VDT) Q:'$P(TEFF,"^",2)
131 . . S TI=TI+1,TA(TI)=TIEN,TA(0)=TI
132 . S:+($G(TA(0)))=1 MIEN=+($G(TA(1)))
133 S:MFT="I" MIEN=+MOD S CODE=$G(CODE)
134 S CODN=$S(CODE?1.N:+CODE,1:$$CODEN^ICPTCOD(CODE))
135 I CODN<1!'$D(^ICPT(CODN,0)) Q "-1^NO SUCH CPT CODE"
136 S CODE=$P($G(^ICPT(CODN,0)),"^") I '$L(CODE) Q:"-1^NO SUCH CPT CODE "
137 Q:$L(CODE)'=5 "-1^Invalid Code"
138 S CODEA=$S(CODE?1N.4N:+CODE,CODE?4N1A:$A($E(CODE,5))*10_$E(CODE,1,4),1:$A(CODE)_$E(CODE,2,5)) Q:+CODEA'>0 "-1^Invalid Code Source"
139 S MIEN=$G(MIEN) Q:+MIEN'>0 "-1^Invalid Modifier"
140 S SRC=+($G(SRC)) S SRC=$S(+SRC>0:1,1:0)
141 S SIEN=$O(^ICPT("BA",(CODE_" "),0)) Q:+SIEN'>0 "-3^Invalid Code"
142 S CPTS=$P($G(^ICPT(+SIEN,0)),"^",6) Q:CPTS="L"&(SRC'>0) "-1^Invalid Code Source"
143 S MODEFF=$$EFF^ICPTSUPT(81.3,MIEN,VDT) Q:'$P(MODEFF,"^",2) "-1^Modifier Inactive"
144 S MODNM=$P($G(^DIC(81.3,MIEN,0)),"^",2) Q:'$L(MODNM) "-1^Invalid Modifier Name"
145 S MODI=$P($G(^DIC(81.3,MIEN,0)),"^",1) Q:'$L(MODI) "-1^Invalid Modifier ID"
146 S MODST=$$VSTCM^ICPTMOD(MIEN,VDT) K STX S (STA,STI)=0 S CDT=($$DTBR^ICPTSUPT(VDT))+.001
147 S RIEN=0 F S RIEN=$O(^DIC(81.3,MIEN,10,RIEN)) Q:+RIEN'>0 D
148 . S ND=$G(^DIC(81.3,MIEN,10,RIEN,0))
149 . S BEGR=$P(ND,"^",1),BEGA=$S(BEGR?1N.4N:+BEGR,BEGR?4N1A:$A($E(BEGR,5))*10_$E(BEGR,1,4),1:$A(BEGR)_$E(BEGR,2,5)) Q:CODEA<BEGA
150 . S ENDR=$P(ND,"^",2),ENDA=$S(ENDR?1N.4N:+ENDR,ENDR?4N1A:$A($E(ENDR,5))*10_$E(ENDR,1,4),1:$A(ENDR)_$E(ENDR,2,5)) Q:CODEA>ENDA
151 . S (ACD,ADT)=$P(ND,"^",3),(ICD,IDT)=$P(ND,"^",4) S:ADT="" ADT=2890101 S:'$L(IDT) IDT=$$FMADD^XLFDT($$DT^XLFDT,365)
152 . S NN="^DIC(81.3,"_MIEN_",10,"_RIEN_",0)"
153 . S STA=+($G(STA))+1,STX(STA)=MIEN_"^"_MODST_"^"_BEGR_"^"_ENDR_"^"_ADT_"^"_ICD_"^"_MODI,STX("B",+ADT,+STA)=""
154 S ADT=$O(STX("B",+CDT),-1),STA=$O(STX("B",+ADT," "),-1),MOD=$G(STX(+STA)) Q:+MOD'>0 "0"
155 Q MOD
156 ;
157MODC(MOD) ; Checks modifier for range including code
158 D MODC^ICPTMOD2($G(MOD))
159 Q
160 ;
161MULT ; Finds Duplicate Modifiers
162 D MULT^ICPTMOD2 Q
163 ;
164CODEN(CODE) ; Return the IEN of a CPT modifier
165 ; Input: CPT modifier code
166 ; Output: IEN
167 ;
168 Q:$G(CODE)="" -1
169 N COD S COD=+$O(^DIC(81.3,"BA",(CODE_" "),0))
170 Q $S(COD>0:COD,1:-1)
171 ;
172VSTCM(IEN,VDATE) ; Versioned Short Text (CPT Modifier)
173 N CPT0,CPTC,CPTI,CPTSTD,CPTSTI,CPTVDT,CPTTXT,CPTTD,CPTTI
174 S CPTI=+($G(IEN)) Q:+CPTI'>0 "" Q:'$D(^DIC(81.3,+CPTI)) ""
175 S CPTVDT=$G(VDATE) S:'$L(CPTVDT)!(+CPTVDT'>0) CPTVDT=$$DT^XLFDT Q:$P(CPTVDT,".",1)'?7N ""
176 S CPT0=$G(^DIC(81.3,+CPTI,0)),CPTC=$P(CPT0,"^",1) Q:'$L(CPTC) ""
177 S CPTSTD=0 S CPTTD=CPTVDT+.000001 F S CPTTD=$O(^DIC(81.3,"AST",(CPTC_" "),CPTTD),-1) Q:+CPTTD=0 Q:+CPTSTD>0 D
178 . S CPTTI=$O(^DIC(81.3,"AST",(CPTC_" "),CPTTD," "),-1) S:CPTTI=CPTI CPTSTD=CPTTD
179 I +CPTSTD>0 D Q:$L($G(CPTTXT)) $G(CPTTXT)
180 . S CPTSTI=$O(^DIC(81.3,"AST",(CPTC_" "),CPTSTD,+CPTI," "),-1),CPTTXT=$P($G(^DIC(81.3,+CPTI,61,+CPTSTI,0)),"^",2)
181 S CPTSTD=$O(^DIC(81.3,+CPTI,61,"B",0)) I +CPTSTD>0 D Q:$L($G(CPTTXT)) $G(CPTTXT)
182 . S CPTSTI=$O(^DIC(81.3,+CPTI,61,"B",CPTSTD,0)),CPTTXT=$P($G(^DIC(81.3,+CPTI,61,+CPTSTI,0)),"^",2)
183 Q $$TRIM($P(CPT0,"^",2))
184VLTCM(IEN,VDATE,ARY) ; Versioned Description - Long Text (CPT Modifier)
185 N CPT0,CPTC,CPTD,CPTI,CPTSTD,CPTSTI,CPTT,CPTVDT,CPTTXT,CPTTD,CPTTI
186 S CPTI=+($G(IEN)) Q:+CPTI'>0 Q:'$D(^DIC(81.3,+CPTI))
187 S CPTVDT=$G(VDATE) S:'$L(CPTVDT)!(+CPTVDT'>0) CPTVDT=$$DT^XLFDT Q:$P(CPTVDT,".",1)'?7N
188 S CPT0=$G(^DIC(81.3,+CPTI,0)),CPTC=$P(CPT0,"^",1) Q:'$L(CPTC)
189 S CPTSTD=0 S CPTTD=CPTVDT+.000001 F S CPTTD=$O(^DIC(81.3,"ADS",(CPTC_" "),CPTTD),-1) Q:+CPTTD=0 Q:+CPTSTD>0 D
190 . S CPTTI=$O(^DIC(81.3,"ADS",(CPTC_" "),CPTTD," "),-1) S:CPTTI=CPTI CPTSTD=CPTTD
191 I +CPTSTD>0 D Q:+($O(ARY(0)))>0
192 . S CPTSTI=$O(^DIC(81.3,"ADS",(CPTC_" "),CPTSTD,+CPTI," "),-1)
193 . S (CPTD,CPTT)=0 F S CPTD=$O(^DIC(81.3,+CPTI,62,CPTSTI,1,CPTD)) Q:+CPTD=0 D
194 . . S CPTT=CPTT+1,ARY(CPTT)=$$TRIM($G(^DIC(81.3,+CPTI,62,+CPTSTI,1,+CPTD,0))),ARY(0)=CPTT
195 S CPTSTD=$O(^DIC(81.3,+CPTI,62,"B",0)) I +CPTSTD>0 D Q:+($O(ARY(0)))>0
196 . S CPTSTI=$O(^DIC(81.3,+CPTI,62,"B",CPTSTD,0))
197 . S (CPTD,CPTT)=0 F S CPTD=$O(^DIC(81.3,+CPTI,62,CPTSTI,1,CPTD)) Q:+CPTD=0 D
198 . . S CPTT=CPTT+1,ARY(CPTT)=$$TRIM($G(^DIC(81.3,+CPTI,62,+CPTSTI,1,+CPTD,0))),ARY(0)=CPTT
199 K ARY S (CPTD,CPTT)=0 F S CPTD=$O(^DIC(81.3,CPTI,"D",CPTD)) Q:+CPTD=0 D
200 . S CPTT=CPTT+1,ARY(CPTT)=$$TRIM($G(^DIC(81.3,CPTI,"D",CPTD,0))),ARY(0)=CPTT
201 Q
202TRIM(X) ; Trim Spaces
203 S X=$G(X) Q:X="" X F Q:$E(X,1)'=" " S X=$E(X,2,$L(X))
204 F Q:$E(X,$L(X))'=" " S X=$E(X,1,($L(X)-1))
205 F Q:X'[" " S X=$P(X," ",1)_" "_$P(X," ",2,229)
206 Q X
207MO(X) ; Modifier X = Modifier IEN
208 Q $P($G(^DIC(81.3,+($G(X)),0)),"^",1)
Note: See TracBrowser for help on using the repository browser.