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

ORWDXR01.m

Go to the documentation of this file.
ORWDXR01 ;SLC/JDL - Utilities for Order Actions;; 6/30/03 11:48
 ;;3.0;ORDER ENTRY/RESULTS REPORTING;**187,190,195,215**;Dec 17, 1997
CANCHG(ORY,ORIFN,TXTOD) ;
 ;If it's an pending or unsigned unreleased renewed order, can edit=True
 S ORY=0
 Q:'$D(^OR(100,+ORIFN,0))
 I TXTOD D TXTCAN(.ORY) Q
 N OUTGRP,URELSTS,USIGSTS,RNTYPE
 N ODGRP,ODREL,ODSIG,ODTYPE,LSTACT
 S OUTGRP=$O(^ORD(100.98,"B","O RX",0))
 S URELSTS=$O(^ORD(100.01,"B","UNRELEASED",0))
 S PDSTS=$O(^ORD(100.01,"B","PENDING",0))
 S USIGSTS=2 ; unsigned order
 S RNTYPE=2 ; renew action
 ;Data from the order entry
 S LSTACT=$P($G(^OR(100,+ORIFN,3)),U,7)
 S ODGRP=$P($G(^OR(100,+ORIFN,0)),U,11)
 S ODREL=$P($G(^OR(100,+ORIFN,3)),U,3)
 S ODSIG=$P($G(^OR(100,+ORIFN,8,LSTACT,0)),U,4)
 S ODTYPE=$P($G(^OR(100,+ORIFN,3)),U,11)
 I (ODGRP=OUTGRP),(ODREL=URELSTS),(ODSIG=USIGSTS),(ODTYPE=RNTYPE) S ORY=1
 Q
 ;
TXTCAN(ORY) ;
 ;if it's an unsigned unreleased renewed text order, can change=true
 N URELSTS,USIGSTS,RNTYPE
 N ODREL,ODSIG,ODTYPE,LSTACT
 S URELSTS=$O(^ORD(100.01,"B","UNRELEASED",0))
 S USIGSTS=2 ; unsigned order
 S RNTYPE=2 ; renew action
 ;Data from the order entry
 S LSTACT=$P($G(^OR(100,+ORIFN,3)),U,7)
 S ODREL=$P($G(^OR(100,+ORIFN,8,LSTACT,0)),U,15)
 S ODSIG=$P($G(^OR(100,+ORIFN,8,LSTACT,0)),U,4)
 S ODTYPE=$P($G(^OR(100,+ORIFN,3)),U,11)
 I (ODREL=URELSTS),(ODSIG=USIGSTS),(ODTYPE=RNTYPE) S ORY=1
 Q
 ;
SAVCHG(ORY,ORID,PARM1,PARM2,TXTOD) ;
 ;save new changes on the unreleased unsigned renewed order
 Q:'$D(^OR(100,+ORID,0))
 ;Update new start and stop date the text order
 I TXTOD D TXTSAV(.ORY,ORID,PARM1,PARM2) Q
 ;Update new refills and pickup for the med order
 N REFID,PICKID,ACT,IX,TXT,REFPOS,NDQUIT
 S (REFID,PICKID,ACT,REFPOS,NDQUIT)=0,ORY=""
 S ACT=+$P(ORID,";",2) S:ACT'>0 ACT=1
 S REFID=$O(^OR(100,+ORID,4.5,"ID","REFILLS",0))
 S PICKID=$O(^OR(100,+ORID,4.5,"ID","PICKUP",0))
 S:$D(^OR(100,+ORID,4.5,REFID,1)) ^(1)=PARM1
 S:$D(^OR(100,+ORID,4.5,PICKID,1)) ^(1)=PARM2
 S IX=0 F  S IX=$O(^OR(100,+ORID,8,ACT,.1,IX)) Q:('IX)!(NDQUIT)  D
 . S TXT=$G(^OR(100,+ORID,8,ACT,.1,IX,0))
 . I ($$UP^XLFSTR(TXT)["QUANTITY:"),($$UP^XLFSTR(TXT)["REFILLS:") D
 . . S REFPOS=$F($$UP^XLFSTR(TXT),"REFILLS")-$L("REFILLS")-1
 . . S TXT=$E(TXT,1,REFPOS)_"Refills: "_PARM1
 . . S ^OR(100,+ORID,8,ACT,.1,IX,0)=TXT,NDQUIT=1 Q
 D GETBYIFN^ORWORR(.ORY,+ORID)
 Q
 ;
TXTSAV(ORY,ORID,PARM1,PARM2) ;
 ; Update new start and stop date for the unsigned unreleased 
 ; renewed text order
 N STRTID,STOPID
 S STRTID=$O(^OR(100,+ORID,4.5,"ID","START",0))
 S STOPID=$O(^OR(100,+ORID,4.5,"ID","STOP",0))
 S:$D(^OR(100,+ORID,4.5,STRTID,1)) ^(1)=PARM1
 S:$D(^OR(100,+ORID,4.5,STOPID,1)) ^(1)=PARM2
 D GETBYIFN^ORWORR(.ORY,+ORID)
 Q
 ;
ISSPLY(ORY,DLGID,QODLG) ;
 ; ORY=1: is "PSO SUPPLY" dialog
 S ORY=""
 Q:'$D(^ORD(101.41,DLGID,0))
 I 'QODLG,($P(^ORD(101.41,DLGID,0),U)="PSO SUPPLY") S ORY=1
 I QODLG D
 . N SPLYDG S SPLYDG=$O(^ORD(100.98,"B","SPLY",0))
 . I $P(^ORD(101.41,DLGID,0),U,5)=SPLYDG S ORY=1
 Q
 ;
OXDATA(ORY,ORIEN) ; Return orderable item data for order check usage
 Q:'$D(^OR(100,+ORIEN,0))
 N DRUGID,OIID,IDX,IDY,DISPIN,DISPOUT,DISPID
 S (DRUGID,OIID,IDX,IDY,DISPIN,DISPOUT)=0
 S DISPID=""
 S DISPIN=$O(^ORD(100.98,"B","UD RX",0))
 S DISPOUT=$O(^ORD(100.98,"B","O RX",0))
 N DISPCM S DISPCM=$O(^ORD(100.98,"B","CLINIC ORDERS",0))
 S DRUGID=$O(^OR(100,+ORIEN,4.5,"ID","DRUG",0))
 S OIID=$O(^OR(100,+ORIEN,4.5,"ID","ORDERABLE",0))
 S DISPID=$P(^OR(100,+ORIEN,0),U,11)
 I DISPID=DISPIN S DISPID="PSI"
 I DISPID=DISPOUT S DISPID="PSO"
 I DISPID=DISPCM S DISPID="PSI"
 I (DISPID'="PSI"),(DISPID'="PSO") Q
 Q:'DRUGID
 Q:'OIID
 S IDX=$O(^OR(100,+ORIEN,4.5,DRUGID,0))
 S IDY=$O(^OR(100,+ORIEN,4.5,OIID,0))
 I IDX,IDY,'+DISPID S ORY=$G(^OR(100,+ORIEN,4.5,OIID,IDY))_U_DISPID_U_$G(^OR(100,+ORIEN,4.5,DRUGID,IDX))
 Q