62 lines
2.6 KiB
Mathematica
62 lines
2.6 KiB
Mathematica
SPNPSR18 ;HIRMFO/JWR,WAA-HUNT: MEDICATION SEARCH ;3/1/96 14:16
|
|
;;2.0;Spinal Cord Dysfunction;**9**;01/02/1997
|
|
;
|
|
EN1(D0,FDATE,TDATE,ACTION,SEQUENCE) ; *** Search entry point
|
|
; Input:
|
|
; ACTION,SEQUENCE = Search ACTION,SEQUENCE number
|
|
; D0 = SCD (SPINAL CORD) REGISTRY file (#154) IEN
|
|
; ^TMP($J,"SPNPRT",ACTION,SEQUENCE,"BEGINING DATE") = Date ^ Date(ext)
|
|
; ^TMP($J,"SPNPRT",ACTION,SEQUENCE,"ENDING DATE") = Date ^ Date(ext)
|
|
; ^TMP($J,"SPNPRT",ACTION,SEQUENCE,"DRUG CLASS",IEN) = DRUG CLASS
|
|
; FDATE = Date
|
|
; TDATE = Date
|
|
; Output:
|
|
; $S( D0_Meets_Search_Criteria : 1 , 1 : 0 )
|
|
;
|
|
N AGE,DFN,I,MEETSRCH,VA,VADM,VAERR
|
|
S (SPNLDFN,DFN)=+$P($G(^SPNL(154,D0,0)),U)
|
|
;
|
|
PHARM S MEETSRCH=0
|
|
Q:'$D(ACTION)
|
|
Q:'$D(SEQUENCE)
|
|
I '$D(TDATE) S TDATE=DT
|
|
S EXPDATE=FDATE-.000001,SPNCN1=0 ; for each expiration date
|
|
F S EXPDATE=$O(^PS(55,SPNLDFN,"P","A",EXPDATE)) Q:EXPDATE'>0!(EXPDATE>TDATE)!(MEETSRCH=1) D
|
|
. S RECNR=0 ; for each prescription on that date
|
|
. F S RECNR=$O(^PS(55,SPNLDFN,"P","A",EXPDATE,RECNR)) Q:RECNR'>0!(MEETSRCH=1) D
|
|
. . S NDRG=$P($G(^PSRX(RECNR,0)),U,6) Q:NDRG=""
|
|
. . S NDREC=$P($G(^PSDRUG(NDRG,0)),U,2) D:NDREC'=""
|
|
. . . S CN="" F S CN=$O(^TMP($J,"SPNPRT",ACTION,SEQUENCE,"DRUG CLASS",CN)) Q:CN<1 I $P($G(^TMP($J,"SPNPRT",ACTION,SEQUENCE,"DRUG CLASS",CN)),U,2)=NDREC S MEETSRCH=1 Q
|
|
. . Q
|
|
. Q
|
|
K NDRG
|
|
Q Q MEETSRCH
|
|
EN2(ACTION,SEQUENCE) ; *** Prompt entry point
|
|
; Input:
|
|
; ACTION,SEQUENCE = Search ACTION,SEQUENCE number
|
|
; ^TMP($J,"SPNPRT",ACTION,SEQUENCE,"BEGINING DATE") = Date ^ Date(ext)
|
|
; ^TMP($J,"SPNPRT",ACTION,SEQUENCE,"ENDING DATE") = Date ^ Date(ext)
|
|
; ^TMP($J,"SPNPRT",ACTION,SEQUENCE,"DRUG CLASS",IEN) =
|
|
; ^TMP($J,"SPNPRT",ACTION,SEQUENCE,0)=$$EN1^SPNPSR18(D0,BDATE,EDATE,ACTION,SEQUENCE)
|
|
; Output:
|
|
; SPNLEXIT = $S( User_Abort/Timeout : 1 , 1 : 0 )
|
|
;
|
|
N DIC,DIR,DIRUT,DTOUT,DUOUT,I
|
|
DIR K ^TMP($J,"SPNPRT",ACTION,SEQUENCE),DIR,DIC
|
|
S DIC=50.605,DIC(0)="AEMNQZ" K DIRUT
|
|
I +Y>1 F D Q:SPNLEXIT Q:Y<1
|
|
. I $D(DUOUT)!($D(DTOUT)) S SPNLEXIT=1 Q
|
|
. Q:Y'>0 D ^DIC I Y>0 D
|
|
.. I $D(^TMP($J,"SPNPRT",ACTION,SEQUENCE,"DRUG CLASS",+Y)) W !,"You have already selected that drug class." Q
|
|
.. S ^TMP($J,"SPNPRT",ACTION,SEQUENCE,"DRUG CLASS",+Y)=$P($G(^PS(50.605,+Y,0)),U,2)_U_$P(Y,U,2)
|
|
. S DIR("A")="Another: "
|
|
. Q
|
|
Q:SPNLEXIT=1 K DIR
|
|
S Y=$O(^TMP($J,"SPNPRT",ACTION,SEQUENCE,"DRUG CLASS",0))
|
|
Q:Y<1
|
|
W !!,"Enter the date range to search for the selected Medications"
|
|
S (BDATE,EDATE)=""
|
|
D EN1^SPNPSR00(ACTION,SEQUENCE+.1,.BDATE,.EDATE)
|
|
S ^TMP($J,"SPNPRT",ACTION,SEQUENCE,0)="$$EN1^SPNPSR18(D0,"_BDATE_","_EDATE_","""_ACTION_""","_SEQUENCE_")"
|
|
Q
|