PXCPTAPI ;ALB/EW - PCE CPT CODE API ; 12/15/2020
;;1.0;PCE PATIENT CARE ENCOUNTER;**73,211**;Aug 12, 1996;Build 454
GETCODE(HELP) ;
N CODE,CODEIEN,CODESYS,EVENTDT,PXCEDT,SERVCAT,SRCHTERM,TEMP
S CODESYS="CPT^CPC"
;Prompt the user for the Lexicon search term.
S SRCHTERM=$$GETST^PXLEX
I SRCHTERM="" Q -1
;Prompt the user for the Event Date and Time. This is only
;for new entries because it is used in the Lexicon search
;to ensure only codes active on that date are returned.
S TEMP=^AUPNVSIT(PXCEVIEN,0)
S SERVCAT=$P(TEMP,U,7)
S EVENTDT=$$EVENTDT^PXDATE("",HELP)
S PXCEDT=EVENTDT
;If the Event Date and Time is null use the Visit Date.
I PXCEDT="" S PXCEDT=$P(TEMP,U,1)
;Let the user select the code(s), only return active codes.
S CODE=$$GETCODE^PXLEXS(CODESYS,SRCHTERM,PXCEDT,1)
I CODE="" Q -1
S CODEIEN=$$CODEN^ICPTCOD(CODE)
S $P(PXCEAFTR(12),U,1)=EVENTDT
Q CODEIEN_U_CODE
;
;GETCODE(PXDFLT,PXCPTDT) ;Read in CPT Code.
;This is replaced by above search in PX*1.0*211
;
; INPUT: PXDFLT - Default CPT code
; PXCPTDT - Visit date
;
; OUTPUT: CPT CODE - Modifier string
;
;
;PROMPT N DIR,DIRUT,DUOUT,DTOUT,PXDATA,X,Y
;S DIR(0)="FAO^^K:'$$VALCPT^PXCPTAPI(X,PXCPTDT,.PXDATA) X"
;S DIR("A")="CPT Code: "
;S DIR("?")="^D CPTHLP^PXCPTAPI"
;S DIR("??")="^S X=$$VALCPT^PXCPTAPI(.X,PXCPTDT,.PXDATA)"
;S:PXDFLT]"" DIR("B")=PXDFLT
;D ^DIR
;I $D(DIRUT),X="@" Q X
;I $D(DIRUT)!($D(DUOUT))!($D(DTOUT))!(Y="") Q -1
;I PXDATA<0 D CPTHLP^PXCPTAPI G PROMPT
;Q PXDATA
;
;
;VALCPT(PXTEXT,PXCPTDT,PXVAL) ;
;Validate free text response entered for CPT Code question
;Input: PXTEXT - CPT Code or CPT Code and CPT Modifier Code
; format: CPT or CPT-MOD,MOD,...
; where CPT = valid CPT Code
; MOD = valid Modifier Code
; PXCPTDT - visit date
;
;
;
;Output: 1 - Valid
; 0 - Invalid
;
;N DIC,X,Y
;S X=$P(PXTEXT,"-")
;S DIC=81
;S DIC(0)="EMQ"
;S DIC("S")="I $$CPTSCREN^PXBUTL(Y,PXCPTDT)"
;D ^DIC
;S PXVAL=Y_$S($P(PXTEXT,"-",2)]"":"-"_$P(PXTEXT,"-",2),1:"")
;Q Y
;
CPTMOD(PXIEN,PXMOD,PXHELP) ;Validate selected modifier
;
; INPUT: PXIEN - IEN for CPT code in V CPT file
; PXMOD - IEN for CPT modifier
; PXHELP - Flag to determine if help text should display
; when an invalid modifier is entered.
; where 1 = Display help text
; 0 = Do not display help text
;
N PXVST,PXVSTDT,PXSTAT
S PXCPT=$P(^AUPNVCPT(PXIEN,0),U)
;If Event Date and Time exists, use it otherwise use Visit Date.
S PXVSTDT=$P($G(^AUPNVCPT(PXIEN,12)),U,1)
I PXVSTDT="" D
. S PXVST=$P(^AUPNVCPT(PXIEN,0),U,3)
. S PXVSTDT=$P($G(^AUPNVSIT(PXVST,0)),U)
S PXSTAT=$$MODP^ICPTMOD(PXCPT,PXMOD,"I",PXVSTDT)
D:PXSTAT'>0 MODHLP
Q PXSTAT
;
CPTHLP ;CPT code help text display
;
W !,"Enter CPT code or partial name for lookup."
Q
MODHLP ;CPT modifier help text display
;
Q:'$G(PXHELP)
W !,"You can only enter a modifier that is valid for the selected CPT code."
Q
--- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HPXCPTAPI 3153 printed Sep 15, 2024@21:52:38 Page 2
PXCPTAPI ;ALB/EW - PCE CPT CODE API ; 12/15/2020
+1 ;;1.0;PCE PATIENT CARE ENCOUNTER;**73,211**;Aug 12, 1996;Build 454
GETCODE(HELP) ;
+1 NEW CODE,CODEIEN,CODESYS,EVENTDT,PXCEDT,SERVCAT,SRCHTERM,TEMP
+2 SET CODESYS="CPT^CPC"
+3 ;Prompt the user for the Lexicon search term.
+4 SET SRCHTERM=$$GETST^PXLEX
+5 IF SRCHTERM=""
QUIT -1
+6 ;Prompt the user for the Event Date and Time. This is only
+7 ;for new entries because it is used in the Lexicon search
+8 ;to ensure only codes active on that date are returned.
+9 SET TEMP=^AUPNVSIT(PXCEVIEN,0)
+10 SET SERVCAT=$PIECE(TEMP,U,7)
+11 SET EVENTDT=$$EVENTDT^PXDATE("",HELP)
+12 SET PXCEDT=EVENTDT
+13 ;If the Event Date and Time is null use the Visit Date.
+14 IF PXCEDT=""
SET PXCEDT=$PIECE(TEMP,U,1)
+15 ;Let the user select the code(s), only return active codes.
+16 SET CODE=$$GETCODE^PXLEXS(CODESYS,SRCHTERM,PXCEDT,1)
+17 IF CODE=""
QUIT -1
+18 SET CODEIEN=$$CODEN^ICPTCOD(CODE)
+19 SET $PIECE(PXCEAFTR(12),U,1)=EVENTDT
+20 QUIT CODEIEN_U_CODE
+21 ;
+22 ;GETCODE(PXDFLT,PXCPTDT) ;Read in CPT Code.
+23 ;This is replaced by above search in PX*1.0*211
+24 ;
+25 ; INPUT: PXDFLT - Default CPT code
+26 ; PXCPTDT - Visit date
+27 ;
+28 ; OUTPUT: CPT CODE - Modifier string
+29 ;
+30 ;
+31 ;PROMPT N DIR,DIRUT,DUOUT,DTOUT,PXDATA,X,Y
+32 ;S DIR(0)="FAO^^K:'$$VALCPT^PXCPTAPI(X,PXCPTDT,.PXDATA) X"
+33 ;S DIR("A")="CPT Code: "
+34 ;S DIR("?")="^D CPTHLP^PXCPTAPI"
+35 ;S DIR("??")="^S X=$$VALCPT^PXCPTAPI(.X,PXCPTDT,.PXDATA)"
+36 ;S:PXDFLT]"" DIR("B")=PXDFLT
+37 ;D ^DIR
+38 ;I $D(DIRUT),X="@" Q X
+39 ;I $D(DIRUT)!($D(DUOUT))!($D(DTOUT))!(Y="") Q -1
+40 ;I PXDATA<0 D CPTHLP^PXCPTAPI G PROMPT
+41 ;Q PXDATA
+42 ;
+43 ;
+44 ;VALCPT(PXTEXT,PXCPTDT,PXVAL) ;
+45 ;Validate free text response entered for CPT Code question
+46 ;Input: PXTEXT - CPT Code or CPT Code and CPT Modifier Code
+47 ; format: CPT or CPT-MOD,MOD,...
+48 ; where CPT = valid CPT Code
+49 ; MOD = valid Modifier Code
+50 ; PXCPTDT - visit date
+51 ;
+52 ;
+53 ;
+54 ;Output: 1 - Valid
+55 ; 0 - Invalid
+56 ;
+57 ;N DIC,X,Y
+58 ;S X=$P(PXTEXT,"-")
+59 ;S DIC=81
+60 ;S DIC(0)="EMQ"
+61 ;S DIC("S")="I $$CPTSCREN^PXBUTL(Y,PXCPTDT)"
+62 ;D ^DIC
+63 ;S PXVAL=Y_$S($P(PXTEXT,"-",2)]"":"-"_$P(PXTEXT,"-",2),1:"")
+64 ;Q Y
+65 ;
CPTMOD(PXIEN,PXMOD,PXHELP) ;Validate selected modifier
+1 ;
+2 ; INPUT: PXIEN - IEN for CPT code in V CPT file
+3 ; PXMOD - IEN for CPT modifier
+4 ; PXHELP - Flag to determine if help text should display
+5 ; when an invalid modifier is entered.
+6 ; where 1 = Display help text
+7 ; 0 = Do not display help text
+8 ;
+9 NEW PXVST,PXVSTDT,PXSTAT
+10 SET PXCPT=$PIECE(^AUPNVCPT(PXIEN,0),U)
+11 ;If Event Date and Time exists, use it otherwise use Visit Date.
+12 SET PXVSTDT=$PIECE($GET(^AUPNVCPT(PXIEN,12)),U,1)
+13 IF PXVSTDT=""
Begin DoDot:1
+14 SET PXVST=$PIECE(^AUPNVCPT(PXIEN,0),U,3)
+15 SET PXVSTDT=$PIECE($GET(^AUPNVSIT(PXVST,0)),U)
End DoDot:1
+16 SET PXSTAT=$$MODP^ICPTMOD(PXCPT,PXMOD,"I",PXVSTDT)
+17 if PXSTAT'>0
DO MODHLP
+18 QUIT PXSTAT
+19 ;
CPTHLP ;CPT code help text display
+1 ;
+2 WRITE !,"Enter CPT code or partial name for lookup."
+3 QUIT
MODHLP ;CPT modifier help text display
+1 ;
+2 if '$GET(PXHELP)
QUIT
+3 WRITE !,"You can only enter a modifier that is valid for the selected CPT code."
+4 QUIT