APSPDIEN ;IHS/MSC/MGH - DRUG IEN REPORT ;04-Jan-2012 12:33;MGH
;;7.0;IHS PHARMACY MODIFICATIONS;**1013**;Sep 23, 2004;Build 33
EN ;EP-
N APSPTYP,APSPNUM,APSPQ,APSPDRG,APSPDARY,APSPNAME,QFLG,APSPCNT
S (APSPQ,APSPTYP)=""
S APSPCNT=0
;All or individual drugs
W @IOF
W !,"Drug List Report",!!
S APSPNUM=$$DIR^APSPUTIL("S^I:Individual Drug;A:All Drugs","Lookup Individual Drug or List ALL Drugs? ",,,.APSPQ)
Q:APSPQ
I APSPNUM="A" D
.S APSPTYP=$$DIR^APSPUTIL("S^A:Active;I:Inactive;B:Both","Drug Type ",,,.APSPQ)
I APSPNUM="I" D
.F D Q:QFLG
..S APSPDRG=$$GETIEN1^APSPUTIL(50,"Select Drug Name: ",-1,"B^C^D")
..I APSPDRG<1 S QFLG=1 Q
..S APSPNAME=$$GET1^DIQ(50,APSPDRG,.01)
..S APSPDARY(APSPNAME)=APSPDRG
..S APSPCNT=APSPCNT+1
..S QFLG='$$DIRYN^APSPUTIL("Want to Select Another Drug","No","Enter a 'Y' or 'YES' to include more drugs in your search",.APSPQ)
..S:'QFLG QFLG=APSPQ
Q:APSPQ
D DEV
Q
DEV ;EP
N XBRP,XBNS
S XBRP="OUT^APSPDIEN"
S XBNS="APS*"
D ^XBDBQUE
Q
OUT ;EP
N IEN,INACT,DRUG,INACTDT
U IO
D HDR
K ^TMP($J)
I APSPNUM="A" D
.S APSPCNT=0
.S IEN=0 F S IEN=$O(^PSDRUG(IEN)) Q:IEN=""!('+IEN) D
..S INACTDT=$$GET1^DIQ(50,IEN,100,"I")
..I INACTDT'="" D
...I INACTDT<DT!(INACTDT=DT) S INACT=1
...I INACTDT>DT S INACT=0
..I INACTDT="" S INACT=0
..I (APSPTYP="A"!(APSPTYP="B"))&(INACT=0) D
...S APSPNAME=$$GET1^DIQ(50,IEN,.01)
...S APSPDARY(APSPNAME)=IEN
...S APSPCNT=APSPCNT+1
..I (APSPTYP="I"!(APSPTYP="B"))&(INACT=1) D
...S APSPNAME=$$GET1^DIQ(50,IEN,.01)
...S APSPDARY(APSPNAME)=IEN
...S APSPCNT=APSPCNT+1
S APSPQ=0
S DRUG="" F S DRUG=$O(APSPDARY(DRUG)) Q:DRUG=""!(+APSPQ) D
.W !,DRUG,?50,$G(APSPDARY(DRUG))
.I $Y+4>IOSL,IOST["C-" D PAUS Q:APSPQ D HDR
.Q:APSPQ=1
Q
PAUS ;
N DTOUT,DUOUT,DIR
S DIR("?")="Enter '^' to Halt or Press Return to continue"
S DIR(0)="FO",DIR("A")="Press Return to continue or '^' to Halt"
D ^DIR
I $D(DUOUT) S APSPQ=1
Q
HDR ;
I IOST["C-" W @IOF
W !,"Drug List Report"
W !,"Drug Name",?50,"Drug IEN",!
Q
APSPDIEN ;IHS/MSC/MGH - DRUG IEN REPORT ;04-Jan-2012 12:33;MGH
+1 ;;7.0;IHS PHARMACY MODIFICATIONS;**1013**;Sep 23, 2004;Build 33
EN ;EP-
+1 NEW APSPTYP,APSPNUM,APSPQ,APSPDRG,APSPDARY,APSPNAME,QFLG,APSPCNT
+2 SET (APSPQ,APSPTYP)=""
+3 SET APSPCNT=0
+4 ;All or individual drugs
+5 WRITE @IOF
+6 WRITE !,"Drug List Report",!!
+7 SET APSPNUM=$$DIR^APSPUTIL("S^I:Individual Drug;A:All Drugs","Lookup Individual Drug or List ALL Drugs? ",,,.APSPQ)
+8 IF APSPQ
QUIT
+9 IF APSPNUM="A"
Begin DoDot:1
+10 SET APSPTYP=$$DIR^APSPUTIL("S^A:Active;I:Inactive;B:Both","Drug Type ",,,.APSPQ)
End DoDot:1
+11 IF APSPNUM="I"
Begin DoDot:1
+12 FOR
Begin DoDot:2
+13 SET APSPDRG=$$GETIEN1^APSPUTIL(50,"Select Drug Name: ",-1,"B^C^D")
+14 IF APSPDRG<1
SET QFLG=1
QUIT
+15 SET APSPNAME=$$GET1^DIQ(50,APSPDRG,.01)
+16 SET APSPDARY(APSPNAME)=APSPDRG
+17 SET APSPCNT=APSPCNT+1
+18 SET QFLG='$$DIRYN^APSPUTIL("Want to Select Another Drug","No","Enter a 'Y' or 'YES' to include more drugs in your search",.APSPQ)
+19 IF 'QFLG
SET QFLG=APSPQ
End DoDot:2
IF QFLG
QUIT
End DoDot:1
+20 IF APSPQ
QUIT
+21 DO DEV
+22 QUIT
DEV ;EP
+1 NEW XBRP,XBNS
+2 SET XBRP="OUT^APSPDIEN"
+3 SET XBNS="APS*"
+4 DO ^XBDBQUE
+5 QUIT
OUT ;EP
+1 NEW IEN,INACT,DRUG,INACTDT
+2 USE IO
+3 DO HDR
+4 KILL ^TMP($JOB)
+5 IF APSPNUM="A"
Begin DoDot:1
+6 SET APSPCNT=0
+7 SET IEN=0
FOR
SET IEN=$ORDER(^PSDRUG(IEN))
IF IEN=""!('+IEN)
QUIT
Begin DoDot:2
+8 SET INACTDT=$$GET1^DIQ(50,IEN,100,"I")
+9 IF INACTDT'=""
Begin DoDot:3
+10 IF INACTDT<DT!(INACTDT=DT)
SET INACT=1
+11 IF INACTDT>DT
SET INACT=0
End DoDot:3
+12 IF INACTDT=""
SET INACT=0
+13 IF (APSPTYP="A"!(APSPTYP="B"))&(INACT=0)
Begin DoDot:3
+14 SET APSPNAME=$$GET1^DIQ(50,IEN,.01)
+15 SET APSPDARY(APSPNAME)=IEN
+16 SET APSPCNT=APSPCNT+1
End DoDot:3
+17 IF (APSPTYP="I"!(APSPTYP="B"))&(INACT=1)
Begin DoDot:3
+18 SET APSPNAME=$$GET1^DIQ(50,IEN,.01)
+19 SET APSPDARY(APSPNAME)=IEN
+20 SET APSPCNT=APSPCNT+1
End DoDot:3
End DoDot:2
End DoDot:1
+21 SET APSPQ=0
+22 SET DRUG=""
FOR
SET DRUG=$ORDER(APSPDARY(DRUG))
IF DRUG=""!(+APSPQ)
QUIT
Begin DoDot:1
+23 WRITE !,DRUG,?50,$GET(APSPDARY(DRUG))
+24 IF $Y+4>IOSL
IF IOST["C-"
DO PAUS
IF APSPQ
QUIT
DO HDR
+25 IF APSPQ=1
QUIT
End DoDot:1
+26 QUIT
PAUS ;
+1 NEW DTOUT,DUOUT,DIR
+2 SET DIR("?")="Enter '^' to Halt or Press Return to continue"
+3 SET DIR(0)="FO"
SET DIR("A")="Press Return to continue or '^' to Halt"
+4 DO ^DIR
+5 IF $DATA(DUOUT)
SET APSPQ=1
+6 QUIT
HDR ;
+1 IF IOST["C-"
WRITE @IOF
+2 WRITE !,"Drug List Report"
+3 WRITE !,"Drug Name",?50,"Drug IEN",!
+4 QUIT