Home   Package List   Routine Alphabetical List   Global Alphabetical List   FileMan Files List   FileMan Sub-Files List   Package Component Lists   Package-Namespace Mapping  
Routine: APCDLINK

APCDLINK.m

Go to the documentation of this file.
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
 ;
 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