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

BMCPCCL.m

Go to the documentation of this file.
BMCPCCL ; IHS/PHXAO/TMJ - PCC LINK FR RCIS OUTSIDE VISIT ;
 ;;4.0;REFERRED CARE INFO SYSTEM;**3,10**;JAN 09, 2006;Build 101
 ;4.0*3 10.30.2007 IHS/OIT/FCJ ADDED CSV CHANGES
 ;THIS IS FOR THE REFERRED VISIT AND NON-CHS TYPE 
 ;
 ;BMCRIEN=RCIS RECORD NUMBER
 ;
 ;
START ;EP - ENTRY POINT BY TASKMAN
 S BMCVFL=0  ;*9
 Q:'BMCPCC  ;no pcc link active
 Q:'$D(^BMCREF(BMCRIEN))
 D PROC
 D XIT
 Q
PROC ;
 S BMCR0=^BMCREF(BMCRIEN,0),BMCR11=$G(^BMCREF(BMCRIEN,11)),BMCERR=0
 I $P(BMCR11,U,6)="" W $C(7),$C(7),!!,"Attempting PCC Link - NO ACTUAL BEGIN DATE OF SERVICE ENTERED.  LINK FAILED.",!! D CONT S BMCERR=1 Q
 Q:BMCRTYPE="C"  ;don't pass chs visits
 Q:BMCRSTAT'="C1"  ;quit if not closed - action occurred
 ;Delete a PCC Visit Then Create A PCC Visit
 ;I $P(BMCR0,U,29) D DELETE  ;*9
 I $P(BMCR0,U,29) S BMCVFL=1 D DELETE  ;*9
 W !,"Creating New PCC Visit, Hold on....."
 D ADD
 Q
ADD ;add a visit
 D SETVISIT Q:BMCERR
 D ^APCDALV
 I $D(APCDALVR("APCDAFLG")) W $C(7),$C(7),!!,"Attempting PCC Link - PCC VISIT CREATION FAILED.  LINK FAILED.",!! S BMCERR=1 D CONT Q
 S BMCVSIT=APCDALVR("APCDVSIT")
 D VFILES
 K DR,DA,DIE S DA=BMCRIEN,DIE="^BMCREF(",DR=".29////"_BMCVSIT D ^DIE
 ;NO ERROR CHECK ABOVE !!
 Q
SETVISIT ;set up visit values
 D KILL
 S APCDALVR("AUPNTALK")=""
 S APCDALVR("APCDDATE")=$P(BMCR11,U,6)
 S APCDALVR("APCDTYPE")=BMCRTYPE I APCDALVR("APCDTYPE")="" W $C(7),$C(7),!!,"Attempting PCC Link - TYPE OF REFERRAL ENTERED.  LINK FAILED.",!! D CONT S BMCERR=1 Q
 S APCDALVR("APCDPAT")=BMCDFN
 S APCDALVR("APCDLOC")=$$VALI^XBDIQ1(90001.31,DUZ(2),.11) I APCDALVR("APCDLOC")="" W $C(7),$C(7),!!,"Attempting PCC Link - OTHER LOCATION ENTERED IN STIE FILE.  LINK FAILED.",!! D CONT S BMCERR=1 Q
 S APCDALVR("APCDCAT")="E"
 S APCDALVR("APCDAUTO")="",APCDALVR("APCDANE")=""
 S APCDALVR("APCDOLOC")=$$FACREF^BMCRLU(BMCRIEN)
 Q
DELETE ;delete visit in PCC
 W !,"Deleting associated PCC Visit.",!
 S APCDVDLT=$P(BMCR0,U,29) I APCDVDLT="" Q
 D ^APCDVDLT
 Q
KILL ;
 K APCDALVR,APCDPAT,APCDLOC,APCDTYPE,APCDCAT,APCDCLN,APCDTPRO,APCDTPS,APCDTPOV,APCDTNQ,APCDTTOP,APCDTLOU,APCDTPRV,APCDTAT,APCDATMP,APCDAFLG,APCDAUTO,APCDANE,AUPNTALK,APCDAPPT,APCDOLOC,APCDVDLT
 Q
CONT ;
 S DIR(0)="E",DIR("A")="Hit <RETURN> to continue" K DA D ^DIR K DIR
 Q
XIT ;CLEAN UP AND EXIT
 D KILL
 LOCK -^BMCREF(BMCRIEN,0)
 K BMCVFL,BMCR0,BMCERR,BMCR11,BMCVSIT,BMCX,BMCC
 D KILL^AUPNPAT
 K X,A,D,D0,DO,DA,DIE,DR,DIY,DIU,DIW,DIV,DIC,DI,DDH,DQ,DIPGM
 Q
VFILES ;create v file entries
 D POV
 D PRC
 D VHOSP:$P(BMCR0,U,14)="I"
 Q
POV ;PURPOSE OF VISIT
 D KILL
 S APCDALVR("APCDVSIT")=BMCVSIT
 S APCDALVR("APCDATMP")="[APCDALVR 9000010.07 (ADD)]"
 S APCDALVR("APCDPAT")=BMCDFN
 S APCDALVR("APCDOVRR")=""
 I '$D(^BMCDX("AD",BMCRIEN)) D NODX Q
 S (BMCX,BMCC)=0 F  S BMCX=$O(^BMCDX("AD",BMCRIEN,BMCX)) Q:BMCX'=+BMCX  I $P(^BMCDX(BMCX,0),U,4)="F" D POV1
 Q:BMCC
 S BMCX=0 F  S BMCX=$O(^BMCDX("AD",BMCRIEN,BMCX)) Q:BMCX'=+BMCX  I $P(^BMCDX(BMCX,0),U,4)="P" D POV1
 Q
POV1 ;
 S BMCC=BMCC+1
 S APCDALVR("APCDTPOV")="`"_$P(^BMCDX(BMCX,0),U)
 S APCDALVR("APCDTPS")=$P(^BMCDX(BMCX,0),U,5)
 S APCDALVR("APCDTNQ")=$S($P(^BMCDX(BMCX,0),U,6):"`"_$P(^(0),U,6),1:"REFERRED FOR: "_$E($$VAL^XBDIQ1(90001.01,BMCX,.019),1,65))
 D ^APCDALVR
 ;4.0*3 10.30.2007 IHS/OIT/FCJ ADDED CSV CHANGES
 ;I $D(APCDALVR("APCDAFLG")) W $C(7),$C(7),!!,"Attempting PCC Link - POV ",$P(^ICD9(+^BMCDX(BMCX,0),0),U)_" FAILED.",!! S BMCERR=1 D CONT
 I $D(APCDALVR("APCDAFLG")) W $C(7),$C(7),!!,"Attempting PCC Link - POV ",$P($$ICDDX^ICDCODE(+^BMCDX(BMCX,0),0),U,2)_" FAILED.",!! S BMCERR=1 D CONT
 Q
PRC ;
 D KILL
 S APCDALVR("APCDVSIT")=BMCVSIT
 S APCDALVR("APCDATMP")="[APCDALVR 9000010.08 (ADD)]"
 S APCDALVR("APCDPAT")=BMCDFN
 S APCDALVR("APCDOVRR")=""
 S (BMCX,BMCC)=0 F  S BMCX=$O(^BMCPX("AD",BMCRIEN,BMCX)) Q:BMCX'=+BMCX  I $P(^BMCPX(BMCX,0),U,4)="F" D PRC1
 Q:BMCC
 S BMCX=0 F  S BMCX=$O(^BMCPX("AD",BMCRIEN,BMCX)) Q:BMCX'=+BMCX  I $P(^BMCPX(BMCX,0),U,4)="P" D PRC1
 Q:'$D(^BMCDX("AD",BMCRIEN))
 I $P(BMCR0,U,13) D
 .S APCDALVR("APCDVSIT")=BMCVSIT
 .S APCDALVR("APCDATMP")="[APCDALVR 9000010.07 (ADD)]"
 .S APCDALVR("APCDPAT")=BMCDFN
 .;S APCDALVR("APCDTPOV")="V68.81" ;BMC*4.0*10
 .S BMCDOS=$$AVDOS^BMCRLU(BMCRIEN,"N") S APCDALVR("APCDTPOV")=$S(BMCDOS>(BMCDX10-1):"Z04.9",1:"V68.81") ;BMC*4.0*10
 .S APCDALVR("APCDTNQ")="REFERRED FOR: "_$P(^BMCTSVC($P(BMCR0,U,13),0),U)
 .D ^APCDALVR
 .I $D(APCDALVR("APCDAFLG")) W $C(7),$C(7),!!,"Attempting PCC Link - POV CPT CATEGORY FAILED.",!! S BMCERR=1 D CONT
 .Q
 Q
PRC1 ;
 S %=$O(^ICPT($P(^BMCPX(BMCX,0),U),"ICD","B",0))
 I %="" S %=$O(^ICD0("AB",99.99,0))
 S APCDALVR("APCDTPRC")="`"_%
 S APCDALVR("APCDTNQ")=$S($P(^BMCPX(BMCX,0),U,6):"`"_$P(^(0),U,6),1:"REFERRED FOR: "_$E($$VAL^XBDIQ1(90001.02,BMCX,.019),1,65))
 D ^APCDALVR
 ;4.0*3 10.30.2007 IHS/OIT/FCJ ADDED CSV CHANGES
 ;I $D(APCDALVR("APCDAFLG")) W $C(7),$C(7),!!,"Attempting PCC Link - POV ",$P(^ICPT(+^BMCPX(BMCX,0),0),U)_" FAILED.",!! S BMCERR=1 D CONT
 I $D(APCDALVR("APCDAFLG")) W $C(7),$C(7),!!,"Attempting PCC Link - POV ",$P($$CPT^ICPTCOD(+^BMCPX(BMCX,0),0),U,2)_" FAILED.",!! S BMCERR=1 D CONT
 Q
VHOSP ;
 D KILL
 S APCDALVR("APCDVSIT")=BMCVSIT
 S APCDALVR("APCDATMP")="[APCDALVR 9000010.02 (ADD)]"
 S APCDALVR("APCDPAT")=BMCDFN
 S APCDALVR("APCDLOOK")=$P(BMCR11,U,6)
 D ^APCDALVR
 I $D(APCDALVR("APCDAFLG")) W $C(7),$C(7),!,"Attempting PCC Link - V HOSPITALIZATION FAILED",! S BMCERR=1 D CONT
 Q
NODX ;no dx's entered, use 2 categories as Pov's
 I $P(BMCR0,U,12) D
 .S APCDALVR("APCDVSIT")=BMCVSIT
 .S APCDALVR("APCDATMP")="[APCDALVR 9000010.07 (ADD)]"
 .S APCDALVR("APCDPAT")=BMCDFN
 .;S APCDALVR("APCDTPOV")="V68.81";BMC*4.0*10
 .S BMCDOS=$$AVDOS^BMCRLU(BMCRIEN,"N") S APCDALVR("APCDTPOV")=$S(BMCDOS>(BMCDX10-1):"Z04.9",1:"V68.81")  ;BMC*4.0*10
 .S APCDALVR("APCDTNQ")="REFERRED FOR: "_$P(^BMCTDXC($P(BMCR0,U,12),0),U)
 .D ^APCDALVR
 .I $D(APCDALVR("APCDAFLG")) W $C(7),$C(7),!!,"Attempting PCC Link - POV DIAGNOSTIC CATEGORY FAILED.",!! S BMCERR=1 D CONT
 .Q
  I $P(BMCR0,U,13) D
 .S APCDALVR("APCDVSIT")=BMCVSIT
 .S APCDALVR("APCDATMP")="[APCDALVR 9000010.07 (ADD)]"
 .S APCDALVR("APCDPAT")=BMCDFN
 .;S APCDALVR("APCDTPOV")="V68.81" ;BMC*4.0*10
 .S BMCDOS=$$AVDOS^BMCRLU(BMCRIEN,"N") S APCDALVR("APCDTPOV")=$S(BMCDOS>(BMCDX10-1):"Z04.9",1:"V68.81") ;BMC*4.0*10
 .S APCDALVR("APCDTNQ")="REFERRED FOR: "_$P(^BMCTSVC($P(BMCR0,U,13),0),U)
 .D ^APCDALVR
 .I $D(APCDALVR("APCDAFLG")) W $C(7),$C(7),!!,"Attempting PCC Link - POV CPT CATEGORY FAILED.",!! S BMCERR=1 D CONT
 .Q
 Q