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

PSJVOSR.m

Go to the documentation of this file.
  1. PSJVOSR ;BIR/DRF-PRINT ACTIVE ORDER SCHEDULE VALIDATION ;13 APR 09 / 5:26 PM
  1. ;;5.0; INPATIENT MEDICATIONS ;**113**;16 DEC 97;Build 63
  1. ;
  1. ; Reference to ^PS(55 is supported by DBIA 2191.
  1. ; Reference to ^%ZTLOAD is supported by DBIA 10063.
  1. ; Reference to ^%DTC is supported by DBIA 10000.
  1. ; Reference to ^%ZIS is supported by DBIA 10086.
  1. ; Reference to ^%ZISC is supported by DBIA 10089.
  1. ; Reference to ^DIR is supported by DBIA 10026.
  1. ;
  1. SELDEV ;Ask for device type for report to output to
  1. K IOP,%ZIS,POP,IO("Q")
  1. W ! S %ZIS("A")="Select output device: ",%ZIS("B")="",%ZIS="Q"
  1. D ^%ZIS I POP W !,"** No device selected **" G EXIT
  1. W:'$D(IO("Q")) !,"this may take a while...(you should QUEUE this report)",!
  1. I $D(IO("Q")) D G EXIT
  1. . S XDESC="Problem Schedules on Orders"
  1. . S ZTRTN="START^PSJVOSR"
  1. . K IO("Q"),ZTSAVE,ZTDTH,ZTSK
  1. . S ZTDESC=XDESC,PSGIO=ION,ZTIO=PSGIO,ZTDTH=$H,ZTSAVE("PSJSORT")="",%ZIS="QN",IOP=PSGIO
  1. . D ^%ZIS,^%ZTLOAD
  1. ;
  1. START ;Loop through open orders.
  1. D NOW^%DTC S UL132="",$P(UL132,"-",132)="",PSJDATE=$$ENDTC^PSGMI(%),PSJPTR=$E(IOST)'="C",PG=0,PSIVAC="PH",PSJPAG=0
  1. U IO
  1. D HEAD
  1. S PSJTYP="U"
  1. S STPDT=$P(%,".")-1 F S STPDT=$O(^PS(55,"AUD",STPDT)) Q:STPDT="" D
  1. . S D0="" F S D0=$O(^PS(55,"AUD",STPDT,D0)) Q:D0="" D
  1. .. S D1="" F S D1=$O(^PS(55,"AUD",STPDT,D0,D1)) Q:D1="" D
  1. ... D TEST
  1. S PSJTYP="V"
  1. S STPDT=$P(%,".")-1 F S STPDT=$O(^PS(55,"AIV",STPDT)) Q:STPDT="" D
  1. . S D0="" F S D0=$O(^PS(55,"AIV",STPDT,D0)) Q:D0="" D
  1. .. S D1="" F S D1=$O(^PS(55,"AIV",STPDT,D0,D1)) Q:D1="" D
  1. ... D TEST
  1. EXIT ;Kill and exit.
  1. K %,%H,%I,%ZIS,ZTDESC,ZTDTH,ZTIO,ZTSAVE,ZTRTN
  1. K D0,D1,DONE,ERR,NAME,PG,PSGAT,PSGIO,PSGS0XT,PSGSCH,PSGSSP,PSGSST,PSGST
  1. K PSIVAC,PSJDATE,PSJPAG,PSJPTR,PSJTYP,SPD,SSN,STD,STPDT,UL132,X,XDESC,Y
  1. K ZTQUEUED,ZTREQ
  1. W:$E(IOST)="C"&($Y) @IOF
  1. S:$D(ZTQUEUED) ZTREQ="@"
  1. S IOP="HOME" D ^%ZISC
  1. Q
  1. ;
  1. DISPLAY ;Display Name, last 4 of SS, order number, start date, stop date, schedule, schedule type, admin times, error.
  1. S NAME=$$GET1^DIQ(2,D0,.01,"O")
  1. S SSN="XXX-XX-"_$E($$GET1^DIQ(2,D0,.09,"O"),6,9)
  1. S Y=PSGSST D DD^%DT S STD=Y
  1. S Y=PSGSSP D DD^%DT S SPD=Y
  1. D:($Y+5)>IOSL HEAD
  1. W !,NAME,?20,SSN,?33,STD,?52,SPD,?71,PSGSCH,?91,$S(+PSGS0XT:"C",1:PSGS0XT),?96,PSGAT,!,ERR
  1. Q
  1. ;
  1. PAUSE ;Hold screen.
  1. K DIR S DIR(0)="E" D ^DIR S:$D(DTOUT)!($D(DUOUT)) DONE=1
  1. Q
  1. ;
  1. TEST ;Check for errors.
  1. N D12,MAX
  1. I PSJTYP="U" D
  1. . S D12=$G(^PS(55,D0,5,D1,2))
  1. . S PSGSCH=$P(D12,"^",1),(X,PSGAT)=$P(D12,"^",5),PSGS0XT=$P(D12,"^",6),PSGSST=$P(D12,"^",2),PSGSSP=$P(D12,"^",4)
  1. I PSJTYP="V" D
  1. . S D12=$G(^PS(55,D0,"IV",D1,0))
  1. . S PSGSCH=$P(D12,"^",9),(X,PSGAT)=$P(D12,"^",11),PSGS0XT=$P(D12,"^",15),PSGSST=$P(D12,"^",2),PSGSSP=$P(D12,"^",3)
  1. I PSGSCH[" PRN" S PSGS0XT="P"
  1. I PSGS0XT="P" D Q ;No times required or allowed for PRN
  1. . I X="" Q
  1. . S ERR="Admin times not permitted for PRN schedule"
  1. . D DISPLAY
  1. I PSGS0XT="D"!(PSGS0XT)="OC" Q
  1. S PSGST=$S(PSGS0XT?1.N:"C",1:PSGS0XT)
  1. S ERR="" D
  1. . I X="" S ERR="This order requires at least one administration time" Q
  1. . I $G(PSGS0XT)="O",$L(X,"-")>1 S ERR="This is a One Time Order - only one admin time is permitted." Q
  1. . I +PSGS0XT=0 Q ;No frequency - can not check frequency related items
  1. . S MAX=1440/PSGS0XT
  1. . I MAX<1 D Q
  1. .. I $L(X,"-")'=1 S ERR="This order requires one admin time." Q
  1. . I MAX'<1,$L(X,"-")>MAX S ERR="The number of admin times entered is greater than indicated by the schedule." Q ;Too many times
  1. . I MAX'<1,$L(X,"-")<MAX S ERR="The number of admin times entered is fewer than indicated by the schedule." Q ;Too few times
  1. I ERR]"" D DISPLAY Q
  1. D ENCHK^PSGS0
  1. I '$D(X) S ERR="Schedule/Admin times failed validation" D DISPLAY
  1. Q
  1. ;
  1. W:$Y @IOF S PSJPAG=PSJPAG+1
  1. W PSJDATE,?47,"Inpatient Medications Schedule Issues",?120,"PAGE: ",PSJPAG,!! W !,"PATIENT",?20,"SSN",?33,"START DATE",?52,"STOP DATE",?71,"SCHEDULE",?91,"TYPE",?96,"ADMIN TIMES"
  1. W !,UL132
  1. Q