Index: FOIAVistA/tag/r/ORDER_ENTRY_RESULTS_REPORTING-OR-OCX--ORRC--ORRJ/ORWDX.m
===================================================================
--- FOIAVistA/trunk/r/ORDER_ENTRY_RESULTS_REPORTING-OR-OCX--ORRC--ORRJ/ORWDX.m	(revision 631)
+++ FOIAVistA/tag/r/ORDER_ENTRY_RESULTS_REPORTING-OR-OCX--ORRC--ORRJ/ORWDX.m	(revision 636)
@@ -1,5 +1,15 @@
-ORWDX ; SLC/KCM/REV/JLI - Order dialog utilities ;11/09/2006
- ;;3.0;ORDER ENTRY/RESULTS REPORTING;**10,85,125,131,132,141,164,178,187,190,195,215,246**;Dec 17, 1997;Build 8
- ;Per VHA Directive 2004-038, this routine should not be modified.
+ORWDX ; SLC/KCM/REV/JLI - Order dailog utilities ;4/21/07  19:18
+ ;;3.0;ORDER ENTRY/RESULTS REPORTING;**10,85,125,131,132,141,164,178,187,190,195,215,269**;Dec 17, 1997;Build 28
+ ; Modified from FOIA VISTA,
+ ; Copyright (C) 2007 WorldVistA
+ ;
+ ; This program is free software; you can redistribute it and/or modify
+ ; it under the terms of the GNU General Public License as published by
+ ; the Free Software Foundation; either version 2 of the License, or
+ ; (at your option) any later version.
+ ;
+NXT() ; -- Gets index in array
+ S ILST=ILST+1
+ Q ILST
  ;
 ORDITM(Y,FROM,DIR,XREF) ; Subset of orderable items
@@ -33,9 +43,23 @@
  ;         X123456;1      = change order,  134      = quick dialog
  N I,J,DLG,INST,ID,VAL,ILST,ROOT S ROOT=""
- I RSPID["-" S ROOT="^TMP(""ORWDXMQ"",$J,"""_RSPID_""")" G XROOT^ORWDX2
- I $E(RSPID)="X" S ROOT="^OR(100,"_+$P(RSPID,"X",2)_",4.5)"  G XROOT^ORWDX2
- I +RSPID=RSPID  S ROOT="^ORD(101.41,"_+RSPID_",6)" G XROOT^ORWDX2
+ I RSPID["-" S ROOT="^TMP(""ORWDXMQ"",$J,"""_RSPID_""")" G XROOT
+ I $E(RSPID)="X" S ROOT="^OR(100,"_+$P(RSPID,"X",2)_",4.5)"  G XROOT
+ I +RSPID=RSPID  S ROOT="^ORD(101.41,"_+RSPID_",6)" G XROOT
  Q:ROOT=""
- G XROOT^ORWDX2
+XROOT S (ILST,I)=0 F  S I=$O(@ROOT@(I)) Q:I'>0  D
+ . S DLG=$P(@ROOT@(I,0),U,2),INST=$P(^(0),U,3)
+ . S ID=$P($G(^ORD(101.41,DLG,1)),U,3)
+ . I '$L(ID) S ID="ID"_DLG
+ . S VAL=$G(@ROOT@(I,1))
+ . I $P($G(^ORD(101.41,DLG,0)),U)="OR GTX ADDITIVE" S ID="ADDITIVE"
+ . I $E(RSPID)="C",(ID="START"),VAL Q  ; skip literal start time on copy
+ . S LST($$NXT)="~"_DLG_U_INST_U_ID
+ . I $L(VAL) D
+ .. S LST($$NXT)="i"_VAL,LST($$NXT)="e"_$$EXTVAL(VAL,DLG)
+ . I $D(@ROOT@(I,2))>1 D
+ .. S J=0 F  S J=$O(@ROOT@(I,2,J)) Q:J'>0  D
+ ... S LST($$NXT)="t"_$G(@ROOT@(I,2,J,0))
+ I $E(ROOT,1,4)="^TMP" K ^TMP("ORWDXMQ",$J)
+ Q
 SAVE(REC,ORVP,ORNP,ORL,DLG,ORDG,ORIT,ORIFN,ORDIALOG,ORDEA,ORAPPT,ORSRC,OREVTDF) ;
  ; ORVP=DFN, ORNP=Provider, ORL=Location, DLG=Order Dialog,
@@ -53,5 +77,5 @@
  I $G(ORDIALOG("ORSLOG")) S ORLOG=ORDIALOG("ORSLOG") K ORDIALOG("ORSLOG")
  I $D(ORDIALOG("OREVENT")) S OREVENT=ORDIALOG("OREVENT") K ORDIALOG("OREVENT")
- ;=====================================================
+ ;=======
  ; Changed for v26.27 (RV)
  S ORCAT=$$INPT^ORCD,ORCAT=$S(ORCAT=1:"I",1:"O")
@@ -62,5 +86,5 @@
  ;. S ORCAT=$S(OREVTYPE="A":"I",OREVTYPE="T":"I",ONPASS=1:"O",1:"O")
  ;E  S ORCAT=$S($L($P($G(^DPT(+ORVP,.1)),U)):"I",1:"O")
- ;=====================================================
+ ;=======
  I DLG="PS MEDS" S ORWP94=1 D
  . I ORIT=$O(^ORD(101.41,"AB","PSO SUPPLY",0)) S DLG="PSO SUPPLY"
@@ -143,4 +167,7 @@
  .. N OK S OK=$$LOCK1^ORX2(ORDERID) I 'OK S ORWERR="1^"_$P(OK,U,2)
  .. I OK D EN^ORCSEND(ORDERID,"",ORWSIG,ORWREL,ORWNATR,"",.ORWERR),UNLK1^ORX2(ORDERID)
+ .. S PSOSITE=$G(^SC(+ORL,"AFRXSITE")) ;+ORL is hospital location from ORWDX
+ .. Q:PSOSITE=""  ;Quits with no autofinish if File#44 does not point to File#59
+ .. I $P($G(^PS(59,PSOSITE,"RXFIN")),"^",1)="Y",$$GET1^DIQ(100,+ORDERID_",",12)="OUTPATIENT PHARMACY" D EN^PSOAFIN ;vfam
  . S ORWLST(ORWI)=ORDERID,X=""
  . I $L(ORWERR) S ORWLST(ORWI)=ORWLST(ORWI)_"^E^"_ORWERR Q
@@ -150,4 +177,10 @@
  I $G(ORLAB) D BTS^ORMBLD(ORVP)
  Q
+EXTVAL(IVAL,DLG) ; External value given a dlg ptr
+ N ORDIALOG
+ S ORDIALOG(DLG,0)=$P($G(^ORD(101.41,DLG,1)),U,1,2)
+ S ORDIALOG(DLG,1)=IVAL
+ I $E(ORDIALOG(DLG,0))="R",(+IVAL'=IVAL) Q IVAL  ; free text date/time
+ Q $$EXT^ORCD(DLG,1)  ; all others
 DLGID(VAL,ORIFN) ; return dlg IEN for order
  S VAL=$P(^OR(100,+ORIFN,0),U,5)
