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

ORPRPM.m

Go to the documentation of this file.
  1. ORPRPM ;DAN/SLC Performance Measure; ;9/4/08 08:17
  1. ;;3.0;ORDER ENTRY/RESULTS REPORTING;**107,114,119,196,190,225,243,296**;Dec 17, 1997;Build 19
  1. ;
  1. ;DBIA SECTION
  1. ;4195 - EN^PSOTPCUL
  1. ;3744 - $$TESTPAT^VADPT
  1. ;10060- Reference to file 200
  1. ;
  1. ;This routine will print a report indicating the percent of
  1. ;orders entered for a provider by a provider holding the ORES key.
  1. ;The data for the report will be stored in ^TMP as follows:
  1. ;^TMP($J,"SUM",Provider Name,Patient Status)=Total # of order (universe)^Denominator^Numerator^Verbal^Written^Telephone^Policy^Electronically entered^Student entered^Outpatient narcotic orders
  1. ;Where Patient Status is I for inpatient or O for outpatient.
  1. ;
  1. N DIR,ORSD,ORED,ORPROV,ORTYPE,ORPT,ORREP,ORPIECE,Y,DIRUT,DUOUT,DTOUT,ZTRTN,ORDT,ORIEN,ORACT0,ORPVID,PG,REPDT,ORSTOP,ORI,ORJ,ORPAT,ORTOT,ORSTOT,X,ORPVNM,ORORD,ORPTST,ORP,ORWROTE,ORNS,ORFS,ORPFILE
  1. D GETDATE K DIR Q:$D(DIRUT) ;quit if no dates selected ;get start and end dates
  1. D GETPROV K DIR Q:'$D(ORPROV)!($G(ORPROV)'="ALL"&($D(ORPROV)'=11))!($D(DUOUT))!($D(DTOUT)) ;quit if user didn't select all providers or if didn't choose individual providers or if user timed out or up-arrowed out
  1. D GETOTHER Q:$D(DIRUT) ;quit if any questions were unanswered in this section
  1. S ZTRTN="DQ^ORPRPM" D QUE^ORUTL1(ZTRTN,"CPRS Performance Monitor")
  1. Q
  1. ;
  1. GETDATE ;Prompt for start and end dates
  1. S DIR(0)="DO^:DT:AE",DIR("A")="Enter starting date",DIR("?")="Enter date to begin searching from" D ^DIR Q:$D(DIRUT) S ORSD=Y
  1. S DIR(0)="DOA^"_ORSD_":DT:AE",DIR("A")="Enter ending date: ",DIR("?")="Enter date to stop searching. Must be between "_$$FMTE^XLFDT(ORSD,2)_" and "_$$FMTE^XLFDT(DT,2) D ^DIR Q:$D(DIRUT)
  1. S ORED=Y_.24,ORSD=ORSD-.1 ;Set end date to end of day, start date back to include current day
  1. Q ;End GETDATE
  1. ;
  1. GETPROV ;Allow selection of all/single/multiple providers
  1. ;return ORPROV="ALL" for all providers or ORPROV array for individual providers
  1. S DIR(0)="Y",DIR("A")="Do you want ALL providers to appear on this report",DIR("B")="Y",DIR("?")="Enter Yes to search for all providers. Enter No to select individual providers" D ^DIR Q:$D(DIRUT) S ORPROV=$S(Y=1:"ALL",1:"") Q:ORPROV="ALL"
  1. K DIR ;clear DIR variables before getting individual providers
  1. F D Q:$D(DIRUT) ;quit when finished selecting
  1. .S DIR(0)="PO^200:AEQM",DIR("S")="I $D(^VA(200,""AK.PROVIDER"",$P(^(0),U)))",DIR("A")="Select "_$S($D(ORPROV)=11:"another ",1:"")_"provider"
  1. .S DIR("?")="Select providers to appear on report. Return when finished, ^ to stop processing" D ^DIR Q:$D(DIRUT) S ORPROV(+Y)=""
  1. Q ;End GETPROV
  1. ;
  1. GETOTHER ;Get order type, patient type, and summary only report response
  1. ;Get order type first
  1. S DIR(0)="S^A:All orders;P:Pharmacy orders only",DIR("A")="Select order category",DIR("B")="P",DIR("?")="Enter P to see pharmacy orders only. Enter A to see all orders. Enter ^ to quit" D ^DIR Q:$D(DIRUT) S ORTYPE=Y
  1. K DIR
  1. ;Get patient status
  1. S DIR(0)="S^I:Inpatient;O:Outpatient;B:Both",DIR("A")="Select patient status",DIR("B")="B",DIR("?")="Enter patient status at time of order. Enter ^ to quit" D ^DIR Q:$D(DIRUT) S ORPT=Y
  1. K DIR
  1. ;Ask if user desires facility subtotal, summary, detail, or both (detail and summary) reports
  1. S DIR(0)="S^S:Summary (includes provider details);D:Detail (includes order details);B:Both (Summary & Detail);T:Summary Report Totals Only (no provider details)",DIR("A")="Select report",DIR("B")="S"
  1. D ^DIR Q:$D(DIRUT) S ORREP=Y,ORFS=0 I Y="T" S ORREP="S",ORFS=1
  1. K DIR
  1. Q ;End GETOTHER
  1. ;
  1. DQ ;Come here to do build and print from QUE^ORUTL either direct or tasked
  1. U IO K ^TMP($J) ;clean out temp space
  1. S ORDT=ORSD F S ORDT=$O(^OR(100,"AF",ORDT)) Q:'ORDT!(ORDT>ORED) S ORIEN="" F S ORIEN=$O(^OR(100,"AF",ORDT,ORIEN)) Q:'ORIEN I $O(^OR(100,"AF",ORDT,ORIEN,0))=1 I $D(^OR(100,ORIEN,8,1,0)) D CHECK
  1. D PRINT^ORPRPM1
  1. K ^TMP($J)
  1. Q
  1. ;
  1. CHECK ;If order matches requirements then save
  1. S ORPFILE=$P($G(^OR(100,ORIEN,0)),"^",2) Q:ORPFILE="" ;Quit if no object of order
  1. I $P(ORPFILE,";",2)["DPT" Q:$$TESTPAT^VADPT(+$P($G(^OR(100,ORIEN,0)),"^",2)) ;225 Quit if test patient
  1. Q:+$P($G(^OR(100,ORIEN,3)),"^",11)'=0 ;190 quit if order type not standard
  1. Q:$P(^ORD(100.98,$P(^OR(100,ORIEN,0),U,11),0),U)="NON-VA MEDICATIONS" ;225 Quit if Non-VA med entry
  1. S ORPTST=$P($G(^OR(100,ORIEN,0)),"^",12) ;patient status (in/out)
  1. I ORPT'="B" Q:ORPTST'=ORPT ;Quit if patient status is not 'both' and status doesn't match selected status
  1. S ORNS=$$NMSP^ORCD($P($G(^OR(100,ORIEN,0)),"^",14))
  1. I ORTYPE'="A"&(ORNS'="PS") Q ;if not getting all types of orders then quit if order is not from pharmacy
  1. I ORPTST="O",ORNS="PS",$G(^OR(100,ORIEN,4))=+$G(^OR(100,ORIEN,4)),$L($T(EN^PSOTPCUL)) Q:$$EN^PSOTPCUL($G(^OR(100,ORIEN,4))) ;196 Don't count if outpatient pharm order is a transitional pharmacy benefit order
  1. S ORACT0=$G(^OR(100,ORIEN,8,1,0)),ORORD=$P(ORACT0,"^",12) ;ORORD holds nature of order ien
  1. S ORPVID=$P(ORACT0,"^",3) I ORPROV'="ALL" Q:'$D(ORPROV(ORPVID)) ;quit if ordering provider doesn't match user selected provider
  1. S ORPVNM=$$GET1^DIQ(200,ORPVID_",",.01) ;225 get provider name
  1. Q:'$D(^XUSEC("ORES",ORPVID)) ;quit if ordering provider doesn't have ORES key DBIA # 10076 allows direct read of XUSEC
  1. Q:"^1^2^3^5^8^"'[("^"_ORORD_"^") ;quit if NATURE OF ORDER is not verbal, written, telephoned, policy, or electronically entered
  1. D COUNT ;Count order
  1. Q
  1. ;
  1. COUNT ;This section determines how the order should be counted
  1. N OREB,ORPIECE
  1. D ADD(1) ;Add one to universe (total # of orders)
  1. S OREB=$P(ORACT0,"^",13) ;Entered by
  1. S ^TMP($J,"DET",ORPVNM,ORIEN)=$D(^XUSEC("ORES",OREB))&(OREB=ORPVID) ;Mark "HAS ORES" column for detailed listing if entered by = provider and has ORES key
  1. I OREB=ORPVID D ADD(2),ADD(3) Q ;if order entered by provider then add one to denominator and numerator
  1. I ORNS="PS" I $$OIDEA=1 D ADD(10) Q ;If order requires wet signature add one to narcotic group
  1. I $$STUDENT D ADD(9) Q ;If order entered by student add one to student group
  1. S ORPIECE=$S(ORORD=1:4,ORORD=2:5,ORORD=3:6,ORORD=8:7,1:8) D ADD(ORPIECE) ;add to exceptions group for orders not entered by provider
  1. I ORORD'=5 D ADD(2) ;Add to denominator if not policy order
  1. Q
  1. ;
  1. ADD(PIECE) ;Add one to storage
  1. S $P(^TMP($J,"SUM",ORPVNM,ORPTST),"^",PIECE)=$P($G(^TMP($J,"SUM",ORPVNM,ORPTST)),"^",PIECE)+1 Q
  1. ;
  1. OIDEA() ;Check to see if pharmacy order requires wet signature
  1. ;dbia 3373 allows call to pharmacy API or dbia 221 allows direct read of ^PSDRUG if routine doesn't exist yet
  1. N OI,PSOI,SIGREQ,PSSXOLP,PSSXOLPD,PSSXOLPX,PSSXNODD,PSSPKLX
  1. Q:ORPTST'="O" 0 ;quit if inpatient
  1. S OI=$$VALUE^ORX8(ORIEN,"ORDERABLE") ;get orderable item
  1. S PSOI=+$P($G(^ORD(101.43,+OI,0)),U,2) I PSOI'>0 Q 0 ;quit if no pharmacy orderable item
  1. I $L($T(OIDEA^PSSUTLA1)) S SIGREQ=$$OIDEA^PSSUTLA1(PSOI,"O") Q:SIGREQ=1 1 Q 0 ;If SIGREQ = 1 then wet signature required
  1. S (PSSXOLPD,PSSXNODD)=0
  1. S PSSPKLX=0
  1. K ^TMP($J,"ORPRPM ASP")
  1. D ASP^PSS50(PSOI,,,"ORPRPM ASP")
  1. F PSSXOLP=0:0 S PSSXOLP=$O(^TMP($J,"ORPRPM ASP","")) Q:'PSSXOLP!(PSSXOLPD=1) D
  1. .K ^TMP($J,"ORPRPM DATA") D DATA^PSS50(PSSXOLP,,(DT-1),,,"ORPRPM DATA") I +^TMP($J,"ORPRPM DATA",0)<0 Q
  1. .I 'PSSPKLX,$G(^TMP($J,"ORPRPM DATA",63))'["O" K ^TMP($J,"ORPRPM DATA") Q
  1. .I PSSPKLX I $G(^TMP($J,"ORPRPM DATA",63))'["U",$G(^TMP($J,"ORPRPM DATA",63))'["I" Q
  1. .S PSSXNODD=1
  1. .S PSSXOLPX=$G(^TMP($J,"ORPRPM DATA",3))
  1. .I PSSXOLPX[1!(PSSXOLPX[2)!((PSSXOLPX[3)&(PSSXOLPX["A")) S PSSXOLPD=1 Q
  1. .I PSSXOLPX[3!(PSSXOLPX[4)!(PSSXOLPX[5) S PSSXOLPD=2
  1. I PSSXOLPD=0,'PSSXNODD S PSSXOLPD=""
  1. K ^TMP($J,"ORPRPM ASP")
  1. K ^TMP($J,"ORPRPM DATA")
  1. Q PSSXOLPD
  1. ;
  1. STUDENT() ;Check to see if entered by is a student
  1. ;Check USER CLASS for membership in "STUDENT" CLASS - DBIA 2324
  1. ;Then check PROVIDER CLASS in NEW PERSON file for "STUDENT" - DBIA 10060
  1. N ORCLASS,ORSUB,EXPIRE,ORUSR
  1. D WHATIS^USRLM(OREB,"ORCLASS") ;API to get user class membership
  1. S ORSUB=0,ORUSR=0 F S ORSUB=$O(ORCLASS(ORSUB)) Q:ORSUB=""!ORUSR D
  1. .I $$UP^XLFSTR(ORSUB)'["STUDENT" Q ;User not a member of student class
  1. .I ORDT'<+$P(ORCLASS(ORSUB),"^",4) S EXPIRE=$S(+$P(ORCLASS(ORSUB),"^",5):$P(ORCLASS(ORSUB),"^",5),1:9999999) I ORDT'>EXPIRE S ORUSR=1 ;member of student class and within date range for class
  1. I ORUSR Q 1 ;User identified as a student
  1. K ORCLASS
  1. S DIC=200,DR=53.5,DA=OREB,DIQ="ORCLASS",DIQ(0)="E" D EN^DIQ1
  1. I $G(ORCLASS(200,OREB,53.5,"E"))["STUDENT" Q 1 ;Provider class set to student
  1. Q 0 ;User not a student