BMCRR201 ; IHS/PHXAO/TMJ - PROCESS REFERRAL LIST ;
;;4.0;REFERRED CARE INFO SYSTEM;;JAN 09, 2006
;IHS/ITSC/FCJ ADDED TEST FOR COMMENT TYPE
;IHS/ITSC/FCJ ADDED TEST FOR SR
;
START ;
S (BMCBT,BMCBTH)=$H,BMCJOB=$J,BMCRCNT=0
D PROCESS,END
Q
;
PROCESS ;
S BMCODAT=$O(^BMCCOM("B",BMCSD)) I BMCODAT="" S BMCET=$H Q
S BMCODAT=BMCSD_".9999" F S BMCODAT=$O(^BMCCOM("B",BMCODAT)) Q:BMCODAT=""!((BMCODAT\1)>BMCED) D R1
Q
;
R1 ;
S BMCRDT="" F S BMCRDT=$O(^BMCCOM("B",BMCODAT,BMCRDT)) Q:BMCRDT'=+BMCRDT S BMCRREC=^BMCCOM(BMCRDT,0) D PROC
Q
END ;
S BMCET=$H
Q
PROC ;
Q:'$D(^BMCCOM(BMCRDT,0))
Q:$P(^BMCCOM(BMCRDT,0),U,5)'="C"
S BMCRREC=^BMCCOM(BMCRDT,0),DFN=$P(BMCRREC,U,2),BMCDATE=$P(BMCRREC,U,1)
S BMCREF=$P(BMCRREC,U,3)
S BMCREVP=$P(BMCRREC,U,4)
;
Q:$P(^BMCREF(BMCREF,0),U,4)="N"
Q:$P(^BMCREF(BMCREF,0),U,5)'=BMCFAC
Q:$P($G(^BMCREF(BMCREF,1)),U)'="" ;TEST FOR SR
I BMCCREV'=0,(BMCCREV'=BMCREVP) Q
S ^XTMP("BMCRR20",BMCJOB,BMCBTH,"DATA HITS",BMCDATE,$P(^DPT(DFN,0),U),BMCRDT)="",BMCRCNT=BMCRCNT+1
Q
BMCRR201 ; IHS/PHXAO/TMJ - PROCESS REFERRAL LIST ;
+1 ;;4.0;REFERRED CARE INFO SYSTEM;;JAN 09, 2006
+2 ;IHS/ITSC/FCJ ADDED TEST FOR COMMENT TYPE
+3 ;IHS/ITSC/FCJ ADDED TEST FOR SR
+4 ;
START ;
+1 SET (BMCBT,BMCBTH)=$HOROLOG
SET BMCJOB=$JOB
SET BMCRCNT=0
+2 DO PROCESS
DO END
+3 QUIT
+4 ;
PROCESS ;
+1 SET BMCODAT=$ORDER(^BMCCOM("B",BMCSD))
IF BMCODAT=""
SET BMCET=$HOROLOG
QUIT
+2 SET BMCODAT=BMCSD_".9999"
FOR
SET BMCODAT=$ORDER(^BMCCOM("B",BMCODAT))
IF BMCODAT=""!((BMCODAT\1)>BMCED)
QUIT
DO R1
+3 QUIT
+4 ;
R1 ;
+1 SET BMCRDT=""
FOR
SET BMCRDT=$ORDER(^BMCCOM("B",BMCODAT,BMCRDT))
IF BMCRDT'=+BMCRDT
QUIT
SET BMCRREC=^BMCCOM(BMCRDT,0)
DO PROC
+2 QUIT
END ;
+1 SET BMCET=$HOROLOG
+2 QUIT
PROC ;
+1 IF '$DATA(^BMCCOM(BMCRDT,0))
QUIT
+2 IF $PIECE(^BMCCOM(BMCRDT,0),U,5)'="C"
QUIT
+3 SET BMCRREC=^BMCCOM(BMCRDT,0)
SET DFN=$PIECE(BMCRREC,U,2)
SET BMCDATE=$PIECE(BMCRREC,U,1)
+4 SET BMCREF=$PIECE(BMCRREC,U,3)
+5 SET BMCREVP=$PIECE(BMCRREC,U,4)
+6 ;
+7 IF $PIECE(^BMCREF(BMCREF,0),U,4)="N"
QUIT
+8 IF $PIECE(^BMCREF(BMCREF,0),U,5)'=BMCFAC
QUIT
+9 ;TEST FOR SR
IF $PIECE($GET(^BMCREF(BMCREF,1)),U)'=""
QUIT
+10 IF BMCCREV'=0
IF (BMCCREV'=BMCREVP)
QUIT
+11 SET ^XTMP("BMCRR20",BMCJOB,BMCBTH,"DATA HITS",BMCDATE,$PIECE(^DPT(DFN,0),U),BMCRDT)=""
SET BMCRCNT=BMCRCNT+1
+12 QUIT