Changeset 636 for FOIAVistA/tag/r/CLINICAL_REMINDERS-PXRM/PXRMAGE.m
- Timestamp:
- Dec 4, 2009, 8:26:01 PM (14 years ago)
- Location:
- FOIAVistA/tag/r
- Files:
-
- 1 edited
- 1 copied
Legend:
- Unmodified
- Added
- Removed
-
FOIAVistA/tag/r/CLINICAL_REMINDERS-PXRM/PXRMAGE.m
r628 r636 1 PXRMAGE ; SLC/PKR - Utilities for age calculations. ;10/07/2005 2 ;;2.0;CLINICAL REMINDERS;**4**;Feb 04, 2005;Build 21 1 PXRMAGE ; SLC/PKR - Utilities for age calculations. ;1/27/07 17:46 2 ;;2.0;CLINICAL REMINDERS;**4,7**;Feb 04, 2005;Build 14 3 ; Modified from FOIA VISTA, 4 ; Copyright (C) 2007 WorldVistA 5 ; 6 ; This program is free software; you can redistribute it and/or modify 7 ; it under the terms of the GNU General Public License as published by 8 ; the Free Software Foundation; either version 2 of the License, or 9 ; (at your option) any later version. 10 ; 11 ; This program is distributed in the hope that it will be useful, 12 ; but WITHOUT ANY WARRANTY; without even the implied warranty of 13 ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 ; GNU General Public License for more details. 15 ; 16 ; You should have received a copy of the GNU General Public License 17 ; along with this program; if not, write to the Free Software 18 ; Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 3 19 ;=========================================== 4 20 AGE(DOB,DOD,DATE) ;Given a date of birth, date of death, and a date … … 6 22 ;return the age on the date of death. All dates should be in VA 7 23 ;Fileman format. 8 N CDATE 24 N CDATE,X,X1,X2,X3 9 25 S CDATE=$S(DOD="":DATE,DOD'="":DOD) 10 Q (CDATE-DOB)\10000 26 S X=(CDATE-DOB)\10000 Q:X>1 X ; Begin VOE changes to support pediatrics 27 S X1=CDATE,X2=DOB 28 D ^%DTC S X3=X\365.25,X=$S(X3>2:X3,1:X_"D") 29 Q X ; End VOE changes to support pediatric ages 11 30 ; 12 31 ;=========================================== 13 AGECHECK( AGE,MINAGE,MAXAGE) ;Given an AGE, MINimumAGE, and MAXimumAGE32 AGECHECK(PXRMAGE,MINAGE,MAXAGE) ;Given an AGE (with "Y", "M" or "D"), MINimumAGE, and MAXimumAGE 14 33 ;return true if age lies within the range. 15 34 ;Special values of NULL or 0 mean there are no limits. 16 35 ; 17 S MAXAGE=+MAXAGE 18 S MINAGE=+MINAGE 36 ; IHS/CIA/MGH - 5/12/2004 PATCH 1001 Changed to function call to calculate age 37 ; Two lines changed and one added ; for VOE too 38 ;S MAXAGE=+MAXAGE 39 ;S MINAGE=+MINAGE 40 ; 41 S MAXAGE=$$DECODE(MAXAGE) ; DECODE used in VOE Pediatric patients 42 S MINAGE=$$DECODE(MINAGE) 43 S AGEDAYS=$$DECODE(PXRMAGE) 44 ; 19 45 ;See if too old. 20 I (AGE >MAXAGE)&(MAXAGE>0) Q 046 I (AGEDAYS>MAXAGE)&(MAXAGE>0) Q 0 21 47 ; 22 48 ;See if too young. 23 49 I MINAGE=0 Q 1 24 I AGE <MINAGE Q 050 I AGEDAYS<MINAGE Q 0 25 51 Q 1 26 52 ; 27 ;=========================================== 53 DECODE(AGEVALUE) ; Put age from VADPT into format for reminders ; for VOE too 54 ; IHS/CIA/MGH - 5/12/2004 PATCH 1001 Added function to change age into days 55 N NUM,CODE,MULT 56 S NUM=+AGEVALUE,CODE=$P(AGEVALUE,NUM,2) 57 S MULT=1.0 58 I CODE="M" S MULT=30.42 59 I CODE=""!(CODE="Y") S MULT=365.25 60 Q +(MULT*NUM) 61 ;====================================================================== 28 62 FMTAGE(MINAGE,MAXAGE) ;Format the minimum age and maximum age for display. 29 63 N STR … … 79 113 OVERLAP(NAR,MINA,MAXA) ;Check age ranges for overlap. Return an error message 80 114 ;if an overlap is found. 115 ;IHS/CIA/MGH Changes made to decode the ages into numeric results 81 116 I NAR'>1 Q 0 82 117 N IC,IN,JC,MAXI,MAXJ,MINI,MINJ,OVRLAP,TEXT 83 118 S OVRLAP=0 84 119 F IC=1:1:NAR-1 D 85 . S MAXI= MAXA(IC)120 . S MAXI=$$DECODE(MAXA(IC)) ; DECODE used in VOE Pediatric patients 86 121 . I MAXI="" S MAXI=1000 87 . S MINI= MINA(IC)122 . S MINI=$$DECODE(MINA(IC)) 88 123 . I MINI="" S MINI=0 89 124 . F JC=IC+1:1:NAR D 90 .. S MAXJ= MAXA(JC)125 .. S MAXJ=$$DECODE(MAXA(JC)) 91 126 .. I MAXJ="" S MAXJ=1000 92 .. S MINJ= MINA(JC)127 .. S MINJ=$$DECODE(MINA(JC)) 93 128 .. I MINJ="" S MINJ=0 94 129 .. S IN=0 … … 122 157 Q OVERLAP 123 158 ; 159 ;====================================================================== 160 RESTORE(SOURCE,INDEX,FREQ,MINAGE,MAXAGE) ;Restore FREQ, MINAGE, and 161 ;MAXAGE back to the original form. From IHS for VOE 162 N IND,TEMP 163 I SOURCE="CFIND" D 164 . S IND=$O(^PXD(811.9,PXRMITEM,10,"B",INDEX,"")) 165 . S TEMP=^PXD(811.9,PXRMITEM,10,IND,0) 166 ; 167 I SOURCE="HFIND" D 168 . S IND=$O(^PXD(811.9,PXRMITEM,6,"B",INDEX,"")) 169 . S TEMP=^PXD(811.9,PXRMITEM,6,IND,0) 170 ; 171 I SOURCE="TFIND" D 172 . S IND=$O(^PXD(811.9,PXRMITEM,4,"B",INDEX,"")) 173 . S TEMP=^PXD(811.9,PXRMITEM,4,IND,0) 174 ; 175 S MINAGE=$P(TEMP,U,2) 176 S MAXAGE=$P(TEMP,U,3) 177 S FREQ=$P(TEMP,U,4) 178 Q 179 ;
Note:
See TracChangeset
for help on using the changeset viewer.