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

BMCRLU.m

Go to the documentation of this file.
  1. BMCRLU ; IHS/PHXAO/TMJ - GEN RETR UTILITIES ;
  1. ;;4.0;REFERRED CARE INFO SYSTEM;**3,9**;JAN 09, 2006;Build 101
  1. ;IHS/ITSC/FCJ REMOVED THE () FOR PRINTING ACT OR EST; FX DT FORMAT
  1. ;4.0*3 10.30.2007 IHS/OIT/FCJ ADDED CSV CHANGES
  1. ;4.0*9 11.2.2012 IHS.OIT.FCJ ADDED ICD-10 CHANGE
  1. ;
  1. RZERO(V,L) ;ep right zero fill
  1. NEW %,I
  1. S %=$L(V),Z=L-% F I=1:1:Z S V=V_"0"
  1. Q V
  1. LZERO(V,L) ;left zero fill
  1. NEW %,I
  1. S %=$L(V),Z=L-% F I=1:1:Z S V="0"_V
  1. Q V
  1. LBLK(V,L) ;left blank fill
  1. NEW %,I
  1. S %=$L(V),Z=L-% F I=1:1:Z S V=" "_V
  1. Q V
  1. ;
  1. ANYINS(P,D) ;EP - return 1 or 0 if patient has any insurance
  1. NEW BMCA
  1. S BMCA=0
  1. S BMCA=$$MCR^AUPNPAT(P,D) I BMCA Q BMCA
  1. S BMCA=$$MCD^AUPNPAT(P,D) I BMCA Q BMCA
  1. S BMCA=$$PI^AUPNPAT(P,D) I BMCA Q BMCA
  1. S BMCA=$$RAIL(P,D)
  1. Q BMCA
  1. AVDX(R,A,T) ;EP - return array of available dx's
  1. NEW BMCFLG,BMCX
  1. I $G(T)="" S T="N"
  1. S BMCFLG=0
  1. I $G(A)="" S A="BMCAVDX"
  1. K @A
  1. I 'R S BMCFLG=1 Q BMCFLG
  1. I '$D(^BMCREF(R)) S BMCFLG=2 Q BMCFLG
  1. S (BMCX,C)=0 F S BMCX=$O(^BMCDX("AD",R,BMCX)) Q:BMCX'=+BMCX I $P(^BMCDX(BMCX,0),U,4)="F" S C=C+1 D SETDX
  1. ;4.0*9 11.2.2012 IHS.OIT.FCJ CHG FOR ICD-10 ADDED BMCDTYP="B" TO NXT LINE
  1. I C=0,BMCDTYP="B" S BMCX=0 F S BMCX=$O(^BMCDX("AD",R,BMCX)) Q:BMCX'=+BMCX I $P(^BMCDX(BMCX,0),U,4)="P" S C=C+1 D SETDX
  1. Q BMCFLG
  1. SETDX ;
  1. I T="N" S @A@($P(^BMCDX(BMCX,0),U))="" Q
  1. NEW BMCCDI S BMCCDI=$P(^BMCDX(BMCX,0),U) ;4.0*9 11.2.2012 IHS.OIT.FCJ CHG FOR ICD-10
  1. ;4.0*3 10.30.2007 IHS/OIT/FCJ ADDED CSV CHANGES NXT 4 LINES;4.0*9 11.2.2012 IHS.OIT.FCJ CHG FOR ICD-10
  1. ;I T="E" S @A@($P(^ICD9($P(^BMCDX(BMCX,0),U),0),U))="" Q
  1. ;I T="E" S @A@($P($$ICDDX^ICDCODE($P(^BMCDX(BMCX,0),U),0),U,2))="" Q
  1. I T="E" S @A@($P($$ICDDX^ICDEX(BMCCDI,,,"I"),U,2))="" Q
  1. ;I T="I" S @A@($P(^ICD9($P(^BMCDX(BMCX,0),U),0),U,3))="" Q
  1. ;I T="I" S @A@($P($$ICDDX^ICDCODE($P(^BMCDX(BMCX,0),U),0),U,4))="" Q
  1. I T="I" S @A@($P($$ICDDX^ICDEX(BMCCDI,,,"I"),U,4))="" Q
  1. Q
  1. AVOP(R,A,T) ;EP
  1. NEW BMCFLG,BMCX
  1. I $G(T)="" S T="N"
  1. S BMCFLG=0
  1. I $G(A)="" S A="BMCAVOP"
  1. K @A
  1. I 'R S BMCFLG=1 Q BMCFLG
  1. I '$D(^BMCREF(R)) S BMCFLG=2 Q BMCFLG
  1. S (BMCX,C)=0 F S BMCX=$O(^BMCPX("AD",R,BMCX)) Q:BMCX'=+BMCX I $P(^BMCPX(BMCX,0),U,4)="F" S C=C+1 D SETOP
  1. I C=0 S BMCX=0 F S BMCX=$O(^BMCPX("AD",R,BMCX)) Q:BMCX'=+BMCX I $P(^BMCPX(BMCX,0),U,4)="P" S C=C+1 D SETOP
  1. Q BMCFLG
  1. SETOP ;
  1. I T="N" S @A@($P(^BMCPX(BMCX,0),U))="" Q
  1. ;4.0*3 10.30.2007 IHS/OIT/FCJ ADDED CSV CHANGES NXT 4 LINES
  1. ;I T="E" S @A@($P(^ICPT($P(^BMCPX(BMCX,0),U),0),U))="" Q
  1. I T="E" S @A@($P($$CPT^ICPTCOD($P(^BMCPX(BMCX,0),U),0),U,2))="" Q
  1. ;I T="I" S @A@($P(^ICPT($P(^BMCPX(BMCX,0),U),0),U,2))="" Q
  1. I T="I" S @A@($P($$CPT^ICPTCOD($P(^BMCPX(BMCX,0),U),0),U,3))="" Q
  1. I T="P",$P(^BMCPX(BMCX,0),U,6) S @A@(BMCX)=$P(^AUTNPOV($P(^BMCPX(BMCX,0),U,6),0),U) Q
  1. Q
  1. AVDOS(R,F) ;EP - return available date of service (actual or estimated) in either internal or external format
  1. NEW BMCDOS
  1. I $G(F)="" S F="E"
  1. S BMCDOS=""
  1. S BMCDOS=$S($P($G(^BMCREF(R,11)),U,6)]"":$P(^BMCREF(R,11),U,6),1:$P($G(^BMCREF(R,11)),U,5))
  1. I BMCDOS="" Q BMCDOS
  1. I F="N" Q BMCDOS
  1. I F="E" S BMCDOS=$$FMTE^XLFDT(BMCDOS,"2P")
  1. I F="S" S BMCDOS=$E(BMCDOS,4,5)_"/"_$E(BMCDOS,6,7)_"/"_$E(BMCDOS,2,3)
  1. I F="C" S BMCDOS=$E(BMCDOS,4,5)_"/"_$E(BMCDOS,6,7)_"/"_$E(BMCDOS,2,3)_" "_$S($$VAL^XBDIQ1(90001,R,1106)]"":"A",1:"E")
  1. Q BMCDOS
  1. AVEOS(R,F) ;EP return available end date of service
  1. NEW BMCDOS
  1. I $G(F)="" S F="E"
  1. S BMCDOS=""
  1. S BMCDOS=$S($P($G(^BMCREF(R,11)),U,8)]"":$P(^BMCREF(R,11),U,8),1:$P($G(^BMCREF(R,11)),U,7))
  1. I F="E",BMCDOS]"" S BMCDOS=$$FMTE^XLFDT(BMCDOS)
  1. I F="S",BMCDOS]"" S Y=BMCDOS D DT1^BMCOSUT S BMCDOS=Y_" "_$S($$VAL^XBDIQ1(90001,R,1106)]"":"A",1:"E")
  1. I F="N" Q BMCDOS
  1. Q BMCDOS
  1. AVLOS(R,F) ;EP return available LOS
  1. I $G(F)="" S F="I"
  1. NEW %
  1. S %=$S($P($G(^BMCREF(R,11)),U,10):$P($G(^BMCREF(R,11)),U,10),1:$P($G(^BMCREF(R,11)),U,9))
  1. I %="" Q %
  1. I F="C" S %=%_$S($P($G(^BMCREF(R,11)),U,10):" A",1:" E")
  1. Q %
  1. AVICOST(R) ; EP
  1. ;best available IHS cost is 1104 if available, else the larger of
  1. ;1103 or 1117
  1. I $G(^BMCREF(R,11))="" Q ""
  1. S %=0 F %1=4,3,17 S %=%+$P(^BMCREF(R,11),U,%1)
  1. I '% Q ""
  1. I $P(^BMCREF(R,11),U,4) Q $P(^(11),U,4)
  1. I $P(^BMCREF(R,11),U,3)>$P(^BMCREF(R,11),U,17) Q $P(^BMCREF(R,11),U,3)
  1. E Q $P(^BMCREF(R,11),U,17)
  1. Q ""
  1. ;
  1. AVTCOST(R) ; EP
  1. ;Final Total Referral Costs 1102 if available Else Estimated Total
  1. ;Costs 1101 Total Referral Cost to Date 1119 whichever is larger
  1. I $G(^BMCREF(R,11))="" Q ""
  1. S %=0 F %1=2,1,19 S %=%+$P(^BMCREF(R,11),U,%1)
  1. I '% Q ""
  1. I $P(^BMCREF(R,11),U,2) Q $P(^(11),U,2)
  1. I $P(^BMCREF(R,11),U)>$P(^BMCREF(R,11),U,19) Q $P(^BMCREF(R,11),U)
  1. E Q $P(^BMCREF(R,11),U,19)
  1. Q ""
  1. FACREF(R) ;EP return facility referred to (piece 7-8-9)
  1. N BMCF,%
  1. S %=^BMCREF(R,0)
  1. S BMCF=$S($P(%,U,7):$P($G(^AUTTVNDR($P(%,U,7),0)),U),$P(%,U,8):$P(^DIC(4,$P(%,U,8),0),U),$P(%,U,9):$P($G(^BMCLPRV($P(%,U,9),0)),U),$P(%,U,23):$P(^DIC(40.7,$P(%,U,23),0),U),1:"<UNKNOWN>")
  1. Q BMCF
  1. CASEMAN(R) ;EP return case manager
  1. Q $S($P(^BMCREF(R,0),U,19)]"":$P(^VA(200,$P(^BMCREF(R,0),U,19),0),U),1:"??")
  1. REFDTI(R,F) ; EP - Date Referral Initiated
  1. NEW BMCDOS
  1. I $G(F)="" S F="E"
  1. S BMCDOS=""
  1. S BMCDOS=$S($P($G(^BMCREF(R,0)),U)]"":$P(^BMCREF(R,0),U),1:$P($G(^BMCREF(R,0)),U,6))
  1. I BMCDOS="" Q BMCDOS
  1. I F="E" S BMCDOS=$$FMTE^XLFDT(BMCDOS)
  1. I F="S" S BMCDOS=$E(BMCDOS,4,5)_"/"_$E(BMCDOS,6,7)_"/"_$E(BMCDOS,2,3)
  1. I F="C" S BMCDOS=$E(BMCDOS,4,5)_"/"_$E(BMCDOS,6,7)_"/"_$E(BMCDOS,2,3)_" "_$S($$VAL^XBDIQ1(90001,R,.01)]"":"A",1:"E")
  1. Q BMCDOS
  1. ;
  1. ;
  1. EXPBGDT(R,F) ;Expected Begin Date of Service
  1. NEW BMCDOS
  1. I $G(F)="" S F="E"
  1. S BMCDOS=""
  1. S BMCDOS=$P($G(^BMCREF(R,11)),U,5)
  1. I F="E",BMCDOS]"" S BMCDOS=$$FMTE^XLFDT(BMCDOS)
  1. I F="S",BMCDOS]"" S Y=BMCDOS D DT1^BMCOSUT S BMCDOS=Y
  1. I F="N" Q BMCDOS
  1. Q BMCDOS
  1. ;
  1. ;
  1. EXPENDT(R,F) ;Expected End DOS
  1. NEW BMCDOS
  1. I $G(F)="" S F="E"
  1. S BMCDOS=""
  1. S BMCDOS=$P($G(^BMCREF(R,11)),U,7)
  1. I F="E",BMCDOS]"" S BMCDOS=$$FMTE^XLFDT(BMCDOS)
  1. I F="S",BMCDOS]"" S Y=BMCDOS D DT1^BMCOSUT S BMCDOS=Y
  1. I F="N" Q BMCDOS
  1. Q BMCDOS
  1. ;
  1. ACTBDT(R,F) ;Actual Beginning DOS
  1. NEW BMCDOS
  1. I $G(F)="" S F="E"
  1. S BMCDOS=""
  1. S BMCDOS=$P($G(^BMCREF(R,11)),U,6)
  1. I F="E",BMCDOS]"" S BMCDOS=$$FMTE^XLFDT(BMCDOS)
  1. I F="S",BMCDOS]"" S Y=BMCDOS D DT1^BMCOSUT S BMCDOS=Y
  1. I F="N" Q BMCDOS
  1. Q BMCDOS
  1. ACTDT(R,F) ;Actual End DOS
  1. NEW BMCDOS
  1. I $G(F)="" S F="E"
  1. S BMCDOS=""
  1. S BMCDOS=$P($G(^BMCREF(R,11)),U,8)
  1. I F="E",BMCDOS]"" S BMCDOS=$$FMTE^XLFDT(BMCDOS)
  1. I F="S",BMCDOS]"" S Y=BMCDOS D DT1^BMCOSUT S BMCDOS=Y
  1. I F="N" Q BMCDOS
  1. Q BMCDOS
  1. ;
  1. RAIL(P,D) ;EP - Check for Railroad Retirement Data
  1. Q $$RRR^BMCRLU1(P,D)
  1. CSECOM(R,D) ;EP -TEST FOR SORT BY, IF BY CSE COM DATES NEED TO TEST FOR DATES
  1. ;4.0 IHS/OIT/FCJ ADDED FOR CASE COMMENTS
  1. S X=1,Y=0 F S Y=$O(^BMCRTMP(BMCRPT,11,Y)) Q:Y'?1N.N D
  1. .S (X1,X2)=1
  1. .I $P(^BMCTSORT(Y,0),U)="Case Rev Comment Dt" D
  1. ..S X1=0,X3=$P(^BMCCOM(D,0),U)
  1. ..Q:X3<$P(^BMCRTMP(BMCRPT,11,Y,11,1,0),U)
  1. ..Q:X3>$P(^BMCRTMP(BMCRPT,11,Y,11,1,0),U,2)
  1. ..S X1=1
  1. .I $P(^BMCTSORT(Y,0),U)="Case Reviewer" D
  1. ..S X2=0
  1. ..S Y1=0 F S Y1=$O(^BMCRTMP(BMCRPT,11,Y,11,Y1)) Q:Y1'?1N.N D Q:X2=1
  1. ...Q:$P(^BMCCOM(D,0),U,4)'=$P(^BMCRTMP(BMCRPT,11,Y,11,Y1,0),U)
  1. ...S X2=1
  1. .I 'X1!'X2 S X=0
  1. Q X