PSOSPMDL ;BIRM/SJA - State Prescription Monitoring Program - Delete unexported batch ;09/20/20
;;7.0;OUTPATIENT PHARMACY;**625**;DEC 1997;Build 42
;
EN ; - entry point for the PSO SPMP1 DELETE BATCH protocol
N %DT,DIR,DIRUT,X,DIC,DTOUT,DUOUT,Y
N II,SELECT,BATCH,EXPORT
D FULL^VALM1 W !
;
I $G(^TMP("PSOSPML1",$J,1,0))["There are no export batches" W !!,"Nothing to be deleted!",$C(7) D ENTER G END
K DIC W ! S DIR("A")="Select batch(es) to delete",DIR(0)="L^"_VALMBG_":"_VALMLST D ^DIR
K DIR I Y["^"!($D(DTOUT))!($D(DUOUT)) W !!,?3,"Nothing selected to delete",! G END
S SELECT=Y
F II=1:1:$L(SELECT,",") Q:'$P(SELECT,",",II) D
. S BATCH=$G(^TMP("PSOSPML1",$J,$P(SELECT,",",II),"BAT")),EXPORT=$$GET1^DIQ(58.42,BATCH,9,"I")
. I EXPORT W !!,"Batch #",BATCH," may not be deleted; it has been exported to the state.",$C(7) D ENTER:(II=($L(SELECT,",")-1)) Q
. I 'EXPORT D DEL(BATCH)
G BACK
Q
;
DEL(BATCH) ; delete selected batch(es)
K DIR,DIRUT,DTOUT
W !! K DIR S DIR(0)="Y",DIR("B")="Y"
S DIR("A",1)="This action cannot be recovered once complete."
S DIR("A")="Are you sure you want to delete batch #"_BATCH_" (Y/N)"
D ^DIR K DIR I Y'=1 W !,"No action taken for batch #",BATCH D ENTER Q
S DA=BATCH,DIK="^PS(58.42," D ^DIK K DA,DIK W !,"Deleting batch #",BATCH," ...",! D ENTER
Q
;
ENTER ;
K DIR S DIR("A")="Press Return to continue",DIR(0)="E" D ^DIR
Q
;
BACK ; go back to the list
D INIT^PSOSPML1 I 'VALMCNT Q
;
END S VALMBCK="R"
Q
--- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HPSOSPMDL 1497 printed Dec 13, 2024@02:35 Page 2
PSOSPMDL ;BIRM/SJA - State Prescription Monitoring Program - Delete unexported batch ;09/20/20
+1 ;;7.0;OUTPATIENT PHARMACY;**625**;DEC 1997;Build 42
+2 ;
EN ; - entry point for the PSO SPMP1 DELETE BATCH protocol
+1 NEW %DT,DIR,DIRUT,X,DIC,DTOUT,DUOUT,Y
+2 NEW II,SELECT,BATCH,EXPORT
+3 DO FULL^VALM1
WRITE !
+4 ;
+5 IF $GET(^TMP("PSOSPML1",$JOB,1,0))["There are no export batches"
WRITE !!,"Nothing to be deleted!",$CHAR(7)
DO ENTER
GOTO END
+6 KILL DIC
WRITE !
SET DIR("A")="Select batch(es) to delete"
SET DIR(0)="L^"_VALMBG_":"_VALMLST
DO ^DIR
+7 KILL DIR
IF Y["^"!($DATA(DTOUT))!($DATA(DUOUT))
WRITE !!,?3,"Nothing selected to delete",!
GOTO END
+8 SET SELECT=Y
+9 FOR II=1:1:$LENGTH(SELECT,",")
if '$PIECE(SELECT,",",II)
QUIT
Begin DoDot:1
+10 SET BATCH=$GET(^TMP("PSOSPML1",$JOB,$PIECE(SELECT,",",II),"BAT"))
SET EXPORT=$$GET1^DIQ(58.42,BATCH,9,"I")
+11 IF EXPORT
WRITE !!,"Batch #",BATCH," may not be deleted; it has been exported to the state.",$CHAR(7)
if (II=($LENGTH(SELECT,",")-1))
DO ENTER
QUIT
+12 IF 'EXPORT
DO DEL(BATCH)
End DoDot:1
+13 GOTO BACK
+14 QUIT
+15 ;
DEL(BATCH) ; delete selected batch(es)
+1 KILL DIR,DIRUT,DTOUT
+2 WRITE !!
KILL DIR
SET DIR(0)="Y"
SET DIR("B")="Y"
+3 SET DIR("A",1)="This action cannot be recovered once complete."
+4 SET DIR("A")="Are you sure you want to delete batch #"_BATCH_" (Y/N)"
+5 DO ^DIR
KILL DIR
IF Y'=1
WRITE !,"No action taken for batch #",BATCH
DO ENTER
QUIT
+6 SET DA=BATCH
SET DIK="^PS(58.42,"
DO ^DIK
KILL DA,DIK
WRITE !,"Deleting batch #",BATCH," ...",!
DO ENTER
+7 QUIT
+8 ;
ENTER ;
+1 KILL DIR
SET DIR("A")="Press Return to continue"
SET DIR(0)="E"
DO ^DIR
+2 QUIT
+3 ;
BACK ; go back to the list
+1 DO INIT^PSOSPML1
IF 'VALMCNT
QUIT
+2 ;
END SET VALMBCK="R"
+1 QUIT