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

PSSSCHRP.m

Go to the documentation of this file.
PSSSCHRP ;BIR/RTR-Schedule Report ; 10/15/15 4:26pm
 ;;1.0;PHARMACY DATA MANAGEMENT;**129,160,189,201**;9/30/97;Build 25
 ;External reference to ^PSNAPIS supported by DBIA #2531
 ;
EN ;Prompts for Administration File Schedule Report
 W !!,"This report displays entries from the ADMINISTRATION SCHEDULE (#51.1) File."
 W !,"It can be run for all Schedules, or only Schedules without a FREQUENCY"
 W !,"(IN MINUTES). Only schedules with a PSJ Package Prefix will be displayed, since"
 W !,"they are the only schedules the software will look at when deriving a FREQUENCY"
 W !,"(IN MINUTES) for the daily dosage checks. If a FREQUENCY (IN MINUTES) cannot",!,"be determined for an order, the daily dosage check cannot occur for that order."
 N DIR,PSSAFRP,PSSALONG,Y,X,DTOUT,DUOUT,DIRUT,DIROUT,IOP,%ZIS,POP,ZTRTN,ZTDESC,ZTSAVE,ZTSK
 K DIR,Y S DIR(0)="SO^A:All Schedules;O:Only Schedules with a missing frequency",DIR("A")="Print All Schedules, or Only Schedules without a frequency",DIR("B")="A"
 S DIR("?")=" ",DIR("?",1)=" ",DIR("?",2)="Enter 'A' to see all Administration Schedules, enter 'O' to see only",DIR("?",3)="those Administration Schedules without data in the FREQUENCY (IN MINUTES)"
 S DIR("?",4)="(#2) Field. A FREQUENCY (IN MINUTES) must be derived from a Schedule",DIR("?",5)="for the daily dosage check to occur for an order."
 W ! D ^DIR K DIR I $D(DUOUT)!($D(DTOUT)) D MESS K DIR,Y S DIR(0)="E",DIR("A")="Press Return to continue" D ^DIR K DIR Q
 I Y'="A",Y'="O" D MESS K DIR,Y S DIR(0)="E",DIR("A")="Press Return to continue" D ^DIR K DIR Q
 S PSSAFRP=Y
 K DIR,Y S DIR(0)="SO^80:80 Column;132:132 Column",DIR("A")="Print report in 80 or 132 column format",DIR("B")="80"
 S DIR("?")=" ",DIR("?",1)="Enter 80 to print the report in an 80 column format,",DIR("?",2)="Enter 132 to print the report in an 132 column format."
 W ! D ^DIR K DIR I $D(DUOUT)!($D(DTOUT)) D MESS K DIR,Y S DIR(0)="E",DIR("A")="Press Return to continue" D ^DIR K DIR Q
 I Y'="80",Y'="132" D MESS K DIR,Y S DIR(0)="E",DIR("A")="Press Return to continue" D ^DIR K DIR Q
 S PSSALONG=Y W !
 K IOP,%ZIS,POP S %ZIS="QM" D ^%ZIS I $G(POP)>0 D MESS K DIR,Y S DIR(0)="E",DIR("A")="Press Return to continue" D ^DIR K DIR,IOP,%ZIS,POP Q
 I $D(IO("Q")) S ZTRTN="START^PSSSCHRP",ZTDESC="Administration Schedule Report",ZTSAVE("PSSAFRP")="",ZTSAVE("PSSALONG")="" D ^%ZTLOAD K %ZIS W !!,"Report queued to print.",! K DIR,Y S DIR(0)="E",DIR("A")="Press Return to continue" D ^DIR K DIR Q
 ;
 ;
START ;Print Administration Schedule File report
 U IO
 N PSSAFCT,PSSAFOUT,PSSAFDEV,PSSAFLIN,PSSAFQ,PSSAFQEN,PSSAFQS,PSSAFQL,PSSAFQQ,PSSAFQC,PSSAFAA,PSSAFAL,PSSWAS,PSSWASEN,PSSWASNM,PSSWASAD,PSSWASLL,PSSTPE
 N PSSAFRA,PSSAFRAA,PSSAFROP,PSSAFQL,PSSAFROO,PSSAFRFL,PSSWASX,PSSAFZZZ,PSSAFABC,PSSAFNOF,PSSFD,PSSDFS
 S (PSSAFOUT,PSSAFNOF)=0,PSSAFDEV=$S($E(IOST,1,2)'="C-":"P",1:"C"),PSSAFCT=1
 K PSSAFLIN S:PSSALONG=132 $P(PSSAFLIN,"-",130)="" S:PSSALONG=80 $P(PSSAFLIN,"-",78)=""
 D HD
 S PSSAFQ="" F  S PSSAFQ=$O(^PS(51.1,"B",PSSAFQ)) Q:PSSAFQ=""!(PSSAFOUT)  D
 .F PSSAFQEN=0:0 S PSSAFQEN=$O(^PS(51.1,"B",PSSAFQ,PSSAFQEN)) Q:'PSSAFQEN!(PSSAFOUT)  D
 ..K PSSAFRA,PSSAFRAA,PSSAFROP,PSSAFQS,PSSAFROP,PSSAFROO,PSSAFQL,PSSWASX,PSSAFQC,PSSAFQQ
 ..S PSSAFRA=PSSAFQEN_","
 ..D GETS^DIQ(51.1,PSSAFRA,".01;1;2;4;8;8.1;9;10;11;11.1*;12;13*","E","PSSAFRAA")
 ..I $G(PSSAFRAA(51.1,PSSAFRA,4,"E"))'="PSJ" Q
 ..I PSSAFRP="O",$G(PSSAFRAA(51.1,PSSAFRA,2,"E")) Q
 ..S PSSAFNOF=1
 ..W !!,$G(PSSAFRAA(51.1,PSSAFRA,.01,"E"))
 ..I ($Y+5)>IOSL D HD Q:PSSAFOUT
 ..S PSSAFQS=$G(PSSAFRAA(51.1,PSSAFRA,1,"E"))
 ..W !?5,"STANDARD ADMINISTRATION TIMES: " D  K PSSAFAA Q:PSSAFOUT
 ...Q:PSSAFQS=""
 ...S PSSAFQL=$L(PSSAFQS)
 ...I PSSALONG=132 D  Q
 ....I PSSAFQL<96 D  Q
 .....W PSSAFQS
 .....I ($Y+5)>IOSL D HD Q:PSSAFOUT
 ....K PSSAFAA D FORMAT(PSSAFQS,96)
 ....S PSSAFRFL=0 F PSSAFAL=0:0 S PSSAFAL=$O(PSSAFAA(PSSAFAL)) Q:'PSSAFAL!(PSSAFOUT)  D
 .....W:'PSSAFRFL ?36,$G(PSSAFAA(PSSAFAL)) W:PSSAFRFL !?36,$G(PSSAFAA(PSSAFAL)) S PSSAFRFL=1
 .....I ($Y+5)>IOSL D HD Q:PSSAFOUT
 ...I PSSAFQL<44 D  Q
 ....W PSSAFQS
 ....I ($Y+5)>IOSL D HD Q:PSSAFOUT
 ...K PSSAFAA D FORMAT(PSSAFQS,44)
 ...S PSSAFRFL=0 F PSSAFAL=0:0 S PSSAFAL=$O(PSSAFAA(PSSAFAL)) Q:'PSSAFAL!(PSSAFOUT)  D
 ....W:'PSSAFRFL ?36,$G(PSSAFAA(PSSAFAL)) W:PSSAFRFL !?36,$G(PSSAFAA(PSSAFAL)) S PSSAFRFL=1
 ....I ($Y+5)>IOSL D HD Q:PSSAFOUT
 ..I ($Y+5)>IOSL D HD Q:PSSAFOUT
 ..W !?14,"OUTPATIENT EXPANSION: " D
 ...S PSSAFROP=$G(PSSAFRAA(51.1,PSSAFRA,8,"E"))
 ...I PSSALONG=132 D  Q
 ....I $L(PSSAFROP)<96 W PSSAFROP,! Q
 ....N X,DIWL,DIWR,DIWF S X=PSSAFROP,DIWL=37,DIWR=131,DIWF="W" K ^UTILITY($J,"W") D ^DIWP D ^DIWW K ^UTILITY($J,"W")
 ...I $L(PSSAFROP)<44 W PSSAFROP,! Q
 ...N X,DIWL,DIWR,DIWF S X=PSSAFROP,DIWL=37,DIWR=79,DIWF="W" K ^UTILITY($J,"W") D ^DIWP D ^DIWW K ^UTILITY($J,"W")
 ..I ($Y+5)>IOSL D HD Q:PSSAFOUT  W !
 ..W ?10,"OTHER LANGUAGE EXPANSION: " D
 ...S PSSAFROO=$G(PSSAFRAA(51.1,PSSAFRA,8.1,"E"))
 ...I PSSALONG=132 D  Q
 ....I $L(PSSAFROO)<96 W PSSAFROO,! Q
 ....N X,DIWL,DIWR,DIWF S X=PSSAFROO,DIWL=37,DIWR=131,DIWF="W" K ^UTILITY($J,"W") D ^DIWP D ^DIWW K ^UTILITY($J,"W")
 ...I $L(PSSAFROO)<44 W PSSAFROO,! Q
 ...N X,DIWL,DIWR,DIWF S X=PSSAFROO,DIWL=37,DIWR=79,DIWF="W" K ^UTILITY($J,"W") D ^DIWP D ^DIWW K ^UTILITY($J,"W")
 ..;Set PSSAFZZZ=0 if last write had a line feed, PSSAFZZZ=1 if last write did not have a line feed, to use for OLD SCHEDULE NAME(S)
 ..S PSSAFZZZ=0 I ($Y+5)>IOSL D HD S PSSAFZZZ=0 Q:PSSAFOUT
 ..S PSSAFRFL=0 F PSSWAS=0:0 S PSSWAS=$O(^PS(51.1,PSSAFQEN,1,PSSWAS)) Q:'PSSWAS!(PSSAFOUT)  D
 ...S PSSWASEN=$P($G(^PS(51.1,PSSAFQEN,1,PSSWAS,0)),"^") Q:'PSSWASEN
 ...S PSSWASX=PSSWAS_","_PSSAFQEN_"," S PSSWASNM=$$GET1^DIQ(51.11,PSSWASX,".01") Q:PSSWASNM=""
 ...;PSSARFRL=0 if last Write ended in Line Feed, =1 if Last Write did not end in line feed, for writing Wards
 ...W:'PSSAFRFL ?30,"WARD: "_PSSWASNM W:PSSAFRFL !?30,"WARD: "_PSSWASNM S (PSSAFZZZ,PSSAFRFL)=1
 ...I ($Y+5)>IOSL D HD S (PSSAFZZZ,PSSAFRFL)=0 Q:PSSAFOUT
 ...W !?9,"WARD ADMINISTRATION TIMES: " S (PSSAFZZZ,PSSAFRFL)=1
 ...S PSSWASAD=$P($G(^PS(51.1,PSSAFQEN,1,PSSWAS,0)),"^",2)
 ...Q:PSSWASAD=""
 ...S (PSSWASLL,PSSAFQL)=$L(PSSWASAD)
 ...I PSSALONG=132 D  Q
 ....I PSSWASLL<96 D  Q
 .....W PSSWASAD S (PSSAFZZZ,PSSAFRFL)=1
 .....I ($Y+5)>IOSL D HD S (PSSAFZZZ,PSSAFRFL)=0 Q:PSSAFOUT
 ....K PSSAFAA D FORMAT(PSSWASAD,96)
 ....S PSSAFABC=0 F PSSAFAL=0:0 S PSSAFAL=$O(PSSAFAA(PSSAFAL)) Q:'PSSAFAL!(PSSAFOUT)  D
 .....W:'PSSAFABC ?36,$G(PSSAFAA(PSSAFAL)) W:PSSAFABC !?36,$G(PSSAFAA(PSSAFAL)) S PSSAFABC=1 S (PSSAFZZZ,PSSAFRFL)=1
 .....I ($Y+5)>IOSL D HD S (PSSAFZZZ,PSSAFRFL)=0 Q:PSSAFOUT
 ...I PSSWASLL<37 D  Q
 ....W PSSWASAD S (PSSAFZZZ,PSSAFRFL)=1
 ....I ($Y+5)>IOSL D HD S (PSSAFZZZ,PSSAFRFL)=0 Q:PSSAFOUT
 ...K PSSAFAA D FORMAT(PSSWASAD,44)
 ...S PSSAFABC=0 F PSSAFAL=0:0 S PSSAFAL=$O(PSSAFAA(PSSAFAL)) Q:'PSSAFAL!(PSSAFOUT)  D
 ....W:'PSSAFABC ?36,$G(PSSAFAA(PSSAFAL)) W:PSSAFABC !?36,$G(PSSAFAA(PSSAFAL)) S PSSAFABC=1 S (PSSAFZZZ,PSSAFRFL)=1
 ....I ($Y+5)>IOSL D HD S (PSSAFZZZ,PSSAFRFL)=0 Q:PSSAFOUT
 ..Q:PSSAFOUT
 ..K PSSAFAA
 ..I ($Y+5)>IOSL D HD S (PSSAFZZZ,PSSAFRFL)=0 Q:PSSAFOUT
 ..W:'PSSAFZZZ ?14,"OLD SCHEDULE NAME(S): "  W:PSSAFZZZ !?14,"OLD SCHEDULE NAME(S): "
 ..S:$D(PSSAFRAA(51.113)) PSSFD=1,PSSDFS=0 IF $D(PSSFD),$D(PSSDFS) FOR  SET PSSFD=$O(PSSAFRAA(51.113,PSSFD)) Q:PSSFD']""!(PSSAFOUT)  D
 ...W:'PSSDFS ?36,$G(PSSAFRAA(51.113,PSSFD,.01,"E")) W:PSSDFS !,?36,$G(PSSAFRAA(51.113,PSSFD,.01,"E")) S PSSDFS=1
 ...I ($Y+5)>IOSL D HD Q:PSSAFOUT
 ..Q:PSSAFOUT
 ..K PSSTPE S PSSTPE=$$GET1^DIQ(51.1,PSSAFQEN_",",5)
 ..W:'PSSAFZZZ !?21,"SCHEDULE TYPE: "_$G(PSSTPE) W:PSSAFZZZ !?21,"SCHEDULE TYPE: "_$G(PSSTPE)
 ..I ($Y+5)>IOSL D HD Q:PSSAFOUT
 ..W !?12,"FREQUENCY (IN MINUTES): "_$G(PSSAFRAA(51.1,PSSAFRA,2,"E"))
 ..I ($Y+5)>IOSL D HD Q:PSSAFOUT
 ..W !?6,"EXCLUDE FROM ALL DOSE CHECKS: "_$G(PSSAFRAA(51.1,PSSAFRA,9,"E"))
 ..I ($Y+5)>IOSL D HD Q:PSSAFOUT
 ..W !?5,"EXCLUDE FROM DAILY DOSE CHECK: "_$G(PSSAFRAA(51.1,PSSAFRA,10,"E"))
 ..I ($Y+5)>IOSL D HD Q:PSSAFOUT
 ..W !?12,"DOSING CHECK FREQUENCY: "_$G(PSSAFRAA(51.1,PSSAFRA,11,"E"))
 ..I ($Y+5)>IOSL D HD Q:PSSAFOUT
 ..W !?7,"DRUG(S) FOR DOSING CHK FREQ: "
 ..S:$D(PSSAFRAA(51.111)) PSSFD=1,PSSDFS=0 IF $D(PSSFD),$D(PSSDFS) FOR  SET PSSFD=$O(PSSAFRAA(51.111,PSSFD)) Q:PSSFD']""!(PSSAFOUT)  D
 ...W:'PSSDFS ?36,$G(PSSAFRAA(51.111,PSSFD,.01,"E")) W:PSSDFS !,?36,$G(PSSAFRAA(51.111,PSSFD,.01,"E")) S PSSDFS=1
 ...I ($Y+5)>IOSL D HD Q:PSSAFOUT
 ..W !?26,"INACTIVE: "_$G(PSSAFRAA(51.1,PSSAFRA,12,"E"))
 ..I ($Y+5)>IOSL D HD Q:PSSAFOUT
 ;
END ;
 I '$G(PSSAFOUT),PSSAFRP="O",'$G(PSSAFNOF) W !!,"No schedules found without frequencies.",!
 I $G(PSSAFDEV)="P"  W !!,"End of Report.",!
 I '$G(PSSAFOUT),$G(PSSAFDEV)="C" W !!,"End of Report." K DIR S DIR(0)="E",DIR("A")="Press Return to continue" D ^DIR K DIR
 I $G(PSSAFDEV)="C" W !
 E  W @IOF
 K PSSAFRP,PSSALONG
 D ^%ZISC S:$D(ZTQUEUED) ZTREQ="@"
 Q
 ;
 ;
HD ;Report Header
 I $G(PSSAFDEV)="C",$G(PSSAFCT)'=1 W ! K DIR,Y S DIR(0)="E",DIR("A")="Press Return to continue, '^' to exit" D ^DIR K DIR I 'Y S PSSAFOUT=1 Q
 W @IOF
 I PSSAFRP="A" W !,"ADMINISTRATION SCHEDULE FILE REPORT (All)"
 I PSSAFRP="O" W !,"ADMINISTRATION SCHEDULE WITHOUT FREQUENCY REPORT"
 W ?$S(PSSALONG=80:68,1:120),"PAGE: "_PSSAFCT,!,PSSAFLIN,! S PSSAFCT=PSSAFCT+1
 Q
 ;
 ;
MESS ;
 W !!,"Nothing queued to print.",!
 Q
 ;
 ;
FORMAT(PSSAFQC,PSSAFQQ) ;Format print arrays, breaking on the "-" character
 ;PSSAFQC = Administration Times text
 ;PSSAFQQ = Character at which to break
 N PSSAFAC,PSSAFAB,PSSAFAZ,PSSAFAD,PSSAFAF,PSSAFAX
 S PSSAFAC=1,PSSAFAZ=0 K PSSAFAB
 F PSSAFAD=1:1:PSSAFQL I $E(PSSAFQC,PSSAFAD)="-" S PSSAFAB(PSSAFAC)=$P(PSSAFQC,"-",PSSAFAC)_"-" S PSSAFAC=PSSAFAC+1,PSSAFAZ=PSSAFAD+1
 I PSSAFAZ<PSSAFAD S:PSSAFAZ=0 PSSAFAZ=1 S PSSAFAB(PSSAFAC)=$E(PSSAFQC,PSSAFAZ,PSSAFQL) S PSSAFAC=PSSAFAC+1
 S PSSAFAF=1
 F PSSAFAX=1:1:PSSAFAC D
 .Q:'$D(PSSAFAB(PSSAFAX))
 .I '$D(PSSAFAA(PSSAFAF)) S PSSAFAA(PSSAFAF)=PSSAFAB(PSSAFAX) Q
 .I $L(PSSAFAA(PSSAFAF))+$L(PSSAFAB(PSSAFAX))<PSSAFQQ S PSSAFAA(PSSAFAF)=PSSAFAA(PSSAFAF)_PSSAFAB(PSSAFAX) Q
 .S PSSAFAF=PSSAFAF+1 S PSSAFAA(PSSAFAF)=PSSAFAB(PSSAFAX)
 Q
 ;
 ;
TRAIL ;Trailing spaces Report
 W !!,"This report displays active, multi-ingredient entries from the DRUG (#50) File"
 W !,"with Local Possible Dosages defined, with trailing spaces in the name. Entries"
 W !,"not matched to National Drug File are also included if there are trailing"
 W !,"spaces. Trailing spaces can potentially cause the Dose check to fail, and"
 W !,"also possibly cause the conjunction and drug name to become part of the Dosage.",!
 N DIR,Y,X,DTOUT,DUOUT,DIRUT,DIROUT,IOP,%ZIS,POP,ZTRTN,ZTDESC,ZTSAVE,ZTSK
 K IOP,%ZIS,POP S %ZIS="QM" D ^%ZIS I $G(POP)>0 D MESS K DIR,Y S DIR(0)="E",DIR("A")="Press Return to continue" D ^DIR K DIR,IOP,%ZIS,POP Q
 I $D(IO("Q")) S ZTRTN="STRAIL^PSSSCHRP",ZTDESC="Trailing Spaces Report" D ^%ZTLOAD K %ZIS W !!,"Report queued to print.",! K DIR,Y S DIR(0)="E",DIR("A")="Press Return to continue" D ^DIR K DIR Q
 ;
 ;
STRAIL ;Print Trailing spaces report
 U IO
 N PSSTRSOT,PSSTRSLG,PSSTRSFL,PSSTRSDV,PSSTRSPG,PSSTRSAA,PSSTRSBB,PSSTRSNM,PSSTRSIN,PSSTRSST,PSSTRSUN,PSSTRSN1,PSSTRSN3,PSSTRSN9
 S (PSSTRSOT,PSSTRSFL)=0,PSSTRSDV=$S($E(IOST,1,2)'="C-":"P",1:"C"),PSSTRSPG=1
 K PSSTRSLG S $P(PSSTRSLG,"-",78)=""
 D STHD
 S PSSTRSAA="" F  S PSSTRSAA=$O(^PSDRUG("B",PSSTRSAA)) Q:PSSTRSAA=""!(PSSTRSOT)  D
 .F PSSTRSBB=0:0 S PSSTRSBB=$O(^PSDRUG("B",PSSTRSAA,PSSTRSBB)) Q:'PSSTRSBB!(PSSTRSOT)  D:$O(^PSDRUG(PSSTRSBB,"DOS2",0))
 ..S PSSTRSNM=$P($G(^PSDRUG(PSSTRSBB,0)),"^"),PSSTRSIN=$P($G(^PSDRUG(PSSTRSBB,"I")),"^")
 ..I $E(PSSTRSNM,$L(PSSTRSNM))'=" " Q
 ..I PSSTRSIN,PSSTRSIN<DT Q
 ..S PSSTRSN1=$P($G(^PSDRUG(PSSTRSBB,"ND")),"^"),PSSTRSN3=$P($G(^PSDRUG(PSSTRSBB,"ND")),"^",3)
 ..I 'PSSTRSN1!('PSSTRSN3) W !,PSSTRSNM_"   ("_PSSTRSBB_")" S PSSTRSFL=1 D:($Y+5)>IOSL STHD Q
 ..S PSSTRSST=$P($G(^PSDRUG(PSSTRSBB,"DOS")),"^"),PSSTRSUN=$P($G(^PSDRUG(PSSTRSBB,"DOS")),"^",2)
 ..I PSSTRSST'="" Q
 ..K PSSTRSN9 I PSSTRSST=""!('PSSTRSUN) S PSSTRSN9=$$DFSU^PSNAPIS(PSSTRSN1,PSSTRSN3)
 ..S PSSTRSST=$P($G(PSSTRSN9),"^",4) I $$STST() Q
 ..W !,PSSTRSNM_"   ("_PSSTRSBB_")" S PSSTRSFL=1 I ($Y+5)>IOSL D STHD
 ;
 ;
STEND ;
 I '$G(PSSTRSOT),'$G(PSSTRSFL) W !!,"No drug names found.",!
 I $G(PSSTRSDV)="P"  W !!,"End of Report.",!
 I '$G(PSSTRSOT),$G(PSSTRSDV)="C" W !!,"End of Report." K DIR S DIR(0)="E",DIR("A")="Press Return to continue" D ^DIR K DIR
 I $G(PSSTRSDV)="C" W !
 E  W @IOF
 D ^%ZISC S:$D(ZTQUEUED) ZTREQ="@"
 Q
 ;
 ;
STHD ;Report Header
 I $G(PSSTRSDV)="C",$G(PSSTRSPG)'=1 W ! K DIR,Y S DIR(0)="E",DIR("A")="Press Return to continue, '^' to exit" D ^DIR K DIR I 'Y S PSSTRSOT=1 Q
 W @IOF
 W !,"DRUG NAME TRAILING SPACES REPORT"
 W ?68,"PAGE: "_PSSTRSPG,!,PSSTRSLG,! S PSSTRSPG=PSSTRSPG+1
 Q
 ;
 ;
STST() ;Is strength numeric
 I PSSTRSST="" Q 0
 I PSSTRSST'?.N&(PSSTRSST'?.N1".".N) Q 0
 Q 1