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

85 lines
3.6 KiB
Mathematica

SPNPSR15 ;HIRMFO/DAD,WAA-HUNT: CHANGE IN TOTAL FIM SCORE ;9/22/95 12:35
;;2.0;Spinal Cord Dysfunction;**11,19**;01/02/1997
;
EN1(D0,FIMTYPE,BDELTA,EDELTA,BDATE,EDATE) ; *** Search entry point
; Input:
; ACTION,SEQUENCE = Search ACTION,SEQUENCE number
; D0 = SCD (SPINAL CORD) REGISTRY file (#154) IEN
; ^TMP($J,"SPNPRT",ACTION,SEQUENCE,"RECORD TYPE") = 1 ! 2 ^ External
; ^TMP($J,"SPNPRT",ACTION,SEQUENCE,"BEGINNING DELTA VALUE") = # ^ #
; ^TMP($J,"SPNPRT",ACTION,SEQUENCE,"ENDING DELTA VALUE") = # ^ #
; ^TMP($J,"SPNPRT",ACTION,SEQUENCE,"BEGINNING DATE") = Date ^ Date_(Ext)
; ^TMP($J,"SPNPRT",ACTION,SEQUENCE,"ENDING DATE") = Date ^ Date_(Ext)
; FIMTYPE = Patient FIM Type
; BDELTA = Beginning Delta Value
; EDELTA = Ending Delta Value
; BDATE = Beginning Date
; EDATE = Ending Date
; Output:
; $S( D0_Meets_Search_Criteria : 1 , 1 : 0 )
;
N DELTAFIM,DFN,FIMDIFF,I,LASTFIM,MEETSRCH,TOTALFIM
S MEETSRCH=0
S DELTAFIM("BEGINNING DELTA VALUE")=BDELTA
S DELTAFIM("ENDING DELTA VALUE")=EDELTA
S RECDATE("BEGINNING DATE")=BDATE
S RECDATE("ENDING DATE")=EDATE
S SPNLDATE=RECDATE("BEGINNING DATE")-.0000001 K LASTFIM
S LASTFIM=0
F S SPNLDATE=$O(^SPNL(154.1,"AA",FIMTYPE,D0,SPNLDATE)) Q:(SPNLDATE'>0)!(SPNLDATE>RECDATE("ENDING DATE"))!MEETSRCH D
. S SPNLD0=0,SPNLD0=$O(^SPNL(154.1,"AA",FIMTYPE,D0,SPNLDATE,SPNLD0)) Q:SPNLD0'>0!MEETSRCH D
.. S TOTALFIM=+$$EN3^SPNFUTL0(SPNLD0)
.. I (TOTALFIM'>0) Q
.. S FIMDIFF=TOTALFIM-LASTFIM
.. I FIMDIFF'<DELTAFIM("BEGINNING DELTA VALUE"),FIMDIFF'>DELTAFIM("ENDING DELTA VALUE") S MEETSRCH=1
.. S LASTFIM=TOTALFIM
.. Q
. Q
Q MEETSRCH
;
EN2(ACTION,SEQUENCE) ; *** Prompt entry point
; Input:
; ACTION,SEQUENCE = Search ACTION,SEQUENCE number
; Output:
; SPNLEXIT = $S( User_Abort/Timeout : 1 , 1 : 0 )
; ^TMP($J,"SPNPRT",ACTION,SEQUENCE,"RECORD TYPE") = 1 ! 2 ^ External
; ^TMP($J,"SPNPRT",ACTION,SEQUENCE,"BEGINNING DELTA VALUE") = # ^ #
; ^TMP($J,"SPNPRT",ACTION,SEQUENCE,"ENDING DELTA VALUE") = # ^ #
; ^TMP($J,"SPNPRT",ACTION,SEQUENCE,"BEGINNING DATE") = Date ^ Date_(Ext)
; ^TMP($J,"SPNPRT",ACTION,SEQUENCE,"ENDING DATE") = Date ^ Date_(Ext)
; ^TMP($J,"SPNPRT",ACTION,SEQUENCE,0) = $$EN1^SPNPSR15(D0,FIMTYPE,BDELTA,EDELTA,BDATE,EDATE)
;
N DELTAFIM,DIR,DIRUT,DTOUT,DUOUT,FIMTYPE,I
K ^TMP($J,"SPNPRT",ACTION,SEQUENCE)
K DIR S DIR(0)="SOAM^1:Self Report of Function;2:FIM;"
S DIR("A")="Record Type: "
S DIR("?")="Enter 1 for Self Report of Function, or 2 for FIM"
D ^DIR S FIMTYPE=Y,FIMTYPE(0)=$G(Y(0))
S SPNLEXIT=$S($D(DTOUT):1,$D(DUOUT):1,1:0)
Q:SPNLEXIT
Q:Y=""
S DELTAFIM=$S(FIMTYPE=1:39,1:108)
K DIR S DIR(0)="NOA^"_-DELTAFIM_":"_DELTAFIM
S DIR("A")="Beginning delta value: "
S DIR("?")="Enter a number from "_-DELTAFIM_" to "_DELTAFIM
D ^DIR S (DELTAFIM("BEGINNING DELTA VALUE"),BDELTA)=Y
S SPNLEXIT=$S($D(DTOUT):1,$D(DUOUT):1,1:0)
Q:SPNLEXIT
Q:Y=""
K DIR S DIR(0)="NOA^"_DELTAFIM("BEGINNING DELTA VALUE")_":"_DELTAFIM
S DIR("A")="Ending delta value: "
S DIR("?")="Enter a number from "_DELTAFIM("BEGINNING DELTA VALUE")_" to "_DELTAFIM
D ^DIR S (DELTAFIM("ENDING DELTA VALUE"),EDELTA)=Y
S SPNLEXIT=$S($D(DTOUT):1,$D(DUOUT):1,1:0)
Q:SPNLEXIT
Q:Y=""
S (BDATE,EDATE)=""
D EN1^SPNPSR00(ACTION,SEQUENCE+.2,.BDATE,.EDATE) Q:SPNLEXIT
S ^TMP($J,"SPNPRT",ACTION,SEQUENCE,"RECORD TYPE")=FIMTYPE_U_FIMTYPE(0)
F I="BEGINNING DELTA VALUE","ENDING DELTA VALUE" D
. S ^TMP($J,"SPNPRT",ACTION,SEQUENCE+.1,I)=$G(DELTAFIM(I))_U_$G(DELTAFIM(I))
. Q
I BDATE=""!(EDATE="") K ^TMP($J,"SPNPRT",ACTION,SEQUENCE+.1),^TMP($J,"SPNPRT",ACTION,SEQUENCE) Q
S ^TMP($J,"SPNPRT",ACTION,SEQUENCE,0)="$$EN1^SPNPSR15(D0,"_FIMTYPE_","_BDELTA_","_EDELTA_","_BDATE_","_EDATE_")"
Q