BPCRC8 ; IHS/OIT/MJL - REFERRED CARE GUI RPC ROUTINES ;
;;1.5;BPC;;MAY 26, 2005
;
GETFACE(BPCRES,BPCPIEN,BPCPARAM) ;EP CALL FROM REMOTE PROC: BPC GETFACEDATA
;
EN ;
S U="^",XWBWRAP=1,BPCCTR=0,BPCPIEN=$G(BPCPIEN),BPCPARAM=$G(BPCPARAM)
S BPCS1="`",BPCS2="~"
K BPCRES,BPCTMP
I BPCPIEN="" S BPCRES(1)=-1,BPCRES(2)="PATIENT IEN NOT SENT!" D KILL Q
I '$D(^AUPNPAT(BPCPIEN,0)) S BPCRES(1)=-1,BPCRES(2)="PATIENT IEN IS NOT DEFINED!" D KILL Q
;I BPCPARAM="JASPER" D EN^BPCFACE Q
D GETAUPN,GETDPT,BUILD,KILL
Q
GETAUPN ;
S BPCDTA=$G(^AUPNPAT(BPCPIEN,0)),BPCEDTE=$P(BPCDTA,U,2),BPCLDTE=$P(BPCDTA,U,3),BPCSSNS=$P(BPCDTA,U,23),BPCTREN=$P(BPCDTA,U,7),BPCEMP=$P(BPCDTA,U,19)
S:BPCSSNS'="" BPCSSNS=$P($G(^AUTTSSN(BPCSSNS,0)),U,2) S:BPCSSNS="" BPCSSNS="UNKNOWN"
I BPCEMP'="" S BPCEMP=$P($G(^AUTNEMPL(BPCEMP,0)),U,1)
S BPCDTA=$G(^AUPNPAT(BPCPIEN,11)),BPCCLS=$P(BPCDTA,U,11),BPCCOM=$P(BPCDTA,U,18),BPCTRIB=$P(BPCDTA,U,8),BPCTQT=$P(BPCDTA,U,9),BPCIQT=$P(BPCDTA,U,10),BPCESTAT=$P(BPCDTA,U,12)
I BPCCLS'="" S BPCCLS=$P($G(^AUTTBEN(BPCCLS,0)),U,1)
I BPCTRIB'="" S BPCTRIB=$P($G(^AUTTTRI(BPCTRIB,0)),U,1)
I BPCESTAT'="" S BPCESTAT=$S(BPCESTAT="I":"INELIGIBLE",BPCESTAT="D":"DIRECT ONLY",BPCESTAT="C":"CHS & DIRECT",1:"PENDING VERIFICATION")
S BPCDTA=$G(^AUPNPAT(BPCPIEN,26)),BPCFCTY=$P(BPCDTA,U,2),BPCFST=$P(BPCDTA,U,3),BPCMCTY=$P(BPCDTA,U,5),BPCMST=$P(BPCDTA,U,6)
I BPCFST'="" S BPCFST=$P($G(^DIC(5,BPCFST,0)),U,1)
I BPCMST'="" S BPCMST=$P($G(^DIC(5,BPCMST,0)),U,1)
Q
GETDPT ;
S BPCDTA=$G(^DPT(BPCPIEN,0)),BPCNAM=$P(BPCDTA,U,1),BPCSSN=$P(BPCDTA,U,9),BPCSEX=$P(BPCDTA,U,2),BPCDOB=$P(BPCDTA,U,3),BPCBCITY=$P(BPCDTA,U,11),BPCBSTA=$P(BPCDTA,U,12),BPCREL=$P(BPCDTA,U,8)
S:BPCBSTA'="" BPCBSTA=$P($G(^DIC(5,BPCBSTA,0)),U,1) S:BPCREL'="" BPCREL=$P($G(^DIC(13,BPCREL,0)),U,1)
S BPCSEX=$S(BPCSEX="M":"MALE",BPCSEX="F":"FEMALE",1:""),BPCAGE="",BPCAUN=""
D:BPCDOB'="" GETAGE
S BPCDTA=$G(^DPT(BPCPIEN,".11")),BPCSTIEN=$P(BPCDTA,U,5),BPCCTY=$P(BPCDTA,U,7),BPCADDR1=$P(BPCDTA,U,1),BPCADDR2=$P(BPCDTA,U,2),BPCADDR3=$P(BPCDTA,U,3),BPCCITY=$P(BPCDTA,U,4),BPCZIP=$P(BPCDTA,U,6)
S BPCSTATE="" I BPCSTIEN'="" S BPCSTATE=$P($G(^DIC(5,BPCSTIEN,0)),U,1) S:BPCCTY'="" BPCCTY=$P($G(^DIC(5,BPCSTIEN,1,BPCCTY,0)),U,1)
S BPCDTA=$G(^DPT(BPCPIEN,".13")),BPCHPH=$P(BPCDTA,U,1),BPCOPH=$P(BPCDTA,U,2)
S BPCDTA=$G(^DPT(BPCPIEN,".24")),BPCFNAM=$P(BPCDTA,U,1),BPCMNAM=$P(BPCDTA,U,3)
S BPCDTA=$G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GUI RPC ROUTINES ;
+1 ;;1.5;BPC;;MAY 26, 2005
+2 ;
GETFACE(BPCRES,BPCPIEN,BPCPARAM) ;EP CALL FROM REMOTE PROC: BPC GETFACEDATA
+1 ;
EN ;
+1 SET U="^"
SET XWBWRAP=1
SET BPCCTR=0
SET BPCPIEN=$GET(BPCPIEN)
SET BPCPARAM=$GET(BPCPARAM)
+2 SET BPCS1="`"
SET BPCS2="~"
+3 KILL BPCRES,BPCTMP
+4 IF BPCPIEN=""
SET BPCRES(1)=-1
SET BPCRES(2)="PATIENT IEN NOT SENT!"
DO KILL
QUIT
+5 IF '$DATA(^AUPNPAT(BPCPIEN,0))
SET BPCRES(1)=-1
SET BPCRES(2)="PATIENT IEN IS NOT DEFINED!"
DO KILL
QUIT
+6 ;I BPCPARAM="JASPER" D EN^BPCFACE Q
+7 DO GETAUPN
DO GETDPT
DO BUILD
DO KILL
+8 QUIT
GETAUPN ;
+1 SET BPCDTA=$GET(^AUPNPAT(BPCPIEN,0))
SET BPCEDTE=$PIECE(BPCDTA,U,2)
SET BPCLDTE=$PIECE(BPCDTA,U,3)
SET BPCSSNS=$PIECE(BPCDTA,U,23)
SET BPCTREN=$PIECE(BPCDTA,U,7)
SET BPCEMP=$PIECE(BPCDTA,U,19)
+2 IF BPCSSNS'=""
SET BPCSSNS=$PIECE($GET(^AUTTSSN(BPCSSNS,0)),U,2)
IF BPCSSNS=""
SET BPCSSNS="UNKNOWN"
+3 IF BPCEMP'=""
SET BPCEMP=$PIECE($GET(^AUTNEMPL(BPCEMP,0)),U,1)
+4 SET BPCDTA=$GET(^AUPNPAT(BPCPIEN,11))
SET BPCCLS=$PIECE(BPCDTA,U,11)
SET BPCCOM=$PIECE(BPCDTA,U,18)
SET BPCTRIB=$PIECE(BPCDTA,U,8)
SET BPCTQT=$PIECE(BPCDTA,U,9)
SET BPCIQT=$PIECE(BPCDTA,U,10)
SET BPCESTAT=$PIECE(BPCDTA,U,12)
+5 IF BPCCLS'=""
SET BPCCLS=$PIECE($GET(^AUTTBEN(BPCCLS,0)),U,1)
+6 IF BPCTRIB'=""
SET BPCTRIB=$PIECE($GET(^AUTTTRI(BPCTRIB,0)),U,1)
+7 IF BPCESTAT'=""
SET BPCESTAT=$SELECT(BPCESTAT="I":"INELIGIBLE",BPCESTAT="D":"DIRECT ONLY",BPCESTAT="C":"CHS & DIRECT",1:"PENDING VERIFICATION")
+8 SET BPCDTA=$GET(^AUPNPAT(BPCPIEN,26))
SET BPCFCTY=$PIECE(BPCDTA,U,2)
SET BPCFST=$PIECE(BPCDTA,U,3)
SET BPCMCTY=$PIECE(BPCDTA,U,5)
SET BPCMST=$PIECE(BPCDTA,U,6)
+9 IF BPCFST'=""
SET BPCFST=$PIECE($GET(^DIC(5,BPCFST,0)),U,1)
+10 IF BPCMST'=""
SET BPCMST=$PIECE($GET(^DIC(5,BPCMST,0)),U,1)
+11 QUIT
GETDPT ;
+1 SET BPCDTA=$GET(^DPT(BPCPIEN,0))
SET BPCNAM=$PIECE(BPCDTA,U,1)
SET BPCSSN=$PIECE(BPCDTA,U,9)
SET BPCSEX=$PIECE(BPCDTA,U,2)
SET BPCDOB=$PIECE(BPCDTA,U,3)
SET BPCBCITY=$PIECE(BPCDTA,U,11)
SET BPCBSTA=$PIECE(BPCDTA,U,12)
SET BPCREL=$PIECE(BPCDTA,U,8)
+2 IF BPCBSTA'=""
SET BPCBSTA=$PIECE($GET(^DIC(5,BPCBSTA,0)),U,1)
IF BPCREL'=""
SET BPCREL=$PIECE($GET(^DIC(13,BPCREL,0)),U,1)
+3 SET BPCSEX=$SELECT(BPCSEX="M":"MALE",BPCSEX="F":"FEMALE",1:"")
SET BPCAGE=""
SET BPCAUN=""
+4 IF BPCDOB'=""
DO GETAGE
+5 SET BPCDTA=$GET(^DPT(BPCPIEN,".11"))
SET BPCSTIEN=$PIECE(BPCDTA,U,5)
SET BPCCTY=$PIECE(BPCDTA,U,7)
SET BPCADDR1=$PIECE(BPCDTA,U,1)
SET BPCADDR2=$PIECE(BPCDTA,U,2)
SET BPCADDR3=$PIECE(BPCDTA,U,3)
SET BPCCITY=$PIECE(BPCDTA,U,4)
SET BPCZIP=$PIECE(BPCDTA,U,6)
+6 SET BPCSTATE=""
IF BPCSTIEN'=""
SET BPCSTATE=$PIECE($GET(^DIC(5,BPCSTIEN,0)),U,1)
IF BPCCTY'=""
SET BPCCTY=$PIECE($GET(^DIC(5,BPCSTIEN,1,BPCCTY,0)),U,1)
+7 SET BPCDTA=$GET(^DPT(BPCPIEN,".13"))
SET BPCHPH=$PIECE(BPCDTA,U,1)
SET BPCOPH=$PIECE(BPCDTA,U,2)
+8 SET BPCDTA=$GET(^DPT(BPCPIEN,".24"))
SET BPCFNAM=$PIECE(BPCDTA,U,1)
SET BPCMNAM=$PIECE(BPCDTA,U,3)
+9 SET BPCDTA=$GET(^DPT(BPCPIEN,".33"))
SET BPCEC=$PIECE(BPCDTA,U,1)
SET BPCECAD1=$PIECE(BPCDTA,U,3)
SET BPCECAD2=$PIECE(BPCDTA,U,4)
SET BPCECAD3=$PIECE(BPCDTA,U,5)
SET BPCECCTY=$PIECE(BPCDTA,U,6)
SET BPCECSTA=$PIECE(BPCDTA,U,7)
SET BPCECZIP=$PIECE(BPCDTA,U,8)
SET BPCECPNE=$PIECE(BPCDTA,U,9)
+10 IF BPCECSTA'=""
SET BPCECSTA=$PIECE($GET(^DIC(5,BPCECSTA,0)),U,1)
+11 SET BPCVET=$GET(^DPT(BPCPIEN,"VET"))
+12 SET (BPCSRVC,BPCSRVDT,BPCSRVSD,BPCCLAIM)=""
+13 IF BPCVET="Y"
Begin DoDot:1
+14 SET BPCDTA=$GET(^DPT(BPCPIEN,".32"))
SET BPCSRVC=$PIECE(BPCDTA,U,5)
SET BPCSRVDT=$PIECE(BPCDTA,U,6)
SET BPCSRVSD=$PIECE(BPCDTA,U,7)
IF BPCSRVC'=""
SET BPCSRVC=$PIECE($GET(^DIC(23,BPCSRVC,0)),U,1)
+15 SET BPCCLAIM=$PIECE($G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OR
SET BPCX=$ORDER(^AUPNPAT(BPCPIEN,43,BPCX))
IF BPCX=""!(BPCX'?1.N)
QUIT
SET BPCDTA=^(BPCX,0)
SET BPCY=$PIECE(BPCDTA,U,1)
SET BPCQ=$PIECE(BPCDTA,U,2)
IF BPCY'=""
SET BPCY=$PIECE($GET(^AUTTTRI(BPCY,0)),U,1)
IF BPCY'=BPCTRIB
Begin DoDot:1
+2 SET BPCC=BPCC+1
+3 IF BPCD'=""
SET BPCD=BPCD_BPCS2_BPCY_U_BPCQ
IF BPCD=""
SET BPCD=BPCY_U_BPCQ
End DoDot:1
+4 IF BPCC>0
SET BPCCTR=BPCCTR+1
SET BPCRES(BPCCTR)="TRIBES"_BPCS1_BPCC_BPCS1_BPCD
+5 QUIT
BUILD2 ;
+1 IF '$DATA(^AUPNMCR("B",BPCPIEN))
QUIT
+2 SET BPCX=""
SET BPCD=""
SET BPCC=0
FOR
SET BPCX=$ORDER(^AUPNMCR("B",BPCPIEN,BPCX))
IF BPCX=""!(BPCX'?1.N)
QUIT
SET BPCDTA=$GET(^AUPNMCR(BPCX,0))
Begin DoDot:1
+3 SET BPCN=$PIECE(BPCDTA,U,3)
SET BPCSUF=$PIECE(BPCDTA,U,4)
+4 IF BPCSUF'=""
SET BPCSUF=$PIECE($GET(^AUTTMCS(BPCSUF,0)),U,1)
+5 SET BPCY=0
FOR
SET BPCY=$ORDER(^AUPNMCR(BPCX,11,BPCY))
IF BPCY=""!(BPCY'?1.N)
QUIT
Begin DoDot:2
+6 SET BPCDTA=^AUPNMCR(BPCX,11,BPCY,0)
SET BPCC=BPCC+1
+7 IF BPCD'=""
SET BPCD=BPCD_BPCS2_BPCDTA
+8 IF BPCD=""
SET BPCD=BPCDTA
End DoDot:2
End DoDot:1
+9 IF BPCC>0
SET BPCCTR=BPCCTR+1
SET BPCRES(BPCCTR)="MCR"_BPCS1_BPCN_BPCSUF_BPCS1_BPCC_BPCS1_BPCD
+10 QUIT
BUILD3 ;
+1 IF '$DATA(^AUPNMCD("B",BPCPIEN))
QUIT
+2 SET BPCX=""
SET BPCD=""
SET BPCC=0
+3 FOR
SET BPCX=$ORDER(^AUPNMCD("B",BPCPIEN,BPCX))
IF BPCX=""!(BPCX'?1.N)
QUIT
Begin DoDot:1
+4 SET BPCDTA=$GET(^AUPNMCD(BPCX,0))
SET BPCN=$PIECE(BPCDTA,U,3)
SET BPCP=$PIECE(BPCDTA,U,10)
+5 IF BPCP'=""
SET BPCP=$PIECE($GET(^AUTNINS(BPCP,0)),U,1)
+6 SET BPCY=0
FOR
SET BPCY=$ORDER(^AUPNMCD(BPCX,11,BPCY))
IF BPCY=""!(BPCY'?1.N)
QUIT
Begin DoDot:2
+7 SET BPCDTA=^AUPNMCD(BPCX,11,BPCY,0)
SET BPCC=BPCC+1
+8 IF BPCD'=""
SET BPCD=BPCD_BPCS2_BPCDTA
+9 IF BPCD=""
SET BPCD=BPCDTA
End DoDot:2
End DoDot:1
+10 IF BPCC>0
SET BPCCTR=BPCCTR+1
SET BPCRES(BPCCTR)="MCD"_BPCS1_BPCN_BPCS1_BPCC_BPCS1_BPCD_BPCS1_BPCP
+11 QUIT
BUILD4 ;
+1 IF '$DATA(^AUPNPRVT("B",BPCPIEN))
QUIT
+2 SET BPCX=""
SET BPCD=""
SET BPCC=0
FOR
SET BPCX=$ORDER(^AUPNPRVT("B",BPCPIEN,BPCX))
IF BPCX=""!(BPCX'?1.N)
QUIT
SET BPCY=0
FOR
SET BPCY=$ORDER(^AUPNPRVT(BPCX,11,BPCY))
IF BPCY=""!(BPCY'?1.N)
QUIT
Begin DoDot:1
+3 SET BPCDTA=^AUPNPRVT(BPCX,11,BPCY,0)
SET BPCC=BPCC+1
SET BPCN=$PIECE(BPCDTA,U,1)
IF BPCN'=""
SET BPCN=$GET(^AUTNINS(BPCN,4))
+4 IF BPCD'=""
SET BPCD=BPCD_BPCS2_BPCN_U_$PIECE(BPCDTA,U,2)_U_$PIECE(BPCDTA,U,6)_U_$PIECE(BPCDTA,U,7)
+5 IF BPCD=""
SET BPCD=BPCN_U_$PIECE(BPCDTA,U,2)_U_$PIECE(BPCDTA,U,6)_U_$PIECE(BPCDTA,U,7)
End DoDot:1
+6 IF BPCC>0
SET BPCCTR=BPCCTR+1
SET BPCRES(BPCCTR)="PI"_BPCS1_BPCC_BPCS1_BPCD
+7 QUIT
BUILD5 ;
+1 IF '$DATA(^DPT(BPCPIEN,".01"))
QUIT
+2 SET BPCX=0
SET BPCD=""
SET BPCC=0
FOR
SET BPCX=$ORDER(^DPT(BPCPIEN,".01",BPCX))
IF BPCX=""!(BPCX'?1.N)
QUIT
Begin DoDot:1
+3 SET BPCDTA=^DPT(BPCPIEN,".01",BPCX,0)
SET BPCC=BPCC+1
SET BPCN=$PIECE(BPCDTA,U,1)
+4 IF BPCD'=""
SET BPCD=BPCD_U_BPCN
+5 IF BPCD=""
SET BPCD=BPCN
End DoDot:1
+6 IF BPCC>0
SET BPCCTR=BPCCTR+1
SET BPCRES(BPCCTR)="NAMES"_BPCS1_BPCC_BPCS1_BPCD
+7 QUIT
BUILD6 ;
+1 IF '$DATA(^AUPNPAT(BPCPIEN,41,0))
QUIT
+2 SET BPCX=0
SET BPCD=""
SET BPCC=0
FOR
SET BPCX=$ORDER(^AUPNPAT(BPCPIEN,41,BPCX))
IF BPCX=""!(BPCX'?1.N)
QUIT
IF BPCX'=$GET(DUZ(2))
Begin DoDot:1
+3 SET BPCDTA=^(BPCX,0)
SET BPCC=BPCC+1
SET BPCN=$PIECE(BPCDTA,U,2)
SET BPCY=$PIECE($GET(^DIC(4,BPCX,0)),U,1)
+4 IF BPCD'=""
SET BPCD=BPCD_BPCS2_BPCY_U_BPCN
+5 IF BPCD=""
SET BPCD=BPCY_U_BPCN
End DoDot:1
+6 IF BPCC>0
SET BPCCTR=BPCCTR+1
SET BPCRES(BPCCTR)="REGS"_BPCS1_BPCC_BPCS1_BPCD
+7 QUIT
BUILD7 ;
+1 IF '$DATA(^AUPNPAT(BPCPIEN,12,0))
QUIT
+2 SET BPCX=0
SET BPCD=""
SET BPCC=0
FOR
SET BPCX=$ORDER(^AUPNPAT(BPCPIEN,12,BPCX))
IF BPCX=""!(BPCX'?1.N)
QUIT
Begin DoDot:1
+3 SET BPCDTA=^AUPNPAT(BPCPIEN,12,BPCX,0)
SET BPCC=BPCC+1
SET BPCN=$PIECE(BPCDTA,U,1)
+4 IF BPCD'=""
SET BPCD=BPCD_U_BPCN
+5 IF BPCD=""
SET BPCD=BPCN
End DoDot:1
+6 IF BPCC>0
SET BPCCTR=BPCCTR+1
SET BPCRES(BPCCTR)="HOME"_BPCS1_BPCC_BPCS1_BPCD
+7 QUIT
BUILD8 ;
+1 IF '$DATA(^AUPNPAT(BPCPIEN,13,0))
QUIT
+2 SET BPCX=0
SET BPCD=""
SET BPCC=0
FOR
SET BPCX=$ORDER(^AUPNPAT(BPCPIEN,13,BPCX))
IF BPCX=""!(BPCX'?1.N)
QUIT
Begin DoDot:1
+3 SET BPCDTA=^AUPNPAT(BPCPIEN,13,BPCX,0)
SET BPCC=BPCC+1
SET BPCN=$PIECE(BPCDTA,U,1)
+4 IF BPCD'=""
SET BPCD=BPCD_U_BPCN
+5 IF BPCD=""
SET BPCD=BPCN
End DoDot:1
+6 IF BPCC>0
SET BPCCTR=BPCCTR+1
SET BPCRES(BPCCTR)="ADD"_BPCS1_BPCC_BPCS1_BPCD
+7 QUIT
GETAGE ;
+1 SET %H=+$HOROLOG
DO YMD^%DTC
SET BPCNOW=X
+2 SET X1=BPCNOW
SET X2=BPCDOB
DO ^%DTC
SET BPCAGE=X\365.25
+3 IF BPCAGE
SET BPCAUN="YRS"
QUIT
+4 IF X#(365.25)>30.5
SET BPCAGE=X#(365.25)\30.5
SET BPCAUN="MONTHS"
QUIT
+5 SET BPCAGE=X
SET BPCAUN="DAYS"
+6 KILL BPCNOW
+7 QUIT
+8 ;
KILL ;
+1 KILL BPCNAM,BPCEDTE,BPCLDTE,BPCSSN,BPCSEX,BPCDOB,BPCAGE,BPCAUN,BPCCLS,BPCCOM,BPCCTY,BPCADDR1,BPCADDR2,BPCADDR3,BPCCITY,BPCSTAT,BPCZIP,BPCHPH,BPCOPH
+2 KILL BPCTRIB,BPCTQT,BPCIQT,BPCTREN,BPCBCITY,BPCBSTA,BPCREL,BPCFNAM,BPCFCTY,BPCFST,BPCMNAM,BPCMCTY,BPCMST,BPCEC,BPCECAD1,BPCECAD2,BPCECAD3
+3 KILL BPCECCTY,BPCECSTA,BPCECZIP,BPCECPNE,BPCEMP,BPCESTAT,BPCVET,BPCSRVC,BPCSAVDT,BPCSRVSD,BPCSCON,BPCCLAIM
+4 KILL BPCC,BPCCTR,BPCD,BPCDTA,BPCN,BPCNOW,BPCQ,BPCS1,BPCS2,BPCSRVDT,BPCSSNS,BPCSTATE,BPCSTIEN,BPCSUF,BPCX,BPCY
+5 QUIT