PSGWAP ;BHAM ISC/PTD,CML-Purge Old AMIS Data ; 14 Feb 1989 1:36 PM
;;2.3; Automatic Replenishment/Ward Stock ;;4 JAN 94
W !!,"This option will purge data from file PSI(58.5) - AMIS stats file.",!,"You should retain the data for at least 1 quarter.",!,"Therefore, the option will NOT ALLOW DELETION of data newer than ""T-100"".",!!
BDT S BDT=0 I '$O(^PSI(58.5,"B",BDT)) W !,"There is NO data in the AMIS stats file.",!! K BDT Q
E S BDT=$O(^PSI(58.5,"B",BDT))
EDT S %DT="AEXP",%DT("A")="Purge AMIS data older than (and including): ",%DT("B")="T-100" D ^%DT K %DT G:Y<0 END S (EDT,X2)=Y
D NOW^%DTC S X1=$P(%,".") D ^%DTC I X<100 W !!,"Data less than 100 days old may NOT BE DELETED!",!! G EDT
I BDT>EDT W !!,"No AMIS data to purge in selected date range.",!! G END
ASK S Y=EDT X ^DD("DD") W !!,"I will now delete AMIS data that is older than (and including) ",Y,!,"Are you SURE that is what you want to do? NO// " R X:DTIME
G:'$T!("^Nn"[$E(X)) END
I "Yy"'[$E(X) W *7,*7,!!,"Answer ""yes"" if you wish to purge AMIS data.",!,"Answer ""no"" or <return> if you do not.",!! G ASK
S ZTRTN="ENQ^PSGWAP",ZTDTH=$H,ZTIO="",ZTDESC="Purge Old AMIS Data" F G="BDT","EDT" S:$D(@G) ZTSAVE(G)=""
D ^%ZTLOAD,HOME^%ZIS W !,"AMIS purge queued!" K ZTSK G END
;
ENQ ;ENTRY POINT WHEN QUEUED
S LPDT=BDT-1,DATDA=0
DTLP S LPDT=$O(^PSI(58.5,"B",LPDT)) G:(LPDT>EDT)!'LPDT END
DTDA S DATDA=$O(^PSI(58.5,"B",LPDT,DATDA)) G:'DATDA DTLP
S DIE="^PSI(58.5,",DA=DATDA,DR=".01///@" D ^DIE K DIE G DTDA
;
END K ZTSK,BDT,EDT,X,Y,LPDT,DATDA,%,%I,%H,G,ZTIO,DA,DR S:$D(ZTQUEUED) ZTREQ="@" Q
--- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HPSGWAP 1588 printed Nov 22, 2024@16:49 Page 2
PSGWAP ;BHAM ISC/PTD,CML-Purge Old AMIS Data ; 14 Feb 1989 1:36 PM
+1 ;;2.3; Automatic Replenishment/Ward Stock ;;4 JAN 94
+2 WRITE !!,"This option will purge data from file PSI(58.5) - AMIS stats file.",!,"You should retain the data for at least 1 quarter.",!,"Therefore, the option will NOT ALLOW DELETION of data newer than ""T-100"".",!!
BDT SET BDT=0
IF '$ORDER(^PSI(58.5,"B",BDT))
WRITE !,"There is NO data in the AMIS stats file.",!!
KILL BDT
QUIT
+1 IF '$TEST
SET BDT=$ORDER(^PSI(58.5,"B",BDT))
EDT SET %DT="AEXP"
SET %DT("A")="Purge AMIS data older than (and including): "
SET %DT("B")="T-100"
DO ^%DT
KILL %DT
if Y<0
GOTO END
SET (EDT,X2)=Y
+1 DO NOW^%DTC
SET X1=$PIECE(%,".")
DO ^%DTC
IF X<100
WRITE !!,"Data less than 100 days old may NOT BE DELETED!",!!
GOTO EDT
+2 IF BDT>EDT
WRITE !!,"No AMIS data to purge in selected date range.",!!
GOTO END
ASK SET Y=EDT
XECUTE ^DD("DD")
WRITE !!,"I will now delete AMIS data that is older than (and including) ",Y,!,"Are you SURE that is what you want to do? NO// "
READ X:DTIME
+1 if '$TEST!("^Nn"[$EXTRACT(X))
GOTO END
+2 IF "Yy"'[$EXTRACT(X)
WRITE *7,*7,!!,"Answer ""yes"" if you wish to purge AMIS data.",!,"Answer ""no"" or <return> if you do not.",!!
GOTO ASK
+3 SET ZTRTN="ENQ^PSGWAP"
SET ZTDTH=$HOROLOG
SET ZTIO=""
SET ZTDESC="Purge Old AMIS Data"
FOR G="BDT","EDT"
if $DATA(@G)
SET ZTSAVE(G)=""
+4 DO ^%ZTLOAD
DO HOME^%ZIS
WRITE !,"AMIS purge queued!"
KILL ZTSK
GOTO END
+5 ;
ENQ ;ENTRY POINT WHEN QUEUED
+1 SET LPDT=BDT-1
SET DATDA=0
DTLP SET LPDT=$ORDER(^PSI(58.5,"B",LPDT))
if (LPDT>EDT)!'LPDT
GOTO END
DTDA SET DATDA=$ORDER(^PSI(58.5,"B",LPDT,DATDA))
if 'DATDA
GOTO DTLP
+1 SET DIE="^PSI(58.5,"
SET DA=DATDA
SET DR=".01///@"
DO ^DIE
KILL DIE
GOTO DTDA
+2 ;
END KILL ZTSK,BDT,EDT,X,Y,LPDT,DATDA,%,%I,%H,G,ZTIO,DA,DR
if $DATA(ZTQUEUED)
SET ZTREQ="@"
QUIT