42 lines
1.9 KiB
Mathematica
42 lines
1.9 KiB
Mathematica
|
PSO5252 ;BHAM ISC/SAB- encap II API to return clozapine rx overrides ; 04/07/05 10:30 am
|
||
|
;;7.0;OUTPATIENT PHARMACY;**213**;DEC 1997
|
||
|
;
|
||
|
EN(LIST,IEN,RX,SDATE,EDATE) ;
|
||
|
;
|
||
|
;LIST: Subscript name used in ^TMP global [REQUIRED]
|
||
|
;IEN: Internal record number [optional]
|
||
|
;RX #: Pointer to Prescription file (#52) [optional]
|
||
|
;SDATE: Starting Date [optional]
|
||
|
;EDATE: Ending Date [optional]
|
||
|
;
|
||
|
Q:$G(LIST)=""
|
||
|
N DA,DR,PSOPOST,DIC,DIQ K ^TMP($J,LIST)
|
||
|
I $G(IEN) D G CLEAN
|
||
|
.I $G(^PS(52.52,IEN,0))']"" S ^TMP($J,LIST,IEN,0)="-1^NO DATA FOUND" Q
|
||
|
.D PROCESS
|
||
|
I $G(RX)]"",'$G(IEN) D G CLEAN
|
||
|
.I '$O(^PS(52.52,"A",RX,0)) S ^TMP($J,LIST,0)="-1^NO DATA FOUND" Q
|
||
|
.S IEN=$O(^PS(52.52,"A",RX,0))
|
||
|
.I $G(^PS(52.52,IEN,0))']"" S ^TMP($J,LIST,0)="-1^NO DATA FOUND" Q
|
||
|
.D PROCESS
|
||
|
I $G(SDATE)!($G(EDATE)) D DATE G CLEAN
|
||
|
F IEN=0:0 S IEN=$O(^PS(52.52,IEN)) Q:'IEN D PROCESS
|
||
|
CLEAN I '$O(^TMP($J,LIST,0)) S ^TMP($J,LIST,0)="-1^NO DATA FOUND"
|
||
|
K DA,DR,DIC,PSOPOST,DIQ,LDATE
|
||
|
Q
|
||
|
PROCESS ;
|
||
|
K PSOPOST S DIC=52.52,DA=IEN,DR=".01:5",DIQ="PSOPOST",DIQ(0)="IE" D EN^DIQ1
|
||
|
F DR=.01,1,2,3,4,5 D
|
||
|
.I DR=.01 S ^TMP($J,LIST,"B",PSOPOST(52.52,DA,DR,"I"),IEN)="",^TMP($J,LIST,0)=$G(^TMP($J,LIST,0))+1
|
||
|
.I PSOPOST(52.52,DA,DR,"E")'=PSOPOST(52.52,DA,DR,"I") S ^TMP($J,LIST,IEN,DR)=PSOPOST(52.52,DA,DR,"I")_"^"_PSOPOST(52.52,DA,DR,"E") Q
|
||
|
.S ^TMP($J,LIST,IEN,DR)=PSOPOST(52.52,DA,DR,"I")
|
||
|
K DA,DR,PSOPOST,DIC,DIQ
|
||
|
Q
|
||
|
DATE ;date range
|
||
|
I $G(SDATE) S LDATE=$P(SDATE,".") D Q
|
||
|
.I $G(EDATE) S EDATE=EDATE_".9999999" F S LDATE=$O(^PS(52.52,"B",LDATE)) Q:'LDATE!(LDATE>EDATE) F IEN=0:0 S IEN=$O(^PS(52.52,"B",LDATE,IEN)) Q:'IEN D PROCESS
|
||
|
.I '$G(EDATE) F S LDATE=$O(^PS(52.52,"B",LDATE)) Q:'LDATE F IEN=0:0 S IEN=$O(^PS(52.52,"B",LDATE,IEN)) Q:'IEN D PROCESS
|
||
|
I $G(EDATE),'$G(SDATE) S EDATE=EDATE_".9999999" D Q
|
||
|
.F LDATE=0:0 S LDATE=$O(^PS(52.52,"B",LDATE)) Q:'LDATE!(LDATE>EDATE) F IEN=0:0 S IEN=$O(^PS(52.52,"B",LDATE,IEN)) Q:'IEN D PROCESS
|
||
|
Q
|