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

ORCMEDT7.m

Go to the documentation of this file.
  1. ORCMEDT7 ;SLC/JM-QO,Edit Quick Orders By User ;2/1/06
  1. ;;3.0;ORDER ENTRY/RESULTS REPORTING;**245**;Dec 17, 1997;Build 2
  1. Q
  1. QCKBYUSR ; Edit quick orders by user
  1. N ORDGINFO,ORTEXT,ORIEN,ORFMDATA,ORUSER,ORDG,ORLINE0
  1. K ^TMP("ORWDQUSR",$J)
  1. S ORUSER=0
  1. F S ORDGINFO=$$QCKUSRDG(ORUSER) Q:ORDGINFO=0 S:ORDGINFO<0 ORUSER=0 I +ORDGINFO>0,$D(^ORD(101.41,+ORDGINFO,0)) D
  1. . S ORIEN=$P(ORDGINFO,U,1)
  1. . S ORFMDATA=$P(ORDGINFO,U,2)
  1. . S ORUSER=$P(ORDGINFO,U,3)
  1. . S ORLINE0=$G(^ORD(101.41,ORIEN,0))
  1. . S ORTEXT=$P(ORLINE0,U,2)
  1. . S ORDG=+$P(ORLINE0,U,5)
  1. . D QCK0^ORCMEDT1(ORIEN) ; edit quick order
  1. . D VERIFYDA(.ORFMDATA,ORIEN)
  1. . I +ORFMDATA D
  1. . . ; If quick order not deleted, and display text changes, change 101.44 display text to match
  1. . . I $D(^ORD(101.41,ORIEN,0)),ORTEXT'=$P(^ORD(101.41,ORIEN,0),U,2) D
  1. . . . N DIE,DA,DR,DIDEL
  1. . . . S DA(1)=$P(ORFMDATA,";",1)
  1. . . . S DIE="^ORD(101.44,"_DA(1)_",10,"
  1. . . . S DA=$P(ORFMDATA,";",2)
  1. . . . ; 101.44 Display text holds 132 chars, 101.41 only 80. so this is ok
  1. . . . S DR="2///"_$P(^ORD(101.41,ORIEN,0),U,2)
  1. . . . D ^DIE
  1. . K ^TMP("ORWDQUSR",$J,"A",ORUSER) ; Force reload of user Quick Order info
  1. . W !
  1. K ^TMP("ORWDQUSR",$J)
  1. Q
  1. QCKUSRDG(ORLSTUSR) ; Get quick order dialog by user
  1. N DIC,DIR,DA,X,Y,ORIDX,ORUSER,ORLEN,ORPRE,ORDIALOG,ORHEADER,ORGROUP,ORCOUNT,USERNAME
  1. N DTOUT,DUOUT,DIROUT,DIRUT,OREXIT,ORINPUT,ORDGNAME,ORDGIEN,ORLASTGP,ORFMDATA,ORFIRST
  1. S ORDIALOG=0
  1. S ORUSER=$$GETUSER(ORLSTUSR)
  1. I ORUSER>0 D
  1. . S ORPRE="ORWDQ USR"_ORUSER,ORLEN=$L(ORPRE)
  1. . S ORIDX=$O(^ORD(101.44,"B",ORPRE))
  1. . I $E(ORIDX,1,ORLEN)=ORPRE D I 1
  1. . . D QULIST(ORUSER)
  1. . . S USERNAME=$P($G(^VA(200,ORUSER,0)),U,1)
  1. . . S ORHEADER=USERNAME_" personal quick orders:"
  1. . . S ORCOUNT=0,ORIDX=0,OREXIT=0,ORLASTGP=U,ORFIRST=1
  1. . . F S ORIDX=$O(^TMP("ORWDQUSR",$J,"A",ORUSER,ORIDX)) Q:'+ORIDX D Q:+OREXIT!(ORDIALOG>0)
  1. . . . S ORCOUNT=ORCOUNT+1
  1. . . . I ORCOUNT=1 D
  1. . . . . I ORFIRST S ORFIRST=0 W !,!
  1. . . . . W !,ORHEADER,!
  1. . . . S ORGROUP=$O(^TMP("ORWDQUSR",$J,"A",ORUSER,ORIDX,""))
  1. . . . S ORDGIEN=$O(^TMP("ORWDQUSR",$J,"A",ORUSER,ORIDX,ORGROUP,""))
  1. . . . S ORFMDATA=$O(^TMP("ORWDQUSR",$J,"A",ORUSER,ORIDX,ORGROUP,ORDGIEN,""))
  1. . . . S ORDGNAME=$G(^TMP("ORWDQUSR",$J,"A",ORUSER,ORIDX,ORGROUP,ORDGIEN,ORFMDATA))
  1. . . . I (ORCOUNT=1)!(ORGROUP'=ORLASTGP) D
  1. . . . . S ORLASTGP=ORGROUP
  1. . . . . S ORCOUNT=ORCOUNT+1
  1. . . . . W ?4,ORGROUP,!
  1. . . . W ?7,ORIDX,?12,ORDGNAME,!
  1. . . . I ORCOUNT'<18 D
  1. . . . . S DIR("A",1)="Press <RETURN> to see more, '^' to exit this list, OR"
  1. . . . . S ORDIALOG=$$QUIDX()
  1. . . . . S ORCOUNT=0
  1. . . I ORDIALOG'>0,'+OREXIT D
  1. . . . S ORIDX=$O(^TMP("ORWDQUSR",$J,"A",ORUSER,999999),-1)
  1. . . . I ORIDX<1 D I 1
  1. . . . . ; If user had quick orders, but doesn't any more, there will be false positives in "B" xref
  1. . . . . D QULIST(0)
  1. . . . . K ^TMP("ORWDQUSR",$J,"B",USERNAME)
  1. . . . . D SHOWUSRS
  1. . . . E D
  1. . . . . S DIR("A",1)=""
  1. . . . . S ORDIALOG=$$QUIDX()
  1. . E D SHOWUSRS
  1. Q ORDIALOG
  1. GETUSER(ORUSER) ;
  1. I +ORUSER Q ORUSER
  1. N DIC,Y,X,DLAYGO,DINUM
  1. S DIC="^VA(200,",DIC(0)="AEMQ"
  1. D ^DIC
  1. Q +Y
  1. SHOWUSRS ;
  1. S ORDIALOG=-1 ; Repeats loop
  1. W !,!,$P($G(^VA(200,ORUSER,0)),U,1)_" does not have any personal quick orders."
  1. S DIR("A")="Would you like to see a list of users with personal quick orders"
  1. S DIR(0)="Y",DIR("B")="YES"
  1. D ^DIR
  1. I +Y D I 1
  1. . W !,!," Choose from:",!
  1. . D QULIST(0)
  1. . S ORUSER="",ORIDX=2,OREXIT=0
  1. . F S ORUSER=$O(^TMP("ORWDQUSR",$J,"B",ORUSER)) Q:OREXIT!(ORUSER="") D Q:OREXIT
  1. . . W " ",ORUSER,!
  1. . . S ORIDX=ORIDX+1
  1. . . I ORIDX=22 D
  1. . . . S ORIDX=0
  1. . . . R " '^' TO STOP: ",ORINPUT:$G(DTIME,300)
  1. . . . E S OREXIT=1
  1. . . . W $C(13),$J("",20),$C(13) Q:OREXIT
  1. . . . I ORINPUT[U S OREXIT=1
  1. E I $D(DTOUT)!$D(DUOUT)!$D(DIRUT)!$D(DIROUT) S ORDIALOG=0
  1. Q
  1. QUIDX() ; Get quick order dialog info
  1. N ORGROUP,ORDGIEN,ORFMDATA,ORRESULT
  1. S DIR("A")="CHOOSE 1-"_ORIDX_": "
  1. S DIR(0)="NOA^1:"_ORIDX
  1. D ^DIR
  1. I +Y>0,+Y'>ORIDX D Q ORRESULT
  1. . S ORGROUP=$O(^TMP("ORWDQUSR",$J,"A",ORUSER,+Y,""))
  1. . S ORDGIEN=$O(^TMP("ORWDQUSR",$J,"A",ORUSER,+Y,ORGROUP,""))
  1. . I $$CONFLICT(ORUSER,ORDGIEN) S OREXIT=1,ORRESULT=-1 Q
  1. . S ORFMDATA=$O(^TMP("ORWDQUSR",$J,"A",ORUSER,+Y,ORGROUP,ORDGIEN,""))
  1. . S ORRESULT=ORDGIEN_U_ORFMDATA_U_ORUSER
  1. W !
  1. I Y[U S OREXIT=1
  1. Q -1 ; -1 Value repeats the enter name loop / 0 exits loop
  1. QULIST(ORUSER) ; Build user info
  1. N PRE,ID,LEN
  1. S PRE="ORWDQ USR"
  1. I ORUSER=0 D Q
  1. . ; "B" node is list of all users with Quick Orders
  1. . I $D(^TMP("ORWDQUSR",$J,"B")) Q
  1. . N LASTUSER,USERNAME,USER
  1. . S LASTUSER=0,ID=PRE,LEN=$L(PRE)
  1. . F S ID=$O(^ORD(101.44,"B",ID)) Q:($E(ID,1,LEN)'=PRE) D
  1. . . S USER=$P($E(ID,LEN+1,999)," ")
  1. . . I USER'=LASTUSER D
  1. . . . S LASTUSER=USER
  1. . . . S USERNAME=$P($G(^VA(200,USER,0)),U,1)
  1. . . . S ^TMP("ORWDQUSR",$J,"B",USERNAME)=""
  1. . Q
  1. ;
  1. ; "A" node is list of quick orders for an individual user
  1. ; Temp array nodes are "ORWDQUSR",$J,"A"
  1. ; User IEN, Index Number, Display Group, Quick Order IEN, 101.44 IEN
  1. ; Data value is Quick Order Name - (Name can be 132 chars so can't be node)
  1. ;
  1. I $D(^TMP("ORWDQUSR",$J,"A",ORUSER)) Q
  1. N GROUP,IDX,NUMBER,QOINDEX,QCKORDER,ORFMDATA
  1. S PRE=PRE_ORUSER,ID=PRE,NUMBER=0,LEN=$L(PRE)
  1. F S ID=$O(^ORD(101.44,"B",ID)) Q:($E(ID,1,LEN)'=PRE) D
  1. . S GROUP=$P(ID," ",3,999)
  1. . S GROUP=$O(^ORD(100.98,"B",GROUP,0))
  1. . I +GROUP S GROUP=$P($G(^ORD(100.98,GROUP,0)),U,1)
  1. . S IDX=$O(^ORD(101.44,"B",ID,0)),QOINDEX=0
  1. . F S QOINDEX=$O(^ORD(101.44,IDX,10,QOINDEX)) Q:'+QOINDEX D
  1. . . S QCKORDER=$G(^ORD(101.44,IDX,10,QOINDEX,0))
  1. . . I +QCKORDER,+$D(^ORD(101.41,+QCKORDER)) D
  1. . . . S NUMBER=NUMBER+1
  1. . . . S ORFMDATA=IDX_";"_QOINDEX
  1. . . . S ^TMP("ORWDQUSR",$J,"A",ORUSER,NUMBER,GROUP,$P(QCKORDER,U,1),ORFMDATA)=$P(QCKORDER,U,2)
  1. Q
  1. VERIFYDA(ORFMDATA,ORIEN) ;
  1. ; Make sure FileMan pointers are still correct
  1. ; - may have changes via CPRS GUI or QCK0^ORCMEDT1(ORIEN)
  1. N IDX1,IDX2,IEN
  1. S IDX1=$P(ORFMDATA,";",1)
  1. S IDX2=$P(ORFMDATA,";",2)
  1. S IEN=$P($G(^ORD(101.44,IDX1,10,IDX2,0)),U,1)
  1. I IEN=ORIEN Q
  1. S ORFMDATA=""
  1. S IDX2=0
  1. F S IDX2=$O(^ORD(101.44,IDX1,10,IDX2)) Q:'+IDX2 D Q:+ORFMDATA
  1. . I $P($G(^ORD(101.44,IDX1,10,IDX2,0)),U,1)=ORIEN S ORFMDATA=IDX1_";"_IDX2
  1. Q
  1. CONFLICT(ORUSER,DIALOG) ; Determine if another user shares the personal quick order
  1. N DG,OTHERS,USR,NAME,ABORT,DIR,Y,DA,X,DTOUT,DUOUT,DIROUT,DIRUT,COUNT,TEMP
  1. S (DG,ABORT)=0
  1. F S DG=$O(^ORD(101.44,"C",DIALOG,DG)) Q:'+DG D
  1. . S USR=$P($G(^ORD(101.44,DG,0)),U,1)
  1. . I $P(USR," ",1)="ORWDQ" D
  1. . . S USR=$P(USR," ",2)
  1. . . I $E(USR,1,3)="USR" D
  1. . . . S USR=$E(USR,4,999)
  1. . . . I USR'=ORUSER D
  1. . . . . S NAME=$P($G(^VA(200,USR,0)),U,1)
  1. . . . . S OTHERS(NAME)=""
  1. I $D(OTHERS) D
  1. . S OTHERS($P($G(^VA(200,ORUSER,0)),U,1))=""
  1. . W !,$C(7),!,!
  1. . W " *********************",!
  1. . W " ***** WARNING *****",!
  1. . W " *********************",!,!
  1. . W " Multiple users share this personal quick order.",!
  1. . W " Modifying this personal quick order will change",!
  1. . W " it for all of the following users:",!,!
  1. . S NAME="",COUNT=7
  1. . F S NAME=$O(OTHERS(NAME)) Q:NAME="" D Q:ABORT
  1. . . S COUNT=COUNT+1
  1. . . I COUNT>20 D Q:ABORT
  1. . . . S COUNT=0,TEMP=""
  1. . . . W !
  1. . . . R " Press <RETURN> to continue, '^' to exit: ",TEMP:$G(DTIME,300)
  1. . . . E S ABORT=1
  1. . . . W $C(13),$J("",50),$C(13) Q:ABORT
  1. . . . I (TEMP[U)!$D(DTOUT)!$D(DUOUT)!$D(DIRUT)!$D(DIROUT) S ABORT=1
  1. . . W " ",NAME,!
  1. . I 'ABORT D
  1. . . S DIR("A")="Are you sure you want to edit this personal quick order? "
  1. . . S DIR(0)="YA",DIR("B")="NO" W ! D ^DIR
  1. . . W !
  1. . . I '+Y S ABORT=1
  1. Q ABORT