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

DGMTU11.m

Go to the documentation of this file.
  1. DGMTU11 ;ALB/MIR,TDM,GTS - Patient Relation Retrieval Utilities ; 10/30/06
  1. ;;5.3;Registration;**33,45,182,311,688**;Aug 13, 1993;Build 29
  1. ;
  1. ;
  1. ;=======================================================================
  1. ; The following utilities will obtain data from the PATIENT RELATION
  1. ; file
  1. ;=======================================================================
  1. ;
  1. ;
  1. GETREL(DFN,DGTYPE,DGDT,DGMT) ; Get all active dependents for a patient
  1. ;
  1. ; Input -- DFN as the IEN of file 2 (for the patient)
  1. ; DGTYPE containing the letters V, S, C, or D representing
  1. ; the type of dependents returned
  1. ; (C and D should be mutually exclusive)
  1. ; DGDT [optional] as active date...DT if not defined
  1. ; if no month/day, checks entire year/month
  1. ; DGMT [optional] IFN of means test
  1. ; Output -- DGREL("V") = veteran reference
  1. ; DGREL("S") = spouse reference
  1. ; DGREL("C",counter) = child reference (only MT dep)
  1. ; DGREL("D",counter) = dependent reference (all deps)
  1. ; reference=IFN of 408.12^dep file ref
  1. ; DGDEP = number of active dependents
  1. ;
  1. N CT,DGX,IFN,IEN,REF,X,DGCD K DGREL
  1. S (CT,IFN,IEN)=0,DGDT=$S($G(DGDT):DGDT,1:DT)
  1. D:$G(DGMT) RELINC ;IFN of Means Test is supplied
  1. D:('$G(DGREL("V"))&(DGTYPE["V"))!('$G(DGMT)) RELFND ;No Means Test IFN or problem setting DGREL(V)
  1. D GETRELQ ; Increment the dependent count
  1. Q
  1. RELINC F S IFN=$O(^DGMT(408.22,"AMT",DGMT,DFN,IFN)) Q:'IFN D
  1. .S IEN=+$P($G(^DGMT(408.21,IFN,0)),"^",2),DGX=$G(^DGPR(408.12,IEN,0))
  1. .D SET
  1. Q
  1. RELFND S IEN=0 F S IEN=$O(^DGPR(408.12,"B",DFN,IEN)) Q:'IEN S DGX=$G(^DGPR(408.12,IEN,0)) I $$ACTIVE(IEN,DGDT) D SET
  1. Q
  1. GETRELQ S DGDEP=CT
  1. Q
  1. ;
  1. ;
  1. SET ; set variables into array...first subscript is relation type, second
  1. ; is IEN of file 408.12 (patient relations file)
  1. ;
  1. N REF,TYPE
  1. S X=$P(DGX,"^",2),REF=$P(DGX,"^",3),TYPE=""
  1. I X=1,(DGTYPE["V") S TYPE="V"
  1. I X=2,(DGTYPE["S") S TYPE="S"
  1. I X>2,(X<7) S TYPE=$S(DGTYPE["D":"D",DGTYPE["C":"C",1:"")
  1. I X>6,(DGTYPE["D") S TYPE="D"
  1. I 'X!(TYPE']"") Q ; not valid or not chosen
  1. I "VS"[TYPE,$D(DGREL(TYPE)) Q ; take first self or spouse on file
  1. S REF=IEN_"^"_REF
  1. I "VS"[TYPE S DGREL(TYPE)=REF
  1. I "CD"[TYPE&('$G(DGCD(REF))) S CT=CT+1,DGREL(TYPE,CT)=REF,DGCD(REF)=CT
  1. Q
  1. ;
  1. ;
  1. ACTIVE(IEN,DGDT) ; Extrinsic function to determine if 408.12 entry is active
  1. ;
  1. ; Input -- IEN as internal entry number of pt relation file
  1. ; DGDT as 'as of' date (uses DT if undefined)
  1. ; Output -- 1 if active, 0 otherwise
  1. ;
  1. N DGFL,DGID,MIEN,DGNOM,DGNOY,ID,Y
  1. S DGID=$S($G(DGDT):DGDT,1:DT) I '$P(DGID,".",2) S $P(DGID,".",2)=2359
  1. S (DGFL,Y,DGNOM,DGNOY)=0
  1. S ID=DGID S:'$E(ID,4,5) ID=$E(ID,1,3)_99_$E(ID,6,99),DGNOM=1 I '$E(ID,6,7) S ID=$E(ID,1,5)_99_$E(ID,8,99),DGNOY=1 ;end of year or end of month if nothing passed
  1. S ID=-ID,DGID=-DGID
  1. F S ID=$O(^DGPR(408.12,IEN,"E","AID",ID)) Q:'ID!DGFL!Y S MIEN=$O(^(ID,0)) D
  1. . S X=$G(^DGPR(408.12,IEN,"E",MIEN,0)) I 'X Q
  1. . ;I 'DGNOY,'DGNOM S DGFL=1 S:$P(X,"^",2) Y=1 Q
  1. . I $P(X,"^",2)=1 S Y=1 Q
  1. . I ID>DGID S DGFL=1 ;quit...already before begin date
  1. Q $S(Y:1,1:0)
  1. ;
  1. ;
  1. RESET(DFN,DGDT,DGMT) ;
  1. ; Sets 'NUMBER OF DEPENDENT CHILDREN' (#.13) and
  1. ; 'DEPENDENT CHILDREN' (#.08) in Income Relation File (#408.22)
  1. ; based upon the count of active child dependents in Patient
  1. ; Relation File (#408.12).
  1. ;
  1. ; IN: DFN - IEN of Patient File (#2)
  1. ; DGDT - [optional] as 'as of' date
  1. ; DGMT - [optional] means test IEN
  1. ; OUT: SETS (.08) & (.13) fields of (408.22)
  1. ; No Formal Output
  1. ;
  1. N DGNODE,DGDEPYN,DGDEP,DGREL,DGX,PRIEN,SPOUSE
  1. S (CT,IEN,PRIEN,SPOUSE,DGDEP)=0,DGDT=$S($G(DGDT):DGDT,1:$$LYR^DGMTSCU1(DT))
  1. D GETREL(DFN,"VSD",DGDT,$G(DGMT)) S PRIEN=+$G(DGREL("V")),SPOUSE=$S($G(DGREL("S")):1,1:0)
  1. S DGX=$$IAI^DGMTU3(+PRIEN,($E(DGDT,1,3)_"0000"),$S($G(DGMT):$P($G(^DGMT(408.31,DGMT,0)),"^",19),1:1)) ;408.21 IEN
  1. S DGX=$O(^DGMT(408.22,"AIND",+DGX,0)) ;408.22 IEN
  1. S DGNODE=$G(^DGMT(408.22,+DGX,0)) I DGNODE']"" Q
  1. S DGDEPYN=$S(DGDEP:1,1:0)
  1. I $P(DGNODE,"^",13)'=DGDEP!($P(DGNODE,"^",8)'=DGDEPYN)!($P(DGNODE,"^",5)'=SPOUSE) D
  1. .S DIE="^DGMT(408.22,",DA=+DGX,DR=".13////^S X=DGDEP"_$S(+$P(DGNODE,"^",8)=DGDEPYN:"",1:";.08////^S X=DGDEPYN")_$S($P(DGNODE,"^",5)=SPOUSE:"",1:";.05////^S X=SPOUSE")
  1. .D ^DIE
  1. .K DR,DA,DIE,DIC,Y,X
  1. Q
  1. ;
  1. GETINACD(DFN,DGREL) ; Get all INACTIVE dependents for a patient
  1. ; Input -- DFN as the IEN of file 2 (for the patient)
  1. ; DGREL as Array of active spouse/dependents
  1. ; Output -- DGIREL("S",counter) = spouse reference
  1. ; DGIREL("C",counter) = child reference
  1. N IEN,XCTR,TMPDGEL,XITYP,EDT,IFN,NODE
  1. K DGIREL
  1. Q:'$D(DGREL)
  1. S IEN=$P($G(DGREL("S")),U) S:IEN'="" TMPDGREL(IEN)=""
  1. S XCTR="" F S XCTR=$O(DGREL("C",XCTR)) Q:XCTR="" D
  1. . S IEN=$P(DGREL("C",XCTR),U) S:IEN'="" TMPDGREL(IEN)=""
  1. S IEN=0 F S IEN=$O(^DGPR(408.12,"B",DFN,IEN)) Q:IEN="" D
  1. . Q:($D(TMPDGREL(IEN)))!('$D(^DGPR(408.12,IEN,"E")))
  1. . S XITYP=$P($G(^DGPR(408.12,IEN,0)),U,2)
  1. . S XITYP=$S(XITYP=2:"S",((XITYP>2)&(XITYP<7)):"C",1:"") Q:XITYP=""
  1. . S EDT=$O(^DGPR(408.12,IEN,"E","AID","")) Q:EDT=""
  1. . S IFN=$O(^DGPR(408.12,IEN,"E","AID",EDT,"")) Q:IFN=""
  1. . Q:$P($G(^DGPR(408.12,IEN,"E",IFN,0)),U,2) ;Don't want Active
  1. . S NODE=$G(^DGPR(408.12,IEN,0))
  1. . S DGIREL(XITYP,$O(DGIREL(XITYP,""),-1)+1)=IEN_U_$P(NODE,U,3)_U_(EDT*-1)
  1. Q
  1. ;
  1. CNTDEPS(DFN) ;Count Dependent children
  1. ; DG*5.3*688 - EVC changes; GTS
  1. ; Called by DGDEP4 and DGRPEIS1
  1. ;
  1. ;INPUT:
  1. ; DFN - Patient file IEN for MT Veteran
  1. ;OUTPUT:
  1. ; Number of child dependents
  1. ;
  1. N IEN,DEPCNT,DGX
  1. S DEPCNT=0
  1. S IEN=0
  1. F S IEN=$O(^DGPR(408.12,"B",DFN,IEN)) Q:'IEN DO
  1. . S DGX=$G(^DGPR(408.12,IEN,0))
  1. . I ($P(DGX,U,2)>2),($P(DGX,U,2)<7) S DEPCNT=DEPCNT+1
  1. Q DEPCNT