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

RAMAG03.m

Go to the documentation of this file.
  1. RAMAG03 ;HCIOFO/SG - ORDERS/EXAMS API (EXAM REGISTRATION) ; 2/10/09 4:14pm
  1. ;;5.0;Radiology/Nuclear Medicine;**90**;Mar 16, 1998;Build 20
  1. ;
  1. Q
  1. ;
  1. ;##### REGISTERS THE EXAM(S)
  1. ;
  1. ; .RAPARAMS Reference to the API descriptor
  1. ; (see the ^RA01 routine for details)
  1. ;
  1. ; .RAEXAMS( Reference to a local array where identifiers of
  1. ; registered examination(s) are returned to.
  1. ;
  1. ; Seq#) Exam/case identifiers:
  1. ; ^01: IEN of the patient in the file #70 (RADFN)
  1. ; ^02: IEN in the REGISTERED EXAMS multiple (RADTI)
  1. ; ^03: IEN in the EXAMINATIONS multiple (RACNI)
  1. ; ^04: Case number
  1. ; ^05: Accession number.
  1. ; SSS-MMDDYY-NNNNN if RA*5*47 is installed;
  1. ; MMDDYY-NNNNN otherwise.
  1. ; ^06: Actual date/time of the case (FileMan)
  1. ;
  1. ; RAOIFN IEN of the order in the file #75.1
  1. ;
  1. ; RADTE Date/time of the exam (FileMan). If seconds are
  1. ; provided, they are ignored. The date must be exact
  1. ; and the time is required.
  1. ;
  1. ; .RAMISC Reference to a local array containing miscellaneous
  1. ; request parameters.
  1. ;
  1. ; See the ^RAMAG routine for additional important
  1. ; details regarding this parameter.
  1. ;
  1. ; RAMISC(
  1. ;
  1. ; "BEDSECT") IEN of the bedsection in the SPECIALTY
  1. ; file (#42.4).
  1. ; Required: No (used for inpatient category only)
  1. ; Default: Bedsection on exam date
  1. ;
  1. ; "EXAMCAT") Exam category: value for the CATEGORY OF EXAM field
  1. ; (4) of the EXAMINATIONS multiple (sub-file #70.03).
  1. ; Required: Yes
  1. ; Default: Exam category from the order
  1. ;
  1. ; "FLAGS") Flags that control the execution (see the ^RAMAG
  1. ; routine for details). Supported flags: "A" and "D".
  1. ; Required: No
  1. ; Default: undefined
  1. ;
  1. ; "PRINCLIN") IEN of the principal clinic in the HOSPITAL
  1. ; LOCATION file (#44).
  1. ; Required: Yes (for non-inpatient categories only)
  1. ; Default: Requesting location if it is a clinic
  1. ;
  1. ; "RAPROC",
  1. ; Seq#) Radiology procedure and modifiers
  1. ; ^01: Procedure IEN in file #71
  1. ; ^02: Optional procedure modifiers (IENs in
  1. ; ... the PROCEDURE MODIFIERS file (#71.2))
  1. ; ^nn:
  1. ; Required: Yes
  1. ; Default: Procedure and modifiers from the order
  1. ;
  1. ; "SERVICE") IEN of the service in the SERVICE/SECTION
  1. ; file (#49).
  1. ; Required: No (used for inpatient category only)
  1. ; Default: Service section on exam date
  1. ;
  1. ; "SINGLERPT") If this parameter is defined and not 0, then all
  1. ; cases should be associated with the same order
  1. ; and they will share the same report. See the
  1. ; MEMBER OF SET (25) and IMAGING ORDER (11) fields
  1. ; of the sub-file #70.03 for more details.
  1. ; Required: No
  1. ; Default: If the order references a parent
  1. ; procedure that requires a single report
  1. ; (see the SINGLE REPORT field (18) of the
  1. ; file #71), then a non-zero value is
  1. ; assigned to this parameter. Otherwise,
  1. ; it is undefined.
  1. ;
  1. ; NOTE: If a parent procedure is being registered,
  1. ; the default value cannot be overridden.
  1. ;
  1. ; "TECHCOMM") Technologist comment
  1. ; Required: No
  1. ; Default: undefined
  1. ;
  1. ; "WARD") IEN of the ward in the WARD LOCATION file (#42).
  1. ; Required: No (used for inpatient category only)
  1. ; Default: Ward location on exam date
  1. ;
  1. ; This function uses the ^TMP($J,"RAREG1") global node.
  1. ;
  1. ; ^TMP($J,
  1. ; "RAREG1",i) Exam identifiers
  1. ; ^01: IEN of the patient in the file #70
  1. ; ^02: IEN in the REGISTERED EXAMS multiple
  1. ; ^03: IEN in the EXAMINATIONS multiple
  1. ;
  1. ; Return values:
  1. ; <0 Error descriptor (see $$ERROR^RAERR)
  1. ; >0 Number of registered examinations
  1. ; (number of elements in the RAEXAMS array)
  1. ;
  1. REGISTER(RAPARAMS,RAEXAMS,RAOIFN,RADTE,RAMISC) ;
  1. N RADFN ; IEN of the patient in the file #70
  1. N RADTI ; "Inverted" date/time of registered exam(s)
  1. N RAEXMVAL ; Exam parameters extracted from the order
  1. N RASACN31 ; Use the new site accession number
  1. N RAIMGTYI ; Imaging type IEN (file #79.2)
  1. N RAMDIV ; Radiology division IEN (file #79)
  1. N RAMLC ; Imaging location IEN (file #79.1)
  1. N RAPARENT ; Indicator of an exam set
  1. N RAPRLST ; List of detailed/series procedures
  1. ;
  1. N HLA,RAEXMCNT,RAFLAGS,RALOCK,RARC,TMP
  1. D:$G(RAPARAMS("DEBUG"))>1
  1. . D W^RAMAGU11("$$REGISTER^RAMAG03","!!")
  1. . D VARS^RAMAGU11("RAOIFN,RADTE")
  1. . D ZW^RAUTL22("RAMISC")
  1. K RAEXAMS,^TMP($J,"RAREG1")
  1. S (RAEXMCNT,RARC)=0
  1. ;
  1. D
  1. . ;=== Setup the error handler
  1. . N $ESTACK,$ETRAP D SETDEFEH^RAERR("RARC")
  1. . ;
  1. . ;=== Validate parameters
  1. . S RARC=$$VALIDATE^RAMAG03A(.RALOCK) Q:RARC<0
  1. . S RAFLAGS=$$TRFLAGS^RAUTL22($G(RAMISC("FLAGS")),"AD","AD")
  1. . S RASACN31=$$USLNGACN^RAMAGU13($G(RAMDIV))
  1. . ;
  1. . ;=== Lock the exam date/time node and double check parameters
  1. . S RARC=$$LOCKDT^RAMAG03D(RADFN,.RADTE,.RALOCK,RAFLAGS) Q:RARC<0
  1. . S RADTI=$$INVDTE^RAMAGU04(RADTE)
  1. . ;
  1. . ;=== Register the exam(s)
  1. . S RARC=$$EXAM^RAMAG03C() Q:RARC<0
  1. . ;
  1. . ;=== Update order status and send OE v3.0 message
  1. . D:$D(^TMP($J,"RAREG1"))>1
  1. . . N RAOSTS,RAPROC D UOSM^RAREG2
  1. . ;
  1. . ;=== Additional post-processing
  1. . S TMP=$$POSTPROC^RAMAG03C(.RAEXAMS,RADTE)
  1. . S:TMP'<0 RAEXMCNT=+TMP
  1. ;
  1. ;=== Error handling and cleanup
  1. D:RARC<0 ROLLBACK^RAMAG03D($G(RADFN),$G(RADTI))
  1. ;--- Unlock the global nodes
  1. D UNLOCKFM^RALOCK(.RALOCK)
  1. ;--- Cleanup
  1. K ^TMP($J,"RAREG1")
  1. Q $S(RARC<0:RARC,1:RAEXMCNT)