VistA-WorldVistAEHR/r/SPINAL_CORD_DYSFUNCTION-SPN/SPNLS1.m

47 lines
2.2 KiB
Mathematica
Raw Permalink Normal View History

2009-11-29 13:37:14 -05:00
SPNLS1 ;ISCSF/RAH - Continuation Parts from SPNLS ;9/27/95 11:00
;;2.0;Spinal Cord Dysfunction;;01/02/1997
FINLUPD ;
S (SPNLPID,SPNLPID(0))=0,SPNLCT=0
F S SPNLPID=$O(^TMP("SPNLS",$J,SPNLPID)) Q:SPNLPID'>0 D
.S SPNLPTX=^TMP("SPNLS",$J,SPNLPID)
.S SPNLFDT=$P(SPNLPTX,U,2)
.S SPNLTDT=$P(SPNLPTX,U,3),SPNLCT=SPNLCT+1
.S DIE="^SPNL(154.9,",DR="1////^S X=SPNLFDT;2////^S X=SPNLTDT"
.S DA=SPNLPID D ^DIE K DIE
.S SPNLPID(0)=SPNLPID
K %,X D NOW^%DTC S SPNLT=%,$P(SPNLNODE,U,8,9)=SPNLT_"^"_SPNLCT K %,X
S $P(SPNLNODE,U,8,9)=SPNLSDT_U_SPNLCT
S DIE="^SPNL(154.93,",DA=SPNLTMP
S DR="2///^S X=SPNLT;4///^S X=SPNLCT;5///^S X=SPNLTYPE;6///^S X=SPNXRECS;7///^S X=SPNXRUN;9////^S X=SPNLPID(0)"
D ^DIE K DIE
I SPNLFULL D
.S $P(SPNLNODE,U,5)=SPNLT
.S DIE="^SPNL(154.93,",DA=SPNLTMP S DR="9////0" D ^DIE K Y,X,DIE,DR
.S SPNLHST=^SPNL(154.93,SPNLTMP,0)
.F SPNLX=1:1:10 S SPNL(SPNLX)=$P(SPNLHST,U,SPNLX)
.S $P(SPNLHST,U,1)=$P(SPNLHST,U,1)+1,SPNLHIEN=$P(SPNLHST,U,1)
.K DD,DIC,DINUM,DO S DIC(0)="LMN",DIC="^SPNL(154.94,",X=SPNLTMP,DINUM=SPNLTMP,DLAYGO=154.94 D FILE^DICN K DIC,Y,X
.S SPNLDR="" F SPNLX=1:1:9 S SPNLDR=SPNLDR_SPNL(SPNLX)_"^"
.S SPNLDR=$E(SPNLDR,1,$L(SPNLDR)-1) S ^SPNL(154.94,SPNLTMP,0)=SPNLDR
.K DD,DIC,DINUM,DO S DIC(0)="LMN",DIC="^SPNL(154.93,",X=SPNLHIEN,DINUM=SPNLHIEN,DLAYGO=154.93 D FILE^DICN K DIC
.S $P(SPNLHST,U,2)=SPNLT,$P(SPNLHST,U,3)="" S ^SPNL(154.93,SPNLHIEN,0)=SPNLHST
.S DA=SPNLTMP,DIK="^SPNL(154.93," D ^DIK K DIK,DA
D FINISHUP^SPNLGE(SPNLNODE)
; fall thru
RESCHED ;
Q S SPNLRRUN=$E($P(SPNLSTRT,".",2),1,4)
S SPNLTIME=$S($E(SPNLFREQ,$L(SPNLFREQ))="W":SPNLFREQ*7,$E(SPNLFREQ,$L(SPNLFREQ))="D":SPNLFREQ,1:1)
S SPNLYRS=$E(SPNLSDT,1,3),SPNLMOS=+$E(SPNLSDT,4,5),SPNLDYS=$E(SPNLSDT,6,7),SPNLDYS=SPNLTIME+SPNLDYS
I SPNLDYS>30 D
.F S SPNLDYS=SPNLDYS-30,SPNLMOS=SPNLMOS+1 Q:SPNLDYS'>30
.I SPNLMOS#12=2&(SPNLDYS>28) S SPNLDYS=28
I SPNLMOS>12 D
.F S SPNLMOS=SPNLMOS-12,SPNLYRS=SPNLYRS+1 Q:SPNLMOS'>12
S:SPNLMOS<10 SPNLMOS="0"_SPNLMOS S:SPNLDYS<10 SPNLDYS="0"_SPNLDYS
S ZTDTH=SPNLYRS_SPNLMOS_SPNLDYS_"."_SPNLRRUN,ZTIO=""
S ZTRTN="SPNLS",ZTDESC="SCD SPINAL CORD REGISTRY EXTRACT"
D ^%ZTLOAD
I '$D(ZTSK) S SPNLERR="6 COULD NOT (RE)TASK SCD EXTRACT" D ERRMSG^SPNLS
K SPNLDYS
Q