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
--- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HPSO5252 1954 printed Nov 22, 2024@17:33:04 Page 2
PSO5252 ;BHAM ISC/SAB- encap II API to return clozapine rx overrides ; 04/07/05 10:30 am
+1 ;;7.0;OUTPATIENT PHARMACY;**213**;DEC 1997
+2 ;
EN(LIST,IEN,RX,SDATE,EDATE) ;
+1 ;
+2 ;LIST: Subscript name used in ^TMP global [REQUIRED]
+3 ;IEN: Internal record number [optional]
+4 ;RX #: Pointer to Prescription file (#52) [optional]
+5 ;SDATE: Starting Date [optional]
+6 ;EDATE: Ending Date [optional]
+7 ;
+8 if $GET(LIST)=""
QUIT
+9 NEW DA,DR,PSOPOST,DIC,DIQ
KILL ^TMP($JOB,LIST)
+10 IF $GET(IEN)
Begin DoDot:1
+11 IF $GET(^PS(52.52,IEN,0))']""
SET ^TMP($JOB,LIST,IEN,0)="-1^NO DATA FOUND"
QUIT
+12 DO PROCESS
End DoDot:1
GOTO CLEAN
+13 IF $GET(RX)]""
IF '$GET(IEN)
Begin DoDot:1
+14 IF '$ORDER(^PS(52.52,"A",RX,0))
SET ^TMP($JOB,LIST,0)="-1^NO DATA FOUND"
QUIT
+15 SET IEN=$ORDER(^PS(52.52,"A",RX,0))
+16 IF $GET(^PS(52.52,IEN,0))']""
SET ^TMP($JOB,LIST,0)="-1^NO DATA FOUND"
QUIT
+17 DO PROCESS
End DoDot:1
GOTO CLEAN
+18 IF $GET(SDATE)!($GET(EDATE))
DO DATE
GOTO CLEAN
+19 FOR IEN=0:0
SET IEN=$ORDER(^PS(52.52,IEN))
if 'IEN
QUIT
DO PROCESS
CLEAN IF '$ORDER(^TMP($JOB,LIST,0))
SET ^TMP($JOB,LIST,0)="-1^NO DATA FOUND"
+1 KILL DA,DR,DIC,PSOPOST,DIQ,LDATE
+2 QUIT
PROCESS ;
+1 KILL PSOPOST
SET DIC=52.52
SET DA=IEN
SET DR=".01:5"
SET DIQ="PSOPOST"
SET DIQ(0)="IE"
DO EN^DIQ1
+2 FOR DR=.01,1,2,3,4,5
Begin DoDot:1
+3 IF DR=.01
SET ^TMP($JOB,LIST,"B",PSOPOST(52.52,DA,DR,"I"),IEN)=""
SET ^TMP($JOB,LIST,0)=$GET(^TMP($JOB,LIST,0))+1
+4 IF PSOPOST(52.52,DA,DR,"E")'=PSOPOST(52.52,DA,DR,"I")
SET ^TMP($JOB,LIST,IEN,DR)=PSOPOST(52.52,DA,DR,"I")_"^"_PSOPOST(52.52,DA,DR,"E")
QUIT
+5 SET ^TMP($JOB,LIST,IEN,DR)=PSOPOST(52.52,DA,DR,"I")
End DoDot:1
+6 KILL DA,DR,PSOPOST,DIC,DIQ
+7 QUIT
DATE ;date range
+1 IF $GET(SDATE)
SET LDATE=$PIECE(SDATE,".")
Begin DoDot:1
+2 IF $GET(EDATE)
SET EDATE=EDATE_".9999999"
FOR
SET LDATE=$ORDER(^PS(52.52,"B",LDATE))
if 'LDATE!(LDATE>EDATE)
QUIT
FOR IEN=0:0
SET IEN=$ORDER(^PS(52.52,"B",LDATE,IEN))
if 'IEN
QUIT
DO PROCESS
+3 IF '$GET(EDATE)
FOR
SET LDATE=$ORDER(^PS(52.52,"B",LDATE))
if 'LDATE
QUIT
FOR IEN=0:0
SET IEN=$ORDER(^PS(52.52,"B",LDATE,IEN))
if 'IEN
QUIT
DO PROCESS
End DoDot:1
QUIT
+4 IF $GET(EDATE)
IF '$GET(SDATE)
SET EDATE=EDATE_".9999999"
Begin DoDot:1
+5 FOR LDATE=0:0
SET LDATE=$ORDER(^PS(52.52,"B",LDATE))
if 'LDATE!(LDATE>EDATE)
QUIT
FOR IEN=0:0
SET IEN=$ORDER(^PS(52.52,"B",LDATE,IEN))
if 'IEN
QUIT
DO PROCESS
End DoDot:1
QUIT
+6 QUIT