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

APCSSILU.m

Go to the documentation of this file.
  1. APCSSILU ; IHS/CMI/LAB - utilities for ili/h1n1 ;
  1. ;;2.0;IHS PCC SUITE;**5**;MAY 14, 2009
  1. ;;* MICHAEL REMILLARD, DDS * CIMARRON MEDICAL INFORMATICS, FOR IHS *
  1. ;; RETRIEVE PATIENTS FOR DUE LISTS & LETTERS.
  1. ;; PATCH 1: Correct test for Active Chart at site DUZ2. INACTREG+11
  1. ;; Also, add Street Address Line 2 aAPCSlity. STREET+0
  1. ;; Also, provide test for patient IneligiAPCSlity INELIG+0
  1. ;
  1. ;----------
  1. DOB(DFN) ;EP
  1. ;---> Return Patient's Date of APCSrth in Fileman format.
  1. ;---> Parameters:
  1. ; 1 - DFN (req) Patient's IEN (DFN).
  1. ;
  1. Q:'$G(DFN) "NO PATIENT"
  1. Q:'$P($G(^DPT(DFN,0)),U,3) "NOT ENTERED"
  1. Q $P(^DPT(DFN,0),U,3)
  1. ;
  1. ;
  1. ;
  1. ;----------
  1. AGE(DFN,APCSZ,APCSDT) ;EP
  1. ;---> Return Patient's Age.
  1. ;---> Parameters:
  1. ; 1 - DFN (req) IEN in PATIENT File.
  1. ; 2 - APCSZ (opt) APCSZ=1,2,3 1=years, 2=months, 3=days.
  1. ; 2 will be assumed if not passed.
  1. ; 3 - APCSDT (opt) Date on which Age should be calculated.
  1. ;
  1. N APCSDOB,X,X1,X2 S:$G(APCSZ)="" APCSZ=2
  1. Q:'$G(DFN) ""
  1. S APCSDOB=$$DOB(DFN)
  1. Q:'APCSDOB ""
  1. S:'$G(DT) DT=$$DT^XLFDT
  1. S:'$G(APCSDT) APCSDT=DT
  1. Q:APCSDT<APCSDOB ""
  1. ;
  1. ;---> Age in Years.
  1. N APCSAGEY,APCSAGEM,APCSD1,APCSD2,APCSM1,APCSM2,APCSY1,APCSY2
  1. S APCSM1=$E(APCSDOB,4,7),APCSM2=$E(APCSDT,4,7)
  1. S APCSY1=$E(APCSDOB,1,3),APCSY2=$E(APCSDT,1,3)
  1. S APCSAGEY=APCSY2-APCSY1 S:APCSM2<APCSM1 APCSAGEY=APCSAGEY-1
  1. S:APCSAGEY<1 APCSAGEY="<1"
  1. Q:APCSZ=1 APCSAGEY
  1. ;
  1. ;---> Age in Months.
  1. S APCSD1=$E(APCSM1,3,4),APCSM1=$E(APCSM1,1,2)
  1. S APCSD2=$E(APCSM2,3,4),APCSM2=$E(APCSM2,1,2)
  1. S APCSAGEM=12*APCSAGEY
  1. I APCSM2=APCSM1&(APCSD2<APCSD1) S APCSAGEM=APCSAGEM+12
  1. I APCSM2>APCSM1 S APCSAGEM=APCSAGEM+APCSM2-APCSM1
  1. I APCSM2<APCSM1 S APCSAGEM=APCSAGEM+APCSM2+(12-APCSM1)
  1. S:APCSD2<APCSD1 APCSAGEM=APCSAGEM-1
  1. Q:APCSZ=2 APCSAGEM
  1. ;
  1. ;---> Age in Days.
  1. S X1=APCSDT,X2=APCSDOB
  1. D ^%DTC
  1. Q X
  1. ;
  1. ;
  1. ;----------
  1. AGEF(DFN,APCSDT) ;EP
  1. ;---> Age formatted "35 Months" or "23 Years"
  1. ;---> Parameters:
  1. ; 1 - DFN (req) Patient's IEN (DFN).
  1. ; 2 - APCSDT (opt) Date on which Age should be calculated.
  1. ;
  1. N Y
  1. S Y=$$AGE(DFN,2,$G(APCSDT))
  1. Q:Y["DECEASED" Y
  1. Q:Y["NOT BORN" Y
  1. ;
  1. ;---> If over 60 months, return years.
  1. I Y>60 S Y=$$AGE(DFN,1,$G(APCSDT)) Q Y_$S(Y=1:"year",1:" yrs")
  1. ;
  1. ;---> If under 1 month return days.
  1. I Y<1 S Y=$$AGE(DFN,3,$G(APCSDT)) Q Y_$S(Y=1:" day",1:" days")
  1. ;
  1. ;---> Return months
  1. Q Y_$S(Y=1:" mth",1:" mths")
  1. ;
  1. ;
  1. ;----------
  1. DECEASED(DFN,APCSDT) ;EP
  1. ;---> Return 1 if patient is deceased, 0 if not deceased.
  1. ;---> Parameters:
  1. ; 1 - DFN (req) Patient's IEN (DFN).
  1. ; 2 - APCSDT (opt) If APCSDT=1 return Date of Death (Fileman format).
  1. ;
  1. Q:'$G(DFN) 0
  1. N X S X=+$G(^DPT(DFN,.35))
  1. Q:'X 0
  1. Q:'$G(APCSDT) 1
  1. Q X
  1. ;
  1. ;