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

BPCRC8.m

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