BMCFREQ1 ; IHS/PHXAO/TMJ - TOP FPR PRCS ;
;;4.0;REFERRED CARE INFO SYSTEM;;JAN 09, 2006
VISIT ;
S BMCJOB=$J,BMCBT=$H
K ^XTMP("BMCFPR",BMCJOB,BMCBT)
D XTMP^BMCOSUT("BMCFPR","PCC - FREQ PROC")
S %="^XTMP(""BMCFPR"",BMCJOB,BMCBT,",BMCA=%_"""PRC"",BMCPRC)",BMCD=%_"1)",BMCF=%_"3)",BMCTOT=0,BMCVTOT=0,BMCLINO=0,BMCGTOT=0
S BMCDATE=BMCBD-.00001
F S BMCDATE=$O(^BMCREF("B",BMCDATE)) Q:'BMCDATE Q:(BMCDATE\1)>BMCED D
.F BMCVIEN=0:0 S BMCVIEN=$O(^BMCREF("B",BMCDATE,BMCVIEN)) Q:'BMCVIEN S BMCGTOT=BMCGTOT+1 I $D(^BMCREF(BMCVIEN,0)),$D(^BMCPX("AD",BMCVIEN)) D CK
D SET
S BMCET=$H
Q
;
CK ;
S BMCRREC=^BMCREF(BMCVIEN,0),DFN=$P(BMCRREC,U,3)
Q:$P($G(^BMCREF(BMCVIEN,1)),U)'="" ;IHS/OIT/FCJ SEC REF NOT INCLUDED
S BMCREF=BMCVIEN D SCREENS ;IHS/OIT/FCJ SCREENS USE BMCREF AS REF IEN
D SCREENS
Q:$D(BMCSKIP)
PRC S BMCPRCN="",BMCVTOT=BMCVTOT+1,BMCC=0
F S BMCPRCN=$O(^BMCPX("AD",BMCVIEN,BMCPRCN)) Q:'BMCPRCN Q:'$D(^BMCPX(BMCPRCN,0)) S BMCPRC=+^(0),BMCC=BMCC+1,BMCPREC=^(0) D PRCX
Q
;
PRCX I '$D(^ICPT($P(BMCPREC,U))) Q
S BMCTOT=BMCTOT+1
F X=BMCA D UTL
Q
;
UTL ;I X=B,'$D(BMCAPC) Q
I '$D(@X) S @X=0
S %=@X,%=%+1,@X=%
Q
;
SCREENS ;
K BMCSKIP
S BMCI=0 F S BMCI=$O(^BMCRTMP(BMCRPT,11,BMCI)) Q:BMCI'=+BMCI!($D(BMCSKIP)) D
.I '$P(^BMCTSORT(BMCI,0),U,8) D SINGLE Q
.D MULT
.Q
Q
SINGLE ;
K X,BMCSPEC S X="",BMCX=0
X:$D(^BMCTSORT(BMCI,1)) ^(1)
I X="" S BMCSKIP="" Q
I '$D(BMCSPEC),'$D(^BMCRTMP(BMCRPT,11,BMCI,11,"B",X)) S BMCSKIP="" Q
Q
MULT ;
K BMCFOUN,BMCSKIP,BMCSPEC,X S BMCX=0,X=""
X:$D(^BMCTSORT(BMCI,1)) ^(1)
I $O(X(""))="" S BMCSKIP="" Q
I '$D(BMCSPEC) S Y="" F S Y=$O(X(Y)) Q:Y="" I $D(^BMCRTMP(BMCRPT,11,BMCI,11,"B",Y)) S BMCFOUN="" Q
I $D(BMCSPEC),$D(X) S BMCFOUN=1 Q
S:'$D(BMCFOUN) BMCSKIP=""
Q
SET F BMCPRC=0:0 S BMCPRC=$O(@BMCA) Q:'BMCPRC S %=^(BMCPRC),@BMCD@(9999999-%,BMCPRC)=""
S1 S (X,I)=0 F S X=$O(@BMCD@(X)) Q:'X F Y=0:0 S Y=$O(@BMCD@(X,Y)) Q:'Y S I=I+1,@BMCF@(I)=Y I I=BMCLNO G S3
S3 Q
;
;
FF I IOST["P-" W:$D(IOF) @IOF Q
I $E(IOST)="C",IO=IO(0),$Y>(IOSL-4) W ! S DIR(0)="EO" D ^DIR K DIR I Y=0!(Y="^")!($D(DTOUT)) S X="^"
W:$D(IOF) @IOF
Q
;
BMCFREQ1 ; IHS/PHXAO/TMJ - TOP FPR PRCS ;
+1 ;;4.0;REFERRED CARE INFO SYSTEM;;JAN 09, 2006
VISIT ;
+1 SET BMCJOB=$JOB
SET BMCBT=$HOROLOG
+2 KILL ^XTMP("BMCFPR",BMCJOB,BMCBT)
+3 DO XTMP^BMCOSUT("BMCFPR","PCC - FREQ PROC")
+4 SET %="^XTMP(""BMCFPR"",BMCJOB,BMCBT,"
SET BMCA=%_"""PRC"",BMCPRC)"
SET BMCD=%_"1)"
SET BMCF=%_"3)"
SET BMCTOT=0
SET BMCVTOT=0
SET BMCLINO=0
SET BMCGTOT=0
+5 SET BMCDATE=BMCBD-.00001
+6 FOR
SET BMCDATE=$ORDER(^BMCREF("B",BMCDATE))
IF 'BMCDATE
QUIT
IF (BMCDATE\1)>BMCED
QUIT
Begin DoDot:1
+7 FOR BMCVIEN=0:0
SET BMCVIEN=$ORDER(^BMCREF("B",BMCDATE,BMCVIEN))
IF 'BMCVIEN
QUIT
SET BMCGTOT=BMCGTOT+1
IF $DATA(^BMCREF(BMCVIEN,0))
IF $DATA(^BMCPX("AD",BMCVIEN))
DO CK
End DoDot:1
+8 DO SET
+9 SET BMCET=$HOROLOG
+10 QUIT
+11 ;
CK ;
+1 SET BMCRREC=^BMCREF(BMCVIEN,0)
SET DFN=$PIECE(BMCRREC,U,3)
+2 ;IHS/OIT/FCJ SEC REF NOT INCLUDED
IF $PIECE($GET(^BMCREF(BMCVIEN,1)),U)'=""
QUIT
+3 ;IHS/OIT/FCJ SCREENS USE BMCREF AS REF IEN
SET BMCREF=BMCVIEN
DO SCREENS
+4 DO SCREENS
+5 IF $DATA(BMCSKIP)
QUIT
PRC SET BMCPRCN=""
SET BMCVTOT=BMCVTOT+1
SET BMCC=0
+1 FOR
SET BMCPRCN=$ORDER(^BMCPX("AD",BMCVIEN,BMCPRCN))
IF 'BMCPRCN
QUIT
IF '$DATA(^BMCPX(BMCPRCN,0))
QUIT
SET BMCPRC=+^(0)
SET BMCC=BMCC+1
SET BMCPREC=^(0)
DO PRCX
+2 QUIT
+3 ;
PRCX IF '$DATA(^ICPT($PIECE(BMCPREC,U)))
QUIT
+1 SET BMCTOT=BMCTOT+1
+2 FOR X=BMCA
DO UTL
+3 QUIT
+4 ;
UTL ;I X=B,'$D(BMCAPC) Q
+1 IF '$DATA(@X)
SET @X=0
+2 SET %=@X
SET %=%+1
SET @X=%
+3 QUIT
+4 ;
SCREENS ;
+1 KILL BMCSKIP
+2 SET BMCI=0
FOR
SET BMCI=$ORDER(^BMCRTMP(BMCRPT,11,BMCI))
IF BMCI'=+BMCI!($DATA(BMCSKIP))
QUIT
Begin DoDot:1
+3 IF '$PIECE(^BMCTSORT(BMCI,0),U,8)
DO SINGLE
QUIT
+4 DO MULT
+5 QUIT
End DoDot:1
+6 QUIT
SINGLE ;
+1 KILL X,BMCSPEC
SET X=""
SET BMCX=0
+2 IF $DATA(^BMCTSORT(BMCI,1))
XECUTE ^(1)
+3 IF X=""
SET BMCSKIP=""
QUIT
+4 IF '$DATA(BMCSPEC)
IF '$DATA(^BMCRTMP(BMCRPT,11,BMCI,11,"B",X))
SET BMCSKIP=""
QUIT
+5 QUIT
MULT ;
+1 KILL BMCFOUN,BMCSKIP,BMCSPEC,X
SET BMCX=0
SET X=""
+2 IF $DATA(^BMCTSORT(BMCI,1))
XECUTE ^(1)
+3 IF $ORDER(X(""))=""
SET BMCSKIP=""
QUIT
+4 IF '$DATA(BMCSPEC)
SET Y=""
FOR
SET Y=$ORDER(X(Y))
IF Y=""
QUIT
IF $DATA(^BMCRTMP(BMCRPT,11,BMCI,11,"B",Y))
SET BMCFOUN=""
QUIT
+5 IF $DATA(BMCSPEC)
IF $DATA(X)
SET BMCFOUN=1
QUIT
+6 IF '$DATA(BMCFOUN)
SET BMCSKIP=""
+7 QUIT
SET FOR BMCPRC=0:0
SET BMCPRC=$ORDER(@BMCA)
IF 'BMCPRC
QUIT
SET %=^(BMCPRC)
SET @BMCD@(9999999-%,BMCPRC)=""
S1 SET (X,I)=0
FOR
SET X=$ORDER(@BMCD@(X))
IF 'X
QUIT
FOR Y=0:0
SET Y=$ORDER(@BMCD@(X,Y))
IF 'Y
QUIT
SET I=I+1
SET @BMCF@(I)=Y
IF I=BMCLNO
GOTO S3
S3 QUIT
+1 ;
+2 ;
FF IF IOST["P-"
IF $DATA(IOF)
WRITE @IOF
QUIT
+1 IF $EXTRACT(IOST)="C"
IF IO=IO(0)
IF $Y>(IOSL-4)
WRITE !
SET DIR(0)="EO"
DO ^DIR
KILL DIR
IF Y=0!(Y="^")!($DATA(DTOUT))
SET X="^"
+2 IF $DATA(IOF)
WRITE @IOF
+3 QUIT
+4 ;