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

APCLOS21.m

Go to the documentation of this file.
  1. APCLOS21 ; IHS/CMI/LAB - continuuation of APCLOS2 ;
  1. ;;2.0;IHS PCC SUITE;;MAY 14, 2009
  1. THIRD ;ENTRY POINT
  1. S APCLOS="APCLOS" S APCLACE=APCLFYB,APCLACED=APCLFYE
  1. S APCLMCR="MCRA",APCLVAL="A" D MCRA
  1. S APCLMCR="MCRB",APCLVAL="B" D MCRA
  1. S APCLMCR="MCRD",APCLVAL="D" D
  1. .D MCRA
  1. .I $D(APCLGOT) Q
  1. .S X=$$PIDD(DFN,APCLACE) ;check for D- in private insurer name
  1. .I X S ^(APCLMCR)=$S($D(^XTMP(APCLOS,APCLJOB,APCLBTH,APCLMCR)):(+^(APCLMCR)+1),1:1)
  1. D PI,MCD
  1. S APCLOS="APCLOSP" S APCLACE=APCLPYB,APCLACED=APCLPYE
  1. S APCLMCR="MCRA",APCLVAL="A" D MCRA
  1. S APCLMCR="MCRB",APCLVAL="B" D MCRA
  1. ;S APCLMCR="MCRD",APCLVAL="D" D MCRA
  1. S APCLMCR="MCRD",APCLVAL="D" D
  1. .D MCRA
  1. .I $D(APCLGOT) Q
  1. .S X=$$PIDD(DFN,APCLACE) ;check for D- in private insurer name
  1. .I X S ^(APCLMCR)=$S($D(^XTMP(APCLOS,APCLJOB,APCLBTH,APCLMCR)):(+^(APCLMCR)+1),1:1)
  1. D PI,MCD
  1. Q
  1. MCRA ;
  1. K APCLGOT
  1. Q:'$D(^AUPNMCR(DFN,11))
  1. Q:'$D(^DPT(DFN,0))
  1. I $D(^DPT(DFN,.35)),$P(^(.35),U)]"",$P(^(.35),U)<APCLACED Q
  1. K APCLGOT S APCLMDFN=0 F S APCLMDFN=$O(^AUPNMCR(DFN,11,APCLMDFN)) Q:APCLMDFN'=+APCLMDFN!($D(APCLGOT)) D MCRA2
  1. Q:'$D(APCLGOT)
  1. S ^(APCLMCR)=$S($D(^XTMP(APCLOS,APCLJOB,APCLBTH,APCLMCR)):(+^(APCLMCR)+1),1:1)
  1. Q
  1. ;
  1. MCRA2 ;
  1. Q:APCLVAL'[$P(^AUPNMCR(DFN,11,APCLMDFN,0),U,3)
  1. Q:$P(^AUPNMCR(DFN,11,APCLMDFN,0),U)>APCLACED ;quit if policy started after the end of time frame
  1. I $P(^AUPNMCR(DFN,11,APCLMDFN,0),U,2)]"",$P(^(0),U,2)<APCLACE Q ;quit if policy ended before beginning of time frame
  1. S APCLGOT=""
  1. Q
  1. ;
  1. PI ;
  1. I $$PI^AUPNPAT(DFN,APCLACE) S ^("PI")=$S($D(^XTMP(APCLOS,APCLJOB,APCLBTH,"PI")):(+^("PI")+1),1:1)
  1. Q
  1. MCD ;
  1. I $$MCD^AUPNPAT(DFN,APCLACE) S ^("MCD")=$S($D(^XTMP(APCLOS,APCLJOB,APCLBTH,"MCD")):(+^("MCD")+1),1:1)
  1. Q
  1. PIDD(P,D) ;EP - Is patient P private insurance MEDICARE D eligible on date D. 1= yes, 0=no.
  1. ; I = IEN
  1. ; Y = 1:yes, 0:no
  1. ; X = Pointer to INSURER file.
  1. I '$G(P) Q 0
  1. I '$G(D) Q 0
  1. NEW I,Y,X
  1. S Y=0,U="^"
  1. I '$D(^DPT(P,0)) G PIDDX
  1. I $P(^DPT(P,0),U,19) G PIDDX
  1. I '$D(^AUPNPAT(P,0)) G PIDDX
  1. I '$D(^AUPNPRVT(P,11)) G PIDDX
  1. I $D(^DPT(P,.35)),$P(^(.35),U)]"",$P(^(.35),U)<D G PIDDX
  1. S I=0
  1. F S I=$O(^AUPNPRVT(P,11,I)) Q:I'=+I D
  1. . Q:$P(^AUPNPRVT(P,11,I,0),U)=""
  1. . S X=$P(^AUPNPRVT(P,11,I,0),U) Q:X=""
  1. . S G=0
  1. . I $E($P(^AUTNINS(X,0),U),1,2)="D-" S G=1
  1. . I $P($G(^AUTNINS(X,2)),U)="MD" S G=1
  1. . Q:'G
  1. . Q:$P(^AUPNPRVT(P,11,I,0),U,6)>D
  1. . I $P(^AUPNPRVT(P,11,I,0),U,7)]"",$P(^(0),U,7)<D Q
  1. . S Y=1
  1. .Q
  1. PIDDX ;
  1. Q Y