source: WorldVistAEHR/trunk/r/SPINAL_CORD_DYSFUNCTION-SPN/SPNAGGO.m@ 1261

Last change on this file since 1261 was 613, checked in by George Lilly, 15 years ago

initial load of WorldVistAEHR

File size: 9.6 KB
Line 
1SPNAGGO ;SD/CM- AGGREGATE OUTPATIENT OUTCOMES REPORT; 2-21-2003
2 ;;2.0;Spinal Cord Dysfunction;**20**;01/02/97
3 ;
4EN ;
5 S U="^"
6 D INPT^SPNAGGU
7PARAMS ;
8 D CED
9 G:SPNLEXIT=1 EXIT
10DEVICE ;
11 S ZTSAVE("SPN*")="",ZTSAVE("B*")="",ZTSAVE("AGE*")="",ZTSAVE("MIN*")=""
12 S ZTSAVE("MAX*")="",ZTSAVE("LOR*")="",ZTSAVE("TF*")="",ZTSAVE("SEX*")=""
13 S ZTSAVE("SL*")="",ZTSAVE("COMD*")="",ZTSAVE("CARETYP")=""
14 S ZTSAVE("EDATE")="",ZTSAVE("BDATE")="",ZTSAVE("LINE")="",ZTSAVE("I")=""
15 S ZTSAVE("ASIA*")=""
16 W !
17 D DEVICE^SPNPRTMT("PRINT^SPNAGGPO","Outpt Rehab Outcomes",.ZTSAVE) Q:SPNLEXIT
18 I SPNIO="Q" D EXIT Q ; Print was queued
19 I IO'="" D PRINT^SPNAGGPO D EXIT Q ; Print was not queued
20 D EXIT
21 Q
22CED ;date range for Care End Date
23 D DATE^SPNAGGA
24 Q
25OIEN ;
26 S SPNPD1=0 F S SPNPD1=$O(^SPNL(154.1,"B",SPNPD0,SPNPD1)) Q:'+SPNPD1 D DIAGCAT
27 Q
28DIAGCAT ;get ASIA Highest Neuro Level and ASIA Imp Scale
29 S SPNDCS=0,SPNDCM=0,SPNDCP=0,SPNDCL=0
30 Q:'$D(^SPNL(154.1,SPNPD1,0))
31 Q:'$D(^SPNL(154.1,SPNPD1,"ASIA"))
32 Q:'$D(^SPNL(154.1,SPNPD1,8))
33 Q:$P(^SPNL(154.1,SPNPD1,0),U,2)'=3
34 Q:$P(^SPNL(154.1,SPNPD1,8),U,3)'=CARETYP
35 Q:$P($G(^SPNL(154.1,SPNPD1,8)),U,2)<BDATE!($P($G(^SPNL(154.1,SPNPD1,8)),U,2)>EDATE)
36 Q:$P($G(^SPNL(154.1,SPNPD1,0)),U,1)=SPNNODUP
37 S SPNNODUP=$P($G(^SPNL(154.1,SPNPD1,0)),U,1)
38 I "ABC"[$P($G(^SPNL(154.1,SPNPD1,"ASIA")),U,1),$P($G(^SPNL(154.1,SPNPD1,"ASIA")),U,14)<5 S SPNDCS=1
39 I "ABC"[$P($G(^SPNL(154.1,SPNPD1,"ASIA")),U,1),$P($G(^SPNL(154.1,SPNPD1,"ASIA")),U,14)<5 S SPNLSTDT="S"
40 I "ABC"[$P($G(^SPNL(154.1,SPNPD1,"ASIA")),U,1)&($P($G(^SPNL(154.1,SPNPD1,"ASIA")),U,14)>4)&($P($G(^SPNL(154.1,SPNPD1,"ASIA")),U,14)<9) S SPNDCM=1
41 I "ABC"[$P($G(^SPNL(154.1,SPNPD1,"ASIA")),U,1)&($P($G(^SPNL(154.1,SPNPD1,"ASIA")),U,14)>4)&($P($G(^SPNL(154.1,SPNPD1,"ASIA")),U,14)<9) S SPNLSTDT="M"
42 I "ABC"[$P($G(^SPNL(154.1,SPNPD1,"ASIA")),U,1),$P($G(^SPNL(154.1,SPNPD1,"ASIA")),U,14)>8 S SPNDCP=1
43 I "ABC"[$P($G(^SPNL(154.1,SPNPD1,"ASIA")),U,1),$P($G(^SPNL(154.1,SPNPD1,"ASIA")),U,14)>8 S SPNLSTDT="P"
44 I $P($G(^SPNL(154.1,SPNPD1,"ASIA")),U,1)="D",$P($G(^SPNL(154.1,SPNPD1,"ASIA")),U,14)<31 S SPNDCL=1
45 I $P($G(^SPNL(154.1,SPNPD1,"ASIA")),U,1)="D",$P($G(^SPNL(154.1,SPNPD1,"ASIA")),U,14)<31 S SPNLSTDT="L"
46 I SPNLSTDT="S" S SPNSEVC=SPNSEVC+1
47 I SPNLSTDT="M" S SPNMODC=SPNMODC+1
48 I SPNLSTDT="P" S SPNPARC=SPNPARC+1
49 I SPNLSTDT="L" S SPNLOWC=SPNLOWC+1
50 S SPNDIAGC=SPNDIAGC+1
51 ;
52AGE ;
53 S AGECALL=$$GET1^DIQ(154.1,SPNPD1,999.025)
54 I +SPNDCS S SPNAGES=SPNAGES+AGECALL,AGESC=AGESC+1 S:AGESC=1 BMAS=AGECALL S MINAGES=$S(AGECALL<BMAS:AGECALL,1:BMAS)
55 I +SPNDCS S:AGESC=1 BHAS=AGECALL S MAXAGES=$S(AGECALL>BHAS:AGECALL,1:BHAS)
56 I +SPNDCM S SPNAGEM=SPNAGEM+AGECALL,AGEMC=AGEMC+1 S:AGEMC=1 BMAM=AGECALL S MINAGEM=$S(AGECALL<BMAM:AGECALL,1:BMAM)
57 I +SPNDCM S:AGEMC=1 BHAM=AGECALL S MAXAGEM=$S(AGECALL>BHAM:AGECALL,1:BHAM)
58 I +SPNDCP S SPNAGEP=SPNAGEP+AGECALL,AGEPC=AGEPC+1 S:AGEPC=1 BMAP=AGECALL S MINAGEP=$S(AGECALL<BMAP:AGECALL,1:BMAP)
59 I +SPNDCP S:AGEPC=1 BHAP=AGECALL S MAXAGEP=$S(AGECALL>BHAP:AGECALL,1:BHAP)
60 I +SPNDCL S SPNAGEL=SPNAGEL+AGECALL,AGELC=AGELC+1 S:AGELC=1 BMAL=AGECALL S MINAGEL=$S(AGECALL<BMAL:AGECALL,1:BMAL)
61 I +SPNDCL S:AGELC=1 BHAL=AGECALL S MAXAGEL=$S(AGECALL>BHAL:AGECALL,1:BHAL)
62 S AGEL=$S((MINAGES<MINAGEM)&(MINAGES<MINAGEP)&(MINAGES<MINAGEL):MINAGES,(MINAGEM<MINAGEP)&(MINAGEM<MINAGEL):MINAGEM,MINAGEP<MINAGEL:MINAGEP,1:MINAGEL)
63 S AGEH=$S((MAXAGES>MAXAGEM)&(MAXAGES>MAXAGEP)&(MAXAGES>MAXAGEL):MAXAGES,(MAXAGEM>MAXAGEP)&(MAXAGEM>MAXAGEL):MAXAGEM,MAXAGEP>MAXAGEL:MAXAGEP,1:MAXAGEL)
64 ;
65SEX ;
66 S SEXCALL=$P(^DPT($P(^SPNL(154.1,SPNPD1,0),U,1),0),U,2)
67 I +SPNDCS,SEXCALL="M" S SPNSEXS=SPNSEXS+1
68 I +SPNDCM,SEXCALL="M" S SPNSEXM=SPNSEXM+1
69 I +SPNDCP,SEXCALL="M" S SPNSEXP=SPNSEXP+1
70 I +SPNDCL,SEXCALL="M" S SPNSEXL=SPNSEXL+1
71LOR ;Length of Rehab in Days (Note: not needed for Outpt aggregate report)
72 I +SPNDCS D STATS I +LORRN S SPNLORS=SPNLORS+$$GET1^DIQ(154.1,LORRN,999.08),LORSC=LORSC+1 S:LORSC=1 BMLS=$$GET1^DIQ(154.1,LORRN,999.08) S MINLORS=$S($$GET1^DIQ(154.1,LORRN,999.08)<BMLS:$$GET1^DIQ(154.1,LORRN,999.08),1:BMLS)
73 I +SPNDCS S:LORSC=1 BHLS=$$GET1^DIQ(154.1,LORRN,999.08) S MAXLORS=$S($$GET1^DIQ(154.1,SPNPD1,999.08)>BHLS:$$GET1^DIQ(154.1,LORRN,999.08),1:BHLS)
74 I +SPNDCS&(+LORRN)&(+TFSRN) S TFS=$$GET1^DIQ(154.1,TFSRN,999.05),TFF=$$GET1^DIQ(154.1,LORRN,999.05),TFCUMS=TFCUMS+(TFF-TFS),TFCS=TFCS+1
75 I +SPNDCS&(+LORRN)&(+TFGRN) S TFG=$$GET1^DIQ(154.1,TFGRN,999.05),TFF=$$GET1^DIQ(154.1,LORRN,999.05),TFGCUMS=TFGCUMS+(TFF-TFG),TFGCS=TFGCS+1
76CDSEV I +SPNDCS&(+LORRN)&($P($G(^SPNL(154.1,LORRN,0)),U,24)<5) S COMDISS=COMDISS+1
77FRETSEV I +SPNDCS&(+LORRN)&(+TFURN) S TFU=$$GET1^DIQ(154.1,TFURN,999.05),TFF=$$GET1^DIQ(154.1,LORRN,999.05),TFUCUMS=TFUCUMS+(TFU-TFF),TFUCS=TFUCS+1
78SLSEV I +SPNDCS&(+SLSRN)&(+SLFRN) S SLS=$P($G(^SPNL(154.1,SLSRN,"SCORE")),U,1),SLF=$P($G(^SPNL(154.1,SLFRN,"SCORE")),U,1),SLCUMS=SLCUMS+(SLF-SLS),SLCS=SLCS+1
79SLUSEV I +SPNDCS&(+SLFRN)&(+SLURN) S SLU=$P($G(^SPNL(154.1,SLURN,"SCORE")),U,1),SLF=$P($G(^SPNL(154.1,SLFRN,"SCORE")),U,1),SLUCUMS=SLUCUMS+(SLU-SLF),SLUCS=SLUCS+1
80 I +SPNDCM D STATS I +LORRN S SPNLORM=SPNLORM+$$GET1^DIQ(154.1,LORRN,999.08),LORMC=LORMC+1 S:LORMC=1 BMLM=$$GET1^DIQ(154.1,LORRN,999.08) S MINLORM=$S($$GET1^DIQ(154.1,LORRN,999.08)<BMLM:$$GET1^DIQ(154.1,LORRN,999.08),1:BMLM)
81 I +SPNDCM S:LORMC=1 BHLM=$$GET1^DIQ(154.1,LORRN,999.08) S MAXLORM=$S($$GET1^DIQ(154.1,LORRN,999.08)>BHLM:$$GET1^DIQ(154.1,LORRN,999.08),1:BHLM)
82 I +SPNDCM&(+LORRN)&(+TFSRN) S TFS=$$GET1^DIQ(154.1,TFSRN,999.05),TFF=$$GET1^DIQ(154.1,LORRN,999.05),TFCUMM=TFCUMM+(TFF-TFS),TFCM=TFCM+1
83 I +SPNDCM&(+LORRN)&(+TFGRN) S TFG=$$GET1^DIQ(154.1,TFGRN,999.05),TFF=$$GET1^DIQ(154.1,LORRN,999.05),TFGCUMM=TFGCUMM+(TFF-TFG),TFGCM=TFGCM+1
84CDMOD I +SPNDCM&(+LORRN)&($P($G(^SPNL(154.1,LORRN,0)),U,24)<5) S COMDISM=COMDISM+1
85FRETMOD I +SPNDCM&(+LORRN)&(+TFURN) S TFU=$$GET1^DIQ(154.1,TFURN,999.05),TFF=$$GET1^DIQ(154.1,LORRN,999.05),TFUCUMM=TFUCUMM+(TFU-TFF),TFUCM=TFUCM+1
86SLMOD I +SPNDCM&(+SLSRN)&(+SLFRN) S SLS=$P($G(^SPNL(154.1,SLSRN,"SCORE")),U,1),SLF=$P($G(^SPNL(154.1,SLFRN,"SCORE")),U,1),SLCUMM=SLCUMM+(SLF-SLS),SLCM=SLCM+1
87SLUMOD I +SPNDCM&(+SLFRN)&(+SLURN) S SLU=$P($G(^SPNL(154.1,SLURN,"SCORE")),U,1),SLF=$P($G(^SPNL(154.1,SLFRN,"SCORE")),U,1),SLUCUMM=SLUCUMM+(SLU-SLF),SLUCM=SLUCM+1
88 I +SPNDCP D STATS I +LORRN S SPNLORP=SPNLORP+$$GET1^DIQ(154.1,LORRN,999.08),LORPC=LORPC+1 S:LORPC=1 BMLP=$$GET1^DIQ(154.1,LORRN,999.08) S MINLORP=$S($$GET1^DIQ(154.1,LORRN,999.08)<BMLP:$$GET1^DIQ(154.1,LORRN,999.08),1:BMLP)
89 I +SPNDCP S:LORPC=1 BHLP=$$GET1^DIQ(154.1,LORRN,999.08) S MAXLORP=$S($$GET1^DIQ(154.1,LORRN,999.08)>BHLP:$$GET1^DIQ(154.1,LORRN,999.08),1:BHLP)
90 I +SPNDCP&(+LORRN)&(+TFSRN) S TFS=$$GET1^DIQ(154.1,TFSRN,999.05),TFF=$$GET1^DIQ(154.1,LORRN,999.05),TFCUMP=TFCUMP+(TFF-TFS),TFCP=TFCP+1
91 I +SPNDCP&(+LORRN)&(+TFGRN) S TFG=$$GET1^DIQ(154.1,TFGRN,999.05),TFF=$$GET1^DIQ(154.1,LORRN,999.05),TFGCUMP=TFGCUMP+(TFF-TFG),TFGCP=TFGCP+1
92CDPARA I +SPNDCP&(+LORRN)&($P($G(^SPNL(154.1,LORRN,0)),U,24)<5) S COMDISP=COMDISP+1
93FRETPAR I +SPNDCP&(+LORRN)&(+TFURN) S TFU=$$GET1^DIQ(154.1,TFURN,999.05),TFF=$$GET1^DIQ(154.1,LORRN,999.05),TFUCUMP=TFUCUMP+(TFU-TFF),TFUCP=TFUCP+1
94SLPAR I +SPNDCP&(+SLSRN)&(+SLFRN) S SLS=$P($G(^SPNL(154.1,SLSRN,"SCORE")),U,1),SLF=$P($G(^SPNL(154.1,SLFRN,"SCORE")),U,1),SLCUMP=SLCUMP+(SLF-SLS),SLCP=SLCP+1
95SLUPAR I +SPNDCP&(+SLFRN)&(+SLURN) S SLU=$P($G(^SPNL(154.1,SLURN,"SCORE")),U,1),SLF=$P($G(^SPNL(154.1,SLFRN,"SCORE")),U,1),SLUCUMP=SLUCUMP+(SLU-SLF),SLUCP=SLUCP+1
96 I +SPNDCL D STATS I +LORRN S SPNLORL=SPNLORL+$$GET1^DIQ(154.1,LORRN,999.08),LORLC=LORLC+1 S:LORLC=1 BMLL=$$GET1^DIQ(154.1,LORRN,999.08) S MINLORL=$S($$GET1^DIQ(154.1,LORRN,999.08)<BMLL:$$GET1^DIQ(154.1,LORRN,999.08),1:BMLL)
97 I +SPNDCL S:LORLC=1 BHLL=$$GET1^DIQ(154.1,LORRN,999.08) S MAXLORL=$S($$GET1^DIQ(154.1,LORRN,999.08)>BHLL:$$GET1^DIQ(154.1,LORRN,999.08),1:BHLL)
98 I +SPNDCL&(+LORRN)&(+TFSRN) S TFS=$$GET1^DIQ(154.1,TFSRN,999.05),TFF=$$GET1^DIQ(154.1,LORRN,999.05),TFCUML=TFCUML+(TFF-TFS),TFCL=TFCL+1
99 I +SPNDCL&(+LORRN)&(+TFGRN) S TFG=$$GET1^DIQ(154.1,TFGRN,999.05),TFF=$$GET1^DIQ(154.1,LORRN,999.05),TFGCUML=TFGCUML+(TFF-TFG),TFGCL=TFGCL+1
100CDLOW I +SPNDCL&(+LORRN)&($P($G(^SPNL(154.1,LORRN,0)),U,24)<5) S COMDISL=COMDISL+1
101FRETLOW I +SPNDCL&(+LORRN)&(+TFURN) S TFU=$$GET1^DIQ(154.1,TFURN,999.05),TFF=$$GET1^DIQ(154.1,LORRN,999.05),TFUCUML=TFUCUML+(TFU-TFF),TFUCL=TFUCL+1
102SLLOW I +SPNDCL&(+SLSRN)&(+SLFRN) S SLS=$P($G(^SPNL(154.1,SLSRN,"SCORE")),U,1),SLF=$P($G(^SPNL(154.1,SLFRN,"SCORE")),U,1),SLCUML=SLCUML+(SLF-SLS),SLCL=SLCL+1
103SLULOW I +SPNDCL&(+SLFRN)&(+SLURN) S SLU=$P($G(^SPNL(154.1,SLURN,"SCORE")),U,1),SLF=$P($G(^SPNL(154.1,SLFRN,"SCORE")),U,1),SLUCUML=SLUCUML+(SLU-SLF),SLUCL=SLUCL+1
104 S LORL=$S((MINLORS<MINLORM)&(MINLORS<MINLORP)&(MINLORS<MINLORL):MINLORS,(MINLORM<MINLORP)&(MINLORM<MINLORL):MINLORM,MINLORP<MINLORL:MINLORP,1:MINLORL)
105 S LORH=$S((MAXLORS>MAXLORM)&(MAXLORS>MAXLORP)&(MAXLORS>MAXLORL):MAXLORS,(MAXLORM>MAXLORP)&(MAXLORM>MAXLORL):MAXLORM,MAXLORP>MAXLORL:MAXLORP,1:MAXLORL)
106 Q
107 ;
108STATS ;finds record with Rehab Finish
109 S LORRN=0,TFSRN=0,TFGRN=0,TFURN=0,SLSRN=0,SLFRN=0,SLURN=0
110 S V=SPNPD1 F S V=$O(^SPNL(154.1,"B",SPNPD0,V)) Q:'+V D GETLOR
111 Q
112GETLOR ;get Rec No. for LOR,TFS (TFF is same RN as LOR),TFU,TFG,SLS,SLF,SLU
113 Q:'$D(^SPNL(154.1,V,0))
114 Q:'+$P($G(^SPNL(154.1,V,2)),U,17)
115 Q:$P($G(^SPNL(154.1,V,8)),U,3)'=CARETYP
116 Q:$P($G(^SPNL(154.1,V,8)),U,2)<BDATE!($P($G(^SPNL(154.1,V,8)),U,2)>EDATE)
117 I $P(^SPNL(154.1,V,2),U,17)=6,($P(^SPNL(154.1,V,0),U,2)=2) S TFSRN=V
118 I $P(^SPNL(154.1,V,2),U,17)=7,($P(^SPNL(154.1,V,0),U,2)=2) S TFGRN=V
119 I $P(^SPNL(154.1,V,2),U,17)=10,($P(^SPNL(154.1,V,0),U,2)=2) S TFURN=V
120 I $P(^SPNL(154.1,V,2),U,17)=6,($P(^SPNL(154.1,V,0),U,2)=6) S SLSRN=V
121 I $P(^SPNL(154.1,V,2),U,17)=9,($P(^SPNL(154.1,V,0),U,2)=6) S SLFRN=V
122 I $P(^SPNL(154.1,V,2),U,17)=10,($P(^SPNL(154.1,V,0),U,2)=6) S SLURN=V
123 I $P($G(^SPNL(154.1,V,8)),U,2)'="",($P(^SPNL(154.1,V,2),U,17)=9) S LORRN=V
124 Q
125EXIT ;
126 D EXIT^SPNAGGU
127 Q
Note: See TracBrowser for help on using the repository browser.