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

BPCLALL.m

Go to the documentation of this file.
BPCLALL ; IHS/OIT/MJL - PCC VISIT LIST FOR GUI ;
 ;;1.5;BPC;;MAY 26, 2005
 ;GETS PCC VISIT DATA
EN ;ENTRY POINT
 S U="^",BPCLIM=20,BPCSUB=$J K ^BGUTMP($J),RESULT,^BGURES($J)
 S RESULT="^BGURES("_BPCSUB_")"
 I '$D(BPCIEN) S ^BGURES(BPCSUB,1)=-1,^BGURES(BPCSUB,2)="NO Lab internal entry found! (BPCIEN)" Q
 ;I '$D(BPCIEN) S RESULT(1)=-1,RESULT(2)="NO Lab internal entry found! (BPCIEN)" Q
 S X=0,BPCCNT=0 F I=1:1:BPCLIM S X=$O(^AUPNVSIT("AA",BPCIEN,X)) Q:+X=0  S BPCVSIT="" F  S BPCVSIT=$O(^AUPNVSIT("AA",BPCIEN,X,BPCVSIT)) Q:BPCVSIT=""  D VISIT
 S X=0,BPCCTR=2 F  S X=$O(^BGUTMP($J,X)) Q:+X=0  S Y="" F  S Y=$O(^BGUTMP($J,X,Y)) Q:Y=""  S Z="" F  S Z=$O(^BGUTMP($J,X,Y,Z)) Q:Z=""  S ^BGURES(BPCSUB,BPCCTR)=^BGUTMP($J,X,Y,Z),BPCCTR=BPCCTR+1
 D TRENDS,ALERTS,REMARKS,NOK,SITEP
 S ^BGURES(BPCSUB,1)=BPCCTR-1
 K BPCCTR,^BGUTMP($J),BPCV
 Q
 ;
VISIT ;
 S BPCV=$G(BPCV)+1
 S Y=^AUPNVSIT(BPCVSIT,0),BPCVDT=$P(Y,U,1),BPCLOC=$P(Y,U,6),BPCSC=$P(Y,U,7),BPCCLIN=$P(Y,U,8)
 I $L(BPCLOC) S BPCLOC=$G(^AUTTLOC(BPCLOC,0)) S:$L(BPCLOC) BPCLOC=$P(BPCLOC,U,2)
 I $L(BPCCLIN) S BPCCLIN=$G(^DIC(40.7,BPCCLIN,0)) S:$L(BPCCLIN) BPCCLIN=$P(BPCCLIN,U,1)
 S X1=0 F  S X1=$O(^AUPNVPRV("AD",BPCVSIT,X1)) Q:+X1=0  D
 . Q:'$D(^AUPNVPRV(X1,0))
 . Q:$P(^AUPNVPRV(X1,0),U,4)'="P"
 . S BPCPRV=$P(X1,U,1),BPCPRV=$P($G(^VA(200,BPCPRV,0)),U,1) S:'$L(BPCPRV) BPCPRV=X1
 S ^BGUTMP($J,X,"VISIT","NONE")=BPCVDT_U_"VISIT"_U_BPCVSIT_U_BPCLOC_U_$G(BPCPRV)_U_BPCSC_U_BPCCLIN D LAB,POV,MED
 S BPCFLG="" S:$D(^BGUTMP($J,X,"LAB")) BPCFLG="L" S:$D(^BGUTMP($J,X,"POV")) BPCFLG=BPCFLG_"P" S:$D(^BGUTMP($J,X,"MED")) BPCFLG=BPCFLG_"M" S $P(^BGUTMP($J,X,"VISIT","NONE"),U,6)=BPCFLG
 Q
 ;
VST2 ;
 Q:$P(^AUPNVPRV(X1,0),U,4)'="P"
 S BPCPRV=$P(X1,U,1),BPCPRV=$P($G(^VA(200,BPCPRV,0)),U,1) S:'$L(BPCPRV) BPCPRV=X1
 Q
 ;
LAB ;
 S X1=0 F  S X1=$O(^AUPNVLAB("AD",BPCVSIT,X1)) Q:+X1=0  D
 . Q:'$D(^AUPNVLAB(X1,0))
 . S Y=^AUPNVLAB(X1,0),Y11=$G(^AUPNVLAB(X1,11)),Y12=$G(^AUPNVLAB(X1,12))
 . S BPCTEST=$P(Y,U,1),BPCTEST=$P($G(^LAB(60,BPCTEST,0)),U,1) Q:'$L(BPCTEST)
 . S BPCVALUE=$P(Y,U,4),BPCFLAGL=$P(Y,U,5),BPCREFL=$P(Y11,U,4),BPCREFH=$P(Y11,U,5),BPCUNITS=$P(Y11,U,1)
 . S BPCSITE="" I $L($P(Y11,U,3)) S BPCSITE=$P(Y11,U,3),BPCSITE=$S(BPCSITE=72:70,BPCSITE=73:BPC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J,X,"POV",X1)=BPCVDT_U_"POV"_U_BPCPOV_U_BPCNAR_U_X1
 Q
 ;
 ;S BPCTEST="" F  S BPCTEST=$O(BPCCTR(BPCTEST)) Q:BPCTEST=""  S RESULT(BPCCTR)="TREND"_U_BPCTEST_U_BPCCTR(BPCTEST),BPCCTR=BPCCTR+1
 S BPCTEST="" F  S BPCTEST=$O(BPCCTR(BPCTEST)) Q:BPCTEST=""  S ^BGURES(BPCSUB,BPCCTR)="TREND"_U_BPCTEST_U_BPCCTR(BPCTEST),BPCCTR=BPCCTR+1
 Q
ALERTS ;EP ADD ALERT DATA FROM BPCPC
 ;I '$D(^AUPNPAT(BPCIEN,15)) S RESULT(BPCCTR)="ALERT"_U_"NO ALERTS",BPCCTR=BPCCTR+1 Q
 I '$D(^AUPNPAT(BPCIEN,15)) S ^BGURES(BPCSUB,BPCCTR)="ALERT"_U_"NO ALERTS",BPCCTR=BPCCTR+1 Q
 ;S BPCX="",BPCFLG=0 F  S BPCX=$O(^AUPNPAT(BPCIEN,15,BPCX)) Q:BPCX=""  S BPCDTA=$G(^AUPNPAT(BPCIEN,15,BPCX,0)) I BPCDTA'="" S RESULT(BPCCTR)="ALERT"_U_BPCDTA,BPCCTR=BPCCTR+1,BPCFLG=1
 S BPCX="",BPCFLG=0 F  S BPCX=$O(^AUPNPAT(BPCIEN,15,BPCX)) Q:BPCX=""  S BPCDTA=$G(^AUPNPAT(BPCIEN,15,BPCX,0)) I BPCDTA'="" S ^BGURES(BPCSUB,BPCCTR)="ALERT"_U_BPCDTA,BPCCTR=BPCCTR+1,BPCFLG=1
 ;I 'BPCFLG S RESULT(BPCCTR)="ALERT"_U_"NO ALERTS",BPCCTR=BPCCTR+1
 I 'BPCFLG S ^BGURES(BPCSUB,BPCCTR)="ALERT"_U_"NO ALERTS",BPCCTR=BPCCTR+1
 Q
REMARKS ;EP ADD REMARK DATA FROM BPCPC
 ;I '$D(^AUPNPAT(BPCIEN,14)) S RESULT(BPCCTR)="REMARK"_U_"NO REMARKS",BPCCTR=BPCCTR+1 Q
 I '$D(^AUPNPAT(BPCIEN,14)) S ^BGURES(BPCSUB,BPCCTR)="REMARK"_U_"NO REMARKS",BPCCTR=BPCCTR+1 Q
 ;S BPCX="",BPCFLG=0 F  S BPCX=$O(^AUPNPAT(BPCIEN,14,BPCX)) Q:BPCX=""  S BPCDTA=$G(^AUPNPAT(BPCIEN,14,BPCX,0)) I BPCDTA'="" S RESULT(BPCCTR)="REMARK"_U_BPCDTA,BPCCTR=BPCCTR+1,BPCFLG=1
 S BPCX="",BPCFLG=0 F  S BPCX=$O(^AUPNPAT(BPCIEN,14,BPCX)) Q:BPCX=""  S BPCDTA=$G(^AUPNPAT(BPCIEN,14,BPCX,0)) I BPCDTA'="" S ^BGURES(BPCSUB,BPCCTR)="REMARK"_U_BPCDTA,BPCCTR=BPCCTR+1,BPCFLG=1
 ;I 'BPCFLG S RESULT(BPCCTR)="REMARK"_U_"NO REMARKS",BPCCTR=BPCCTR+1
 I 'BPCFLG S ^BGURES(BPCSUB,BPCCTR)="REMARK"_U_"NO REMARKS",BPCCTR=BPCCTR+1
 Q
NOK ; ADD NEXT OF KIN DATA
 D NOK^BPCLALL1
 Q
SITEP ;
 D SITEP^BPCLALL1
 Q