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

BQIPLLK.m

Go to the documentation of this file.
  1. BQIPLLK ;VNGT/HS/KJH-Panel Lock/Unlock Functions ; 23 Feb 2006 5:08 PM
  1. ;;2.3;ICARE MANAGEMENT SYSTEM;;Apr 18, 2012;Build 59
  1. ;
  1. Q
  1. ;
  1. LOCK(DATA,OWNR,PLIEN) ; EP -- BQI LOCK PANEL
  1. ; Description
  1. ; Attempt to lock the panel specified by OWNR and PLIEN for
  1. ; exclusive editing access.
  1. ; If successful, sets 'LAST LOCKED BY' with the current DUZ
  1. ; and returns a RESULT of 1 and the current DUZ.
  1. ; If unsuccessful, returns a RESULT of 0 and the DUZ from the
  1. ; 'LAST LOCKED BY' field.
  1. ; Input:
  1. ; OWNR - Owner of the panel to be locked
  1. ; PLIEN - Panel IEN to be locked
  1. ; Output:
  1. ; DATA = name of global (passed by reference) in which the data is stored
  1. ;
  1. ; RESULT = 1 if the lock succeeded
  1. ; = 0 if the lock failed
  1. ; USER = DUZ of the last user to successfully lock this panel
  1. ; or
  1. ; BMXSEC - if $D(ERROR) when filing or M error encountered
  1. ;
  1. N UID,X,BQII
  1. S UID=$S($G(ZTSK):"Z"_ZTSK,1:$J)
  1. S DATA=$NA(^TMP("BQIPLLK",UID))
  1. K ^TMP("BQIPLLK",UID)
  1. ;
  1. NEW $ESTACK,$ETRAP S $ETRAP="D ERR^BQIPLLK D UNWIND^%ZTER" ; SAC 2006 2.2.3.3.2
  1. ;
  1. ; Create header record
  1. S BQII=0,^TMP("BQIPLLK",UID,BQII)="I00010RESULT^I00010USER^T00035NAME"_$C(30)
  1. ;
  1. ; Check for existence of the panel. (May have been edited/deleted by owner while share had it on their list.)
  1. I $G(PLIEN)="" S BMXSEC="RPC Call Failed: Panel does not exist. May have been edited by another user." Q
  1. I '$D(^BQICARE(OWNR,1,PLIEN,0)) S BMXSEC="RPC Call Failed: Panel does not exist. May have been edited by another user." Q
  1. ;
  1. N DA,IENS,RESULT,USER,NAME,ERROR
  1. S DA=PLIEN,DA(1)=OWNR,IENS=$$IENS^DILF(.DA),USER=""
  1. ;
  1. ; Attempt lock and set RESULT accordingly
  1. S RESULT=1
  1. L +^BQICARE(OWNR,1,PLIEN,0):1 E S RESULT=0
  1. ;
  1. ; If lock is unsuccessful, get 'LAST LOCKED BY' from the panel.
  1. I RESULT=0 S USER=$$GET1^DIQ(90505.01,IENS,.16,"I")
  1. ;
  1. ; If lock is successful, update 'LAST LOCKED BY' on the panel.
  1. I RESULT=1 D
  1. . N BQINEW
  1. . S (BQINEW(90505.01,IENS,.16),USER)=DUZ
  1. . D FILE^DIE("","BQINEW","ERROR")
  1. . I $D(ERROR) S BMXSEC="RPC Call Failed: Error encountered while updating user last locked." Q
  1. . Q
  1. ;
  1. ; If an error occurred after the lock was set then unlock and quit.
  1. I $G(BMXSEC)'="" L -^BQICARE(OWNR,1,PLIEN,0) Q
  1. ;
  1. ; Get user name (if available)
  1. S NAME=$$GET1^DIQ(200,USER,.01,"E")
  1. I NAME="" S NAME="an unknown user"
  1. ;
  1. ; Report results
  1. S BQII=BQII+1,^TMP("BQIPLLK",UID,BQII)=RESULT_"^"_USER_"^"_NAME_$C(30)
  1. S BQII=BQII+1,^TMP("BQIPLLK",UID,BQII)=$C(31)
  1. Q
  1. ;
  1. UNLOCK(DATA,OWNR,PLIEN) ; EP -- BQI UNLOCK PANEL
  1. ; Description
  1. ; Unlock the panel specified by OWNR and PLIEN which was
  1. ; previously locked for exclusive editing access. If the
  1. ; entry in the 'LAST LOCKED BY' field is for this DUZ then
  1. ; delete it (so another user can't accidentally update it).
  1. ; Input:
  1. ; OWNR - Owner of the panel to be unlocked
  1. ; PLIEN - Panel IEN to be unlocked
  1. ; Output:
  1. ; DATA = name of global (passed by reference) in which the data is stored
  1. ;
  1. ; RESULT = 1 (unlock will always succeed)
  1. ; or
  1. ; BMXSEC - if $D(ERROR) when filing or M error encountered
  1. ;
  1. N UID,X,BQII
  1. S UID=$S($G(ZTSK):"Z"_ZTSK,1:$J)
  1. S DATA=$NA(^TMP("BQIPLLK",UID))
  1. K ^TMP("BQIPLLK",UID)
  1. ;
  1. NEW $ESTACK,$ETRAP S $ETRAP="D ERR^BQIPLLK D UNWIND^%ZTER" ; SAC 2006 2.2.3.3.2
  1. ;
  1. ; Create header record
  1. S BQII=0,^TMP("BQIPLLK",UID,BQII)="I00010RESULT"_$C(30)
  1. ;
  1. N DA,IENS,RESULT,USER,ERROR
  1. S DA=PLIEN,DA(1)=OWNR,IENS=$$IENS^DILF(.DA)
  1. ;
  1. ; Get 'LAST LOCKED BY' from the panel.
  1. S USER=$$GET1^DIQ(90505.01,IENS,.16,"I")
  1. ;
  1. ; If 'LAST LOCKED BY' is this DUZ then delete it from the panel.
  1. I USER=DUZ D
  1. . N BQINEW
  1. . S BQINEW(90505.01,IENS,.16)="@"
  1. . D FILE^DIE("","BQINEW","ERROR")
  1. . I $D(ERROR) S BMXSEC="RPC Call Failed: Error encountered while updating user last locked." Q
  1. . Q
  1. ;
  1. ; Unlock and set RESULT
  1. S RESULT=1
  1. L -^BQICARE(OWNR,1,PLIEN,0)
  1. ;
  1. ; Report results
  1. S BQII=BQII+1,^TMP("BQIPLLK",UID,BQII)=RESULT_$C(30)
  1. S BQII=BQII+1,^TMP("BQIPLLK",UID,BQII)=$C(31)
  1. Q
  1. ;
  1. ERR ;
  1. D ^%ZTER
  1. N Y,ERRDTM
  1. S Y=$$NOW^XLFDT() X ^DD("DD") S ERRDTM=Y
  1. S BMXSEC="Recording that an error occurred at "_ERRDTM
  1. Q
  1. ;
  1. ULK(DATA,OWNR) ; EP -- BQI LOCK ICARE USER
  1. ; Input:
  1. ; OWNR - Owner of the panel to be locked
  1. ;
  1. ; RESULT = 1 if the lock succeeded
  1. ; = 0 if the lock failed
  1. NEW UID,X,BQII,RESULT
  1. S UID=$S($G(ZTSK):"Z"_ZTSK,1:$J)
  1. S DATA=$NA(^TMP("BQIPLULK",UID))
  1. K @DATA
  1. S BQII=0,OWNR=$G(OWNR,DUZ)
  1. ;
  1. NEW $ESTACK,$ETRAP S $ETRAP="D ERR^BQIPLLK D UNWIND^%ZTER" ; SAC 2006 2.2.3.3.2
  1. ;
  1. ; Create header record
  1. S @DATA@(BQII)="I00010RESULT"_$C(30)
  1. ;
  1. ; Attempt lock and set RESULT accordingly
  1. S RESULT=1
  1. L +^BQICARE(OWNR,0):1 E S RESULT=0
  1. ;
  1. ; Report results
  1. S BQII=BQII+1,@DATA@(BQII)=RESULT_$C(30)
  1. S BQII=BQII+1,@DATA@(BQII)=$C(31)
  1. Q
  1. ;
  1. UULK(DATA,OWNR) ; EP -- BQI UNLOCK ICARE USER
  1. NEW UID,X,BQII,RESULT
  1. S UID=$S($G(ZTSK):"Z"_ZTSK,1:$J)
  1. S DATA=$NA(^TMP("BQIPLUULK",UID))
  1. K @DATA
  1. S BQII=0,OWNR=$G(OWNR,DUZ)
  1. ;
  1. NEW $ESTACK,$ETRAP S $ETRAP="D ERR^BQIPLLK D UNWIND^%ZTER" ; SAC 2006 2.2.3.3.2
  1. ;
  1. ; Create header record
  1. S @DATA@(BQII)="I00010RESULT"_$C(30)
  1. ;
  1. ; Unlock and set RESULT
  1. S RESULT=1
  1. L -^BQICARE(OWNR,0)
  1. ;
  1. ; Report results
  1. S BQII=BQII+1,@DATA@(BQII)=RESULT_$C(30)
  1. S BQII=BQII+1,@DATA@(BQII)=$C(31)
  1. Q