VENPCCMH ; IHS/OIT/GIS - GLOBAL MANAGEMENT OF DIAGNOSES AND ICD CODES ;
;;2.6;PCC+;;NOV 12, 2007
;
;
;
N TMP,PIEN,X,CODE,TEXT,Y,T,Z,PATH,FILE,POP,STOP,%,%Y
S TMP="^TMP(""VEN TABLE"","_$J_")" K @TMP
W !,"Building master table of ICD codes and diagnoses..."
ARR S PIEN=0 F S PIEN=$O(^VEN(7.1,PIEN)) Q:'PIEN D ; BUILD THE DATA ARRAY
. S X=$G(^VEN(7.1,PIEN,0)) I '$L(X) Q
. S CODE=$P(X,U,2),TEXT=$P(X,U,3)
. I CODE=""!(TEXT="") Q
. I $D(@TMP@(CODE)) D Q
.. S Y=0,STOP=0
.. F S Y=$O(@TMP@(CODE,Y)) Q:'Y D I STOP=1 Q
... S T=@TMP@(CODE,Y)
... I T=TEXT S STOP=1
... Q
.. I STOP Q
.. S Z=$O(@TMP@(CODE,99999),-1)
.. S @TMP@(CODE,Z+1)=TEXT
.. Q
. S @TMP@(CODE,1)=TEXT
. Q
LIST ; MAKE A LIST FROM THE ARRAY
W !,"Get ready to store the ICD information in a file..."
S DIR(0)="FO^1:8",DIR("A")="Enter the name of the file",DIR("B")="icd_info" K DA
D ^DIR K DIR ; GET FILE NAME
I '$L(Y) Q
I Y?1."^" Q
S FILE=Y_".txt"
S PATH=$G(^VEN(7.5,$$CFG^VENPCCU,3))
W !,"'",FILE,"' will be stored in '",PATH,"' OK"
S %=1 D YN^DICN I %'=1 Q
S POP=$$OPN^VENPCCP(PATH,FILE,"W","D FMT^VENPCCMH")
I POP W !,"Unable to create this file. Sesion terminated..." Q
W !,"Done!"
K @TMP
Q
;
FMT ; FORMAT THE DATA FOR OUTPUT
N ICD,X,TXT,Y,TAB
W !!,"ICD",$C(9),"POV",!!
S ICD="" F S ICD=$O(@TMP@(ICD)) Q:'ICD S X=0 F S X=$O(@TMP@(ICD,X)) Q:'X D
. S TXT=@TMP@(ICD,X)
. S Y=ICD_$C(9)_TXT
. W Y,!
. Q
Q
VENPCCMH ; IHS/OIT/GIS - GLOBAL MANAGEMENT OF DIAGNOSES AND ICD CODES ;
+1 ;;2.6;PCC+;;NOV 12, 2007
+2 ;
+3 ;
+4 ;
+5 NEW TMP,PIEN,X,CODE,TEXT,Y,T,Z,PATH,FILE,POP,STOP,%,%Y
+6 SET TMP="^TMP(""VEN TABLE"","_$JOB_")"
KILL @TMP
+7 WRITE !,"Building master table of ICD codes and diagnoses..."
ARR ; BUILD THE DATA ARRAY
SET PIEN=0
FOR
SET PIEN=$ORDER(^VEN(7.1,PIEN))
IF 'PIEN
QUIT
Begin DoDot:1
+1 SET X=$GET(^VEN(7.1,PIEN,0))
IF '$LENGTH(X)
QUIT
+2 SET CODE=$PIECE(X,U,2)
SET TEXT=$PIECE(X,U,3)
+3 IF CODE=""!(TEXT="")
QUIT
+4 IF $DATA(@TMP@(CODE))
Begin DoDot:2
+5 SET Y=0
SET STOP=0
+6 FOR
SET Y=$ORDER(@TMP@(CODE,Y))
IF 'Y
QUIT
Begin DoDot:3
+7 SET T=@TMP@(CODE,Y)
+8 IF T=TEXT
SET STOP=1
+9 QUIT
End DoDot:3
IF STOP=1
QUIT
+10 IF STOP
QUIT
+11 SET Z=$ORDER(@TMP@(CODE,99999),-1)
+12 SET @TMP@(CODE,Z+1)=TEXT
+13 QUIT
End DoDot:2
QUIT
+14 SET @TMP@(CODE,1)=TEXT
+15 QUIT
End DoDot:1
LIST ; MAKE A LIST FROM THE ARRAY
+1 WRITE !,"Get ready to store the ICD information in a file..."
+2 SET DIR(0)="FO^1:8"
SET DIR("A")="Enter the name of the file"
SET DIR("B")="icd_info"
KILL DA
+3 ; GET FILE NAME
DO ^DIR
KILL DIR
+4 IF '$LENGTH(Y)
QUIT
+5 IF Y?1."^"
QUIT
+6 SET FILE=Y_".txt"
+7 SET PATH=$GET(^VEN(7.5,$$CFG^VENPCCU,3))
+8 WRITE !,"'",FILE,"' will be stored in '",PATH,"' OK"
+9 SET %=1
DO YN^DICN
IF %'=1
QUIT
+10 SET POP=$$OPN^VENPCCP(PATH,FILE,"W","D FMT^VENPCCMH")
+11 IF POP
WRITE !,"Unable to create this file. Sesion terminated..."
QUIT
+12 WRITE !,"Done!"
+13 KILL @TMP
+14 QUIT
+15 ;
FMT ; FORMAT THE DATA FOR OUTPUT
+1 NEW ICD,X,TXT,Y,TAB
+2 WRITE !!,"ICD",$CHAR(9),"POV",!!
+3 SET ICD=""
FOR
SET ICD=$ORDER(@TMP@(ICD))
IF 'ICD
QUIT
SET X=0
FOR
SET X=$ORDER(@TMP@(ICD,X))
IF 'X
QUIT
Begin DoDot:1
+4 SET TXT=@TMP@(ICD,X)
+5 SET Y=ICD_$CHAR(9)_TXT
+6 WRITE Y,!
+7 QUIT
End DoDot:1
+8 QUIT