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

RARIC.m

Go to the documentation of this file.
  1. RARIC ;HISC/FPT,GJC AISC/SAW-Radiologic Image Capture and Display Routine ;08/05/08 14:35
  1. ;;5.0;Radiology/Nuclear Medicine;**23,27,101,47**;Mar 16, 1998;Build 21
  1. ;
  1. ;In response to: Remedy #330689 (Tucson); PSPO 1460
  1. ;
  1. ;Supported IA #2053 FILE/UPDATE^DIE
  1. ;Supported IA #2054 LOCK^DILF
  1. ;Supported IA #10103 $$NOW^XLFDT
  1. ;
  1. CREATE ; >>create new stub entry in file 74<<
  1. ; --------------------------------------------------------------------
  1. ; IA: 1178 (the value of RARPT is currently null) If no report entry is
  1. ; created, RARPT is set to null or negative (negative w/report)
  1. ;
  1. ;input variables
  1. ; RADTE - ext. date/time of exam, RADFN - patient DFN,
  1. ; RADTI - int. date/time of exam), RACN - case number &
  1. ; RACNI - IEN of case record
  1. ; RATIMEOUT - An integer representing the number of seconds
  1. ; in which the process attempts to gain access
  1. ; to the node in question. RATIMEOUT is set ONLY
  1. ; on the Imaging Gateway side. All other applications
  1. ; calling the CREATE entry point will not have
  1. ; RATIMEOUT set and will use a default timeout
  1. ; value set at 1E9.
  1. ;
  1. ; Note: Imaging (Gateway) sets and kills RATIMEOUT.
  1. ;
  1. ;output variables
  1. ; RARPT - IEN of the report: null if error; or positive
  1. ;
  1. ; lock the exam node; quit if the lock fails
  1. S RARPT="" S U=$G(U,"^")
  1. L +^RADPT(RADFN,"DT",RADTI,"P",RACNI,0):$G(RATIMEOUT,1E9) E S RARPT="-1^radiology exam locked" Q
  1. ;
  1. ; Set RAY2 to the REGISTERED EXAMS node.
  1. ; Set RAY3 to the EXAMINATIONS node.
  1. N RAY2,RAY3 S RAY2=$G(^RADPT(RADFN,"DT",RADTI,0))
  1. S RAY3=$G(^RADPT(RADFN,"DT",RADTI,"P",RACNI,0))
  1. ;
  1. ;
  1. ; 1 - If the Imaging value of the case number does not match
  1. ; the case number on disk quit. 2 - Quit if the exam was purged.
  1. ; =================================================================
  1. I $P(RAY3,U)'=RACN D UNLOCXAM Q ; - 1
  1. I $P($G(^RADPT(RADFN,"DT",RADTI,"P",RACNI,"PURGE")),U)>0 D UNLOCXAM Q ; - 2
  1. ;
  1. ;
  1. ; If a report was created for this case while waiting
  1. ; to access the exam node (timeout) set RARPT, unlock
  1. ; the exam node & exit (XIT).
  1. ; =================================================================
  1. S RARPT=$P(RAY3,U,17)
  1. I RARPT D UNLOCXAM Q
  1. ;
  1. ;
  1. ; Create the accession number. The format may be that
  1. ; of the legacy accession or it may be (w/p47) a site
  1. ; specific accession (SSAN). Check if patch RA*5.0*47
  1. ; has been installed.
  1. ;
  1. ; Because we entered the Radiology application through
  1. ; a foreign source the following package wide Radiology
  1. ; variables must be defined: RAMDIV & RAMDV
  1. ; =================================================================
  1. N RACESION,RAMDIV,RAMDV
  1. S RAMDIV=+$P(RAY2,U,3),RAMDV=$S($D(^RA(79,RAMDIV,.1)):^(.1),1:"")
  1. I $P(RAY3,U,31)'="" D ; use SSAN
  1. .S RACESION=$P(RAY3,U,31)
  1. .Q
  1. ; else use the legacy accession
  1. E S RACESION=$E(RADTE,4,7)_$E(RADTE,2,3)_"-"_RACN
  1. ;
  1. ;
  1. N RA1,RAERR,RAFDA,RAFDAIEN,RAIEN,RAPRTSET,RAMEMARR,RATXT,RAX,RAXIT,RAY
  1. ;
  1. ; Check if this case is part of a print set.
  1. ; =================================================================
  1. ; D EN2^RAUTL20(.RAMEMARR) is a silent call!
  1. ; RAMEMARR = # of descendents
  1. ; RAMEMARR(n)=case #^procedure IEN^report text IEN^exam status IEN
  1. ; (where 'n' is RACNI)
  1. ; If printset RAPRTSET=1, else RAPRTSET=0
  1. D EN2^RAUTL20(.RAMEMARR) ; is this case part of a print set ?
  1. ;
  1. ;
  1. ; Find the next available RAD/NUC MED REPORTS IEN, lock that record
  1. ; & file the report specific data into that new report record.
  1. ; =================================================================
  1. S RAFDAIEN(1)=$$NEWIEN()
  1. ;
  1. ; ** Note: ^RARPT(RAFDAIEN(1)) is locked; it is up to **
  1. ; ** YOU to unlock the record before the process quits **
  1. ;
  1. S RAY="+1",RAX="RAFDA(74,"""_RAY_","")"
  1. S @RAX@(.01)=RACESION
  1. S @RAX@(2)=RADFN
  1. S @RAX@(3)=(9999999.9999-RADTI)
  1. S @RAX@(4)=RACN
  1. S @RAX@(6)=DT
  1. ;
  1. ;The filing of report text is no longer required.
  1. ;K RATXT("RPT") S RATXT("RPT",1)="Images collected."
  1. ;S @RAX@(200)="RATXT(""RPT"")"
  1. ;
  1. ; Create the Activity Log (74.01) sub-file record.
  1. S RAX="RAFDA(74.01,""+2,"_RAY_","")"
  1. S @RAX@(.01)=$$NOW^XLFDT()
  1. S @RAX@(2)=$S($D(RAESIG)#2:"V",1:"C")
  1. S @RAX@(3)=$S($G(RAVERF):RAVERF,1:DUZ)
  1. D UPDATE^DIE("","RAFDA","RAFDAIEN","RAERR")
  1. ;
  1. ;
  1. ; If there happened to be an error when calling UPDATE^DIE
  1. ; kill off the stub report record.
  1. ; =================================================================
  1. I $D(RAERR("DIERR"))#2,($D(^RARPT(RAFDAIEN(1),0))#2) D D XIT Q
  1. .D DELRPT(RAFDAIEN(1)) ;note: RARPT is null
  1. .QUIT
  1. ;
  1. ;
  1. ;
  1. ; ** 70.03 - set report text field in the EXAMINATIONS node - 70.03 **
  1. ; ** 70.03 - locked at the top of RARIC - 70.03 **
  1. ; =================================================================
  1. K RAERR,RAFDA,RAIEN,RATXT
  1. ;
  1. S RAIEN=RACNI_","_RADTI_","_RADFN_","
  1. S RAFDA(70.03,RAIEN,17)=RAFDAIEN(1)
  1. D FILE^DIE("","RAFDA","RAERR")
  1. ;
  1. ; the REPORT TEXT field was not set correctly
  1. I $D(RAERR("DIERR"))#2 D DELRPT(RAFDAIEN(1)) D XIT Q
  1. ;
  1. ;
  1. ;the report record has been created, set RARPT = RAFDAIEN(1)
  1. S RARPT=RAFDAIEN(1)
  1. ;
  1. ;
  1. ; create a var RARIC to suppress display of info msg from PTR^RARTE2
  1. ; PTR^RARTE2 requires that RARPT the IEN of an existing report record.
  1. ; =================================================================
  1. N RARPTN S RARPTN=$P(^RARPT(RARPT,0),U)
  1. I RAPRTSET N RARIC S RARIC=1 D PTR^RARTE2
  1. ; don't have to check raxit, since we're quitting now
  1. ;
  1. ;
  1. XIT ;exit the CREATE subroutine
  1. ; =================================================================
  1. ;Unlock the case node & unlock the report.
  1. D UNLOCXAM L -^RARPT(RAFDAIEN(1))
  1. QUIT
  1. ;
  1. ;
  1. PTR ; associate images with a radiology report record
  1. ; --------------------------------------------------------------------
  1. ;
  1. ; input: RARPT - IEN of Rad/NM Report file #74
  1. ; MAGGP - IEN of record in file 2005 pointed to by a report
  1. ;
  1. ; returns: Y=0 - variable MAGGP does not exist
  1. ; Y=-1 - FileMan could not create an entry (may be -1 w/report)
  1. ; Y>0 - FileMan created an entry
  1. ;
  1. S Y=0 Q:$G(MAGGP)'>0
  1. L +^RARPT(RARPT):$G(DILOCKTM,5)
  1. I '$T S Y="-1^radiology report locked" Q ;lock failed...
  1. N RAFDA,RAIEN,RARSLT
  1. S RAFDA(74.02005,"+1,"_RARPT_",",.01)=MAGGP
  1. D UPDATE^DIE(,"RAFDA","RAIEN","RARSLT")
  1. I $D(RARSLT("DIERR"))#2 D
  1. .S Y=-1 ;RAIEN(1) undef
  1. .QUIT
  1. E I RAIEN(1)>0 S Y=RAIEN(1)
  1. L -^RARPT(RARPT)
  1. QUIT
  1. ;
  1. ;
  1. DELRPT(Y) ; delete a report (RARIC). The report record should
  1. ;be locked by the software calling this function.
  1. ; --------------------------------------------------------------------
  1. ; Input: Y = the IEN of the report record
  1. ;
  1. K RAERR,RAFDA S RAFDA(74,Y_",",.01)="@"
  1. D FILE^DIE("","RAFDA","RAERR") K RAERR,RAFDA
  1. Q
  1. ;
  1. ;
  1. NEWIEN() ; ##### ALLOCATES A NEW RECORD IN THE RAD/NUC MED REPORTS FILE
  1. ; (#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. 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
  1. ;
  1. ;
  1. UNLOCXAM ;Unlock the EXAMINATION node locked by this process.
  1. ; --------------------------------------------------------------------
  1. L -^RADPT(RADFN,"DT",RADTI,"P",RACNI,0) QUIT
  1. ;