OREV3 ;SLC/DAN Event delayed orders set up continued ;12/23/02 13:28 ;;3.0;ORDER ENTRY/RESULTS REPORTING;**141,165**;Dec 17, 1997 ;DBIA reference section ;10116 - VALM1 ;2324 - USRLM ;10009 - DICN ;2056 - DIQ ;2336 - XPAREDIT ;2263 - XPAR ;10006 - DIC ;10026 - DIR ;10018 - DIE ;10103 - XLFDT ; ACE ;Add child events to existing events N DIC,ORJ,ORTMP,DA,Y,ORGLOB,ADD D FULL^VALM1 ;get full screen S VALMBCK="R" S (DIC,ORGLOB)="^ORD(100.5," I $G(ORNMBR)="" S ORNMBR=$$ORDERS^OREV1("add child events to") Q:ORNMBR="^" ;If action selected before items, get items I $G(ORNMBR)="" D Q .S DIC(0)="AEMQ",DIC("S")="I '+$P($G(^(0)),U,12)" ;Screen children from being parents .D ^DIC Q:Y=-1 S DA=+Y .Q:'$$PARENTOK^OREV4 .L +@(ORGLOB_DA_")"):1 I '$T W !!,"This entry is being edited by another user." H 3 Q .W !!,"Adding children to parent ",$P(^ORD(100.5,DA,0),U) .D ADDCHLD(DA,.ADD) ;Add child to selected event .I $G(ADD) D AUDIT^OREV(DA,"E"),CHKPRM^OREV4 ;If child event added update audit history and check parameters .L -@(ORGLOB_DA_")") F ORJ=1:1:$L(ORNMBR,",")-1 S ORTMP=$P(ORNMBR,",",ORJ),DA=$O(^TMP("OREDO",$J,"IDX",ORTMP,0)) D .I $P($G(^ORD(100.5,DA,0)),U,12) W !!,"You may not add child events to events that are already children.",!,$P($G(^ORD(100.5,DA,0)),U)," - SKIPPED!",! H 3 Q .Q:'$$PARENTOK^OREV4 .L +@(ORGLOB_DA_")"):1 I '$T W !!,"This entry is being edited by another user." H 3 Q ;Lock global .W !!,"Adding children to parent ",$P(^ORD(100.5,DA,0),U) .D ADDCHLD(DA,.ADD) ;Add child to selected event .I $G(ADD) D AUDIT^OREV(DA,"E"),CHKPRM^OREV4 ;If child event added update audit history and check paramters .L -@(ORGLOB_DA_")") ;Unlock global Q ; ADDCHLD(ENTRY,ADD) ;Add child(ren) to event ;ENTRY - Internal entry number of event that will be the parent ;ADD - Will be set to 1 if a child is successfully added ; N DIR,Y,DIC,DIE,DA,DR,DIRUT,X,NEW F D Q:$G(DIRUT) .W ! .S DIR(0)="FAO^3:50" .S DIR("A")="OE/RR CHILD RELEASE EVENT NAME: " .S DIR("?")="Enter the name of the child event you wish to create. It must be free text between 3 and 50 characters and be unique." .D ^DIR .Q:$G(DIRUT) .I $D(^ORD(100.5,"B",Y)) W !,"There is already an entry with this name. Please select a different name." Q .S DIC="^ORD(100.5,",DIC(0)="",X=Y D FILE^DICN ;Add child to file .Q:Y=-1 .S DIE=DIC .S DR="[OREV CHILD EVENT" .S DA=+Y .S NEW=1 .D ^DIE .Q:'$G(DA) ;Child event deleted, stop processing .D AUDIT^OREV(DA,"N") ;Update audit history for child .S DR="1///"_$$NOW^XLFDT_";14///`"_ENTRY D ^DIE ;Add parent pointer to child entry .S ADD=1 ;Indicate that child was added .W !!,"Enter next child name or press enter to stop adding children." Q ; UPDTCHLD(PARENT,CDT) ;Update children to inactive when parent is inactivated N DA,DIE,CHILD,DR,DONE S DONE=0 S CHILD="" F S CHILD=$O(^ORD(100.5,"DAD",PARENT,CHILD)) Q:'+CHILD D .I 'DONE W !!,"Updating children..." S DONE=1 .Q:$G(^ORD(100.5,CHILD,1)) ;Child is already inactive .S DA=CHILD .S DIE="^ORD(100.5," .S DR="1///"_CDT .D ^DIE ;Sets inactivated date/time for child .; .S DA(1)=DA .S DA=$O(^ORD(100.5,DA(1),2,"ACT",0)) .S DIE="^ORD(100.5,DA(1),2," .S DR="1///"_CDT .D ^DIE ;Update inactivated date/time of activation multiple for child Q ; PARAM ;Allow user to edit event delayed order parameters N DIR,Y S VALMBCK="R" D FULL^VALM1 F D Q:'Y .S DIR(0)="SO^1:Write orders list by event;2:Default release event;3:Common release event list;4:Manual release controlled by;5:Set manual release parameter;6:Exclude display groups from copy" .S DIR("A")="Select parameter to edit" .D ^DIR Q:'Y .I Y=2!(Y=3) D:Y=2 SETDFLT() D:Y=3 EVENTLST Q .D EDITPAR^XPAREDIT($S(Y=1:"ORWDX WRITE ORDERS EVENT LIST",Y=4:"OREVNT MANUAL RELEASE CONTROL",Y=5:"OREVNT MANUAL RELEASE",1:"OREVNT EXCLUDE DGRP")) Q ; CANREL() ;Function to determine if delayed order can be manually released N ORMAN,CAN S ORMAN=$$GET^XPAR("ALL","OREVNT MANUAL RELEASE CONTROL") S:ORMAN="" ORMAN="K" ;If no value found, default to checking for keys I ORMAN="K",'$$KEY Q 0 I ORMAN="P",'$$MANPARAM Q 0 I ORMAN="B" D Q:$G(CAN)=0 0 .I $$KEY,$$MANPARAM=0 S CAN=0 Q .I '$$KEY,'$$MANPARAM S CAN=0 Q 1 ; KEY() ;Check for ORES or ORELSE keys I '$D(^XUSEC("ORES",DUZ))&('$D(^XUSEC("ORELSE",DUZ))) Q 0 Q 1 ; MANPARAM() ;Check setting of OREVNT MANUAL RELEASE parameter N LST,I,FND,PRM,X,Y,DIC,EXP,STR,VAL,FNDNO S DIC=8989.51,DIC(0)="MX",X="OREVNT MANUAL RELEASE" D ^DIC I Y=-1 Q 0 ;Parameter not found so quit S PRM=+Y ;Check USER level S VAL=$$GET^XPAR("USR",PRM) I VAL'="" Q VAL ;Check USER CLASS D WHATIS^USRLM(DUZ,"LST") I $O(LST(0))'="" D I FND'="" Q FND .S FND="" .S I=0 F S I=$O(LST(I)) Q:I=""!(FND) S EXP=+$P(LST(I),U,5),STR=+$P(LST(I),U,4) I 'EXP!(EXP'