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

RAHLTCPU.m

Go to the documentation of this file.
  1. RAHLTCPU ; HIRMFO/GJC,SG - Rad/Nuc Med HL7 TCP/IP Bridge utilities;10/10/07
  1. ;;5.0;Radiology/Nuclear Medicine;**84,94**;Mar 16, 1998;Build 9
  1. ;
  1. LOCKX(RAERR,UNLOCK) ;lock/unlock the Rad/Nuc Med Patient record at one of two levels:
  1. ;If part of a printset (RAY3(25)=2) lock at the "DT" level
  1. ;Else lock at the "P" or case level
  1. ;Input: RADFN, RADTI, & RACNI are all assumed to be defined.
  1. ; UNLOCK: if defined the function unlocks the encounter at the appropriate level
  1. ;Returns: RAERR (lock attempt only) if $D(RAERR)#2 lock failed, else lock successful
  1. N RANODE,RAY3 S RAY3=$G(^RADPT(RADFN,"DT",RADTI,"P",RACNI,0)),RAY3(25)=$P(RAY3,U,25)
  1. S RANODE=$S(RAY3(25)=2:$NA(^RADPT(RADFN,"DT",RADTI)),1:$NA(^RADPT(RADFN,"DT",RADTI,"P",RACNI)))
  1. I $G(UNLOCK)=1 L -@RANODE Q
  1. L +@RANODE:DILOCKTM E S RAERR=$S(RAY3(25)=2:"Encounter",1:"Accession")_" locked within VistA"
  1. Q
  1. ;
  1. LOCKR(RAERR) ;lock/unlock the report associated with an exam record/
  1. ;Input: RARPT is assumed to be defined
  1. ;Return: RAERR will be set if the lock attempt failed, else RAERR will not be defined
  1. I $D(RARPT)#2,($D(^RARPT(RARPT,0))#2) D
  1. .D LOCK^DILF($NA(^RARPT(RARPT))) ;$T=1 if lock attained, else 0
  1. .S:'$T RAERR="Report: "_$P($G(^RARPT(RARPT,0)),U)_" locked within VistA Radiology" Q
  1. E S RAERR="The report record '"_$G(RARPT,"<UNDEFINED> RARPT")_"' is non-existent."
  1. Q
  1. ;
  1. ;
  1. ;##### ALLOCATES A NEW RECORD IN THE RAD/NUC MED REPORTS FILE (#74) AND LOCKS IT
  1. ;
  1. ; Return Values
  1. ; =============
  1. ; >0 IEN for the new record in the RAD/NUC MED REPORTS FILE (#74)
  1. ;
  1. ; Notes
  1. ; =====
  1. ;
  1. ; The placeholder for the new record (^RARPT(IEN) node) is LOCKed
  1. ; by this function. It is responsibility of the caller to unlock the
  1. ; record after it is created or the record creation is canceled.
  1. ;
  1. NEWIEN() ;
  1. N IEN,NEWIEN,NODE
  1. S NEWIEN=0
  1. ;---
  1. F D Q:NEWIEN
  1. . S IEN=$O(^RARPT(" "),-1)+1
  1. . ;--- If the record already exists, skip it
  1. . S NODE=$NA(^RARPT(IEN)) Q:$D(@NODE)
  1. . ;--- Lock the placeholder in order to make sure that nobody
  1. . ;--- else is trying to allocate it at the same time.
  1. . D LOCK^DILF(NODE) E Q
  1. . ;--- Double check that the record has not been created after the
  1. . ;--- previous $D() check and the LOCK command (a race condition)
  1. . I $D(@NODE) L -@NODE Q
  1. . ;--- Success
  1. . S NEWIEN=IEN
  1. . Q
  1. ;---
  1. Q NEWIEN