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

PSSLDOSE.m

Go to the documentation of this file.
  1. PSSLDOSE ;BIR/RTR-Local Possible Dosages Report ;06/22/07
  1. ;;1.0;PHARMACY DATA MANAGEMENT;**129**;9/30/07;Build 67
  1. ;
  1. ;External reference to PS(50.607 supported by DBIA 2221
  1. ;
  1. EN ;
  1. W !!,"This report will print Local Possible Dosage information only for Drugs for"
  1. W !,"which Dosage Checks can be performed. Drugs that are inactive, marked and/or"
  1. W !,"classed as supply items, not matched to NDF or excluded from dosage checks (due"
  1. W !,"to dosage form or VA Product override) will not be included in this report."
  1. W !!,"Users will be able to print Local Possible Dosage information for all eligible"
  1. W !,"drugs or only for drugs with missing data in the Numeric Dose and Dose Unit"
  1. W !,"fields. These two fields must be populated to perform Dosage Checks for a Local"
  1. W !,"Possible Dosage selected when placing a Pharmacy order."
  1. N DIR,PSSKZTPE,X,Y,DTOUT,DUOUT,DIRUT,DIROUT,IOP,%ZIS,POP,ZTRTN,ZTDESC,ZTSAVE,ZTSK
  1. K DIR S DIR(0)="SO^A:ALL LOCAL POSSIBLE DOSAGES;O:ONLY LOCAL POSSIBLE DOSAGE WITH MISSING DATA",DIR("A")="Enter 'A' for All, 'O' for Only",DIR("B")="O"
  1. S DIR("?")=" ",DIR("?",1)="Enter 'A' to see All Local Possible Dosages, regardless of whether or not the ",DIR("?",2)="associated Numeric Dose and Dose Unit fields are populated. Enter 'O' to see"
  1. S DIR("?",3)="only those Local Possible Dosages with missing data in either the Numeric Dose",DIR("?",4)="or Dose Unit fields. The two fields must be populated if Dosage Checks are"
  1. S DIR("?",5)="to be performed when this Local Possible Dosage is selected when placing a",DIR("?",6)="Pharmacy order."
  1. D ^DIR K DIR I $D(DUOUT)!($D(DTOUT)) D MESS K DIR S DIR(0)="E",DIR("A")="Press Return to continue" D ^DIR K DIR Q
  1. I Y'="A",Y'="O" D MESS K DIR S DIR(0)="E",DIR("A")="Press Return to continue" D ^DIR K DIR Q
  1. S PSSKZTPE=Y
  1. W !!,"This report is designed for 132 column format!",!
  1. K IOP,%ZIS,POP S %ZIS="QM" D ^%ZIS I $G(POP)>0 D MESS K DIR S DIR(0)="E",DIR("A")="Press Return to continue" D ^DIR K DIR,IOP,%ZIS,POP Q
  1. I $D(IO("Q")) S ZTRTN="START^PSSLDOSE",ZTDESC="Local Possible Dosages Report",ZTSAVE("PSSKZTPE")="" D ^%ZTLOAD K %ZIS W !!,"Report queued to print.",! D Q
  1. .K DIR S DIR(0)="E",DIR("A")="Press Return to continue" D ^DIR K DIR
  1. ;
  1. ;
  1. START ;Print Local Possible Dosages Report
  1. U IO
  1. N PSSKZDEV,PSSKZCT,PSSKZOUT,PSSKZLIN,PSSKZNOF,PSSKZNM,PSSKZIEN,PSSKZOK,PSSKZDAT,PSSKZLIP,PSSKZND1,PSSKZND3,PSSKZZR,PSSKZNDF,PSSKZDF,PSSKZDT1,PSSKZLP1
  1. N PSSKZNFL,PSSKZMSG,PSSKZSTR,PSSKZUNT,PSSKZUNZ,PSSKZAPU,PSSKZ1,PSSKZ2,PSSKZ3,PSSKZLD5,PSSKZLD6,PSSKZLD7,PSSKZNN1,PSSKZNN2
  1. S (PSSKZOUT,PSSKZNOF)=0,PSSKZDEV=$S($E(IOST,1,2)'="C-":"P",1:"C"),PSSKZCT=1
  1. K PSSKZLIN S $P(PSSKZLIN,"-",130)=""
  1. D HD
  1. S PSSKZNM="" F S PSSKZNM=$O(^PSDRUG("B",PSSKZNM)) Q:PSSKZNM=""!(PSSKZOUT) F PSSKZIEN=0:0 S PSSKZIEN=$O(^PSDRUG("B",PSSKZNM,PSSKZIEN)) Q:'PSSKZIEN!(PSSKZOUT) D
  1. .K PSSKZOK,PSSKZDAT,PSSKZLIP,PSSKZZR,PSSKZNDF,PSSKZDF,PSSKZDT1,PSSKZLP1,PSSKZNFL,PSSKZMSG,PSSKZSTR,PSSKZUNT,PSSKZUNZ,PSSKZAPU,PSSKZ1,PSSKZ2,PSSKZ3,PSSKZND1,PSSKZND3
  1. .S PSSKZZR=$G(^PSDRUG(PSSKZIEN,0))
  1. .S PSSKZSTR=$P($G(^PSDRUG(PSSKZIEN,"DOS")),"^"),PSSKZUNT=$P($G(^PSDRUG(PSSKZIEN,"DOS")),"^",2)
  1. .S PSSKZSTR=$S($E(PSSKZSTR,1)=".":"0"_PSSKZSTR,1:PSSKZSTR)
  1. .I PSSKZUNT S PSSKZUNZ=$P($G(^PS(50.607,+PSSKZUNT,0)),"^")
  1. .S PSSKZNFL=$S($P(PSSKZZR,"^",9):1,1:0),PSSKZMSG=$P(PSSKZZR,"^",10)
  1. .S PSSKZAPU=$P($G(^PSDRUG(PSSKZIEN,2)),"^",3)
  1. .S PSSKZND1=$P($G(^PSDRUG(PSSKZIEN,"ND")),"^"),PSSKZND3=$P($G(^PSDRUG(PSSKZIEN,"ND")),"^",3)
  1. .S PSSKZOK=$$TEST
  1. .I 'PSSKZOK Q
  1. .S PSSKZDAT=0 F PSSKZLIP=0:0 S PSSKZLIP=$O(^PSDRUG(PSSKZIEN,"DOS2",PSSKZLIP)) Q:'PSSKZLIP!(PSSKZDAT) I $P($G(^PSDRUG(PSSKZIEN,"DOS2",PSSKZLIP,0)),"^")'="" S PSSKZDAT=1
  1. .I 'PSSKZDAT Q
  1. .S PSSKZDT1=0 I PSSKZTPE="O" F PSSKZLP1=0:0 S PSSKZLP1=$O(^PSDRUG(PSSKZIEN,"DOS2",PSSKZLP1)) Q:'PSSKZLP1!(PSSKZDT1) I $P($G(^PSDRUG(PSSKZIEN,"DOS2",PSSKZLP1,0)),"^")'="" D
  1. ..I '$P($G(^PSDRUG(PSSKZIEN,"DOS2",PSSKZLP1,0)),"^",5)!($P($G(^PSDRUG(PSSKZIEN,"DOS2",PSSKZLP1,0)),"^",6)="") S PSSKZDT1=1
  1. .I PSSKZTPE="O",'PSSKZDT1 Q
  1. .S PSSKZNOF=1
  1. .W !!!,"("_PSSKZIEN_")",?19,$P(PSSKZZR,"^")_$S(PSSKZNFL:" *N/F*",1:"")
  1. .I ($Y+5)>IOSL D HD Q:PSSKZOUT
  1. .I PSSKZMSG'="" W !?12,PSSKZMSG
  1. .I ($Y+5)>IOSL D HD Q:PSSKZOUT
  1. .W !?12,"Strength: "_PSSKZSTR W ?43,"Units: " I $G(PSSKZUNZ)'="" W $G(PSSKZUNZ)
  1. .I $G(PSSKZUNZ)'="",$L(PSSKZUNZ)>15 W !
  1. .;I ($Y+5)>IOSL D HD Q:PSSKZOUT
  1. .W ?66,"Application Package: "_PSSKZAPU
  1. .I ($Y+5)>IOSL D HD Q:PSSKZOUT
  1. .S PSSKZ3=0 W !?4,"Local Possible Dosages: " F PSSKZ1=0:0 S PSSKZ1=$O(^PSDRUG(PSSKZIEN,"DOS2",PSSKZ1)) Q:'PSSKZ1!(PSSKZOUT) D
  1. ..S PSSKZ2=$G(^PSDRUG(PSSKZIEN,"DOS2",PSSKZ1,0))
  1. ..I $P(PSSKZ2,"^")="" Q
  1. ..I $P(PSSKZ2,"^",5),$P(PSSKZ2,"^",6)'="",PSSKZTPE="O" Q
  1. ..S PSSKZ3=1
  1. ..I ($Y+5)>IOSL D HD Q:PSSKZOUT
  1. ..W !?6,$P(PSSKZ2,"^")
  1. ..I ($Y+5)>IOSL D HD Q:PSSKZOUT
  1. ..K PSSKZLD5,PSSKZLD6,PSSKZLD7
  1. ..S PSSKZLD5=$P(PSSKZ2,"^",5),PSSKZLD6=$P(PSSKZ2,"^",6)
  1. ..S PSSKZLD7=$S($E(PSSKZLD6,1)=".":"0"_PSSKZLD6,1:PSSKZLD6)
  1. ..W !?6,"Numeric Dose: "_PSSKZLD7,?46,"Dose Unit: "_$S($G(PSSKZLD5):$P($G(^PS(51.24,+PSSKZLD5,0)),"^"),1:""),?92,"Package: "_$P(PSSKZ2,"^",2)
  1. ..I ($Y+5)>IOSL D HD Q:PSSKZOUT
  1. .Q:PSSKZOUT
  1. .I 'PSSKZ3 W "(None)"
  1. .I ($Y+5)>IOSL D HD Q:PSSKZOUT
  1. .K PSSKZNN1,PSSKZNN2
  1. .I 'PSSKZND1!('PSSKZND3) Q
  1. .S PSSKZNN1=$$PROD0^PSNAPIS(PSSKZND1,PSSKZND3)
  1. .S PSSKZNN2=$S($E($P(PSSKZNN1,"^",3),1)=".":"0"_$P(PSSKZNN1,"^",3),1:$P(PSSKZNN1,"^",3))
  1. .I PSSKZSTR'="",PSSKZNN2'="",PSSKZNN2'=PSSKZSTR W !?3,"Note: Strength of "_PSSKZSTR_" does not match NDF strength of "_PSSKZNN2_"."
  1. .I ($Y+5)>IOSL D HD Q:PSSKZOUT
  1. .W !?3,"VA PRODUCT MATCH: "_$P(PSSKZNN1,"^")
  1. .I ($Y+5)>IOSL D HD Q:PSSKZOUT
  1. ;
  1. END ;
  1. I '$G(PSSKZOUT),PSSKZTPE="O",'$G(PSSKZNOF) W !!,"No local possible dosage missing data found.",!
  1. I PSSKZDEV="P" W !!,"End of Report.",!
  1. I '$G(PSSKZOUT),PSSKZDEV="C" W !!,"End of Report." K DIR S DIR(0)="E",DIR("A")="Press Return to continue" D ^DIR K DIR
  1. I PSSKZDEV="C" W !
  1. E W @IOF
  1. K PSSKZTPE
  1. D ^%ZISC S:$D(ZTQUEUED) ZTREQ="@"
  1. Q
  1. ;
  1. ;
  1. HD ;Report Header
  1. I PSSKZDEV="C",PSSKZCT'=1 W ! K DIR,Y S DIR(0)="E",DIR("A")="Press Return to continue, '^' to exit" D ^DIR I 'Y S PSSKZOUT=1 Q
  1. W @IOF
  1. I PSSKZTPE="A" W !,"Local Possible Dosages Report (All)"
  1. I PSSKZTPE="O" W !,"Local Possible Dosages Report (Missing Data Only)"
  1. W ?118,"PAGE: "_PSSKZCT,!,PSSKZLIN,! S PSSKZCT=PSSKZCT+1
  1. Q
  1. ;
  1. ;
  1. MESS ;
  1. W !!,"Nothing queued to print.",!
  1. Q
  1. ;
  1. ;
  1. TEST() ;Test to see if Drug meets criteria
  1. ;No need to have Local Possible Dose check here, you have it right after calling this at top
  1. I 'PSSKZND3!('PSSKZND1) Q 0
  1. I $P($G(^PSDRUG(PSSKZIEN,"I")),"^"),$P($G(^PSDRUG(PSSKZIEN,"I")),"^")<DT Q 0
  1. N PSSKZDOV
  1. S PSSKZDOV=""
  1. I PSSKZND1,PSSKZND3,$T(OVRIDE^PSNAPIS)]"" S PSSKZDOV=$$OVRIDE^PSNAPIS(PSSKZND1,PSSKZND3)
  1. I $P(PSSKZZR,"^",3)["S"!($E($P(PSSKZZR,"^",2),1,2)="XA") Q 0
  1. K PSSKZDF
  1. I PSSKZND1,PSSKZND3 S PSSKZNDF=$$DFSU^PSNAPIS(PSSKZND1,PSSKZND3) S PSSKZDF=$P(PSSKZNDF,"^")
  1. I $G(PSSKZDF)'>0,$P($G(^PSDRUG(PSSKZIEN,2)),"^") S PSSKZDF=$P($G(^PS(50.7,+$P($G(^PSDRUG(PSSKZIEN,2)),"^"),0)),"^",2)
  1. I PSSKZDOV=""!('$G(PSSKZDF))!($P($G(^PS(50.606,+$G(PSSKZDF),1)),"^")="") Q 1
  1. I $P($G(^PS(50.606,+$G(PSSKZDF),1)),"^"),'PSSKZDOV Q 0
  1. I '$P($G(^PS(50.606,+$G(PSSKZDF),1)),"^"),PSSKZDOV Q 0
  1. Q 1