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

RAMAG07.m

Go to the documentation of this file.
  1. RAMAG07 ;HCIOFO/SG - ORDERS/EXAMS API (EXAMINED) ; 9/30/08 8:52am
  1. ;;5.0;Radiology/Nuclear Medicine;**90**;Mar 16, 1998;Build 20
  1. ;
  1. Q
  1. ;
  1. ;##### INDICATES THAT THE PROCEDURE HAS BEEN PERFORMED
  1. ;
  1. ; .RAPARAMS Reference to the API descriptor
  1. ; (see the ^RA01 routine for details)
  1. ;
  1. ; RACASE 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. ;
  1. ; [.RAMISC] Reference to a local array containing miscellaneous
  1. ; exam parameters.
  1. ;
  1. ; See the ^RAMAG routine for additional important
  1. ; details regarding this parameter.
  1. ;
  1. ; RAMISC(
  1. ;
  1. ; "CMUSED") Internal value for the CONTRAST MEDIA USED field
  1. ; (10) of the EXAMINATIONS multiple (sub-file
  1. ; #70.03).
  1. ; Required: No
  1. ; Default: undefined
  1. ;
  1. ; "COMPLICAT") Internal values for the COMPLICATION (16)
  1. ; and COMPLICATION TEXT (16.5) fields of the
  1. ; sub-file #70.03.
  1. ; ^01: IEN in the COMPLICATION TYPES file (#78.1)
  1. ; ^02: Complication text
  1. ; Required: No
  1. ; Default: undefined
  1. ;
  1. ; "CONTMEDIA"
  1. ; Seq#) Internal value for the CONTRAST MEDIA field (.01)
  1. ; of the sub-file #70.3225.
  1. ; Required: No
  1. ; Default: undefined
  1. ;
  1. ; "CPTMODS",
  1. ; Seq#) Internal value for the CPT MODIFIERS field (.01)
  1. ; of the sub-file #70.3135: IEN in the CPT MODIFIER
  1. ; file (#81.3).
  1. ; Required: Site and/or imaging type specific
  1. ; Default: undefined
  1. ;
  1. ; "FILMSIZE",
  1. ; Seq#) Internal values for the record of the FILM SIZE
  1. ; multiple (70) of the sub-file #70.03.
  1. ; ^01: IEN in the FILM SIZES file (#78.4)
  1. ; ^02: Amount (#films or cine ft)
  1. ; Required: Site and/or imaging type specific
  1. ; Default: undefined
  1. ;
  1. ; "FLAGS") Flags that control the execution (see the ^RAMAG
  1. ; routine for details). Supported flags: "F", "S".
  1. ; Required: No
  1. ; Default: undefined
  1. ;
  1. ; "PRIMCAM") Internal value for the PRIMARY CAMERA/EQUIP/RM
  1. ; field (18) of the sub-file #70.03: IEN in the
  1. ; CAMERA/EQUIP/RM file (#78.6).
  1. ; Required: Site and/or imaging type specific
  1. ; Default: undefined
  1. ;
  1. ; "PRIMDXCODE") Internal value for the PRIMARY DIAGNOSTIC CODE
  1. ; field (13) of the sub-file #70.03: IEN in the
  1. ; DIAGNOSTIC CODES file (#78.3).
  1. ; Required: Site and/or imaging type specific
  1. ; Default: undefined
  1. ;
  1. ; "PRIMINTRES") Internal value for the PRIMARY INTERPRETING
  1. ; RESIDENT field (12) of the sub-file #70.03: IEN in
  1. ; the NEW PERSON file (#200).
  1. ; Required: Site and/or imaging type specific
  1. ; Default: undefined
  1. ;
  1. ; "PRIMINTSTF") Internal value for the PRIMARY INTERPRETING
  1. ; STAFF field (15) of the sub-file #70.03: IEN in
  1. ; the NEW PERSON file (#200).
  1. ; Required: Site and/or imaging type specific
  1. ; Default: undefined
  1. ;
  1. ; "RAPROC",
  1. ; 1) 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: No (if defined, replaces the existing
  1. ; value assigned by $$REGISTER^RAMAG03)
  1. ; Default: undefined
  1. ;
  1. ; NOTE: Only a single procedure is associated with
  1. ; a case. Therefore, only the first subnode
  1. ; of the "RAPROC" with a subscript greater
  1. ; than 0 is used.
  1. ;
  1. ; "RDPHARMS", INTERNAL VALUES FOR THE RECORDS OF THE
  1. ; i, 'RADIOPHARMACEUTICALS' MULTIPLE (100) OF THE
  1. ; 'NUC MED EXAM DATA' FILE (#70.2).
  1. ;
  1. ; "RDPH-ACDR") Internal value for the ACTIVITY DRAWN
  1. ; field (4).
  1. ; Required: Site and/or imaging type specific
  1. ; Default: undefined
  1. ;
  1. ; "RDPH-DOSE") Internal value for the DOSE ADMINISTERED
  1. ; field (7).
  1. ; Required: Yes (if any other radiopharmaceutical
  1. ; parameters are provided)
  1. ; Default: undefined
  1. ;
  1. ; "RDPH-DRUG") Internal value for the RADIOPHARMACEUTICAL
  1. ; field (.01).
  1. ; Required: Yes (if any other radiopharmaceutical
  1. ; parameters are provided)
  1. ; Default: undefined
  1. ;
  1. ; "RDPH-DTADM") Internal value for the DATE/TIME DOSE
  1. ; ADMINISTERED field (8).
  1. ; Required: Site and/or imaging type specific
  1. ; Default: undefined
  1. ;
  1. ; "RDPH-DTDRW") Internal value for the DATE/TIME DRAWN
  1. ; field (5).
  1. ; Required: Site and/or imaging type specific
  1. ; Default: undefined
  1. ;
  1. ; "RDPH-FORM") Internal value for the FORM field (15).
  1. ; Required: Site and/or imaging type specific
  1. ; Default: undefined
  1. ;
  1. ; "RDPH-LOTN") Internal value for the LOT NO field (13).
  1. ; Required: Site and/or imaging type specific
  1. ; Default: undefined
  1. ;
  1. ; "RDPH-PWADM") Internal value for the PERSON WHO ADMINISTERED
  1. ; DOSE field (9).
  1. ; Required: Site and/or imaging type specific
  1. ; Default: undefined
  1. ;
  1. ; "RDPH-PWMSD") Internal value for the PERSON WHO MEASURED DOSE
  1. ; field (6).
  1. ; Required: Site and/or imaging type specific
  1. ; Default: undefined
  1. ;
  1. ; "RDPH-ROUTE") Internal value for the ROUTE OF ADMINISTRATION
  1. ; field (11).
  1. ; Required: Site and/or imaging type specific
  1. ; Default: undefined
  1. ;
  1. ; "RDPH-SITE") Internal value for the SITE OF ADMINISTRATION
  1. ; field (12).
  1. ; Required: Site and/or imaging type specific
  1. ; Default: undefined
  1. ;
  1. ; "RDPH-VOL") Internal value for the VOLUME field (14).
  1. ; Required: Site and/or imaging type specific
  1. ; Default: undefined
  1. ;
  1. ; "TECH",
  1. ; Seq#) Internal value for the TECHNOLOGIST field (.01)
  1. ; of the subfile #70.12: IEN in the NEW PERSON
  1. ; file (#200).
  1. ; Required: Site and/or imaging type specific
  1. ; Default: undefined
  1. ;
  1. ; "TECHCOMM") Technologist comment
  1. ; Required: No
  1. ; Default: undefined
  1. ;
  1. ; "BEDSECT") If any of these optional parameters are defined,
  1. ; "EXAMCAT") their values replace the existing ones assigned
  1. ; "PRINCLIN") by the $$REGISTER^RAMAG03.
  1. ; "SERVICE")
  1. ; "WARD")
  1. ;
  1. ; Return values:
  1. ; <0 Error descriptor (see $$ERROR^RAERR)
  1. ; 0 Case has been marked as 'examined'
  1. ;
  1. EXAMINED(RAPARAMS,RACASE,RAMISC) ;
  1. N RACN ; Case number
  1. N RACNI ; IEN of the exam in the EXAMINATIONS multiple
  1. N RADFN ; IEN of the patient in the file #70
  1. N RADTE ; Date/time of the exam
  1. N RADTI ; Inverted date/time of the exam
  1. N RAIENS ; IENS of the exam record
  1. N RAIMGTYI ; Imaging type IEN (file #79.2)
  1. N RAMSPSDEFS ; Data for miscellaneous parameters validation
  1. N RANMDIEN ; IEN of the nuclear medicine data (file #70.2)
  1. N RAPROCIEN ; Radiology procedure IEN
  1. ;
  1. N RALOCK,RAMSG,RARC,TMP
  1. D:$G(RAPARAMS("DEBUG"))>1
  1. . D W^RAMAGU11("$$EXAMINED^RAMAG07","!!")
  1. . D VARS^RAMAGU11("RACASE")
  1. . D ZW^RAUTL22("RAMISC")
  1. ;
  1. ;--- Validate case identifiers
  1. S RARC=$$CHKREQ^RAUTL22("RACASE") Q:RARC<0 RARC
  1. S RARC=$$CHKEXMID^RAMAGU04(RACASE) Q:RARC<0 RARC
  1. S RADFN=$P(RACASE,U),RADTI=$P(RACASE,U,2),RACNI=$P(RACASE,U,3)
  1. S RAIENS=$$EXAMIENS^RAMAGU04(RACASE)
  1. ;
  1. ;--- Lock the exam
  1. K TMP S TMP(70.03,RAIENS)=""
  1. S RARC=$$LOCKFM^RALOCK(.TMP)
  1. Q:RARC $$LOCKERR^RAERR(RARC,"examination")
  1. M RALOCK=TMP
  1. ;
  1. D
  1. . ;--- Setup the error handler
  1. . N $ESTACK,$ETRAP D SETDEFEH^RAERR("RARC")
  1. . ;
  1. . ;--- Initialize variables
  1. . N EXMST,RACTION,RAFDA,RAFDAM,RAPRIEN,RATRKCMB
  1. . D LDMSPRMS^RAMAGU01(.RAMSPSDEFS)
  1. . S RACTION="E"
  1. . ;
  1. . ;--- Get the current exam status
  1. . S EXMST=$$EXMSTAT^RAMAGU05(RACASE)
  1. . I EXMST<0 S RARC=EXMST Q
  1. . ;--- Find the exam status that has 'E:Examined' value
  1. . ;--- in the VISTARAD CATEGORY field (9).
  1. . S RARC=$$GETEXMND^RAMAGU06(+EXMST) Q:RARC<0
  1. . I RARC'>0 D Q
  1. . . S RARC=$$ERROR^RAERR(-31,"RACASE='"_RACASE_"'","EXAMINED")
  1. . S EXMST=RARC ; New exam status
  1. . ;
  1. . ;--- Load exam properties and initialize key variables
  1. . S RARC=$$EXAMVARS^RAMAGU04(RAIENS) Q:RARC<0
  1. . ;
  1. . ;--- Validate general parameters
  1. . S RARC=$$VAL70^RAMAGU08(RAIENS,+EXMST,.RACTION,.RAMISC,.RAFDAM)
  1. . I RARC<0 S RARC=$$ERROR^RAERR(-11) Q
  1. . Q:RACTION="" ;--- Exam is at or past the requested status
  1. . ;
  1. . ;--- Nuclear medicine (including parameter validation)
  1. . S RARC=$$NUCMED^RAMAG06A(RACASE,RACTION,.RAMISC,.RAFDAM) Q:RARC<0
  1. . S RANMDIEN=RARC
  1. . ;
  1. . ;--- Pre-processing
  1. . S RARC=$$EDTPRE^RAMAG06A(RACTION,.RATRKCMB,.RAPRIEN) Q:RARC<0
  1. . K RAFDAM("RACNT"),RAFDAM("RAIENS")
  1. . ;
  1. . ;--- Update the exam record
  1. . K RAFDA,RAMSG M RAFDA(70.03)=RAFDAM(70.03) K RAFDAM(70.03)
  1. . I $D(RAFDA)>1 D Q:RARC<0
  1. . . D FILE^DIE(,"RAFDA","RAMSG")
  1. . . S:$G(DIERR) RARC=$$DBS^RAERR("RAMSG",-9,70.03,RAIENS)
  1. . ;
  1. . ;--- Update the nuclear medicine data
  1. . K RAFDA,RAMSG M RAFDA(70.21)=RAFDAM(70.21) K RAFDAM(70.21)
  1. . I $D(RAFDA)>1 D Q:RARC<0
  1. . . S RARC=$$UPDMULT^RAMAGU13(.RAFDA,RANMDIEN_",")
  1. . ;
  1. . ;--- Update procedure and modifiers
  1. . S TMP=$O(RAMISC("RAPROC",0))
  1. . I TMP>0 S TMP=$G(RAMISC("RAPROC",TMP)) D:TMP'="" Q:RARC<0
  1. . . S RARC=$$UPDEXMPR^RAMAGU04(RACASE,TMP)
  1. . ;
  1. . ;--- Update multiples of the exam record
  1. . I $D(RAFDAM)>1 D Q:RARC<0
  1. . . S RARC=$$UPDMULT^RAMAGU13(.RAFDAM,RAIENS)
  1. . ;
  1. . ;--- Create the stub report
  1. . S RARC=$$RPTSTUB^RAMAGU12(RACASE,RADTE,RACN) Q:RARC<0
  1. . ;
  1. . ;--- Exam status
  1. . S TMP=$$TRFLAGS^RAUTL22($G(RAMISC("FLAGS")),"F","F")
  1. . S RARC=$$UPDEXMST^RAMAGU05(RACASE,EXMST,TMP) Q:RARC<0
  1. . ;--- Activity log
  1. . S TMP=$G(RAMISC("TECHCOMM"))
  1. . S RARC=$$UPDEXMAL^RAMAGU05(RACASE,"C",TMP)
  1. . ;
  1. . ;--- Post-processing and notifications
  1. . S RARC=$$EDTPST^RAMAG06A(RACTION,RATRKCMB) Q:RARC<0
  1. ;
  1. ;=== Error handling and cleanup
  1. D UNLOCKFM^RALOCK(.RALOCK)
  1. Q $S(RARC<0:RARC,1:0)