ACDPCCL2 ;IHS/ADC/EDE/KML - PCC LINK;
;;4.1;CHEMICAL DEPENDENCY MIS;;MAY 11, 1998
;
;
GENEVENT ; EP - GENERATE CDMIS EVENT ARRAY FOR ONE PATIENT VISIT
;//^ACDPCCL
K ACDEV
I '$D(^ACDVIS(ACDVIEN,0)) S ACDQ=1 D ERROR^ACDPCCL("Specified visit doesn't exist",3) Q
D SETPVARS
Q:ACDQ
D SETVVARS
Q:ACDQ
S X=ACDEV("TC")
D @("SET"_$S(X="CS":"CS",X="TD":"TDC",1:"IIF")_"^ACDPCCL3")
Q:ACDQ
I ACDEV("TC")'="CS" D Q:ACDQ
. S ACDQ=1
. S W=$O(^ICD9("AB","V70.8",0))
. I 'W D ERROR^ACDPCCL("Cannot find ICD9 code V70.8 - notify programmer",3) Q
. S ACDEV("POV",1)=W_":V70.8:CHEMICAL DEPENDENCY-"_$S(ACDEV("TC")="IN":"NEW PATIENT ",1:"")_"EVALUATION & MANAGEMENT"
. S ACDQ=0
. Q
Q
;
SETPVARS ; SET PROGRAM VARIABLES
S ACDQ=1
I '$G(ACDPGM) D ERROR^ACDPCCL("CDMIS Program variable not set-notify programmer",3) Q
S X=$P($G(^ACDF5PI(ACDPGM,11)),U,2)
S:X="" X="?"
I ACDFPCC,X="?" D ERROR^ACDPCCL("No site type in CDMIS PROGRAM file",3) Q
S ACDEV("SITE TYPE")=X
S X=$O(^DIC(40.7,"C",43,0))
I X="" D ERROR^ACDPCCL("No clinic stop entry for alcoholism program",3) Q
S ACDEV("CLINIC")=X
S ACDEV("LOCATION")=ACDPGM
I $G(ACDMODE)="" D ERROR^ACDPCCL("No mode-notify programmer",3) Q
S ACDEV("TYPE")=$G(ACDMODE)
I "AED"'[ACDEV("TYPE") D ERROR^ACDPCCL("Invalid mode-notify programmer",3) Q
S ACDQ=0
Q
;
SETVVARS ; SET VISIT VARIABLES
S ACDQ=1
S X=^ACDVIS(ACDVIEN,0)
Q:$P(X,U,5)="" ; no patient
Q:$P(X,U,4)="IR"!($P(X,U,4)="OT") ; not patient related
; neither of the above should ever happen
S ACDEV("VISIT")=ACDVIEN
S ACDEV("PAT")=ACDDFNP
S ACDEV("V DATE")=$P(X,U)
S ACDEV("COMP CODE")=$P(X,U,2)
S ACDEV("COMP TYPE")=$P(X,U,7)
S ACDEV("PRI PROV")=$S($P(X,U,3):$P(X,U,3),1:"NOT ENTERED")
S ACDEV("TC")=$P(X,U,4)
S X=$P($G(^ACDVIS(ACDVIEN,11)),U)
S ACDEV("SVC CAT")=$S(X]"":X,1:"A") ; default to ambulatory
S ACDQ=0
Q
ACDPCCL2 ;IHS/ADC/EDE/KML - PCC LINK;
+1 ;;4.1;CHEMICAL DEPENDENCY MIS;;MAY 11, 1998
+2 ;
+3 ;
GENEVENT ; EP - GENERATE CDMIS EVENT ARRAY FOR ONE PATIENT VISIT
+1 ;//^ACDPCCL
+2 KILL ACDEV
+3 IF '$DATA(^ACDVIS(ACDVIEN,0))
SET ACDQ=1
DO ERROR^ACDPCCL("Specified visit doesn't exist",3)
QUIT
+4 DO SETPVARS
+5 IF ACDQ
QUIT
+6 DO SETVVARS
+7 IF ACDQ
QUIT
+8 SET X=ACDEV("TC")
+9 DO @("SET"_$SELECT(X="CS":"CS",X="TD":"TDC",1:"IIF")_"^ACDPCCL3")
+10 IF ACDQ
QUIT
+11 IF ACDEV("TC")'="CS"
Begin DoDot:1
+12 SET ACDQ=1
+13 SET W=$ORDER(^ICD9("AB","V70.8",0))
+14 IF 'W
DO ERROR^ACDPCCL("Cannot find ICD9 code V70.8 - notify programmer",3)
QUIT
+15 SET ACDEV("POV",1)=W_":V70.8:CHEMICAL DEPENDENCY-"_$SELECT(ACDEV("TC")="IN":"NEW PATIENT ",1:"")_"EVALUATION & MANAGEMENT"
+16 SET ACDQ=0
+17 QUIT
End DoDot:1
IF ACDQ
QUIT
+18 QUIT
+19 ;
SETPVARS ; SET PROGRAM VARIABLES
+1 SET ACDQ=1
+2 IF '$GET(ACDPGM)
DO ERROR^ACDPCCL("CDMIS Program variable not set-notify programmer",3)
QUIT
+3 SET X=$PIECE($GET(^ACDF5PI(ACDPGM,11)),U,2)
+4 IF X=""
SET X="?"
+5 IF ACDFPCC
IF X="?"
DO ERROR^ACDPCCL("No site type in CDMIS PROGRAM file",3)
QUIT
+6 SET ACDEV("SITE TYPE")=X
+7 SET X=$ORDER(^DIC(40.7,"C",43,0))
+8 IF X=""
DO ERROR^ACDPCCL("No clinic stop entry for alcoholism program",3)
QUIT
+9 SET ACDEV("CLINIC")=X
+10 SET ACDEV("LOCATION")=ACDPGM
+11 IF $GET(ACDMODE)=""
DO ERROR^ACDPCCL("No mode-notify programmer",3)
QUIT
+12 SET ACDEV("TYPE")=$GET(ACDMODE)
+13 IF "AED"'[ACDEV("TYPE")
DO ERROR^ACDPCCL("Invalid mode-notify programmer",3)
QUIT
+14 SET ACDQ=0
+15 QUIT
+16 ;
SETVVARS ; SET VISIT VARIABLES
+1 SET ACDQ=1
+2 SET X=^ACDVIS(ACDVIEN,0)
+3 ; no patient
IF $PIECE(X,U,5)=""
QUIT
+4 ; not patient related
IF $PIECE(X,U,4)="IR"!($PIECE(X,U,4)="OT")
QUIT
+5 ; neither of the above should ever happen
+6 SET ACDEV("VISIT")=ACDVIEN
+7 SET ACDEV("PAT")=ACDDFNP
+8 SET ACDEV("V DATE")=$PIECE(X,U)
+9 SET ACDEV("COMP CODE")=$PIECE(X,U,2)
+10 SET ACDEV("COMP TYPE")=$PIECE(X,U,7)
+11 SET ACDEV("PRI PROV")=$SELECT($PIECE(X,U,3):$PIECE(X,U,3),1:"NOT ENTERED")
+12 SET ACDEV("TC")=$PIECE(X,U,4)
+13 SET X=$PIECE($GET(^ACDVIS(ACDVIEN,11)),U)
+14 ; default to ambulatory
SET ACDEV("SVC CAT")=$SELECT(X]"":X,1:"A")
+15 SET ACDQ=0
+16 QUIT