APCDLINK ; IHS/CMI/LAB - LINK IN HOSPITAL VISITS ;
;;2.0;IHS PCC SUITE;;MAY 14, 2009
;
HDR ; Write Header
W:$D(IOF) @IOF
F APCDJ=1:1:5 S APCDX=$P($T(TEXT+APCDJ),";;",2) W !?80-$L(APCDX)\2,APCDX
K APCDX,APCDJ
W !!
PROCESS ;
S APCDPAT=""
D GETPAT
I APCDPAT="" W !!,"No PATIENT selected!" D EOJ Q
S APCDI=""
D GETIN
I APCDI="" W !!,"No IN-HOSPITAL Visit selected!" D EOJ Q
S APCDH=""
D GETHOSP
I APCDH="" W !!,"No HOSPITALIZATION Visit selected!" D EOJ Q
S APCDANS=""
D CONFIRM
I 'APCDANS W !!,"Leaving this option BYE!",! D EOJ Q
S APCDFAIL="" D LINK
I APCDFAIL=1 W !!,"The LINK failed!! Try again later."
D EOJ
Q
GETPAT ; GET PATIENT
W !
S DIC="^AUPNPAT(",DIC(0)="AEMQ" D ^DIC K DIC
Q:Y<0
S APCDPAT=+Y
Q
;
GETIN S DIR(0)="DO^::EP",DIR("A")="Enter IN-HOSPITAL Visit date" D ^DIR K DIR S:$D(DUOUT) DIRUT=1
K APCDLKT
S APCDLDC=Y,(APCDLI,APCDLV)=0 K Y
F S APCDLV=$O(^AUPNVSIT("AC",APCDPAT,APCDLV)) Q:APCDLV="" I APCDLDC=$P(+^AUPNVSIT(APCDLV,0),"."),'$P(^(0),U,11),$P(^(0),U,7)="I" S APCDLI=APCDLI+1,APCDLKT(APCDLI)=APCDLV
I '$D(APCDLKT) W !,"No In-Hospital Visit on that date for this patient!" Q
I APCDLI=1 S APCDI=APCDLKT(1) S DA=APCDI D DISP Q
D SELECT
I APCDDFN="" Q
S APCDI=APCDDFN S DA=APCDI D DISP Q
Q
SELECT ; SELECT EXISTING VISIT
W !!,"PATIENT: ",$P(^DPT(APCDPAT,0),U)," has one or more IN-HOSPITAL Visits on this date.",!
S APCDLI="" F S APCDLI=$O(APCDLKT(APCDLI)) Q:APCDLI="" S APCDLX=^AUPNVSIT(APCDLKT(APCDLI),0) D WRITE
S APCDLV=""
SRDR S APCDDFN="" W !!,"Select one: " R APCDLI:DTIME E S APCDLI="" Q
Q:APCDLI=""!(APCDLI="^")
I APCDLI'?1N.N W $C(7),$C(7) G SELECT
I '$D(APCDLKT(APCDLI)) W $C(7),$C(7) G SELECT
S APCDDFN=APCDLKT(APCDLI)
Q
;
GETHOSP S DIR(0)="DO^::EP",DIR("A")="Enter HOSPITALIZATION Admission date" D ^DIR K DIR S:$D(DUOUT) DIRUT=1 I $D(DTOUT) S X=""
K APCDLKT
S APCDLDC=Y,(APCDLI,APCDLV)=0 K Y
F S APCDLV=$O(^AUPNVSIT("AC",APCDPAT,APCDLV)) Q:APCDLV="" I APCDLDC=$P(+^AUPNVSIT(APCDLV,0),"."),'$P(^(0),U,11),$P(^(0),U,7)="H" S APCDLI=APCDLI+1,APCDLKT(APCDLI)=APCDLV
I '$D(APCDLKT) W !,"No Hospitalization Visit on that date for this patient!" Q
I APCDLI=1 S APCDH=APCDLKT(1) S DA=APCDH D DISP Q
S APCDDFN=""
D SELECT
I APCDDFN="" Q
S (APCDH,DA)=APCDDFN D DISP Q
Q
;
LINK ;
S DA=APCDI,DIE="^AUPNVSIT(",DR=".12///`"_APCDH D ^DIE
I $D(Y) S APCDFAIL=1 Q
; -- IHS/DAOU/EJN for HL7
Q:'$G(APCDI)
I $T(A08^BTSEVENT)]"" S APCDHLER=$$A08^BTSEVENT(APCDI) K APCDHLER
; -- END HL7 mods
W !,"In-Hospital Visit Linked!!"
Q
CONFIRM ;
S DIR(0)="Y",DIR("A")="Do you want to continue",DIR("B")="N" D ^DIR K DIR S:$D(DUOUT) DIRUT=1
I $D(DIRUT) S APCDANS=0 Q
S APCDANS=Y
Q
;
WRITE ; WRITE VISITS FOR SELECT
S APCDLT=$P(+APCDLX,".",2),APCDLT=$S(APCDLT="":"<NONE>",$L(APCDLT)=1:APCDLT_"0:00 ",1:$E(APCDLT,1,2)_":"_$E(APCDLT,3,4)_$E("00",1,2-$L($E(APCDLT,3,4)))_" ")
S APCDLOC=""
I $P(APCDLX,U,6),$D(^AUTTLOC($P(APCDLX,U,6),0)) S APCDLOC=$P(^(0),U,7),APCDLOC=APCDLOC_$E(" ",1,4-$L(APCDLOC))
S:APCDLOC="" APCDLOC="...."
W !,APCDLI," TIME: ",APCDLT," LOC: ",APCDLOC," TYPE: ",$P(APCDLX,U,3)," CATEGORY: ",$P(APCDLX,U,7)," CLINIC: ",$S($P(APCDLX,U,8)]"":$P(^DIC(40.7,$P(APCDLX,U,8),0),U),1:"<NONE>")
K APCDLT,APCDLOC
Q
;
DISP ;
W !
S DIC="^AUPNVSIT(" D EN^DIQ K DIC,DIQ,DR,Y,X,S,A,DK,DL,D0
W !,"Do you want to see the Entire Visit (V FILE entries)?" S %=2 D YN^DICN S %Y=$E(%Y)
I "Nn"[%Y K DA Q
S APCDVDSP=DA D ^APCDVDSP K DA
Q
EOJ ;
K APCDLDC,APCDLDT,APCDLI,APCDLKT,APCDLOC,APCDLT,APCDLV,APCDLX,Y,APCDPAT,APCDI,APCDH,APCDDFN,DA,DIC,Y,%Y,DR,X,Y,%,%DT,D,C,D0,DA,DICR,DIE,DIH,DIU,DIV,DIW,APCDFAIL,APCDANS
Q
TEXT ;
;;PCC Data Entry Module
;;
;;*********************************************
;;* Link In-Hospital Visit to Hospitalization *
;;*********************************************
Q
APCDLINK ; IHS/CMI/LAB - LINK IN HOSPITAL VISITS ;
+1 ;;2.0;IHS PCC SUITE;;MAY 14, 2009
+2 ;
HDR ; Write Header
+1 IF $DATA(IOF)
WRITE @IOF
+2 FOR APCDJ=1:1:5
SET APCDX=$PIECE($TEXT(TEXT+APCDJ),";;",2)
WRITE !?80-$LENGTH(APCDX)\2,APCDX
+3 KILL APCDX,APCDJ
+4 WRITE !!
PROCESS ;
+1 SET APCDPAT=""
+2 DO GETPAT
+3 IF APCDPAT=""
WRITE !!,"No PATIENT selected!"
DO EOJ
QUIT
+4 SET APCDI=""
+5 DO GETIN
+6 IF APCDI=""
WRITE !!,"No IN-HOSPITAL Visit selected!"
DO EOJ
QUIT
+7 SET APCDH=""
+8 DO GETHOSP
+9 IF APCDH=""
WRITE !!,"No HOSPITALIZATION Visit selected!"
DO EOJ
QUIT
+10 SET APCDANS=""
+11 DO CONFIRM
+12 IF 'APCDANS
WRITE !!,"Leaving this option BYE!",!
DO EOJ
QUIT
+13 SET APCDFAIL=""
DO LINK
+14 IF APCDFAIL=1
WRITE !!,"The LINK failed!! Try again later."
+15 DO EOJ
+16 QUIT
GETPAT ; GET PATIENT
+1 WRITE !
+2 SET DIC="^AUPNPAT("
SET DIC(0)="AEMQ"
DO ^DIC
KILL DIC
+3 IF Y<0
QUIT
+4 SET APCDPAT=+Y
+5 QUIT
+6 ;
GETIN SET DIR(0)="DO^::EP"
SET DIR("A")="Enter IN-HOSPITAL Visit date"
DO ^DIR
KILL DIR
IF $DATA(DUOUT)
SET DIRUT=1
+1 KILL APCDLKT
+2 SET APCDLDC=Y
SET (APCDLI,APCDLV)=0
KILL Y
+3 FOR
SET APCDLV=$ORDER(^AUPNVSIT("AC",APCDPAT,APCDLV))
IF APCDLV=""
QUIT
IF APCDLDC=$PIECE(+^AUPNVSIT(APCDLV,0),".")
IF '$PIECE(^(0),U,11)
IF $PIECE(^(0),U,7)="I"
SET APCDLI=APCDLI+1
SET APCDLKT(APCDLI)=APCDLV
+4 IF '$DATA(APCDLKT)
WRITE !,"No In-Hospital Visit on that date for this patient!"
QUIT
+5 IF APCDLI=1
SET APCDI=APCDLKT(1)
SET DA=APCDI
DO DISP
QUIT
+6 DO SELECT
+7 IF APCDDFN=""
QUIT
+8 SET APCDI=APCDDFN
SET DA=APCDI
DO DISP
QUIT
+9 QUIT
SELECT ; SELECT EXISTING VISIT
+1 WRITE !!,"PATIENT: ",$PIECE(^DPT(APCDPAT,0),U)," has one or more IN-HOSPITAL Visits on this date.",!
+2 SET APCDLI=""
FOR
SET APCDLI=$ORDER(APCDLKT(APCDLI))
IF APCDLI=""
QUIT
SET APCDLX=^AUPNVSIT(APCDLKT(APCDLI),0)
DO WRITE
+3 SET APCDLV=""
SRDR SET APCDDFN=""
WRITE !!,"Select one: "
READ APCDLI:DTIME
IF '$TEST
SET APCDLI=""
QUIT
+1 IF APCDLI=""!(APCDLI="^")
QUIT
+2 IF APCDLI'?1N.N
WRITE $CHAR(7),$CHAR(7)
GOTO SELECT
+3 IF '$DATA(APCDLKT(APCDLI))
WRITE $CHAR(7),$CHAR(7)
GOTO SELECT
+4 SET APCDDFN=APCDLKT(APCDLI)
+5 QUIT
+6 ;
GETHOSP SET DIR(0)="DO^::EP"
SET DIR("A")="Enter HOSPITALIZATION Admission date"
DO ^DIR
KILL DIR
IF $DATA(DUOUT)
SET DIRUT=1
IF $DATA(DTOUT)
SET X=""
+1 KILL APCDLKT
+2 SET APCDLDC=Y
SET (APCDLI,APCDLV)=0
KILL Y
+3 FOR
SET APCDLV=$ORDER(^AUPNVSIT("AC",APCDPAT,APCDLV))
IF APCDLV=""
QUIT
IF APCDLDC=$PIECE(+^AUPNVSIT(APCDLV,0),".")
IF '$PIECE(^(0),U,11)
IF $PIECE(^(0),U,7)="H"
SET APCDLI=APCDLI+1
SET APCDLKT(APCDLI)=APCDLV
+4 IF '$DATA(APCDLKT)
WRITE !,"No Hospitalization Visit on that date for this patient!"
QUIT
+5 IF APCDLI=1
SET APCDH=APCDLKT(1)
SET DA=APCDH
DO DISP
QUIT
+6 SET APCDDFN=""
+7 DO SELECT
+8 IF APCDDFN=""
QUIT
+9 SET (APCDH,DA)=APCDDFN
DO DISP
QUIT
+10 QUIT
+11 ;
LINK ;
+1 SET DA=APCDI
SET DIE="^AUPNVSIT("
SET DR=".12///`"_APCDH
DO ^DIE
+2 IF $DATA(Y)
SET APCDFAIL=1
QUIT
+3 ; -- IHS/DAOU/EJN for HL7
+4 IF '$GET(APCDI)
QUIT
+5 IF $TEXT(A08^BTSEVENT)]""
SET APCDHLER=$$A08^BTSEVENT(APCDI)
KILL APCDHLER
+6 ; -- END HL7 mods
+7 WRITE !,"In-Hospital Visit Linked!!"
+8 QUIT
CONFIRM ;
+1 SET DIR(0)="Y"
SET DIR("A")="Do you want to continue"
SET DIR("B")="N"
DO ^DIR
KILL DIR
IF $DATA(DUOUT)
SET DIRUT=1
+2 IF $DATA(DIRUT)
SET APCDANS=0
QUIT
+3 SET APCDANS=Y
+4 QUIT
+5 ;
WRITE ; WRITE VISITS FOR SELECT
+1 SET APCDLT=$PIECE(+APCDLX,".",2)
SET APCDLT=$SELECT(APCDLT="":"<NONE>",$LENGTH(APCDLT)=1:APCDLT_"0:00 ",1:$EXTRACT(APCDLT,1,2)_":"_$EXTRACT(APCDLT,3,4)_$EXTRACT("00",1,2-$LENGTH($EXTRACT(APCDLT,3,4)))_" ")
+2 SET APCDLOC=""
+3 IF $PIECE(APCDLX,U,6)
IF $DATA(^AUTTLOC($PIECE(APCDLX,U,6),0))
SET APCDLOC=$PIECE(^(0),U,7)
SET APCDLOC=APCDLOC_$EXTRACT(" ",1,4-$LENGTH(APCDLOC))
+4 IF APCDLOC=""
SET APCDLOC="...."
+5 WRITE !,APCDLI," TIME: ",APCDLT," LOC: ",APCDLOC," TYPE: ",$PIECE(APCDLX,U,3)," CATEGORY: ",$PIECE(APCDLX,U,7)," CLINIC: ",$SELECT($PIECE(APCDLX,U,8)]"":$PIECE(^DIC(40.7,$PIECE(APCDLX,U,8),0),U),1:"<NONE>")
+6 KILL APCDLT,APCDLOC
+7 QUIT
+8 ;
DISP ;
+1 WRITE !
+2 SET DIC="^AUPNVSIT("
DO EN^DIQ
KILL DIC,DIQ,DR,Y,X,S,A,DK,DL,D0
+3 WRITE !,"Do you want to see the Entire Visit (V FILE entries)?"
SET %=2
DO YN^DICN
SET %Y=$EXTRACT(%Y)
+4 IF "Nn"[%Y
KILL DA
QUIT
+5 SET APCDVDSP=DA
DO ^APCDVDSP
KILL DA
+6 QUIT
EOJ ;
+1 KILL APCDLDC,APCDLDT,APCDLI,APCDLKT,APCDLOC,APCDLT,APCDLV,APCDLX,Y,APCDPAT,APCDI,APCDH,APCDDFN,DA,DIC,Y,%Y,DR,X,Y,%,%DT,D,C,D0,DA,DICR,DIE,DIH,DIU,DIV,DIW,APCDFAIL,APCDANS
+2 QUIT
TEXT ;
+1 ;;PCC Data Entry Module
+2 ;;
+3 ;;*********************************************
+4 ;;* Link In-Hospital Visit to Hospitalization *
+5 ;;*********************************************
+6 QUIT