APCLCOD1 ; IHS/CMI/LAB - CODE RANGES IN TABLE ;
;;2.0;IHS PCC SUITE;;MAY 14, 2009
;
I 'APCLSUB D ADD I 1
E D DEL
D EOJ
Q
;
ADD ; SECTION FOR ADDING CODES TO TABLE
I '$D(APCLTBLE) S APCLTBLE(APCL("LOW"))=APCL("HI") G X1
S APCLDONE=0
S APCLVAL="" F S APCLVAL=$O(APCLTBLE(APCLVAL)) Q:APCLVAL="" D GETCASE,ADDPROC Q:APCLDONE
D:'APCLDONE SETRANGE
K APCLDONE,APCLVAL,APCLCASE
X1 Q
;
ADDPROC ; CASE SPECIFIC ADD PROCESSING
G @("ADD"_APCLCASE)
ADD2 ;;
ADD3 ;;
ADD4 ;;
S APCLTBLE(APCL("LOW"))=APCLTBLE(APCLVAL)
K APCLTBLE(APCLVAL)
ADD6 ;;
ADD7 ;;
ADD9 ;;
ADD10 ;;
S APCLDONE=1
Q
ADD11 ;;
ADD12 ;;
S APCL("LOW")=APCLVAL
ADD5 ;;
ADD8 ;;
K APCLTBLE(APCLVAL)
Q
ADD1 ;;
I $O(^ICD9("BA",APCL("HI")))=APCLVAL,$E(APCLVAL)=$E(APCL("HI"))!(APCLVAL&APCL("HI")) S APCLTBLE(APCL("LOW"))=APCLTBLE(APCLVAL) K APCLTBLE(APCLVAL) S APCLDONE=1
Q
ADD13 ;;
I $O(^ICD9("BA",APCLTBLE(APCLVAL)))=APCL("LOW"),$E(APCLVAL)=$E(APCL("LOW"))!(APCLVAL&APCL("LOW")) S APCL("LOW")=APCLVAL K APCLTBLE(APCLVAL)
; continue
Q
;
SETRANGE ;
;;
SET1 ;;
SET5 ;;
SET8 ;;
SET11 ;;
SET12 ;;
SET13 ;;
S APCLTBLE(APCL("LOW"))=APCL("HI")
Q
;
DEL ; SECTION FOR DELETING CODES FROM TABLE
I '$D(APCLTBLE) G X2
S APCLDONE=0
S APCLVAL="" F S APCLVAL=$O(APCLTBLE(APCLVAL)) Q:APCLVAL="" D GETCASE,DELPROC Q:APCLDONE
X2 Q
;
DELPROC ;CASE SPECIFIC DEL PROCESSING
G @("DEL"_APCLCASE)
DEL2 ;;
I APCL("HI")=APCLTBLE(APCLVAL) K APCLTBLE(APCLVAL)
E S APCLTBLE($O(^ICD9("BA",APCL("HI"))))=APCLTBLE(APCLVAL) K APCLTBLE(APCLVAL)
S APCLDONE=1
Q
;
DEL3 ;;
DEL6 ;;
S APCLTBLE($O(^ICD9("BA",APCL("HI"))))=APCLTBLE(APCLVAL) K APCLTBLE(APCLVAL)
S APCLDONE=1
Q
;
DEL4 ;;
DEL5 ;;
DEL7 ;;
DEL8 ;;
K APCLTBLE(APCLVAL)
I APCLCASE'=8,APCLCASE'=5 S APCLDONE=1
Q
;
DEL10 ;;
DEL11 ;;
DEL12 ;;
D @$S($E(APCLTBLE(APCLVAL))?1N:"NUMBER",1:"LETTER")
S APCLTBLE(APCLVAL)=APCL("NEWHI")
I APCLCASE=10 S APCLDONE=1
Q
;
DEL9 ;;
D @$S($E(APCLTBLE(APCLVAL))?1N:"NUMBER",1:"LETTER")
S APCLTBLE($O(^ICD9("BA",APCL("HI"))))=APCLTBLE(APCLVAL)
S APCLTBLE(APCLVAL)=APCL("NEWHI")
S APCLDONE=1
Q
;
DEL1 ;;
DEL13 ;;
Q
;
GETCASE ; SUBROUTINE TO DETERMINE APCLCASE # FROM INPUT CODE RANGE
S APCL("TLOW")=APCLVAL,APCL("THI")=APCLTBLE(APCLVAL)
D CASEA:APCL("TLOW")]APCL("LOW"),CASEB:APCL("LOW")=APCL("TLOW"),CASEC:APCL("LOW")]APCL("TLOW")
K APCL("TLOW"),APCL("THI")
Q
;
CASEA ;
I APCL("HI")]APCL("TLOW") S APCLCASE=$S(APCL("THI")]APCL("HI"):3,APCL("HI")=APCL("THI"):4,1:5)
E S APCLCASE=$S(APCL("TLOW")]APCL("HI"):1,1:2)
Q
;
CASEB ;
S APCLCASE=$S(APCL("THI")]APCL("HI"):6,APCL("HI")=APCL("THI"):7,1:8)
Q
;
CASEC ;
I APCL("THI")]APCL("LOW") S APCLCASE=$S(APCL("THI")]APCL("HI"):9,APCL("HI")=APCL("THI"):10,1:11)
E S APCLCASE=$S(APCL("LOW")=APCL("THI"):12,1:13)
Q
;
NUMBER ;
S APCL("CODE")=APCL("LOW")-5 F Q:APCL("LOW")]$O(^ICD9("BA",APCL("CODE")_" ")) S APCL("CODE")=APCL("CODE")-5
S APCL("CODE")=$O(^ICD9("BA",APCL("CODE")_" ")) F S APCL("NEWHI")=APCL("CODE"),APCL("CODE")=$O(^ICD9("BA",APCL("CODE"))) Q:APCL("CODE")=APCL("LOW")
Q
;
LETTER ;
S APCL("LET")=$E(APCL("LOW"))_" " F S APCL("NEWHI")=$S($L(APCL("LET"))>2:APCL("LET"),1:APCL("LOW")),APCL("LET")=$O(^ICD9("BA",APCL("LET"))) Q:APCL("LET")=APCL("LOW")
Q
EOJ ;
K APCLCASE,APCLDONE,APCLNEXT,APCLONE,APCLVAL
Q
;
APCLCOD1 ; IHS/CMI/LAB - CODE RANGES IN TABLE ;
+1 ;;2.0;IHS PCC SUITE;;MAY 14, 2009
+2 ;
+3 IF 'APCLSUB
DO ADD
IF 1
+4 IF '$TEST
DO DEL
+5 DO EOJ
+6 QUIT
+7 ;
ADD ; SECTION FOR ADDING CODES TO TABLE
+1 IF '$DATA(APCLTBLE)
SET APCLTBLE(APCL("LOW"))=APCL("HI")
GOTO X1
+2 SET APCLDONE=0
+3 SET APCLVAL=""
FOR
SET APCLVAL=$ORDER(APCLTBLE(APCLVAL))
IF APCLVAL=""
QUIT
DO GETCASE
DO ADDPROC
IF APCLDONE
QUIT
+4 IF 'APCLDONE
DO SETRANGE
+5 KILL APCLDONE,APCLVAL,APCLCASE
X1 QUIT
+1 ;
ADDPROC ; CASE SPECIFIC ADD PROCESSING
+1 GOTO @("ADD"_APCLCASE)
ADD2 ;;
ADD3 ;;
ADD4 ;;
+1 SET APCLTBLE(APCL("LOW"))=APCLTBLE(APCLVAL)
+2 KILL APCLTBLE(APCLVAL)
ADD6 ;;
ADD7 ;;
ADD9 ;;
ADD10 ;;
+1 SET APCLDONE=1
+2 QUIT
ADD11 ;;
ADD12 ;;
+1 SET APCL("LOW")=APCLVAL
ADD5 ;;
ADD8 ;;
+1 KILL APCLTBLE(APCLVAL)
+2 QUIT
ADD1 ;;
+1 IF $ORDER(^ICD9("BA",APCL("HI")))=APCLVAL
IF $EXTRACT(APCLVAL)=$EXTRACT(APCL("HI"))!(APCLVAL&APCL("HI"))
SET APCLTBLE(APCL("LOW"))=APCLTBLE(APCLVAL)
KILL APCLTBLE(APCLVAL)
SET APCLDONE=1
+2 QUIT
ADD13 ;;
+1 IF $ORDER(^ICD9("BA",APCLTBLE(APCLVAL)))=APCL("LOW")
IF $EXTRACT(APCLVAL)=$EXTRACT(APCL("LOW"))!(APCLVAL&APCL("LOW"))
SET APCL("LOW")=APCLVAL
KILL APCLTBLE(APCLVAL)
+2 ; continue
+3 QUIT
+4 ;
SETRANGE ;
+1 ;;
SET1 ;;
SET5 ;;
SET8 ;;
SET11 ;;
SET12 ;;
SET13 ;;
+1 SET APCLTBLE(APCL("LOW"))=APCL("HI")
+2 QUIT
+3 ;
DEL ; SECTION FOR DELETING CODES FROM TABLE
+1 IF '$DATA(APCLTBLE)
GOTO X2
+2 SET APCLDONE=0
+3 SET APCLVAL=""
FOR
SET APCLVAL=$ORDER(APCLTBLE(APCLVAL))
IF APCLVAL=""
QUIT
DO GETCASE
DO DELPROC
IF APCLDONE
QUIT
X2 QUIT
+1 ;
DELPROC ;CASE SPECIFIC DEL PROCESSING
+1 GOTO @("DEL"_APCLCASE)
DEL2 ;;
+1 IF APCL("HI")=APCLTBLE(APCLVAL)
KILL APCLTBLE(APCLVAL)
+2 IF '$TEST
SET APCLTBLE($ORDER(^ICD9("BA",APCL("HI"))))=APCLTBLE(APCLVAL)
KILL APCLTBLE(APCLVAL)
+3 SET APCLDONE=1
+4 QUIT
+5 ;
DEL3 ;;
DEL6 ;;
+1 SET APCLTBLE($ORDER(^ICD9("BA",APCL("HI"))))=APCLTBLE(APCLVAL)
KILL APCLTBLE(APCLVAL)
+2 SET APCLDONE=1
+3 QUIT
+4 ;
DEL4 ;;
DEL5 ;;
DEL7 ;;
DEL8 ;;
+1 KILL APCLTBLE(APCLVAL)
+2 IF APCLCASE'=8
IF APCLCASE'=5
SET APCLDONE=1
+3 QUIT
+4 ;
DEL10 ;;
DEL11 ;;
DEL12 ;;
+1 DO @$SELECT($EXTRACT(APCLTBLE(APCLVAL))?1N:"NUMBER",1:"LETTER")
+2 SET APCLTBLE(APCLVAL)=APCL("NEWHI")
+3 IF APCLCASE=10
SET APCLDONE=1
+4 QUIT
+5 ;
DEL9 ;;
+1 DO @$SELECT($EXTRACT(APCLTBLE(APCLVAL))?1N:"NUMBER",1:"LETTER")
+2 SET APCLTBLE($ORDER(^ICD9("BA",APCL("HI"))))=APCLTBLE(APCLVAL)
+3 SET APCLTBLE(APCLVAL)=APCL("NEWHI")
+4 SET APCLDONE=1
+5 QUIT
+6 ;
DEL1 ;;
DEL13 ;;
+1 QUIT
+2 ;
GETCASE ; SUBROUTINE TO DETERMINE APCLCASE # FROM INPUT CODE RANGE
+1 SET APCL("TLOW")=APCLVAL
SET APCL("THI")=APCLTBLE(APCLVAL)
+2 IF APCL("TLOW")]APCL("LOW")
DO CASEA
IF APCL("LOW")=APCL("TLOW")
DO CASEB
IF APCL("LOW")]APCL("TLOW")
DO CASEC
+3 KILL APCL("TLOW"),APCL("THI")
+4 QUIT
+5 ;
CASEA ;
+1 IF APCL("HI")]APCL("TLOW")
SET APCLCASE=$SELECT(APCL("THI")]APCL("HI"):3,APCL("HI")=APCL("THI"):4,1:5)
+2 IF '$TEST
SET APCLCASE=$SELECT(APCL("TLOW")]APCL("HI"):1,1:2)
+3 QUIT
+4 ;
CASEB ;
+1 SET APCLCASE=$SELECT(APCL("THI")]APCL("HI"):6,APCL("HI")=APCL("THI"):7,1:8)
+2 QUIT
+3 ;
CASEC ;
+1 IF APCL("THI")]APCL("LOW")
SET APCLCASE=$SELECT(APCL("THI")]APCL("HI"):9,APCL("HI")=APCL("THI"):10,1:11)
+2 IF '$TEST
SET APCLCASE=$SELECT(APCL("LOW")=APCL("THI"):12,1:13)
+3 QUIT
+4 ;
NUMBER ;
+1 SET APCL("CODE")=APCL("LOW")-5
FOR
IF APCL("LOW")]$ORDER(^ICD9("BA",APCL("CODE")_" "))
QUIT
SET APCL("CODE")=APCL("CODE")-5
+2 SET APCL("CODE")=$ORDER(^ICD9("BA",APCL("CODE")_" "))
FOR
SET APCL("NEWHI")=APCL("CODE")
SET APCL("CODE")=$ORDER(^ICD9("BA",APCL("CODE")))
IF APCL("CODE")=APCL("LOW")
QUIT
+3 QUIT
+4 ;
LETTER ;
+1 SET APCL("LET")=$EXTRACT(APCL("LOW"))_" "
FOR
SET APCL("NEWHI")=$SELECT($LENGTH(APCL("LET"))>2:APCL("LET"),1:APCL("LOW"))
SET APCL("LET")=$ORDER(^ICD9("BA",APCL("LET")))
IF APCL("LET")=APCL("LOW")
QUIT
+2 QUIT
EOJ ;
+1 KILL APCLCASE,APCLDONE,APCLNEXT,APCLONE,APCLVAL
+2 QUIT
+3 ;