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

BQIAGE.m

Go to the documentation of this file.
  1. BQIAGE ;PRXM/HC/ALA - Age Function calls ; 06 Nov 2006 1:23 PM
  1. ;;2.1;ICARE MANAGEMENT SYSTEM;;Feb 07, 2011
  1. ;
  1. AGE(D0,PDATE,QUAL) ;EP
  1. ; Description
  1. ; This program is copied from the computed AGE field (2,.033) which
  1. ; calculates the AGE of a person based on their DOB (date of birth)
  1. ; and either the current date (DT) or their DOD (date of death)
  1. ;
  1. ; It has been modified to use another date passed into this function
  1. ; instead of just the previous two dates, DT and DOD.
  1. ;
  1. ; Input
  1. ; D0 - Patient IEN
  1. ; PDATE - Other date to compare patient's date of birth with
  1. ; QUAL - Include qualifier (YRS, DYS, MOS)
  1. ;
  1. ; Assumes variables U,DT
  1. ;
  1. S PDATE=$G(PDATE,""),QUAL=$G(QUAL,"")
  1. Q $$AGE^AUPNPAT(D0,PDATE,QUAL)
  1. ;
  1. NEW X,Y,AUX,QFLR
  1. S QUAL=$G(QUAL,0)
  1. I 'QUAL D
  1. . S Y(2,.033,5)=$S($D(^DPT(D0,0)):^(0),1:""),X=$S($G(PDATE)<+$G(^DPT(D0,.35))&$G(PDATE):PDATE,$G(^DPT(D0,.35)):+^(.35),$G(PDATE)'="":PDATE,1:DT)
  1. . S X=X,Y(2,.033,1)=X
  1. . S X=1,Y(2,.033,2)=X
  1. . S X=3,X=$E(Y(2,.033,1),Y(2,.033,2),X),Y(2,.033,3)=X,Y(2,.033,4)=X
  1. . S X=$P(Y(2,.033,5),U,3),X=X
  1. . S X=X,Y(2,.033,6)=X
  1. . S X=1,Y(2,.033,7)=X
  1. . S X=3,X=$E(Y(2,.033,6),Y(2,.033,7),X)
  1. . S Y=X,X=Y(2,.033,3),X=X-Y
  1. . S Y(2,.033,8)=X,Y(2,.033,9)=X,Y(2,.033,10)=X,X=$S($G(PDATE)<+$G(^DPT(D0,.35))&$G(PDATE):PDATE,$G(^DPT(D0,.35)):+^(.35),$G(PDATE)'="":PDATE,1:DT)
  1. . S X=X,Y(2,.033,11)=X
  1. . S X=4,Y(2,.033,12)=X
  1. . S X=7,X=$E(Y(2,.033,11),Y(2,.033,12),X)
  1. . S Y(2,.033,13)=X,Y(2,.033,14)=X
  1. . S X=$P(Y(2,.033,5),U,3),X=X
  1. . S X=X,Y(2,.033,15)=X
  1. . S X=4,Y(2,.033,16)=X
  1. . S X=7
  1. . S X=$E(Y(2,.033,15),Y(2,.033,16),X)
  1. . S Y=X,X=Y(2,.033,13),X=X<Y,Y=X,X=Y(2,.033,8),X=X-Y
  1. ;
  1. ; if the qualifier flag is set, then the returned value is the same
  1. ; as the PRINTED AGE value which includes YRS, DYS, or MOS.
  1. I QUAL D
  1. . S X=$$FMDIFF^XLFDT($S($G(PDATE)<+$G(^DPT(D0,.35))&$G(PDATE):PDATE,$G(^DPT(D0,.35)):+^(.35),$G(PDATE)'="":PDATE,1:DT),$P(^DPT(D0,0),U,3))
  1. . S AUX=X\365.25
  1. . S QFLR=$S(AUX>2:AUX_" YRS",X<31:X_" DYS",1:X\30_" MOS")
  1. Q $S(QUAL=1:QFLR,1:X)