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

AMQQAVR.m

Go to the documentation of this file.
  1. AMQQAVR ; IHS/CMI/THL - RELATIVE DATE ;
  1. ;;2.0;IHS PCC SUITE;;MAY 14, 2009
  1. ;-----
  1. TYPE W !,"Relative to what date =>",!!
  1. S %="DATE OF BIRTH^DATE OF DEATH^A PARTICULAR AGE"
  1. F I=1:1 S Y=$P(%,U,I) Q:Y="" W ?3,I,") ",Y,!
  1. RT W !,"Your choice (1-",I-1,"): 1// "
  1. R X:DTIME E S X=U
  1. I X="" S X=1 W " (1)"
  1. I X?1."?" W !!!,"Results are screened by comparing the date of result with the ""relative"" date",!! G RT
  1. I $E(X)=U S AMQQQUIT="" G EXIT
  1. I X?1N,X<I D @("R"_X) G EXIT
  1. W " ??",*7
  1. G RT
  1. ;
  1. EXIT I $D(AMQQQUIT) S AMQQCOMP=""
  1. I AMQQCOMP'="" S AMQQSQCV=AMQQCOMP
  1. K X,Y,%,C,F,I,Z
  1. Q
  1. ;
  1. R1 ; BIRTHDAY
  1. S AMQQCOMP="0^0^CDOB"
  1. W !
  1. R1RS W !,"Time window begins how long after patient's birth: "
  1. S Z="1^R1RS^R1RE"
  1. D RG
  1. G @AMQQDEST
  1. R1RE W !,"The window ends how long after birth: "
  1. S Z="2^R1RE^R1CK"
  1. D RG
  1. G @AMQQDEST
  1. R1CK I +AMQQCOMP'<$P(AMQQCOMP,U,2) W " ??",*7 G R1
  1. D SET
  1. Q
  1. ;
  1. R2 ; DEATHDAY
  1. S AMQQCOMP="0^0^CDOD" W !
  1. R2RS W !,"The window of time begins how long before each patient's death: "
  1. S Z="1^R2RS^R2RE"
  1. D RG
  1. G @AMQQDEST
  1. R2RE W !,"The window ends how long before death: "
  1. S Z="2^R1RE^R2CK"
  1. D RG
  1. G @AMQQDEST
  1. R2CK I $P(AMQQCOMP,U,2)'<+AMQQCOMP W " ??",*7 G R2
  1. D SET
  1. Q
  1. ;
  1. R3 ; AGE
  1. W ! S AMQQCOMP="0^0^CAGE"
  1. W !,"Enter the baseline age: "
  1. R X:DTIME E S X=U
  1. I U[$E(X) S AMQQQUIT="" Q
  1. I X?1."?" D HELPA G R3
  1. I X="" S AMQQCOMP="" Q
  1. I X?1.N S X=X_"Y" I $G(AMQQCOMP)'["CDOB" W " (years)"
  1. S F=""
  1. D DATE
  1. I Y=-1 G R3
  1. S $P(AMQQCOMP,U,4)=Y
  1. R3RS W !,"Enter beginning of time window relative to each patient's age: "
  1. S Z="1^R3RS^R3RE^1"
  1. D RG
  1. G @AMQQDEST
  1. R3RE W !,"Enter the end of the time window relative to the baseline age: "
  1. S Z="2^R3RE^R3CK^1"
  1. D RG
  1. G @AMQQDEST
  1. R3CK I +AMQQCOMP'<$P(AMQQCOMP,U,2) W " ??",*7 G R3
  1. D SET
  1. Q
  1. ;
  1. RG R X:DTIME E S X=U
  1. I X="" S X=$S(+Z=1:"0D",1:"999999D")
  1. I X=U S AMQQQUIT="" S AMQQDEST="EXIT" Q
  1. I X?1."?" D @("HELPD"_$P(Z,U,4)) S AMQQDEST=$P(Z,U,2) Q
  1. I X?.1P1.N S X=X_"Y" I $G(AMQQCOMP)'["CDOB" W " (years)"
  1. S F=""
  1. D @("DATE"_$P(Z,U,4))
  1. I Y=-1 S AMQQDEST=$P(Z,U,2) Q
  1. S $P(AMQQCOMP,U,+Z)=Y
  1. S AMQQDEST=$P(Z,U,3)
  1. Q
  1. ;
  1. DATE1 S F="+"
  1. I $E(X)="+"!($E(X)="-") S F=$E(X),X=$E(X,2,99)
  1. DATE I $E(X)'?1N G D1
  1. I X?1.N W !!,"You must also specify time units; e.g. 6 MONTHS or 30 YEARS",!!,*7 S Y=-1 Q
  1. F Q:X'[" " S X=$P(X," ")_$P(X," ",2,99)
  1. S C=+X,X=$P(X,+X,2)
  1. I $E(X)="Y",$G(AMQQCOMP)["CDOB" W " (",C,$S(C=1:"st",C=2:"nd",C=3:"rd",1:"th")," BIRTHDAY)"
  1. I $L(X),"DWMY"[$E(X) S %=$E(X),Y=C*$S(%="D":1,%="W":7,%="M":30.44,1:365.25),Y=Y\1,Y=F_Y Q
  1. D1 W " ??",*7
  1. S Y=-1
  1. Q
  1. ;
  1. SET S AMQQFROU=$P(AMQQCOMP,U,3)_"^AMQQF1"
  1. S AMQQCOMP=$P(AMQQCOMP,U)_";"_$P(AMQQCOMP,U,2)_";"_$P(AMQQCOMP,U,4)
  1. Q
  1. ;
  1. HELPD W !!,"Enter a time period like ""6 MONTHS"" or ""30 DAYS"" or ""2 YEARS""",!!
  1. Q
  1. ;
  1. HELPA W !!,"Enter a baseline age like ""3 YEARS"" or ""18 MONTHS""",!!
  1. Q
  1. ;
  1. HELPD1 W !!,"Enter a time period relative to the ",$S($D(AMQQSQRD):"visit",1:"baseline age"),".",!
  1. W "For example, ""+3 YEARS"" includes a time period 3 years beyond the ",$S($D(AMQQSQRD):"visit",1:"baseline age"),".",!
  1. W "Similarly, ""-18 MONTHS"" includes the 18 month period before the ",$S($D(AMQQSQRD):"visit",1:"baseline age"),".",!!
  1. Q
  1. ;
  1. EN1 ; ENTRY POINT FOR VISITS
  1. W !!,"You can specify a time window relative to the visit date.",!!
  1. R4RS W "Enter the start of the time window relative to the visit: "
  1. S Z="1^R4RS^R4RE^1"
  1. D RG
  1. G @AMQQDEST
  1. R4RE W !,"Enter the end of the time window relative to the visit: "
  1. S Z="2^R4RE^R3CK^1"
  1. D RG
  1. G @AMQQDEST
  1. R4CK I +AMQQCOMP'<$P(AMQQCOMP,U,2) W " ??",*7 G R4RS
  1. D SET
  1. Q
  1. ;