BMCSEL ; IHS/PHXAO/TMJ - FY PO COST ANALYSIS PROCESS ROUTINE ;
;;4.0;REFERRED CARE INFO SYSTEM;**3**;JAN 09, 2006;Build 101
;4.0*3 10.30.2007 IHS/OIT/FCJ ADDED CSV CHANGES
;
VISIT ;
S BMCJOB=$J,BMCBT=$H
K ^XTMP("BMCFY",BMCJOB,BMCBT)
D XTMP^BMCOSUT("BMCFY","PCC TOP FY DX REPORT")
S %="^XTMP(""BMCFY"",BMCJOB,BMCBT,",BMCA=%_"""POV"",BMCPOV)",BMCB=%_"""APC"",BMCAPC)",BMCC=%_"1)",BMCE=%_"2)",BMCF=%_"3)",BMCG=%_"4)",BMCTOT=0,BMCRTOT=0,BMCLINO=0
;S BMCBD=BMCBD-.00001
F BMCDATE=BMCBD:0 S BMCDATE=$O(^BMCREF("B",BMCDATE)) Q:'BMCDATE Q:(BMCDATE\1)>BMCED F BMCRIEN=0:0 S BMCRIEN=$O(^BMCREF("B",BMCDATE,BMCRIEN)) Q:'BMCRIEN I $D(^BMCREF(BMCRIEN,0)),$D(^BMCREF(BMCRIEN,41,0)) D CK
D SET
S BMCET=$H
Q
;
CK ;
S BMCRREC=^BMCREF(BMCRIEN,0),DFN=$P(BMCRREC,U,5)
Q:$P(BMCRREC,U,4)'="C" ;Quit if NOT a CHS Type Referral
;Q:$P(^BMCREF(BMCRIEN,11,BMCPOVN),U,11)'=BMCLNO
;Q:'$P(BMCRREC,U,9)
;Q:$P(BMCRREC,U,11)
D SCREENS
Q:$D(BMCSKIP)
POV S BMCPOVN="",BMCRTOT=BMCRTOT+1,BMCCC=0
F S BMCPOVN=$O(^BMCREF(BMCRIEN,41,0)) Q:'BMCPOVN Q:'$D(^BMCREF(BMCRIEN,41,BMCPOVN,0)) S BMCPOV=+^(0),BMCCC=BMCCC+1,BMCPREC=^(0) D POVX
Q
;
POVX Q ;Quit - This isn't DX Code Conversion
I $D(BMCPRIM),$P(BMCRREC,U,7)="H",$P(BMCPREC,U,12)'="P" Q
I $D(BMCPRIM),BMCCC>1 Q
S BMCTOT=BMCTOT+1
;4.0*3 10.30.2007 IHS/OIT/FCJ ADDED CSV CHANGES NXT 2 LINES
;S %=$P(^ICD9(BMCPOV,0),U,5) K BMCAPC I % S BMCAPC=%
S %=$P($$ICDDX^ICDCODE(BMCPOV,0),U,6) K BMCAPC I % S BMCAPC=%
F X=BMCA,BMCB D UTL
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
UTL I X=BMCB,'$D(BMCAPC) Q
I '$D(@X) S @X=0
S %=@X,%=%+1,@X=%
Q
;
SET F BMCPOV=0:0 S BMCPOV=$O(@BMCA) Q:'BMCPOV S %=^(BMCPOV),@BMCC@(9999999-%,BMCPOV)=""
F BMCAPC=0:0 S BMCAPC=$O(@BMCB) Q:'BMCAPC S %=^(BMCAPC),@BMCE@(9999999-%,BMCAPC)=""
S1 S (X,I)=0 F S X=$O(@BMCC@(X)) Q:'X F Y=0:0 S Y=$O(@BMCC@(X,Y)) Q:'Y S I=I+1,@BMCF@(I)=Y I I=BMC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 DO XTMP^BMCOSUT("BMCFY","PCC TOP FY DX REPORT")
+4 SET %="^XTMP(""BMCFY"",BMCJOB,BMCBT,"
SET BMCA=%_"""POV"",BMCPOV)"
SET BMCB=%_"""APC"",BMCAPC)"
SET BMCC=%_"1)"
SET BMCE=%_"2)"
SET BMCF=%_"3)"
SET BMCG=%_"4)"
SET BMCTOT=0
SET BMCRTOT=0
SET BMCLINO=0
+5 ;S BMCBD=BMCBD-.00001
+6 FOR BMCDATE=BMCBD:0
SET BMCDATE=$ORDER(^BMCREF("B",BMCDATE))
IF 'BMCDATE
QUIT
IF (BMCDATE\1)>BMCED
QUIT
FOR BMCRIEN=0:0
SET BMCRIEN=$ORDER(^BMCREF("B",BMCDATE,BMCRIEN))
IF 'BMCRIEN
QUIT
IF $DATA(^BMCREF(BMCRIEN,0))
IF $DATA(^BMCREF(BMCRIEN,41,0))
DO CK
+7 DO SET
+8 SET BMCET=$HOROLOG
+9 QUIT
+10 ;
CK ;
+1 SET BMCRREC=^BMCREF(BMCRIEN,0)
SET DFN=$PIECE(BMCRREC,U,5)
+2 ;Quit if NOT a CHS Type Referral
IF $PIECE(BMCRREC,U,4)'="C"
QUIT
+3 ;Q:$P(^BMCREF(BMCRIEN,11,BMCPOVN),U,11)'=BMCLNO
+4 ;Q:'$P(BMCRREC,U,9)
+5 ;Q:$P(BMCRREC,U,11)
+6 DO SCREENS
+7 IF $DATA(BMCSKIP)
QUIT
POV SET BMCPOVN=""
SET BMCRTOT=BMCRTOT+1
SET BMCCC=0
+1 FOR
SET BMCPOVN=$ORDER(^BMCREF(BMCRIEN,41,0))
IF 'BMCPOVN
QUIT
IF '$DATA(^BMCREF(BMCRIEN,41,BMCPOVN,0))
QUIT
SET BMCPOV=+^(0)
SET BMCCC=BMCCC+1
SET BMCPREC=^(0)
DO POVX
+2 QUIT
+3 ;
POVX ;Quit - This isn't DX Code Conversion
QUIT
+1 IF $DATA(BMCPRIM)
IF $PIECE(BMCRREC,U,7)="H"
IF $PIECE(BMCPREC,U,12)'="P"
QUIT
+2 IF $DATA(BMCPRIM)
IF BMCCC>1
QUIT
+3 SET BMCTOT=BMCTOT+1
+4 ;4.0*3 10.30.2007 IHS/OIT/FCJ ADDED CSV CHANGES NXT 2 LINES
+5 ;S %=$P(^ICD9(BMCPOV,0),U,5) K BMCAPC I % S BMCAPC=%
+6 SET %=$PIECE($$ICDDX^ICDCODE(BMCPOV,0),U,6)
KILL BMCAPC
IF %
SET BMCAPC=%
+7 FOR X=BMCA,BMCB
DO UTL
+8 QUIT
+9 ;
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
UTL IF X=BMCB
IF '$DATA(BMCAPC)
QUI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