Home   Package List   Routine Alphabetical List   Global Alphabetical List   FileMan Files List   FileMan Sub-Files List   Package Component Lists   Package-Namespace Mapping  
Routine: APSPRXD

APSPRXD.m

Go to the documentation of this file.
  1. APSPRXD ; IHS/DSD/ENM - DELETE PRESCRIPTIONS UP TO CERTAIN DATE ; [ 09/03/97 1:30 PM ]
  1. ;;6.0;IHS PHARMACY MODIFICATIONS;;09/03/97
  1. ;
  1. ; This routine deletes prescriptions up to a user specified number
  1. ; of months from the day it is run. It it meant to be run from
  1. ; the background but could be called at ENQUE if APSPRXD("ED") was
  1. ; defined with a Fileman formatted date. This deletes entries
  1. ; from the PSRX,PS(55,PS(52.5, globals which correspond to the
  1. ; Prescription, Pharmacy Patient, RX Suspense files.
  1. ; When checking the prescriptions for deletion it checks for
  1. ; refills that were done for the prescription and if any of the
  1. ; refills were filled after the APSPRXD("ED") date, the prescription
  1. ; entry is not deleted.
  1. ;--------------------------------------------------------------------
  1. START ;
  1. S MWR=0
  1. D ASK G ENQUE ;IHS/ANMC/MWR 03/17/92
  1. Q
  1. D QUE G END
  1. ENQUE ; EP
  1. D PROCESS
  1. END D EOJ
  1. Q
  1. ;---------------------------------------------------------------------
  1. ASK ;
  1. S DIR(0)="NO^6:24",DIR("B")=15
  1. S DIR("A")="Number of months of prescriptions to keep"
  1. S DIR("?")="If you enter a 15, all prescriptions older than 15 months will be deleted."
  1. D ^DIR
  1. I $D(DTOUT)!($D(DUOUT)) S APSPRXD("QFLG")=1 G ASKX
  1. S X="T-"_Y_"M" D ^%DT S APSPRXD("ED")=Y
  1. ASKX K DIR,X,Y
  1. Q
  1. ;
  1. QUE ;
  1. S ZTRTN="ENQUE^APSPRXD",ZTIO="",ZTSAVE("APSPRXD(""ED"")")=""
  1. S ZTDESC="PRESCRIPTION DELETION"
  1. D ^%ZTLOAD
  1. Q
  1. ;
  1. PROCESS ;
  1. F APSPRXD("DATE")=0:0 S APSPRXD("DATE")=$O(^PSRX("AD",APSPRXD("DATE"))) Q:APSPRXD("DATE")'<APSPRXD("ED") D RX
  1. Q
  1. RX ;
  1. ;APSPRXD("IRXN") IS THE SUBSCRIPT PRESCRIPTION NUMBER
  1. F APSPRXD("IRXN")=0:0 S APSPRXD("IRXN")=$O(^PSRX("AD",APSPRXD("DATE"),APSPRXD("IRXN"))) Q:APSPRXD("IRXN")="" D CHECK
  1. Q
  1. ;
  1. CHECK ;
  1. ; IF THE ENTRY DOES NOT EXIST, KILL THE XREF. ;IHS/ANMC/MWR 03/19/92
  1. I '$D(^PSRX(APSPRXD("IRXN"))) K ^PSRX("AD",APSPRXD("DATE"),APSPRXD("IRXN")) Q ;IHS/ANMC/MWR 03/19/92
  1. ;
  1. ;
  1. S APSPRXD("CHECK QFLG")=0
  1. I $O(^PSRX(APSPRXD("IRXN"),1,0)) F %=0:0 S %=$O(^PSRX(APSPRXD("IRXN"),1,%)) Q:'%!(APSPRXD("CHECK QFLG")) S:+^(%,0)'<APSPRXD("ED") APSPRXD("CHECK QFLG")=1
  1. D:'APSPRXD("CHECK QFLG") DELETE
  1. Q
  1. ;
  1. DELETE ;
  1. K APSPRXDI S APSPRXD("PAT")=$P(^PSRX(APSPRXD("IRXN"),0),U,2)
  1. I APSPRXD("PAT") F APSPRXDI=0:0 S APSPRXDI=$O(^PS(55,APSPRXD("PAT"),"P",APSPRXDI)) Q:'APSPRXDI I +^(APSPRXDI,0)=APSPRXD("IRXN") D
  1. . S ^PS(55,APSPRXD("PAT"),"P",0)=$P(^PS(55,APSPRXD("PAT"),"P",0),U,1,3)_U_($P(^(0),U,4)-1)
  1. . K ^PS(55,APSPRXD("PAT"),"P",APSPRXDI)
  1. . F %=0:0 S %=$O(^PS(55,APSPRXD("PAT"),"P","A",%)) Q:'% I $D(^(%,APSPRXD("IRXN"))) K ^(APSPRXD("IRXN"))
  1. . K:$D(^PS(55,APSPRXD("PAT"),"P","CP",APSPRXD("IRXN"))) ^(APSPRXD("IRXN"))
  1. . Q
  1. ;
  1. I $D(^PS(52.5,"B",APSPRXD("IRXN"))) S DA=$O(^PS(52.5,"B",APSPRXD("IRXN"),0)),DIK="^PS(52.5," D ^DIK K DIK,DA
  1. S DIK="^PSRX(",DA=APSPRXD("IRXN") D ^DIK K DIK,DA
  1. S MWR=MWR+1
  1. Q
  1. ;
  1. EOJ ;
  1. K APSPRXD,ZTSK
  1. S:$D(ZTQUEUED) ZTREQ="@"
  1. Q