RAMAGU08 ;HCIOFO/SG,GJC - ORDERS/EXAMS API (RAMISC VALID. #70) ; 4/12/13 6:25pm
 ;;5.0;Radiology/Nuclear Medicine;**90,116**;Mar 16, 1998;Build 1
 ;
 Q
 ;
 ;***** VALIDATES RAMISC PARAMETERS RELATED TO THE FILE #70
 ;
 ; RAIENS        IENS of the exam/case (subfile #70.03)
 ;
 ; RASTIEN       IEN of the requested exam status
 ;
 ; .RACTION      Reference to a local variable that indicates the
 ;               actions (can be combined):
 ;                 E  Examined (procedure has been performed)
 ;                 C  Complete
 ;
 ;               After exiting the function, this parameter contains
 ;               only those actions that actually have to be performed
 ;               in order to reach the requested status. For example, 
 ;               if "EC" is passed and the procedure has already been 
 ;               performed, then "E" will be removed.
 ;
 ;               If this parameter is empty after the call, then the
 ;               exam already has requested status.
 ;
 ; .RAMISC       Reference to a local array containing miscellaneous
 ;               request parameters.
 ;
 ; .RAFDA(       Reference to a local array where field values will
 ;               be prepared for storage (FileMan FDA array).
 ;
 ;   "RACNT")    This is an additional node that stores counter for
 ;               the IENS placeholders. Do not forget to remove this
 ;               node before passing the array into a FileMan API.
 ;
 ;   "RAIENS")   This is an additional node that stores IENS of the
 ;               record being processed. Do not forget to remove this 
 ;               node before passing the array into a FileMan API.
 ;
 ; [RAFDACNT]    New value for the placeholder counter for the RAFDA. 
 ;               If this parameter is greater than zero, it replaces
 ;               the value stored in the RAFDA("RACNT").
 ;
 ; Input variables:
 ;   RACN, RADTE, RAIMGTYI, RAMSPSDEFS
 ;
 ; Output variables:
 ;   RAMSPSDEFS, RAPROCIEN
 ;
 ; Return values:
 ;       <0  Error code
 ;        0  Ok
 ;
VAL70(RAIENS,RASTIEN,RACTION,RAMISC,RAFDA,RAFDACNT) ;
 N ERRCNT,EXMST,PNODE,RABUF,RACAT,RAI,RAMSG,RAPROC,RC,TMP
 ;
 ;=== Check required parameters and variables
 S RC=$$CHKREQ^RAUTL22("RACTION,RAIENS")  Q:RC<0 RC
 S RC=$$CHKREQ^RAUTL22("RACN,RADTE,RAIMGTYI","V")
 Q:RC<0 RC
 Q:$TR(RACTION,"EC")'="" $$IPVE^RAERR("RACTION")
 ;
 ;=== Initialize variables
 S RAFDA("RAIENS")=RAIENS
 S:$G(RAFDACNT)>0 RAFDA("RACNT")=+RAFDACNT
 S (ERRCNT,RC)=0
 ;
 ;=== Data from the EXAMINATIONS multiple
 D GETS^DIQ(70.03,RAIENS,"2;3;4","I","RABUF","RAMSG")
 Q:$G(DIERR) $$DBS^RAERR("RAMSG",-9,70.03,RAIENS)
 ;
 ;=== Check the current exam status
 S TMP=+$G(RABUF(70.03,RAIENS,3,"I"))
 S EXMST=$$EXMSTINF^RAMAGU06(TMP)  Q:EXMST<0 EXMST
 ;--- Already COMPLETE
 I $P(EXMST,U,3)=9  S RACTION=""  Q 0
 ;--- Already "EXAMINED"
 I $P(EXMST,U,3)>1  D  Q:RC<0 RC
 . S RC=$$GETEXMND^RAMAGU06(+EXMST)
 . ;--- Cannot find the "EXAMINED" status
 . S:'RC RACTION=$TR(RACTION,"E")
 Q:RACTION="" 0
 ;
 ;=== Detailed/series procedure and modifiers
 S PNODE=$NA(RAMISC("RAPROC"))
 S RAI=$O(@PNODE@(0))
 I RAI>0  S RAPROC=@PNODE@(RAI)  D         ; Update procedure
 . I $O(@PNODE@(RAI))>0  D ERROR^RAERR(-49)  S ERRCNT=ERRCNT+1
 E  S RAPROC=$G(RABUF(70.03,RAIENS,2,"I")) ; Current procedure
 ;--- Validate the procedure and modifiers
 S TMP=$$CHKPROC^RAMAGU03(RAPROC,RAIMGTYI,RADTE,"DS")
 S:TMP<0 ERRCNT=ERRCNT+1
 S RAPROCIEN=$S('TMP:+RAPROC,1:"")
 ;
 ;=== Get the exam status requirements
 S TMP=$$EXMSTREQ^RAMAGU06(RASTIEN,RAPROCIEN)  Q:TMP<0 TMP
 ;--- The "EF" report status means outside work. In this case,
 ;    cancel requirements for anything except (possibly) the
 ;--- diagnostic code. See the HELP1^RASTREQ for more details.
 I $G(RAMISC("RPTSTATUS"))'="EF"  S RAMSPSDEFS("R")=TMP
 E  S RAMSPSDEFS("R")="",$P(RAMSPSDEFS("R"),U,5)=$P(TMP,U,5)
 ;
 ;=== Category of exam
 S PNODE=$NA(RAMISC("EXAMCAT"))
 I $D(@PNODE)#10  S RACAT=@PNODE  D        ; Update category
 . S:$$CHECKFLD^RAMAGU09(PNODE,RACAT,70.03,4,RAIENS,1)<0 ERRCNT=ERRCNT+1
 E  S RACAT=$G(RABUF(70.03,RAIENS,4,"I"))  ; Current category
 ;
 ;=== Parameters specific to the exam category
 S:$$VALECPRM^RAMAGU09(RACAT)<0 ERRCNT=ERRCNT+1
 ;
 ;=== Technologist comment
 S:$$VALPRM^RAMAGU09("TECHCOMM")<0 ERRCNT=ERRCNT+1
 ;
 ;=== Validate parameters specific to different exam statuses
 I $TR(RACTION,"EC")'=RACTION  D  S:TMP<0 ERRCNT=ERRCNT+1
 . S TMP=$$VEXAMND(RAIENS,RACTION,.RAMISC,.RAFDA)
 I RACTION["C"  D  S:TMP<0 ERRCNT=ERRCNT+1
 . S TMP=$$VCOMPLT(RAIENS,RACTION,.RAMISC,.RAFDA)
 ;
 ;=== Error handling and cleanup
 K RAFDA(70.07) ; Do not modify the activity log directly
 Q $S(ERRCNT>0:-11,1:0)
 ;
 ;+++++ VALIDATES 'COMPLETE' PARAMETERS
VCOMPLT(RAIENS,RACTION,RAMISC,RAFDA) ;
 N ERRCNT,PNODE,TMP
 S ERRCNT=0
 ;
 ;=== Error handling and cleanup
 Q $S(ERRCNT>0:-11,1:0)
 ;
 ;+++++ VALIDATES 'EXAMINED' PARAMETERS
VEXAMND(RAIENS,RACTION,RAMISC,RAFDA) ;
 N ECNT,NAME,PI,PNODE,RAI,RC,TMP
 S ECNT=0
 ;
 ;=== Contrast media used
 S RC=$$VALPRM^RAMAGU09("CMUSED",,RAIENS)
 I RC>0  D
 . ;--- Clear the CONTMEDIA list if necessary
 . S TMP=$G(RAFDA(70.03,RAIENS,10))
 . I TMP'="Y"  K RAMISC("CONTMEDIA")  S RAMISC("CONTMEDIA")=""
 E  S:RC<0 ECNT=ECNT+1
 ;
 ;=== Contrast media
 S NAME="CONTMEDIA"
 S RC=$$VALPRM^RAMAGU09(NAME)
 I RC>0  D
 . S RAI=0
 . F  S RAI=$O(RAMISC(NAME,RAI))  Q:RAI'>0  D
 . . S:$$VALPRM^RAMAGU09(NAME,RAI)<0 ECNT=ECNT+1
 . ;--- Make the value of the CONTRAST MEDIA USED consistent
 . S TMP=$D(RAFDA(70.3225))
 . S:TMP RAFDA(70.03,RAIENS,10)=$S(TMP>1:"Y",1:"N")
 E  S:RC<0 ECNT=ECNT+1
 ;
 ;=== Complication
 S NAME="COMPLICAT"
 S RC=$$VALPRM^RAMAGU09(NAME,,RAIENS)
 I RC>0  D
 . S PNODE=$NA(RAMISC(NAME))
 . ;--- COMPLICATION TEXT
 . S TMP=$P($G(@PNODE),U,2)
 . S:$$CHECKFLD^RAMAGU09(PNODE,TMP,70.03,16.5,RAIENS)<0 ECNT=ECNT+1
 E  S:RC<0 ECNT=ECNT+1
 ;
 ;=== CPT Modifiers
 S NAME="CPTMODS"
 S RC=$$VALPRM^RAMAGU09(NAME)
 I RC>0  D
 . S RAI=0
 . F  S RAI=$O(RAMISC(NAME,RAI))  Q:RAI'>0  D
 . . S:$$VALPRM^RAMAGU09(NAME,RAI)<0 ECNT=ECNT+1
 E  S:RC<0 ECNT=ECNT+1
 ;
 ;=== Film size
 S NAME="FILMSIZE"
 S RC=$$VALPRM^RAMAGU09(NAME)
 I RC>0  D
 . S RAI=0
 . F  S RAI=$O(RAMISC(NAME,RAI))  Q:RAI'>0  D
 . . S PI=$NA(RAMISC(NAME,RAI))  K IENS
 . . ;--- FILM SIZE
 . . S:$$VALPRM^RAMAGU09(NAME,RAI,.IENS)<0 ECNT=ECNT+1
 . . ;--- AMOUNT
 . . S TMP=$P($G(@PI),U,2)
 . . S:$$CHECKFLD^RAMAGU09(PI,TMP,70.04,2,IENS)<0 ECNT=ECNT+1
 E  S:RC<0 ECNT=ECNT+1
 ;
 ;=== Primary camera/equipment/room
 S:$$VALPRM^RAMAGU09("PRIMCAM",,RAIENS)<0 ECNT=ECNT+1
 ;
 ;=== Technologist
 S NAME="TECH"
 S RC=$$VALPRM^RAMAGU09(NAME)
 I RC>0  D
 . S RAI=0
 . F  S RAI=$O(RAMISC(NAME,RAI))  Q:RAI'>0  D
 . . S:$$VALPRM^RAMAGU09(NAME,RAI)<0 ECNT=ECNT+1
 E  S:RC<0 ECNT=ECNT+1
 ;
 ;=== Primary diagnostic code
 S:$$VALPRM^RAMAGU09("PRIMDXCODE",,RAIENS)<0 ECNT=ECNT+1
 ;
 ;=== Secondary diagnostic code(s)
 S NAME="SECDXCODE"
 S RC=$$VALPRM^RAMAGU09(NAME)
 I RC>0  D
 . S RAI=0
 . F  S RAI=$O(RAMISC(NAME,RAI))  Q:RAI'>0  D
 . . S:$$VALPRM^RAMAGU09(NAME,RAI)<0 ECNT=ECNT+1
 E  S:RC<0 ECNT=ECNT+1
 ;
 ;=== Primary interpreting resident and staff
 S RC=0
 F NAME="PRIMINTRES","PRIMINTSTF"  D
 . ;--- Check the parameter but does not record errors
 . S TMP=$$VALPRM^RAMAGU09(NAME,,RAIENS,,"C")
 . ;--- Handle defined/not defined cases
 . I TMP'<0  S RC=RC+1  Q
 . I +TMP=-8  S RC=RC-1  Q
 . ;--- Otherwise, call again to record the error(s)
 . S TMP=$$VALPRM^RAMAGU09(NAME,,RAIENS),ECNT=ECNT+1
 . ;--- Prevent the code below from recording additional errors
 . S RC=3
 ;--- If neither of the two parameters is defined but one of
 ;--- them is required, record the error.
 I RC<0  D  S ECNT=ECNT+1
 . S TMP=$NA(RAMISC("PRIMINTRES"))_", "_$NA(RAMISC("PRIMINTSTF"))
 . D ERROR^RAERR(-13,TMP)
 ;
 ;=== Error handling and cleanup
 Q $S(ECNT>0:-11,1:0)
 
--- Routine Detail   --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HRAMAGU08   8023     printed  Sep 23, 2025@20:13:10                                                                                                                                                                                                    Page 2
RAMAGU08  ;HCIOFO/SG,GJC - ORDERS/EXAMS API (RAMISC VALID. #70) ; 4/12/13 6:25pm
 +1       ;;5.0;Radiology/Nuclear Medicine;**90,116**;Mar 16, 1998;Build 1
 +2       ;
 +3        QUIT 
 +4       ;
 +5       ;***** VALIDATES RAMISC PARAMETERS RELATED TO THE FILE #70
 +6       ;
 +7       ; RAIENS        IENS of the exam/case (subfile #70.03)
 +8       ;
 +9       ; RASTIEN       IEN of the requested exam status
 +10      ;
 +11      ; .RACTION      Reference to a local variable that indicates the
 +12      ;               actions (can be combined):
 +13      ;                 E  Examined (procedure has been performed)
 +14      ;                 C  Complete
 +15      ;
 +16      ;               After exiting the function, this parameter contains
 +17      ;               only those actions that actually have to be performed
 +18      ;               in order to reach the requested status. For example, 
 +19      ;               if "EC" is passed and the procedure has already been 
 +20      ;               performed, then "E" will be removed.
 +21      ;
 +22      ;               If this parameter is empty after the call, then the
 +23      ;               exam already has requested status.
 +24      ;
 +25      ; .RAMISC       Reference to a local array containing miscellaneous
 +26      ;               request parameters.
 +27      ;
 +28      ; .RAFDA(       Reference to a local array where field values will
 +29      ;               be prepared for storage (FileMan FDA array).
 +30      ;
 +31      ;   "RACNT")    This is an additional node that stores counter for
 +32      ;               the IENS placeholders. Do not forget to remove this
 +33      ;               node before passing the array into a FileMan API.
 +34      ;
 +35      ;   "RAIENS")   This is an additional node that stores IENS of the
 +36      ;               record being processed. Do not forget to remove this 
 +37      ;               node before passing the array into a FileMan API.
 +38      ;
 +39      ; [RAFDACNT]    New value for the placeholder counter for the RAFDA. 
 +40      ;               If this parameter is greater than zero, it replaces
 +41      ;               the value stored in the RAFDA("RACNT").
 +42      ;
 +43      ; Input variables:
 +44      ;   RACN, RADTE, RAIMGTYI, RAMSPSDEFS
 +45      ;
 +46      ; Output variables:
 +47      ;   RAMSPSDEFS, RAPROCIEN
 +48      ;
 +49      ; Return values:
 +50      ;       <0  Error code
 +51      ;        0  Ok
 +52      ;
VAL70(RAIENS,RASTIEN,RACTION,RAMISC,RAFDA,RAFDACNT) ;
 +1        NEW ERRCNT,EXMST,PNODE,RABUF,RACAT,RAI,RAMSG,RAPROC,RC,TMP
 +2       ;
 +3       ;=== Check required parameters and variables
 +4        SET RC=$$CHKREQ^RAUTL22("RACTION,RAIENS")
           if RC<0
               QUIT RC
 +5        SET RC=$$CHKREQ^RAUTL22("RACN,RADTE,RAIMGTYI","V")
 +6        if RC<0
               QUIT RC
 +7        if $TRANSLATE(RACTION,"EC")'=""
               QUIT $$IPVE^RAERR("RACTION")
 +8       ;
 +9       ;=== Initialize variables
 +10       SET RAFDA("RAIENS")=RAIENS
 +11       if $GET(RAFDACNT)>0
               SET RAFDA("RACNT")=+RAFDACNT
 +12       SET (ERRCNT,RC)=0
 +13      ;
 +14      ;=== Data from the EXAMINATIONS multiple
 +15       DO GETS^DIQ(70.03,RAIENS,"2;3;4","I","RABUF","RAMSG")
 +16       if $GET(DIERR)
               QUIT $$DBS^RAERR("RAMSG",-9,70.03,RAIENS)
 +17      ;
 +18      ;=== Check the current exam status
 +19       SET TMP=+$GET(RABUF(70.03,RAIENS,3,"I"))
 +20       SET EXMST=$$EXMSTINF^RAMAGU06(TMP)
           if EXMST<0
               QUIT EXMST
 +21      ;--- Already COMPLETE
 +22       IF $PIECE(EXMST,U,3)=9
               SET RACTION=""
               QUIT 0
 +23      ;--- Already "EXAMINED"
 +24       IF $PIECE(EXMST,U,3)>1
               Begin DoDot:1
 +25               SET RC=$$GETEXMND^RAMAGU06(+EXMST)
 +26      ;--- Cannot find the "EXAMINED" status
 +27               if 'RC
                       SET RACTION=$TRANSLATE(RACTION,"E")
               End DoDot:1
               if RC<0
                   QUIT RC
 +28       if RACTION=""
               QUIT 0
 +29      ;
 +30      ;=== Detailed/series procedure and modifiers
 +31       SET PNODE=$NAME(RAMISC("RAPROC"))
 +32       SET RAI=$ORDER(@PNODE@(0))
 +33      ; Update procedure
           IF RAI>0
               SET RAPROC=@PNODE@(RAI)
               Begin DoDot:1
 +34               IF $ORDER(@PNODE@(RAI))>0
                       DO ERROR^RAERR(-49)
                       SET ERRCNT=ERRCNT+1
               End DoDot:1
 +35      ; Current procedure
          IF '$TEST
               SET RAPROC=$GET(RABUF(70.03,RAIENS,2,"I"))
 +36      ;--- Validate the procedure and modifiers
 +37       SET TMP=$$CHKPROC^RAMAGU03(RAPROC,RAIMGTYI,RADTE,"DS")
 +38       if TMP<0
               SET ERRCNT=ERRCNT+1
 +39       SET RAPROCIEN=$SELECT('TMP:+RAPROC,1:"")
 +40      ;
 +41      ;=== Get the exam status requirements
 +42       SET TMP=$$EXMSTREQ^RAMAGU06(RASTIEN,RAPROCIEN)
           if TMP<0
               QUIT TMP
 +43      ;--- The "EF" report status means outside work. In this case,
 +44      ;    cancel requirements for anything except (possibly) the
 +45      ;--- diagnostic code. See the HELP1^RASTREQ for more details.
 +46       IF $GET(RAMISC("RPTSTATUS"))'="EF"
               SET RAMSPSDEFS("R")=TMP
 +47      IF '$TEST
               SET RAMSPSDEFS("R")=""
               SET $PIECE(RAMSPSDEFS("R"),U,5)=$PIECE(TMP,U,5)
 +48      ;
 +49      ;=== Category of exam
 +50       SET PNODE=$NAME(RAMISC("EXAMCAT"))
 +51      ; Update category
           IF $DATA(@PNODE)#10
               SET RACAT=@PNODE
               Begin DoDot:1
 +52               if $$CHECKFLD^RAMAGU09(PNODE,RACAT,70.03,4,RAIENS,1)<0
                       SET ERRCNT=ERRCNT+1
               End DoDot:1
 +53      ; Current category
          IF '$TEST
               SET RACAT=$GET(RABUF(70.03,RAIENS,4,"I"))
 +54      ;
 +55      ;=== Parameters specific to the exam category
 +56       if $$VALECPRM^RAMAGU09(RACAT)<0
               SET ERRCNT=ERRCNT+1
 +57      ;
 +58      ;=== Technologist comment
 +59       if $$VALPRM^RAMAGU09("TECHCOMM")<0
               SET ERRCNT=ERRCNT+1
 +60      ;
 +61      ;=== Validate parameters specific to different exam statuses
 +62       IF $TRANSLATE(RACTION,"EC")'=RACTION
               Begin DoDot:1
 +63               SET TMP=$$VEXAMND(RAIENS,RACTION,.RAMISC,.RAFDA)
               End DoDot:1
               if TMP<0
                   SET ERRCNT=ERRCNT+1
 +64       IF RACTION["C"
               Begin DoDot:1
 +65               SET TMP=$$VCOMPLT(RAIENS,RACTION,.RAMISC,.RAFDA)
               End DoDot:1
               if TMP<0
                   SET ERRCNT=ERRCNT+1
 +66      ;
 +67      ;=== Error handling and cleanup
 +68      ; Do not modify the activity log directly
           KILL RAFDA(70.07)
 +69       QUIT $SELECT(ERRCNT>0:-11,1:0)
 +70      ;
 +71      ;+++++ VALIDATES 'COMPLETE' PARAMETERS
VCOMPLT(RAIENS,RACTION,RAMISC,RAFDA) ;
 +1        NEW ERRCNT,PNODE,TMP
 +2        SET ERRCNT=0
 +3       ;
 +4       ;=== Error handling and cleanup
 +5        QUIT $SELECT(ERRCNT>0:-11,1:0)
 +6       ;
 +7       ;+++++ VALIDATES 'EXAMINED' PARAMETERS
VEXAMND(RAIENS,RACTION,RAMISC,RAFDA) ;
 +1        NEW ECNT,NAME,PI,PNODE,RAI,RC,TMP
 +2        SET ECNT=0
 +3       ;
 +4       ;=== Contrast media used
 +5        SET RC=$$VALPRM^RAMAGU09("CMUSED",,RAIENS)
 +6        IF RC>0
               Begin DoDot:1
 +7       ;--- Clear the CONTMEDIA list if necessary
 +8                SET TMP=$GET(RAFDA(70.03,RAIENS,10))
 +9                IF TMP'="Y"
                       KILL RAMISC("CONTMEDIA")
                       SET RAMISC("CONTMEDIA")=""
               End DoDot:1
 +10      IF '$TEST
               if RC<0
                   SET ECNT=ECNT+1
 +11      ;
 +12      ;=== Contrast media
 +13       SET NAME="CONTMEDIA"
 +14       SET RC=$$VALPRM^RAMAGU09(NAME)
 +15       IF RC>0
               Begin DoDot:1
 +16               SET RAI=0
 +17               FOR 
                       SET RAI=$ORDER(RAMISC(NAME,RAI))
                       if RAI'>0
                           QUIT 
                       Begin DoDot:2
 +18                       if $$VALPRM^RAMAGU09(NAME,RAI)<0
                               SET ECNT=ECNT+1
                       End DoDot:2
 +19      ;--- Make the value of the CONTRAST MEDIA USED consistent
 +20               SET TMP=$DATA(RAFDA(70.3225))
 +21               if TMP
                       SET RAFDA(70.03,RAIENS,10)=$SELECT(TMP>1:"Y",1:"N")
               End DoDot:1
 +22      IF '$TEST
               if RC<0
                   SET ECNT=ECNT+1
 +23      ;
 +24      ;=== Complication
 +25       SET NAME="COMPLICAT"
 +26       SET RC=$$VALPRM^RAMAGU09(NAME,,RAIENS)
 +27       IF RC>0
               Begin DoDot:1
 +28               SET PNODE=$NAME(RAMISC(NAME))
 +29      ;--- COMPLICATION TEXT
 +30               SET TMP=$PIECE($GET(@PNODE),U,2)
 +31               if $$CHECKFLD^RAMAGU09(PNODE,TMP,70.03,16.5,RAIENS)<0
                       SET ECNT=ECNT+1
               End DoDot:1
 +32      IF '$TEST
               if RC<0
                   SET ECNT=ECNT+1
 +33      ;
 +34      ;=== CPT Modifiers
 +35       SET NAME="CPTMODS"
 +36       SET RC=$$VALPRM^RAMAGU09(NAME)
 +37       IF RC>0
               Begin DoDot:1
 +38               SET RAI=0
 +39               FOR 
                       SET RAI=$ORDER(RAMISC(NAME,RAI))
                       if RAI'>0
                           QUIT 
                       Begin DoDot:2
 +40                       if $$VALPRM^RAMAGU09(NAME,RAI)<0
                               SET ECNT=ECNT+1
                       End DoDot:2
               End DoDot:1
 +41      IF '$TEST
               if RC<0
                   SET ECNT=ECNT+1
 +42      ;
 +43      ;=== Film size
 +44       SET NAME="FILMSIZE"
 +45       SET RC=$$VALPRM^RAMAGU09(NAME)
 +46       IF RC>0
               Begin DoDot:1
 +47               SET RAI=0
 +48               FOR 
                       SET RAI=$ORDER(RAMISC(NAME,RAI))
                       if RAI'>0
                           QUIT 
                       Begin DoDot:2
 +49                       SET PI=$NAME(RAMISC(NAME,RAI))
                           KILL IENS
 +50      ;--- FILM SIZE
 +51                       if $$VALPRM^RAMAGU09(NAME,RAI,.IENS)<0
                               SET ECNT=ECNT+1
 +52      ;--- AMOUNT
 +53                       SET TMP=$PIECE($GET(@PI),U,2)
 +54                       if $$CHECKFLD^RAMAGU09(PI,TMP,70.04,2,IENS)<0
                               SET ECNT=ECNT+1
                       End DoDot:2
               End DoDot:1
 +55      IF '$TEST
               if RC<0
                   SET ECNT=ECNT+1
 +56      ;
 +57      ;=== Primary camera/equipment/room
 +58       if $$VALPRM^RAMAGU09("PRIMCAM",,RAIENS)<0
               SET ECNT=ECNT+1
 +59      ;
 +60      ;=== Technologist
 +61       SET NAME="TECH"
 +62       SET RC=$$VALPRM^RAMAGU09(NAME)
 +63       IF RC>0
               Begin DoDot:1
 +64               SET RAI=0
 +65               FOR 
                       SET RAI=$ORDER(RAMISC(NAME,RAI))
                       if RAI'>0
                           QUIT 
                       Begin DoDot:2
 +66                       if $$VALPRM^RAMAGU09(NAME,RAI)<0
                               SET ECNT=ECNT+1
                       End DoDot:2
               End DoDot:1
 +67      IF '$TEST
               if RC<0
                   SET ECNT=ECNT+1
 +68      ;
 +69      ;=== Primary diagnostic code
 +70       if $$VALPRM^RAMAGU09("PRIMDXCODE",,RAIENS)<0
               SET ECNT=ECNT+1
 +71      ;
 +72      ;=== Secondary diagnostic code(s)
 +73       SET NAME="SECDXCODE"
 +74       SET RC=$$VALPRM^RAMAGU09(NAME)
 +75       IF RC>0
               Begin DoDot:1
 +76               SET RAI=0
 +77               FOR 
                       SET RAI=$ORDER(RAMISC(NAME,RAI))
                       if RAI'>0
                           QUIT 
                       Begin DoDot:2
 +78                       if $$VALPRM^RAMAGU09(NAME,RAI)<0
                               SET ECNT=ECNT+1
                       End DoDot:2
               End DoDot:1
 +79      IF '$TEST
               if RC<0
                   SET ECNT=ECNT+1
 +80      ;
 +81      ;=== Primary interpreting resident and staff
 +82       SET RC=0
 +83       FOR NAME="PRIMINTRES","PRIMINTSTF"
               Begin DoDot:1
 +84      ;--- Check the parameter but does not record errors
 +85               SET TMP=$$VALPRM^RAMAGU09(NAME,,RAIENS,,"C")
 +86      ;--- Handle defined/not defined cases
 +87               IF TMP'<0
                       SET RC=RC+1
                       QUIT 
 +88               IF +TMP=-8
                       SET RC=RC-1
                       QUIT 
 +89      ;--- Otherwise, call again to record the error(s)
 +90               SET TMP=$$VALPRM^RAMAGU09(NAME,,RAIENS)
                   SET ECNT=ECNT+1
 +91      ;--- Prevent the code below from recording additional errors
 +92               SET RC=3
               End DoDot:1
 +93      ;--- If neither of the two parameters is defined but one of
 +94      ;--- them is required, record the error.
 +95       IF RC<0
               Begin DoDot:1
 +96               SET TMP=$NAME(RAMISC("PRIMINTRES"))_", "_$NAME(RAMISC("PRIMINTSTF"))
 +97               DO ERROR^RAERR(-13,TMP)
               End DoDot:1
               SET ECNT=ECNT+1
 +98      ;
 +99      ;=== Error handling and cleanup
 +100      QUIT $SELECT(ECNT>0:-11,1:0)