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

BPCRC5.m

Go to the documentation of this file.
BPCRC5 ; IHS/OIT/MJL - FHL-12/11/96 - REFERRED CARE GUI ROUTINES ;
 ;;1.5;BPC;;MAY 26, 2005
GETREF(BPCRES,BPCRIEN,BPCPARAM) ;;EP CALL FROM REMOTE PROC: BPC GETREFERRALDATA
 ;
EN1 ;
 S U="^",XWBWRAP=1,BPCCTR=0,BPCRIEN=$G(BPCRIEN),BPCPARAM=$G(BPCPARAM)
 S BPCS1="`"
 K BPCRES,BPCTMP
 I BPCRIEN="" S BPCRES(1)=-1,BPCRES(2)="REFERRAL IEN NOT SENT!" D KILL Q
 S BPCDTA=$G(^BMCREF(BPCRIEN,0)) I BPCDTA="" S BPCRES(1)=-1,BPCRES(2)="NO DATA AVAILABLE FOR REFERRAL IEN: "_BPCRIEN D KILL Q
 D GETREF1,KILL
 Q
GETREF1 ;
 S BPCIDAT=$P(BPCDTA,U,1),BPCREF=$P(BPCDTA,U,2),BPCRTYP=$P(BPCDTA,U,4),BPCFAC=$P(BPCDTA,U,5),BPCPROV=$P(BPCDTA,U,6),BPCPVEND=$P(BPCDTA,U,7),BPCTOIHS=$P(BPCDTA,U,8)
 S BPCTOPRV=$P(BPCDTA,U,9),BPCPAYOR=$P(BPCDTA,U,11),BPCICD=$P(BPCDTA,U,12),BPCCPT=$P(BPCDTA,U,13),BPCPTYP=$P(BPCDTA,U,14),BPCSTAT=$P(BPCDTA,U,15),BPCDRG=$P(BPCDTA,U,21),BPCCLIN=$P(BPCDTA,U,23)
 S BPCUSR=$P(BPCDTA,U,25),BPCCDAT=$P(BPCDTA,U,26),BPCMDAT=$P(BPCDTA,U,27),BPCPRIOR=$P(BPCDTA,U,32),BPCSNDA=$P(BPCDTA,U,34)
 S BPCDTA=$G(^BMCREF(BPCRIEN,11)),BPCEBDAT=$P(BPCDTA,U,5),BPCEEDAT=$P(BPCDTA,U,7),BPCABDAT=$P(BPCDTA,U,6),BPCAEDAT=$P(BPCDTA,U,8),BPCELOS=$P(BPCDTA,U,9),BPCALOS=$P(BPCDTA,U,10),BPCNOVIS=$P(BPCDTA,U,11)
 S BPCPURP=$G(^BMCREF(BPCRIEN,12)),BPCDTA=$G(^BMCREF(BPCRIEN,13)),BPCSNOTE=$P(BPCDTA,U,1),BPCWDAYS=$P(BPCDTA,U,2)
 S BPCSFAC="" I BPCFAC'="" S BPCSFAC=$P($G(^AUTTLOC(BPCFAC,0)),U,1) S:BPCSFAC'="" BPCSFAC=$G(^DIC(4,BPCSFAC,0))
 S BPCSPROV="" I BPCPROV'="" S BPCSPROV=$P($G(^VA(200,BPCPROV,0)),U,1)
 S BPCSPVND="" I BPCPVEND'="" S BPCSPVND=$P($G(^AUTTVNDR(BPCPVEND,0)),U,1)
 S BPCSIHS="" I BPCTOIHS'="" S BPCSIHS=$P($G(^AUTTLOC(BPCTOIHS,0)),U,1) S:BPCSIHS'="" BPCSIHS=$P($G(^DIC(4,BPCSIHS,0)),U,1)
 S BPCSTPRV="" I BPCTOPRV'="" S BPCSTPRV=$P($G(^BMCLPRV(BPCTOPRV,0)),U,1)
 S BPCSICD="" I BPCICD'="" S BPCSICD=$P($G(^BMCTDXC(BPCICD,0)),U,1)
 S BPCSCPT="" I BPCCPT'="" S BPCSCPT=$P($G(^BMCTSVC(BPCCPT,0)),U,1)
 S BPCSDRG="" I BPCDRG'="" S BPCSDRG=$P($G(^ICD(BPCDRG,0)),U,1)
 S BPCSCLIN="" I BPCCLIN'="" S BPCSCLIN=$P($G(^DIC(40.7,BPCCLIN,0)),U,1)
 S BPCSUSR="" I BPCUSR'="" S BPCSUSR=$P($G(^VA(200,BPCUSR,0)),U,1)
 S BPCTMP("DATA",0)="DATA"_BPCS1_BPCIDAT_BPCS1_BPCPROV_BPCS1_BPCSPROV_BPCS1_BPCRTYP_BPCS1_BPCFAC_BPCS1_BPCSFAC
 S BPCTM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TY=$P(BPCDTA,U,4),BPCPRIM=$P(BPCDTA,U,5)
 S BPCPXC=BPCPXC+1,BPCDTA=$G(^ICPT(BPCPX,0)),BPCCDE=$P(BPCDTA,U,1),BPCSPX=$P(BPCDTA,U,2),BPCSNAR=""
 S:BPCNARR'="" BPCSNAR=$P($G(^AUTNPOV(BPCNARR,0)),U,1)
 S BPCCTR=BPCCTR+1,BPCTMP("PXS",BPCCTR)="PXS"_BPCS1_BPCPX_BPCS1_BPCCDE_BPCS1_BPCSPX_BPCS1_BPCSNAR_BPCS1_BPCTY_BPCS1_BPCPRIM
 Q
SETRES ;
 S BPCCTR=0,BPCSB1="" F  S BPCSB1=$O(BPCTMP(BPCSB1)) Q:BPCSB1=""  S BPCSB2="" F  S BPCSB2=$O(BPCTMP(BPCSB1,BPCSB2)) Q:BPCSB2=""  S BPCCTR=BPCCTR+1,BPCRES(BPCCTR)=BPCTMP(BPCSB1,BPCSB2)
 S BPCRES(0)=BPCCTR K BPCTMP
 Q
 ;
DRGLIST(BPCRES,BPCX,BPCMAX,BPCMORE,BPCPARAM) ;;EP CALL FROM REMOTE PROC: BPC GETDRGLIST
 ;
 S BPCGUI=1
EN ;
 S U="^",XWBWRAP=1,BPCCTR=0,BPCSUB=$J,BPCC="",BPCMORE=$G(BPCMORE),BPCGUI=$G(BPCGUI),BPCMAX=$G(BPCMAX),BPCX=$G(BPCX),BPCPARAM=$G(BPCPARAM),BPCLEN=$L(BPCX)
 S BPCRES="^BPCRES("_BPCSUB_")",BPCN=""
 S:'BPCMAX BPCMAX=$S(BPCGUI:50,1:1E10) ;
 K ^BPCRES(BPCSUB)
 S BPCSAV=BPCX
 I BPCMORE'="" D MORE,KILL Q
 I BPCX'="" I $D(^ICD("B",BPCX)) D GETDRG1,KILL Q
 S:BPCX'="" BPCN=$O(^ICD("B",BPCX),-1) D GETDRG2,KILL
 Q
KILL ;
 K BPCDXIEN,BPCNARR,BPCNIEN,BPCERR,BPCFDA,BPCEMSG,BPCFDR,BPC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 Q
 S BPCCTR=BPCCTR+1,^BPCRES(BPCSUB,BPCCTR)=$P(^ICD(BPCIEN,0),U,1)_U_BPCIEN
 Q
SETMORE ;
 S BPCCTR=BPCCTR+1,^BPCRES(BPCSUB,BPCCTR)="..MORE"_U_BPCIEN_"|"_$P(^ICD(BPCIEN,0),U,1)_"|B"_"|"_BPCN
 Q
MORE ;
 S BPCFLAG=0,BPCIEN=$P(BPCMORE,"|",1),BPCN=$P(BPCMORE,"|",4) D SETDRG
 D:'BPCFLAG GETDRG3 D:'BPCFLAG GETDRG2
 S ^BPCRES(BPCSUB,0)=BPCCTR
 Q
SETDXS ;EP CALLED WHEN ADDING REFERRALS FROM BPCRC3
 F BPCQ=1:1:$L(BPCDXS,BPCS2) S BPCDTA=$P(BPCDXS,BPCS2,BPCQ) D SETDXS1
 Q
SETDXS1 ;
 S BPCDXIEN=$P(BPCDTA,BPCS3,1),BPCNARR=$P(BPCDTA,BPCS3,2),BPCNIEN=""
 D:BPCNARR'="" SETNAR
 Q:BPCERR
 L +^BMCDX(0):10 I '$T S BPCERR=1 Q
 K BPCFDA,BPCEMSG S BPCFDR="BPCFDA(1)"
 S BPCFDA(1,90001.01,"+1,",.01)=BPCDXIEN
 S BPCFDA(1,90001.01,"+1,",.02)=BPCPIEN
 S BPCFDA(1,90001.01,"+1,",.03)=BPCRIEN
 S BPCFDA(1,90001.01,"+1,",.04)="P"
 S:BPCNIEN'="" BPCFDA(1,90001.01,"+1,",.06)=BPCNIEN
 K BPCIEN D UPDATE^DIE("",BPCFDR,"BPCIEN","BPCEMSG")
 I $D(BPCEMSG("DIERR")) S BPCERR=1
 L -^BMCDX(0)
 Q
SETPRCS ;EP CALLED WHEN ADDING REFERRALS FROM BPCRC3
 F BPCQ=1:1:$L(BPCPRCS,BPCS2) S BPCDTA=$P(BPCPRCS,BPCS2,BPCQ) D SETPRC1
 Q
SETPRC1 ;
 S BPCPXIEN=$P(BPCDTA,BPCS3,1),BPCNARR=$P(BPCDTA,BPCS3,2),BPCNIEN=""
 D:BPCNARR'="" SETNAR
 Q:BPCERR
 L +^BMCPX(0):10 I '$T S BPCERR=1 Q
 K BPCFDA,BPCEMSG S BPCFDR="BPCFDA(1)"
 S BPCFDA(1,90001.02,"+1,",.01)=BPCPXIEN
 S BPCFDA(1,90001.02,"+1,",.02)=BPCPIEN
 S BPCFDA(1,90001.02,"+1,",.03)=BPCRIEN
 S BPCFDA(1,90001.02,"+1,",.04)="P"
 S:BPCNIEN'="" BPCFDA(1,90001.02,"+1,",.06)=BPCNIEN
 K BPCIEN D UPDATE^DIE("",BPCFDR,"BPCIEN","BPCEMSG")
 I $D(BPCEMSG("DIERR")) S BPCERR=1
 L -^BMCPX(0)
 Q
SETNAR ;
 I $D(^AUTNPOV("B",$E(BPCNARR,1,30))) S BPCNIEN=$O(^AUTNPOV("B",$E(BPCNARR,1,30),"")) Q
 L +^AUTNPOV(0):10 I '$T S BPCERR=1 Q
 K BPCFDA,BPCEMSG S BPCFDR="BPCFDA(1)"
 S BPCFDA(1,9999999.27,"+1,",.01)=BPCNARR
 K BPCIEN D UPDATE^DIE("",BPCFDR,"BPCIEN","BPCEMSG")
 I $D(BPCEMSG("DIERR")) S BPCERR=1
 L -^AUTNPOV(0)
 I 'BPCERR S BPCNIEN=BPCIEN(1)
 Q