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

BPCPC.m

Go to the documentation of this file.
BPCPC ; IHS/OIT/MJL - PATIENT CHART RELATED ROUTINES FOR GUI ;
 ;;1.5;BPC;;MAY 26, 2005
BPCCHT(RESULT,BPCIEN,BPCOPT,BPCLIM,BPCSDATE,BPCEDATE) ;EP CALL FROM REMOTE PROC: BPC CHARTDATA
 ;
 ;POSSIBLE OPTIONS (BPCOPT)
 ;1 - RETURN CHOSEN NUMBER OF VISITS (BPCLIM) WITHIN DATE RANGE
 ;2 - RETURN ALL VISITS WITHIN DATE RANGE
 ;3 - RETURN LAB VISITS ONLY WITHIN DATE RANGE
EN ;
 S U="^",XWBWRAP=1,BPCLIM=$G(BPCLIM,10),BPCSUB=$J,BPCMFLG="" K ^BGUTMP(BPCSUB),^BGURES(BPCSUB),RESULT
 S:'BPCLIM BPCLIM=10
 S RESULT="^BGURES("_BPCSUB_")"
 ;I '$D(BPCIEN) S RESULT(1)=-1,RESULT(2)="NO PATIENT IEN SENT!" Q
 I '$D(BPCIEN) S ^BGURES(BPCSUB,1)=-1,^BGURES(BPCSUB,2)="NO PATIENT IEN SENT!" Q
 S BPCOPT=$G(BPCOPT,1),BPCSDATE=$G(BPCSDATE),BPCEDATE=$G(BPCEDATE)
 S:BPCOPT=2 BPCLIM=9999999
 I BPCSDATE'="" S BPCFLG=0 D GETDATES I BPCFLG D KILL Q
 D VISIT,SETRES,KILL
 Q
GETDATES ;
 D DT^DILF("",BPCSDATE,.BPCSDAT)
 ;I BPCSDAT=-1 S RESULT(1)=-1,RESULT(2)="INVALID START DATE!",BPCFLG=1 Q
 I BPCSDAT=-1 S ^BGURES(BPCSUB,1)=-1,^BGURES(BPCSUB,2)="INVALID START DATE!",BPCFLG=1 Q
 I BPCEDATE="" S BPCEDATE="T"
 D DT^DILF("",BPCEDATE,.BPCEDAT)
 ;I BPCEDAT=-1 S R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PCY,U,1),BPCTEST=$P($G(^LAB(60,BPCTST,0)),U,1) Q:'$L(BPCTEST)
 S BPCATOM=$O(^LAB(60,BPCTST,2,0))=""
 S BPCVALUE=$P(BPCY,U,4),BPCFLAGL=$P(BPCY,U,5),BPCREFL=$P(BPCY11,U,4),BPCREFH=$P(BPCY11,U,5),BPCUNITS=$P(BPCY11,U,1)
 S BPCPRNT=$P(BPCY12,U,8)
 S BPCCTR=BPCCTR+1,BPCTEST1=BPCTEST
 I $D(^BGUTMP(BPCSUB,BPCX,"LAB",BPCTEST)) S BPCTEST1=BPCTEST_BPCCTR
 S BPCSITE="" I $L($P(BPCY11,U,3)) S BPCSITE=$P(BPCY11,U,3),BPCSITE=$S(BPCSITE=72:70,BPCSITE=73:70,1:BPCSITE),BPCSITE=$P($G(^LAB(61,BPCSITE,0)),U,1)
 I BPCATOM D  Q
 .S BPCCTR(BPCTEST)=$G(BPCCTR(BPCTEST))+1
 .S BPCCDT=$P(BPCY12,U,1) S:BPCCDT="" BPCCDT=BPCVDT
 . I BPCPRNT'="",$D(^BGUTMP(BPCSUB,BPCX,"PARENT",BPCPRNT)) D  Q
 ..S BPCTEST1=^BGUTMP(BPCSUB,BPCX,"PARENT",BPCPRNT)
 ..S ^BGUTMP(BPCSUB,BPCX,"LAB",BPCTEST1,BPCTST)=BPCVDT_U_"LAB"_U_"     "_BPCTEST_U_BPCX1_U_BPCVALUE_U_BPCFLAGL_U_BPCUNITS_U_BPCREFL_U_BPCREFH_U_BPCSITE_U_BPCCDT
 ..S $P(^BGUTMP(BPCSUB,BPCX,"LAB",BPCTEST1),U,10)=BPCSITE
 .S ^BGUTMP(BPCSUB,BPCX,"LAB",BPCTEST1)=BPCVDT_U_"LAB"_U_BPCTEST_U_BPCX1_U_BPCVALUE_U_BPCFLAGL_U_BPCUNITS_U_BPCREFL_U_BPCREFH_U_BPCSITE_U_BPCCDT
 S ^BGUTMP(BPCSUB,BPCX,"LAB",BPCTEST1)=BPCVDT_U_"LAB"_U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