211 lines
9.6 KiB
Mathematica
211 lines
9.6 KiB
Mathematica
SPNAGGC ;SD/CM- AGGREGATE CONT OF CARE OUTCOMES REPORT; 9-17-2003
|
|
;;2.0;Spinal Cord Dysfunction;**20,21**;01/02/97
|
|
;
|
|
EN ;
|
|
S U="^"
|
|
D INPT^SPNAGGU
|
|
S (LDATE,TDATE,LORCALL,MAX1,MAX2)=0
|
|
PARAMS ;
|
|
D CED
|
|
G:SPNLEXIT=1 EXIT
|
|
DEVICE ;
|
|
S ZTSAVE("SPN*")="",ZTSAVE("B*")="",ZTSAVE("AGE*")="",ZTSAVE("MIN*")=""
|
|
S ZTSAVE("MAX*")="",ZTSAVE("LOR*")="",ZTSAVE("TF*")="",ZTSAVE("SEX*")=""
|
|
S ZTSAVE("SL*")="",ZTSAVE("COMD*")="",ZTSAVE("CARETYP")=""
|
|
S ZTSAVE("EDATE")="",ZTSAVE("BDATE")="",ZTSAVE("LINE")="",ZTSAVE("I")=""
|
|
S ZTSAVE("ASIA*")="",ZTSAVE("LDATE")="",ZTSAVE("TDATE")=""
|
|
W !
|
|
D DEVICE^SPNPRTMT("PRINT^SPNAGGPC","Continuum of Care Outcomes",.ZTSAVE) Q:SPNLEXIT
|
|
I SPNIO="Q" D EXIT Q ; Print was queued
|
|
I IO'="" D PRINT^SPNAGGPC D EXIT Q ; Print not queued
|
|
D EXIT
|
|
Q
|
|
CED ;
|
|
D DATE^SPNAGGA
|
|
Q
|
|
OIEN ;
|
|
S SPNPD1=0 F S SPNPD1=$O(^SPNL(154.1,"B",SPNPD0,SPNPD1)) Q:'+SPNPD1 D DIAGCAT
|
|
Q
|
|
DIAGCAT ;
|
|
S SPNDCS=0,SPNDCM=0,SPNDCP=0,SPNDCL=0
|
|
Q:'$D(^SPNL(154.1,SPNPD1,0))
|
|
Q:'$D(^SPNL(154.1,SPNPD1,"ASIA"))
|
|
Q:'$D(^SPNL(154.1,SPNPD1,8))
|
|
Q:$P(^SPNL(154.1,SPNPD1,0),U,2)'=3
|
|
Q:$P(^SPNL(154.1,SPNPD1,8),U,3)'=CARETYP
|
|
Q:$P($G(^SPNL(154.1,SPNPD1,0)),U,4)<BDATE!($P($G(^SPNL(154.1,SPNPD1,0)),U,4)>EDATE)
|
|
Q:$P($G(^SPNL(154.1,SPNPD1,0)),U,1)=SPNNODUP
|
|
S SPNNODUP=$P($G(^SPNL(154.1,SPNPD1,0)),U,1)
|
|
S ASIAONE=$P($G(^SPNL(154.1,SPNPD1,"ASIA")),U,1),ASIAFRTN=$P($G(^SPNL(154.1,SPNPD1,"ASIA")),U,14)
|
|
I "ABC"[ASIAONE,ASIAFRTN<5 S SPNDCS=1
|
|
I "ABC"[ASIAONE,ASIAFRTN<5 S SPNLSTDT="S"
|
|
I "ABC"[ASIAONE&(ASIAFRTN>4)&(ASIAFRTN<9) S SPNDCM=1
|
|
I "ABC"[ASIAONE&(ASIAFRTN>4)&(ASIAFRTN<9) S SPNLSTDT="M"
|
|
I "ABC"[ASIAONE,ASIAFRTN>8 S SPNDCP=1
|
|
I "ABC"[ASIAONE,ASIAFRTN>8 S SPNLSTDT="P"
|
|
I ASIAONE="D",ASIAFRTN<31 S SPNDCL=1
|
|
I ASIAONE="D",ASIAFRTN<31 S SPNLSTDT="L"
|
|
I SPNLSTDT="S" S SPNSEVC=SPNSEVC+1
|
|
I SPNLSTDT="M" S SPNMODC=SPNMODC+1
|
|
I SPNLSTDT="P" S SPNPARC=SPNPARC+1
|
|
I SPNLSTDT="L" S SPNLOWC=SPNLOWC+1
|
|
S SPNDIAGC=SPNDIAGC+1
|
|
;
|
|
AGE ;
|
|
S AGECALL=$$GET1^DIQ(154.1,SPNPD1,999.025)
|
|
I +SPNDCS S SPNAGES=SPNAGES+AGECALL,AGESC=AGESC+1 S:AGESC=1 BMAS=AGECALL S MINAGES=$S(AGECALL<BMAS:AGECALL,1:BMAS)
|
|
I +SPNDCS S:AGESC=1 BHAS=AGECALL S MAXAGES=$S(AGECALL>BHAS:AGECALL,1:BHAS)
|
|
I +SPNDCM S SPNAGEM=SPNAGEM+AGECALL,AGEMC=AGEMC+1 S:AGEMC=1 BMAM=AGECALL S MINAGEM=$S(AGECALL<BMAM:AGECALL,1:BMAM)
|
|
I +SPNDCM S:AGEMC=1 BHAM=AGECALL S MAXAGEM=$S(AGECALL>BHAM:AGECALL,1:BHAM)
|
|
I +SPNDCP S SPNAGEP=SPNAGEP+AGECALL,AGEPC=AGEPC+1 S:AGEPC=1 BMAP=AGECALL S MINAGEP=$S(AGECALL<BMAP:AGECALL,1:BMAP)
|
|
I +SPNDCP S:AGEPC=1 BHAP=AGECALL S MAXAGEP=$S(AGECALL>BHAP:AGECALL,1:BHAP)
|
|
I +SPNDCL S SPNAGEL=SPNAGEL+AGECALL,AGELC=AGELC+1 S:AGELC=1 BMAL=AGECALL S MINAGEL=$S(AGECALL<BMAL:AGECALL,1:BMAL)
|
|
I +SPNDCL S:AGELC=1 BHAL=AGECALL S MAXAGEL=$S(AGECALL>BHAL:AGECALL,1:BHAL)
|
|
S AGEL=$S((MINAGES<MINAGEM)&(MINAGES<MINAGEP)&(MINAGES<MINAGEL):MINAGES,(MINAGEM<MINAGEP)&(MINAGEM<MINAGEL):MINAGEM,MINAGEP<MINAGEL:MINAGEP,1:MINAGEL)
|
|
S AGEH=$S((MAXAGES>MAXAGEM)&(MAXAGES>MAXAGEP)&(MAXAGES>MAXAGEL):MAXAGES,(MAXAGEM>MAXAGEP)&(MAXAGEM>MAXAGEL):MAXAGEM,MAXAGEP>MAXAGEL:MAXAGEP,1:MAXAGEL)
|
|
;
|
|
SEX ;
|
|
S SEXCALL=$P(^DPT($P(^SPNL(154.1,SPNPD1,0),U,1),0),U,2)
|
|
I +SPNDCS,SEXCALL="M" S SPNSEXS=SPNSEXS+1
|
|
I +SPNDCM,SEXCALL="M" S SPNSEXM=SPNSEXM+1
|
|
I +SPNDCP,SEXCALL="M" S SPNSEXP=SPNSEXP+1
|
|
I +SPNDCL,SEXCALL="M" S SPNSEXL=SPNSEXL+1
|
|
LOR ;
|
|
I +SPNDCS D STATS I +LORRN S SPNLORS=SPNLORS+LORCALL,LORSC=LORSC+1
|
|
I +SPNDCS S ^TMP($J,"SPNLSNS",SPNPD1)=LORCALL S MINLORS=$$MINLOS(SPNPD1)
|
|
I +SPNDCS S ^TMP($J,"SPNLSXS",SPNPD1)=LORCALL S MAXLORS=$$MAXLOS(SPNPD1)
|
|
I +SPNDCS&(+LORRN)&(+TFSRN) S TFS=TFSCALL,TFF=LOR5CALL,TFCUMS=TFCUMS+(TFF-TFS),TFCS=TFCS+1
|
|
I +SPNDCS&(+LORRN)&(+TFGRN) S TFG=TFGCALL,TFF=LOR5CALL,TFGCUMS=TFGCUMS+(TFF-TFG),TFGCS=TFGCS+1
|
|
CDSEV I +SPNDCS&(+LORRN)&($P($G(^SPNL(154.1,LORRN,0)),U,24)<5) S COMDISS=COMDISS+1
|
|
FRETSEV I +SPNDCS&(+LORRN)&(+TFURN) S TFU=TFUCALL,TFF=LOR5CALL,TFUCUMS=TFUCUMS+(TFU-TFF),TFUCS=TFUCS+1
|
|
SLSEV I +SPNDCS&(+SLSRN)&(+SLFRN) S SLS=SLSCALL,SLF=SLFCALL,SLCUMS=SLCUMS+(SLF-SLS),SLCS=SLCS+1
|
|
SLUSEV I +SPNDCS&(+SLFRN)&(+SLURN) S SLU=SLUCALL,SLF=SLFCALL,SLUCUMS=SLUCUMS+(SLU-SLF),SLUCS=SLUCS+1
|
|
I +SPNDCM D STATS I +LORRN S SPNLORM=SPNLORM+LORCALL,LORMC=LORMC+1
|
|
I +SPNDCM S ^TMP($J,"SPNLSNM",SPNPD1)=LORCALL S MINLORM=$$MINLOM(SPNPD1)
|
|
I +SPNDCM S ^TMP($J,"SPNLSXM",SPNPD1)=LORCALL S MAXLORM=$$MAXLOM(SPNPD1)
|
|
I +SPNDCM&(+LORRN)&(+TFSRN) S TFS=TFSCALL,TFF=LOR5CALL,TFCUMM=TFCUMM+(TFF-TFS),TFCM=TFCM+1
|
|
I +SPNDCM&(+LORRN)&(+TFGRN) S TFG=TFGCALL,TFF=LOR5CALL,TFGCUMM=TFGCUMM+(TFF-TFG),TFGCM=TFGCM+1
|
|
CDMOD I +SPNDCM&(+LORRN)&($P($G(^SPNL(154.1,LORRN,0)),U,24)<5) S COMDISM=COMDISM+1
|
|
FRETMOD I +SPNDCM&(+LORRN)&(+TFURN) S TFU=TFUCALL,TFF=LOR5CALL,TFUCUMM=TFUCUMM+(TFU-TFF),TFUCM=TFUCM+1
|
|
SLMOD I +SPNDCM&(+SLSRN)&(+SLFRN) S SLS=SLSCALL,SLF=SLFCALL,SLCUMM=SLCUMM+(SLF-SLS),SLCM=SLCM+1
|
|
SLUMOD I +SPNDCM&(+SLFRN)&(+SLURN) S SLU=SLUCALL,SLF=SLFCALL,SLUCUMM=SLUCUMM+(SLU-SLF),SLUCM=SLUCM+1
|
|
I +SPNDCP D STATS I +LORRN S SPNLORP=SPNLORP+LORCALL,LORPC=LORPC+1
|
|
I +SPNDCP S ^TMP($J,"SPNLSNP",SPNPD1)=LORCALL S MINLORP=$$MINLOP(SPNPD1)
|
|
I +SPNDCP S ^TMP($J,"SPNLSXP",SPNPD1)=LORCALL S MAXLORP=$$MAXLOP(SPNPD1)
|
|
I +SPNDCP&(+LORRN)&(+TFSRN) S TFS=TFSCALL,TFF=LOR5CALL,TFCUMP=TFCUMP+(TFF-TFS),TFCP=TFCP+1
|
|
I +SPNDCP&(+LORRN)&(+TFGRN) S TFG=TFGCALL,TFF=LOR5CALL,TFGCUMP=TFGCUMP+(TFF-TFG),TFGCP=TFGCP+1
|
|
CDPARA I +SPNDCP&(+LORRN)&($P($G(^SPNL(154.1,LORRN,0)),U,24)<5) S COMDISP=COMDISP+1
|
|
FRETPAR I +SPNDCP&(+LORRN)&(+TFURN) S TFU=TFUCALL,TFF=LOR5CALL,TFUCUMP=TFUCUMP+(TFU-TFF),TFUCP=TFUCP+1
|
|
SLPAR I +SPNDCP&(+SLSRN)&(+SLFRN) S SLS=SLSCALL,SLF=SLFCALL,SLCUMP=SLCUMP+(SLF-SLS),SLCP=SLCP+1
|
|
SLUPAR I +SPNDCP&(+SLFRN)&(+SLURN) S SLU=SLUCALL,SLF=SLFCALL,SLUCUMP=SLUCUMP+(SLU-SLF),SLUCP=SLUCP+1
|
|
I +SPNDCL D STATS I +LORRN S SPNLORL=SPNLORL+LORCALL,LORLC=LORLC+1
|
|
I +SPNDCL S ^TMP($J,"SPNLSNL",SPNPD1)=LORCALL S MINLORL=$$MINLOL(SPNPD1)
|
|
I +SPNDCL S ^TMP($J,"SPNLSXL",SPNPD1)=LORCALL S MAXLORL=$$MAXLOL(SPNPD1)
|
|
I +SPNDCL&(+LORRN)&(+TFSRN) S TFS=TFSCALL,TFF=LOR5CALL,TFCUML=TFCUML+(TFF-TFS),TFCL=TFCL+1
|
|
I +SPNDCL&(+LORRN)&(+TFGRN) S TFG=TFGCALL,TFF=LOR5CALL,TFGCUML=TFGCUML+(TFF-TFG),TFGCL=TFGCL+1
|
|
CDLOW I +SPNDCL&(+LORRN)&($P($G(^SPNL(154.1,LORRN,0)),U,24)<5) S COMDISL=COMDISL+1
|
|
FRETLOW I +SPNDCL&(+LORRN)&(+TFURN) S TFU=TFUCALL,TFF=LOR5CALL,TFUCUML=TFUCUML+(TFU-TFF),TFUCL=TFUCL+1
|
|
SLLOW I +SPNDCL&(+SLSRN)&(+SLFRN) S SLS=SLSCALL,SLF=SLFCALL,SLCUML=SLCUML+(SLF-SLS),SLCL=SLCL+1
|
|
SLULOW I +SPNDCL&(+SLFRN)&(+SLURN) S SLU=SLUCALL,SLF=SLFCALL,SLUCUML=SLUCUML+(SLU-SLF),SLUCL=SLUCL+1
|
|
S LORL=$S((MINLORS<MINLORM)&(MINLORS<MINLORP)&(MINLORS<MINLORL):MINLORS,(MINLORM<MINLORP)&(MINLORM<MINLORL):MINLORM,MINLORP<MINLORL:MINLORP,1:MINLORL)
|
|
S LORH=$S((MAXLORS>MAXLORM)&(MAXLORS>MAXLORP)&(MAXLORS>MAXLORL):MAXLORS,(MAXLORM>MAXLORP)&(MAXLORM>MAXLORL):MAXLORM,MAXLORP>MAXLORL:MAXLORP,1:MAXLORL)
|
|
Q
|
|
;
|
|
STATS ;
|
|
S LORRN=0,TFSRN=0,TFGRN=0,TFURN=0,SLSRN=0,SLFRN=0,SLURN=0,LDATE=0,TDATE=0,LORCALL=0
|
|
S V=SPNPD1 F S V=$O(^SPNL(154.1,"B",SPNPD0,V)) Q:'+V D GETLOR
|
|
S LDATE=$P($G(^SPNL(154.1,LORRN,0)),U,4),TDATE=$P($G(^SPNL(154.1,TFSRN,0)),U,4)
|
|
I +LDATE,(+TDATE) S LORCALL=$$FMDIFF^XLFDT(LDATE,TDATE)
|
|
S LOR5CALL=$$GET1^DIQ(154.1,LORRN,999.05)
|
|
S TFSCALL=$$GET1^DIQ(154.1,TFSRN,999.05)
|
|
S TFGCALL=$$GET1^DIQ(154.1,TFGRN,999.05)
|
|
S TFUCALL=$$GET1^DIQ(154.1,TFURN,999.05)
|
|
S SLSCALL=$P($G(^SPNL(154.1,SLSRN,"SCORE")),U,1)
|
|
S SLFCALL=$P($G(^SPNL(154.1,SLFRN,"SCORE")),U,1)
|
|
S SLUCALL=$P($G(^SPNL(154.1,SLURN,"SCORE")),U,1)
|
|
Q
|
|
GETLOR ;get Rec No. for LOR,TFS (TFF same RN as LOR), etc
|
|
;LORRN is ~TFDRN
|
|
Q:'$D(^SPNL(154.1,V,0))
|
|
Q:'+$P($G(^SPNL(154.1,V,2)),U,17)
|
|
Q:$P($G(^SPNL(154.1,V,8)),U,3)'=CARETYP
|
|
Q:$P($G(^SPNL(154.1,V,0)),U,4)<BDATE!($P($G(^SPNL(154.1,V,0)),U,4)>EDATE)
|
|
I $P(^SPNL(154.1,V,2),U,17)=12,($P(^SPNL(154.1,V,0),U,2)=2) S TFSRN=V
|
|
I $P(^SPNL(154.1,V,2),U,17)=13,($P(^SPNL(154.1,V,0),U,2)=2) S TFGRN=V
|
|
I $P(^SPNL(154.1,V,2),U,17)=15,($P(^SPNL(154.1,V,0),U,2)=2) S LORRN=V
|
|
I $P(^SPNL(154.1,V,2),U,17)=16,($P(^SPNL(154.1,V,0),U,2)=2) S TFURN=V
|
|
I $P(^SPNL(154.1,V,2),U,17)=12,($P(^SPNL(154.1,V,0),U,2)=6) S SLSRN=V
|
|
I $P(^SPNL(154.1,V,2),U,17)=15,($P(^SPNL(154.1,V,0),U,2)=6) S SLFRN=V
|
|
I $P(^SPNL(154.1,V,2),U,17)=16,($P(^SPNL(154.1,V,0),U,2)=6) S SLURN=V
|
|
Q
|
|
MAXLOS(SPNPD1) ;
|
|
S MAX1=0
|
|
S X=0 F S X=$O(^TMP($J,"SPNLSXS",X)) Q:'+X D
|
|
.Q:'$D(^TMP($J,"SPNLSXS",X))
|
|
.S MAX2=$P(^TMP($J,"SPNLSXS",X),U,1)
|
|
.I MAX2>MAX1 S MAX1=MAX2
|
|
.Q
|
|
Q MAX1
|
|
MAXLOM(SPNPD1) ;
|
|
S MAX1=0
|
|
S X=0 F S X=$O(^TMP($J,"SPNLSXM",X)) Q:'+X D
|
|
.Q:'$D(^TMP($J,"SPNLSXM",X))
|
|
.S MAX2=$P(^TMP($J,"SPNLSXM",X),U,1)
|
|
.I MAX2>MAX1 S MAX1=MAX2
|
|
.Q
|
|
Q MAX1
|
|
MAXLOP(SPNPD1) ;
|
|
S MAX1=0
|
|
S X=0 F S X=$O(^TMP($J,"SPNLSXP",X)) Q:'+X D
|
|
.Q:'$D(^TMP($J,"SPNLSXP",X))
|
|
.S MAX2=$P(^TMP($J,"SPNLSXP",X),U,1)
|
|
.I MAX2>MAX1 S MAX1=MAX2
|
|
.Q
|
|
Q MAX1
|
|
MAXLOL(SPNPD1) ;
|
|
S MAX1=0
|
|
S X=0 F S X=$O(^TMP($J,"SPNLSXL",X)) Q:'+X D
|
|
.Q:'$D(^TMP($J,"SPNLSXL",X))
|
|
.S MAX2=$P(^TMP($J,"SPNLSXL",X),U,1)
|
|
.I MAX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