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

RAMAGU08.m

Go to the documentation of this file.
  1. 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
  1. ;
  1. Q
  1. ;
  1. ;***** VALIDATES RAMISC PARAMETERS RELATED TO THE FILE #70
  1. ;
  1. ; RAIENS IENS of the exam/case (subfile #70.03)
  1. ;
  1. ; RASTIEN IEN of the requested exam status
  1. ;
  1. ; .RACTION Reference to a local variable that indicates the
  1. ; actions (can be combined):
  1. ; E Examined (procedure has been performed)
  1. ; C Complete
  1. ;
  1. ; After exiting the function, this parameter contains
  1. ; only those actions that actually have to be performed
  1. ; in order to reach the requested status. For example,
  1. ; if "EC" is passed and the procedure has already been
  1. ; performed, then "E" will be removed.
  1. ;
  1. ; If this parameter is empty after the call, then the
  1. ; exam already has requested status.
  1. ;
  1. ; .RAMISC Reference to a local array containing miscellaneous
  1. ; request parameters.
  1. ;
  1. ; .RAFDA( Reference to a local array where field values will
  1. ; be prepared for storage (FileMan FDA array).
  1. ;
  1. ; "RACNT") This is an additional node that stores counter for
  1. ; the IENS placeholders. Do not forget to remove this
  1. ; node before passing the array into a FileMan API.
  1. ;
  1. ; "RAIENS") This is an additional node that stores IENS of the
  1. ; record being processed. Do not forget to remove this
  1. ; node before passing the array into a FileMan API.
  1. ;
  1. ; [RAFDACNT] New value for the placeholder counter for the RAFDA.
  1. ; If this parameter is greater than zero, it replaces
  1. ; the value stored in the RAFDA("RACNT").
  1. ;
  1. ; Input variables:
  1. ; RACN, RADTE, RAIMGTYI, RAMSPSDEFS
  1. ;
  1. ; Output variables:
  1. ; RAMSPSDEFS, RAPROCIEN
  1. ;
  1. ; Return values:
  1. ; <0 Error code
  1. ; 0 Ok
  1. ;
  1. VAL70(RAIENS,RASTIEN,RACTION,RAMISC,RAFDA,RAFDACNT) ;
  1. N ERRCNT,EXMST,PNODE,RABUF,RACAT,RAI,RAMSG,RAPROC,RC,TMP
  1. ;
  1. ;=== Check required parameters and variables
  1. S RC=$$CHKREQ^RAUTL22("RACTION,RAIENS") Q:RC<0 RC
  1. S RC=$$CHKREQ^RAUTL22("RACN,RADTE,RAIMGTYI","V")
  1. Q:RC<0 RC
  1. Q:$TR(RACTION,"EC")'="" $$IPVE^RAERR("RACTION")
  1. ;
  1. ;=== Initialize variables
  1. S RAFDA("RAIENS")=RAIENS
  1. S:$G(RAFDACNT)>0 RAFDA("RACNT")=+RAFDACNT
  1. S (ERRCNT,RC)=0
  1. ;
  1. ;=== Data from the EXAMINATIONS multiple
  1. D GETS^DIQ(70.03,RAIENS,"2;3;4","I","RABUF","RAMSG")
  1. Q:$G(DIERR) $$DBS^RAERR("RAMSG",-9,70.03,RAIENS)
  1. ;
  1. ;=== Check the current exam status
  1. S TMP=+$G(RABUF(70.03,RAIENS,3,"I"))
  1. S EXMST=$$EXMSTINF^RAMAGU06(TMP) Q:EXMST<0 EXMST
  1. ;--- Already COMPLETE
  1. I $P(EXMST,U,3)=9 S RACTION="" Q 0
  1. ;--- Already "EXAMINED"
  1. I $P(EXMST,U,3)>1 D Q:RC<0 RC
  1. . S RC=$$GETEXMND^RAMAGU06(+EXMST)
  1. . ;--- Cannot find the "EXAMINED" status
  1. . S:'RC RACTION=$TR(RACTION,"E")
  1. Q:RACTION="" 0
  1. ;
  1. ;=== Detailed/series procedure and modifiers
  1. S PNODE=$NA(RAMISC("RAPROC"))
  1. S RAI=$O(@PNODE@(0))
  1. I RAI>0 S RAPROC=@PNODE@(RAI) D ; Update procedure
  1. . I $O(@PNODE@(RAI))>0 D ERROR^RAERR(-49) S ERRCNT=ERRCNT+1
  1. E S RAPROC=$G(RABUF(70.03,RAIENS,2,"I")) ; Current procedure
  1. ;--- Validate the procedure and modifiers
  1. S TMP=$$CHKPROC^RAMAGU03(RAPROC,RAIMGTYI,RADTE,"DS")
  1. S:TMP<0 ERRCNT=ERRCNT+1
  1. S RAPROCIEN=$S('TMP:+RAPROC,1:"")
  1. ;
  1. ;=== Get the exam status requirements
  1. S TMP=$$EXMSTREQ^RAMAGU06(RASTIEN,RAPROCIEN) Q:TMP<0 TMP
  1. ;--- The "EF" report status means outside work. In this case,
  1. ; cancel requirements for anything except (possibly) the
  1. ;--- diagnostic code. See the HELP1^RASTREQ for more details.
  1. I $G(RAMISC("RPTSTATUS"))'="EF" S RAMSPSDEFS("R")=TMP
  1. E S RAMSPSDEFS("R")="",$P(RAMSPSDEFS("R"),U,5)=$P(TMP,U,5)
  1. ;
  1. ;=== Category of exam
  1. S PNODE=$NA(RAMISC("EXAMCAT"))
  1. I $D(@PNODE)#10 S RACAT=@PNODE D ; Update category
  1. . S:$$CHECKFLD^RAMAGU09(PNODE,RACAT,70.03,4,RAIENS,1)<0 ERRCNT=ERRCNT+1
  1. E S RACAT=$G(RABUF(70.03,RAIENS,4,"I")) ; Current category
  1. ;
  1. ;=== Parameters specific to the exam category
  1. S:$$VALECPRM^RAMAGU09(RACAT)<0 ERRCNT=ERRCNT+1
  1. ;
  1. ;=== Technologist comment
  1. S:$$VALPRM^RAMAGU09("TECHCOMM")<0 ERRCNT=ERRCNT+1
  1. ;
  1. ;=== Validate parameters specific to different exam statuses
  1. I $TR(RACTION,"EC")'=RACTION D S:TMP<0 ERRCNT=ERRCNT+1
  1. . S TMP=$$VEXAMND(RAIENS,RACTION,.RAMISC,.RAFDA)
  1. I RACTION["C" D S:TMP<0 ERRCNT=ERRCNT+1
  1. . S TMP=$$VCOMPLT(RAIENS,RACTION,.RAMISC,.RAFDA)
  1. ;
  1. ;=== Error handling and cleanup
  1. K RAFDA(70.07) ; Do not modify the activity log directly
  1. Q $S(ERRCNT>0:-11,1:0)
  1. ;
  1. ;+++++ VALIDATES 'COMPLETE' PARAMETERS
  1. VCOMPLT(RAIENS,RACTION,RAMISC,RAFDA) ;
  1. N ERRCNT,PNODE,TMP
  1. S ERRCNT=0
  1. ;
  1. ;=== Error handling and cleanup
  1. Q $S(ERRCNT>0:-11,1:0)
  1. ;
  1. ;+++++ VALIDATES 'EXAMINED' PARAMETERS
  1. VEXAMND(RAIENS,RACTION,RAMISC,RAFDA) ;
  1. N ECNT,NAME,PI,PNODE,RAI,RC,TMP
  1. S ECNT=0
  1. ;
  1. ;=== Contrast media used
  1. S RC=$$VALPRM^RAMAGU09("CMUSED",,RAIENS)
  1. I RC>0 D
  1. . ;--- Clear the CONTMEDIA list if necessary
  1. . S TMP=$G(RAFDA(70.03,RAIENS,10))
  1. . I TMP'="Y" K RAMISC("CONTMEDIA") S RAMISC("CONTMEDIA")=""
  1. E S:RC<0 ECNT=ECNT+1
  1. ;
  1. ;=== Contrast media
  1. S NAME="CONTMEDIA"
  1. S RC=$$VALPRM^RAMAGU09(NAME)
  1. I RC>0 D
  1. . S RAI=0
  1. . F S RAI=$O(RAMISC(NAME,RAI)) Q:RAI'>0 D
  1. . . S:$$VALPRM^RAMAGU09(NAME,RAI)<0 ECNT=ECNT+1
  1. . ;--- Make the value of the CONTRAST MEDIA USED consistent
  1. . S TMP=$D(RAFDA(70.3225))
  1. . S:TMP RAFDA(70.03,RAIENS,10)=$S(TMP>1:"Y",1:"N")
  1. E S:RC<0 ECNT=ECNT+1
  1. ;
  1. ;=== Complication
  1. S NAME="COMPLICAT"
  1. S RC=$$VALPRM^RAMAGU09(NAME,,RAIENS)
  1. I RC>0 D
  1. . S PNODE=$NA(RAMISC(NAME))
  1. . ;--- COMPLICATION TEXT
  1. . S TMP=$P($G(@PNODE),U,2)
  1. . S:$$CHECKFLD^RAMAGU09(PNODE,TMP,70.03,16.5,RAIENS)<0 ECNT=ECNT+1
  1. E S:RC<0 ECNT=ECNT+1
  1. ;
  1. ;=== CPT Modifiers
  1. S NAME="CPTMODS"
  1. S RC=$$VALPRM^RAMAGU09(NAME)
  1. I RC>0 D
  1. . S RAI=0
  1. . F S RAI=$O(RAMISC(NAME,RAI)) Q:RAI'>0 D
  1. . . S:$$VALPRM^RAMAGU09(NAME,RAI)<0 ECNT=ECNT+1
  1. E S:RC<0 ECNT=ECNT+1
  1. ;
  1. ;=== Film size
  1. S NAME="FILMSIZE"
  1. S RC=$$VALPRM^RAMAGU09(NAME)
  1. I RC>0 D
  1. . S RAI=0
  1. . F S RAI=$O(RAMISC(NAME,RAI)) Q:RAI'>0 D
  1. . . S PI=$NA(RAMISC(NAME,RAI)) K IENS
  1. . . ;--- FILM SIZE
  1. . . S:$$VALPRM^RAMAGU09(NAME,RAI,.IENS)<0 ECNT=ECNT+1
  1. . . ;--- AMOUNT
  1. . . S TMP=$P($G(@PI),U,2)
  1. . . S:$$CHECKFLD^RAMAGU09(PI,TMP,70.04,2,IENS)<0 ECNT=ECNT+1
  1. E S:RC<0 ECNT=ECNT+1
  1. ;
  1. ;=== Primary camera/equipment/room
  1. S:$$VALPRM^RAMAGU09("PRIMCAM",,RAIENS)<0 ECNT=ECNT+1
  1. ;
  1. ;=== Technologist
  1. S NAME="TECH"
  1. S RC=$$VALPRM^RAMAGU09(NAME)
  1. I RC>0 D
  1. . S RAI=0
  1. . F S RAI=$O(RAMISC(NAME,RAI)) Q:RAI'>0 D
  1. . . S:$$VALPRM^RAMAGU09(NAME,RAI)<0 ECNT=ECNT+1
  1. E S:RC<0 ECNT=ECNT+1
  1. ;
  1. ;=== Primary diagnostic code
  1. S:$$VALPRM^RAMAGU09("PRIMDXCODE",,RAIENS)<0 ECNT=ECNT+1
  1. ;
  1. ;=== Secondary diagnostic code(s)
  1. S NAME="SECDXCODE"
  1. S RC=$$VALPRM^RAMAGU09(NAME)
  1. I RC>0 D
  1. . S RAI=0
  1. . F S RAI=$O(RAMISC(NAME,RAI)) Q:RAI'>0 D
  1. . . S:$$VALPRM^RAMAGU09(NAME,RAI)<0 ECNT=ECNT+1
  1. E S:RC<0 ECNT=ECNT+1
  1. ;
  1. ;=== Primary interpreting resident and staff
  1. S RC=0
  1. F NAME="PRIMINTRES","PRIMINTSTF" D
  1. . ;--- Check the parameter but does not record errors
  1. . S TMP=$$VALPRM^RAMAGU09(NAME,,RAIENS,,"C")
  1. . ;--- Handle defined/not defined cases
  1. . I TMP'<0 S RC=RC+1 Q
  1. . I +TMP=-8 S RC=RC-1 Q
  1. . ;--- Otherwise, call again to record the error(s)
  1. . S TMP=$$VALPRM^RAMAGU09(NAME,,RAIENS),ECNT=ECNT+1
  1. . ;--- Prevent the code below from recording additional errors
  1. . S RC=3
  1. ;--- If neither of the two parameters is defined but one of
  1. ;--- them is required, record the error.
  1. I RC<0 D S ECNT=ECNT+1
  1. . S TMP=$NA(RAMISC("PRIMINTRES"))_", "_$NA(RAMISC("PRIMINTSTF"))
  1. . D ERROR^RAERR(-13,TMP)
  1. ;
  1. ;=== Error handling and cleanup
  1. Q $S(ECNT>0:-11,1:0)