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

BEXRQUE.m

Go to the documentation of this file.
  1. BEXRQUE ;IHS/CMI/DAY - BEX - Refill Queue Report ; 05 Oct 2015 10:51 AM
  1. ;;1.0;BEX TELEPHONE REFILL SYSTEM;**4,5,6**;APR 20, 2015;Build 7
  1. ;
  1. ;Prints the Refill Queue Report
  1. ;
  1. ; New routine released in Patch 5
  1. ; Patch 6 improves Site Selection
  1. ;
  1. W #
  1. ;
  1. W !,"Refill Queue Report"
  1. W !
  1. W !,"This option prints a list of entries in the Refill Queue."
  1. W !
  1. ;
  1. ;IHS/BJI/DAY - Patch 6 - Improved Site Selection
  1. ;
  1. ;Capture Site when entering BEXRQUE
  1. D HOLD^BEXSITE
  1. ;
  1. ;Display Site to User and Ask for Change
  1. D CHANGE^BEXSITE
  1. ;
  1. ;End Patch 6
  1. ;
  1. K BEXOPSIT
  1. S BEXOPSIT=0
  1. S BEXQUIT=0
  1. S BEXEXIT=0
  1. ;
  1. W !,"Press Enter to select ALL Outpatient Sites, or"
  1. F D Q:BEXQUIT=1
  1. .K DUOUT,DIC,DIR,DIE,DA,DR,DO,DD
  1. .S DIC(0)="AEQMZ"
  1. .S DIC("A")="Select a Outpatient Site: "
  1. .S DIC=59
  1. .D ^DIC
  1. .K DIC,DIR,DIE,DA,DD,DR,DO
  1. .I $G(DUOUT) K DUOUT S (BEXQUIT,BEXEXIT)=1 Q
  1. .I X="" S BEXQUIT=1 Q
  1. .I Y<0 Q
  1. .S BEXOPSIT=BEXOPSIT+1
  1. .I +Y S BEXOPSIT(+Y)=""
  1. ;
  1. I BEXEXIT=1 Q
  1. ;
  1. W !
  1. K DIR,DIRUT
  1. S DIR("A")="Choose Sorting Order"
  1. S DIR(0)="SO^A:Alphabetic within Window/Local/Mail;I:Internal Numbers - Similar to Refill Queue Order"
  1. S DIR("B")="A"
  1. D ^DIR
  1. K DIR
  1. I $D(DIRUT) K DIRUT G EOJ
  1. I Y="A" S BEXSAME=0
  1. I Y="I" S BEXSAME=1
  1. ;
  1. ;Only have Unprocessed entries
  1. S BEXRTYPE="UNPROC"
  1. ;
  1. W !
  1. K DIR,DIRUT
  1. S DIR(0)="S^A:All Entries;L:Local Mail Only;M:Mail Only (CMOP);W:Window Only"
  1. S DIR("A")="Process All, Local Mail, Mail, or Window"
  1. D ^DIR
  1. I $G(DIRUT) K DIR,DIRUT Q
  1. K DIR
  1. S BEXWIND=Y
  1. ;
  1. ;
  1. ;--------------------------------------------------------------------------
  1. ;
  1. W !
  1. S XBRP="LIST^BEXRQUE"
  1. S XBRX="EOJ^BEXRQUE"
  1. S XBNS="BEX"
  1. D ^XBDBQUE
  1. Q
  1. ;
  1. ;
  1. ;---------------------------------------------------------------
  1. EOJ ;EP - End of Job Processing
  1. ;---------------------------------------------------------------
  1. ;
  1. X ^%ZIS("C")
  1. I $E(IOST)="C",$G(BEXEXIT)'=1 W ! K DIR S DIR(0)="E" D ^DIR K DIR
  1. ;
  1. ;IHS/BJI/DAY - Patch 6 - Check if User Changed Sites
  1. ;
  1. I $$CHECK^BEXSITE() D
  1. .;
  1. .W !!
  1. .W "You may have changed your Outpatient Site!",!
  1. .;
  1. .D CHANGE^BEXSITE
  1. ;
  1. ;End Patch 6
  1. ;
  1. K BEX
  1. K ^BEXUTL($J)
  1. D EN^XBVK("BEX")
  1. K DIR,DIE,DIC,DD,DA,DR
  1. Q
  1. ;
  1. ;
  1. ;---------------------------------------------------------------
  1. LIST ;EP - Entry Point from XBDBQUE
  1. ;---------------------------------------------------------------
  1. ;
  1. ;
  1. U IO
  1. W #
  1. D HEADER
  1. ;
  1. K ^BEXUTL($J)
  1. K BEXTOT
  1. S BEXTOT=0
  1. K BEXSUM
  1. S BEXSUM="0^0^0^0^0^0^0"
  1. ;
  1. S BEXQUIT=0
  1. S BEXEXIT=0
  1. ;
  1. ;VEXHRX is subscripted by the value in ^DD("SITE",1) for all Divs
  1. S BEXSITE=0
  1. F S BEXSITE=$O(^VEXHRX(19080,BEXSITE)) Q:'BEXSITE D Q:BEXQUIT=1 Q:BEXEXIT=1
  1. .;
  1. .S BEXIEN=0
  1. .F S BEXIEN=$O(^VEXHRX(19080,BEXSITE,BEXIEN)) Q:'BEXIEN D Q:BEXQUIT=1 Q:BEXEXIT=1
  1. ..;
  1. ..S BEXPTIEN=$P(BEXIEN,"-")
  1. ..S BEXRXIEN=$P(BEXIEN,"-",2)
  1. ..;
  1. ..;Screen by Division
  1. ..S BEXOPIEN=0
  1. ..I +BEXRXIEN S BEXOPIEN=$P($G(^PSRX(BEXRXIEN,2)),U,9)
  1. ..S BEXRFIEN=0
  1. ..I +BEXRXIEN S BEXRFIEN=$O(^PSRX(BEXRXIEN,1,99),-1)
  1. ..I +BEXRFIEN S BEXOPIEN=$P($G(^PSRX(BEXRXIEN,1,BEXRFIEN,0)),U,9)
  1. ..I +BEXOPSIT,+BEXOPIEN=0 Q
  1. ..I +BEXOPSIT,'$D(BEXOPSIT(BEXOPIEN)) Q
  1. ..;
  1. ..S BEXMAIL=$P(^VEXHRX(19080,BEXSITE,BEXIEN),U,4)
  1. ..I BEXMAIL="" S BEXMAIL="M"
  1. ..;
  1. ..;Did user want only Unprocessed entries
  1. ..S BEXFILL=$P($G(^PSRX(BEXRXIEN,3)),U)
  1. ..I BEXRTYPE="UNPROC",BEXFILL=DT Q
  1. ..I BEXRTYPE="UNPROC",BEXFILL>DT Q
  1. ..;
  1. ..;Did user want to restrict to certain values
  1. ..I BEXMAIL="W",BEXWIND="M" Q
  1. ..I BEXMAIL="W",BEXWIND="L" Q
  1. ..I BEXMAIL="L",BEXWIND="M" Q
  1. ..I BEXMAIL="L",BEXWIND="W" Q
  1. ..I BEXMAIL="M",BEXWIND="L" Q
  1. ..I BEXMAIL="M",BEXWIND="W" Q
  1. ..;
  1. ..;Want to sort by Window, Local, then Mail
  1. ..I BEXMAIL="W" S BEXSORT=1
  1. ..I BEXMAIL="L" S BEXSORT=2
  1. ..I BEXMAIL="M" S BEXSORT=3
  1. ..I $G(BEXSAME)=1 S BEXSORT=4
  1. ..;
  1. ..;Get Patient ID for Sort
  1. ..S BEXPAT=$$GET1^DIQ(2,BEXPTIEN,.01)
  1. ..I BEXPAT="" S BEXPAT="??"
  1. ..I $G(BEXSAME)=1 S BEXPAT=BEXPTIEN
  1. ..;
  1. ..S ^BEXUTL($J,BEXOPIEN,BEXSORT,BEXPAT,BEXRXIEN)=BEXPTIEN_U_BEXMAIL
  1. ;
  1. ;Loop BEXUTL to extract sorted data
  1. ;
  1. S BEXOPIEN=0
  1. F S BEXOPIEN=$O(^BEXUTL($J,BEXOPIEN)) Q:'BEXOPIEN D Q:BEXEXIT=1
  1. .;
  1. .S BEXSORT=0
  1. .F S BEXSORT=$O(^BEXUTL($J,BEXOPIEN,BEXSORT)) Q:'BEXSORT D Q:BEXEXIT=1
  1. ..;
  1. ..S BEXPAT=""
  1. ..F S BEXPAT=$O(^BEXUTL($J,BEXOPIEN,BEXSORT,BEXPAT)) Q:BEXPAT="" D Q:BEXEXIT=1
  1. ...;
  1. ...S BEXRXIEN=0
  1. ...F S BEXRXIEN=$O(^BEXUTL($J,BEXOPIEN,BEXSORT,BEXPAT,BEXRXIEN)) Q:'BEXRXIEN D Q:BEXEXIT=1
  1. ....;
  1. ....S BEXPTIEN=$P(^BEXUTL($J,BEXOPIEN,BEXSORT,BEXPAT,BEXRXIEN),U)
  1. ....S BEXMAIL=$P(^BEXUTL($J,BEXOPIEN,BEXSORT,BEXPAT,BEXRXIEN),U,2)
  1. ....;
  1. ....D DETAIL
  1. ;
  1. ;
  1. ;Write Totals
  1. ;
  1. I BEXEXIT=1 Q
  1. ;
  1. I $Y>(IOSL-5) D
  1. .I $E(IOST)="C" K DIR S DIR(0)="E" D ^DIR S:X="^" BEXEXIT=1 K DIR
  1. .I BEXEXIT=1 Q
  1. .D HEADER
  1. .W !
  1. ;
  1. I BEXEXIT=1 Q
  1. ;
  1. I BEXTOT>0 D
  1. .W !,"WINDOW",?14,$J(BEXTOT("W"),7)
  1. .W !,"LOCAL MAIL",?14,$J(BEXTOT("L"),7)
  1. .W !,"MAIL",?14,$J(BEXTOT("M"),7)
  1. .W !,"TOTAL",?14,$J(BEXTOT,7)
  1. ;
  1. Q
  1. ;
  1. ;
  1. ;--------------------------------------------------------------
  1. ;---------------------------------------------------------------
  1. ;
  1. U IO
  1. W #
  1. W !,"REPORT: Refill Queue Report"
  1. W " for "
  1. I BEXOPSIT=1 W $$GET1^DIQ(59,$O(BEXOPSIT(0)),.01)
  1. I BEXOPSIT=0 W "all Divisions"
  1. I BEXOPSIT>1 W "selected Divisions"
  1. W !,"DATE RUN: " S Y=DT X ^DD("DD") W Y
  1. W !,"PARAMETERS: "
  1. ;
  1. ;
  1. I BEXRTYPE="ALL" W "Both Processed and Unprocessed Entries"
  1. I BEXRTYPE="UNPROC" W "Unprocessed Entries"
  1. I BEXWIND="W" W ", Window Only"
  1. I BEXWIND="L" W ", Local Mail Only"
  1. I BEXWIND="M" W ", Mail (CMOP) Only"
  1. I BEXSAME=0 W ", Alpha within W/L/M"
  1. I BEXSAME=1 W ", Internal Sort"
  1. ;
  1. W !
  1. W "-------------------------------------------------------------------------------"
  1. W !
  1. W "Name"
  1. W ?21,"Chart"
  1. W ?30,"RX #"
  1. W ?37,"M/W"
  1. W ?42,"LFill"
  1. W ?49,"Drug"
  1. W ?74,"DEA"
  1. ;
  1. W !
  1. W "-------------------------------------------------------------------------------"
  1. W !
  1. ;
  1. Q
  1. ;
  1. ;
  1. ;-----------------------------------------------------------------
  1. DETAIL ;EP - Write Detail for each Record and Add up totals
  1. ;-----------------------------------------------------------------
  1. ;
  1. U IO
  1. S BEXTOT=BEXTOT+1
  1. ;
  1. ;Initialize Counters for each type
  1. I '$D(BEXTOT("M")) S BEXTOT("M")=0
  1. I '$D(BEXTOT("L")) S BEXTOT("L")=0
  1. I '$D(BEXTOT("W")) S BEXTOT("W")=0
  1. ;
  1. ;
  1. ;Add to Counters by Type
  1. I BEXMAIL="W" S BEXTOT("W")=BEXTOT("W")+1
  1. I BEXMAIL="L" S BEXTOT("L")=BEXTOT("L")+1
  1. I BEXMAIL="M" S BEXTOT("M")=BEXTOT("M")+1
  1. ;
  1. ;--> Let's write out the record detail
  1. ;
  1. ;Patient Name
  1. S Y=$$GET1^DIQ(2,BEXPTIEN,.01)
  1. S Y=$E(Y,1,17)
  1. I Y]"" W Y
  1. ;
  1. ;Write Patient HRNO
  1. S Y=""
  1. I +$G(BEXOPIEN) D
  1. .S BEXINST=$P($G(^PS(59,BEXOPIEN,"INI")),U)
  1. .I +BEXINST S Y=$$HRN^AUPNPAT(BEXPTIEN,BEXINST)
  1. I Y="" S Y=$$HRN^AUPNPAT(BEXPTIEN,DUZ(2))
  1. I Y>0 W ?20,$J(Y,6)
  1. ;
  1. ;Write RX Number
  1. S BEXRXNUM=$$GET1^DIQ(52,BEXRXIEN,.01)
  1. ;Align numbers, then add any alpha to the end
  1. I BEXRXNUM W ?28,$J(+BEXRXNUM,8)
  1. S Y=$E(BEXRXNUM,$L(BEXRXNUM)) I Y?1A W Y
  1. ;
  1. ;Mail/Window Code
  1. I BEXMAIL="W" W ?39,"W"
  1. I BEXMAIL="L" W ?39,"L"
  1. I BEXMAIL="M" W ?39,"M"
  1. ;
  1. ;
  1. ;Write Last Fill Date
  1. S Y=$P($G(^PSRX(BEXRXIEN,3)),U)
  1. I Y S Y=$E(Y,4,5)_"/"_$E(Y,6,7)
  1. W ?42,Y
  1. ;
  1. ;Write Drug Name
  1. S Y=$$GET1^DIQ(52,BEXRXIEN,6)
  1. S Y=$E(Y,1,22)
  1. W ?49,Y
  1. ;
  1. ;DEA, Special Handling
  1. S BEXDRIEN=$$GET1^DIQ(52,BEXRXIEN,6,"I")
  1. S Y=""
  1. I BEXDRIEN D
  1. .S X=$$GET1^DIQ(50,BEXDRIEN,3)
  1. .I X[3 S Y=X
  1. .I X[4 S Y=X
  1. .I X[5 S Y=X
  1. W ?74,Y
  1. ;
  1. W !
  1. ;
  1. I $Y>(IOSL-5) D
  1. .I $E(IOST)="C" K DIR S DIR(0)="E" D ^DIR K DIR
  1. .I X="^" S BEXEXIT=1 Q
  1. .D HEADER
  1. ;
  1. Q
  1. ;