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

APSDALV.m

Go to the documentation of this file.
APSDALV ;IHS/DSD/ENM/JCM ; FIX PHARM LINKS TO VMED FILE; [ 03/13/2001  8:07 AM ]
 ;;V6.0;IHS PHARMACY MODIFICATIONS;**1,3**;09/03/97
 ;;V5.06;APSP;MAY 07, 1990
 ; This routine will go through the prescription file beginning
 ; between a site manager specified date interval.  It will check
 ; to see the prescriptions have links to the PCC VMED file and if
 ; not it will create an entry.  If no visit has been made for that
 ; date a visit with the time stamp of noon will be created, otherwise
 ; it will attach the V MED entry to the first visit encountered that
 ; day.  TaskMan must be running to use this utility.
 ;
 ;------------------------------------------------------------------
START ;
 D ^XBKSET
 D ASK
 G:'$D(ED) END
 D DATE
END D EOJ
 Q
 ;-------------------------------------------------------------------
ASK ;
 S APSDALV("DUZ(0)")=DUZ(0)
 S DUZ(0)="MPp"
 S %DT("A")="PLEASE ENTER BEGINNING DATE: "
 S %DT="AE"
 D ^%DT
 I Y=-1 G ASKX
 S BD=Y
 S %DT("A")="PLEASE ENTER ENDING DATE: "
 D ^%DT
 I Y=-1 G:X="" ASK G ASKX
 S ED=Y
TYPE ;
 S DIR(0)="9000010,.03"
 S DIR("A")="TYPE OF VISIT TO CREATE"
 D ^DIR
 K DIR I $D(DIRUT) K DIRUT,DTOUT,DUOUT,BD,ED G ASK
 S APSDALV("APCDTYPE")=Y K X,Y
CAT ;
 S DIR(0)="Y"
 S DIR("A")="DO YOU WANT TO CREATE HISTORICAL VISITS"
 D ^DIR
 K DIR I $D(DIRUT) K DIRUT,DTOUT,DUOUT,BD,ED G TYPE
 I Y S APSDALV("APCDCAT")="E"
 K X,Y
ASKX ;
 Q
DATE ;
 W !
 F DATE=(BD-1):0 S DATE=$O(^PSRX("AD",DATE)) Q:(DATE>ED)!(DATE="")  D RX
 S DUZ(0)=APSDALV("DUZ(0)")
 W !!,"All done ..."
 Q
RX ;
 ;IRXN IS THE SUBSCRIPT PRESCRIPTION NUMBER
 F IRXN=0:0 S IRXN=$O(^PSRX("AD",DATE,IRXN)) Q:IRXN=""  S RFN=$O(^(IRXN,"")) D CHECK
 Q
CHECK ;
 Q:$P(^PSRX(IRXN,0),"^",15)=13  ;THIS RX HAS BEEN MARKED DELTED DUMBO IHS/OKCAO/POC 11/30/2000
 I RFN>0,$S('$D(^PSRX(IRXN,1,RFN,999999911)):1,^(999999911)=""!(^(999999911)=" "):1,1:0) D
 . S APCDALVR("APCDCAT")=$S($D(APSDALV("APCDCAT")):"E",$P(^PSRX(IRXN,0),U,3)'=1:"I",1:"A")
 . S APSRX=IRXN,APSRCT=RFN
 . S APCDALVR("APCDPAT")=$P(^PSRX(IRXN,0),U,2)
 . S APCDALVR("APCDLOC")=DUZ(2)
 . S APCDALVR("APCDTYPE")=APSDALV("APCDTYPE")
 . S APC("PRV")=$P(^PSRX(IRXN,0),U,4)
 . S APSPDOC1=$P($G(^VA(200,APC("PRV"),0)),U,16),APCDALVR("APCDTPRV")=$S($P($G(^AUTTSITE(1,0)),U,22):APC("PRV"),1:APSPDOC1) ;IHS/DSD/ENM 09/03/97
 . S APCDALVR("APCDDATE")=$P(^PSRX(IRXN,1,RFN,0),U,1)
 . D ^APSDALVR
 . W "."
 ;
 I RFN=0,$S('$D(^PSRX(IRXN,999999911)):1,^(999999911)=""!(^(999999911)=" "):1,1:0) D
 . S APSRX0=^PSRX(IRXN,0)
 . S APCDALVR("APCDLOC")=DUZ(2)
 . S APCDALVR("APCDTYPE")=APSDALV("APCDTYPE")
 . S APCDALVR("APCDPAT")=$P(APSRX0,U,2)
 . S APSRX=IRXN,APCDALVR("APCDDATE")=$P(APSRX0,U,13)
 . S APC("PRV")=$P(^PSRX(IRXN,0),U,4)
 . S APSPDOC1=$P($G(^VA(200,APC("PRV"),0)),U,16),APCDALVR("APCDTPRV")=$S($P($G(^AUTTSITE(1,0)),U,22):APC("PRV"),1:APSPDOC1) ;IHS/DSD/ENM 09/03/97
 . S APCDALVR("APCDCAT")=$S($D(APSDALV("APCDCAT")):"E",$P(APSRX0,U,3)'=1:"I",1:"A")
 . D ^APSDALVN
 . W "."
 K RFN,APSRX,APSRCT,APSRX0,APCDALVR
 Q
EOJ ;
 K BD,ED,IRXN,DATE,APSDALV
 Q
 ;NEXT PART FIXES (TRIES) TO DELETE V MED ENTRIES WITH STATUS MARKED DELETED IN THE PRESCRIPTION FILE...WHAT A MESS IHS/OKCAO/POC 11/30/2000
DEL ;
 S APSDALV("DUZ(0)")=DUZ(0)
 S DUZ(0)="MPp"
 S %DT("A")="PLEASE ENTER BEGINNING DATE: "
 S %DT="AE"
 D ^%DT
 I Y=-1 G ASKX
 S BD=Y
 S %DT("A")="PLEASE ENTER ENDING DATE: "
 D ^%DT
 I Y=-1 G:X="" ASK G ASKX
 S ED=Y
 ;
 ;
 W !
 F DATE=(BD-1):0 S DATE=$O(^PSRX("AD",DATE)) Q:(DATE>ED)!(DATE="")  D RXDEL
 S DUZ(0)=APSDALV("DUZ(0)")
 W !!,"All done ..."
 Q
RXDEL ;
 ;IRXN IS THE SUBSCRIPT PRESCRIPTION NUMBER
 F IRXN=0:0 S IRXN=$O(^PSRX("AD",DATE,IRXN)) Q:IRXN=""  S RFN=$O(^(IRXN,"")) D CHECKDEL
 Q
CHECKDEL ;
 ;I RFN>0,$S('$D(^PSRX(IRXN,1,RFN,999999911)):1,^(999999911)=""!(^(999999911)=" "):1,1:0) D
 I RFN>0 Q  ;SHOULDN'T BE A PROBLEM WITH REFILLS
 ;
 I RFN=0 D
 .Q:$P(^PSRX(IRXN,0),"^",15)'=13  ;STOP IF THIS IS NOT MARKED DELETED
 .S APSRX=IRXN
 .S APSRM=+$G(^PSRX(IRXN,999999911))
 .Q:'APSRM  ;GOT NOTHING TO TRY TO DELETE IN VMED
 .S ^AZOPAT("DEL",IRXN,APSRM)="" ;THIS IS DA OF RX, DA OF V MED FILE
 .S DIE="^PSRX(",DR="9999999.11///@",DA=IRXN D ^DIE
 .D ^APSPCCD
 .W "."
 K RFN,APSRX,APSRCT,APSRX0,APCDALVR
 Q
EOJD ;