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

RAMAGU06.m

Go to the documentation of this file.
  1. RAMAGU06 ;HCIOFO/SG - ORDERS/EXAMS API (EXAM STATUS UTILS) ; 2/6/09 11:21am
  1. ;;5.0;Radiology/Nuclear Medicine;**90**;Mar 16, 1998;Build 20
  1. ;
  1. ; Exam Status Descriptor
  1. ; ----------------------
  1. ;
  1. ; ^01: IEN of the status record in the EXAMINATION STATUS
  1. ; file (#72).
  1. ;
  1. ; ^02: Status name (value of the NAME field (.01)
  1. ; of the file #72.
  1. ;
  1. ; ^03: Status code. Currently, the value of the ORDER field (3)
  1. ; of the file #72 is used. As the result, only 0 (cancelled),
  1. ; 1 (waiting for exam), and 9 (completed) codes are the same
  1. ; at all sites and all imaging types. All others are site
  1. ; and/or imaging type specific.
  1. ;
  1. ; ^04: VistARAD category (field 9 of the file #72).
  1. ;
  1. ; ^05: Generic exam status characteristics (can be combined):
  1. ; E 'Examined' HL7 message is generated
  1. ; R Report is required
  1. ;
  1. ; These flags have the same meaning at all sites for all
  1. ; imaging types.
  1. ;
  1. Q
  1. ;
  1. ;***** RETURNS A DESCRIPTOR OF THE EXAM STATUS
  1. ;
  1. ; STATUS IEN of the status record in the EXAMINATION STATUS
  1. ; file (#72) or the status order number in the 3rd.
  1. ; ^-piece.
  1. ;
  1. ; First, the function checks the 1st ^-piece. If it
  1. ; is greater than 0, then it is used as IEN of the
  1. ; status.
  1. ;
  1. ; Otherwise, the third piece is checked for a status
  1. ; order number (value of the ORDER field (3) of the
  1. ; EXAMINATION STATUS file (#72)). The RAIMGTYI
  1. ; parameter must reference a valid imaging type in
  1. ; this case.
  1. ;
  1. ; Only 0 (cancelled), 1 (waiting for exam), and 9
  1. ; (completed) order numbers are the same at all sites
  1. ; and all imaging types. All others are site and/or
  1. ; imaging type specific.
  1. ;
  1. ; [RAIMGTYI] Imaging type IEN (file #79.2). This parameter is
  1. ; required if a status is referenced by the order
  1. ; number (see above).
  1. ;
  1. ; Return Values:
  1. ; <0 Error descriptor (see $$ERROR^RAERR)
  1. ; >0 Exam status descriptor (see the comment in
  1. ; the beginning of this routine)
  1. ;
  1. EXMSTINF(STATUS,RAIMGTYI) ;
  1. N IENS,RABUF,RAMSG,RC,TMP
  1. S RC=0
  1. ;
  1. ;=== Search for status record
  1. I STATUS'>0 D Q:RC<0 RC
  1. . N IEN72,RAIMGTY,RANODE
  1. . I $P(STATUS,U,3)'?1.N S RC=$$IPVE^RAERR("STATUS") Q
  1. . I $G(RAIMGTYI)'>0 S RC=$$IPVE^RAERR("RAIMGTYI") Q
  1. . ;--- Get the imaging type name
  1. . S IENS=+RAIMGTYI_","
  1. . S RAIMGTY=$$GET1^DIQ(79.2,IENS,.01,,,"RAMSG")
  1. . I $G(DIERR) S RC=$$DBS^RAERR("RAMSG",-9,70.02,IENS) Q
  1. . I RAIMGTY="" S RC=$$ERROR^RAERR(-19,,70.02,IENS,2) Q
  1. . ;--- Search for status record by status order number
  1. . S RANODE=$NA(^RA(72,"AA",RAIMGTY,+$P(STATUS,U,3)))
  1. . S IEN72=+$O(@RANODE@(""))
  1. . I IEN72'>0 S RC=$$IPVE^RAERR("STATUS") Q
  1. . ;--- Check if there is another status with the same order number
  1. . I $O(@RANODE@(IEN72))>0 D Q
  1. . . S RC=$$ERROR^RAERR(-14,,"status order number",STATUS)
  1. . S STATUS=IEN72
  1. ;
  1. ;=== Load status properties
  1. S IENS=+STATUS_","
  1. D GETS^DIQ(72,IENS,".01;.111;3;8;9","I","RABUF","RAMSG")
  1. Q:$G(DIERR) $$DBS^RAERR("RAMSG",-9,72,IENS)
  1. ;
  1. ;=== Build basic descriptor
  1. S $P(STATUS,U,2)=$G(RABUF(72,IENS,.01,"I")) ; STATUS
  1. S $P(STATUS,U,3)=$G(RABUF(72,IENS,3,"I")) ; ORDER
  1. S $P(STATUS,U,4)=$G(RABUF(72,IENS,9,"I")) ; VISTARAD CATEGORY
  1. ;
  1. ;=== Add generic characteristics
  1. S TMP=""
  1. ;--- REPORT ENTERED REQUIRED?
  1. S:$G(RABUF(72,IENS,.111,"I"))="Y" TMP=TMP_"R"
  1. ;--- GENERATE EXAMINED HL7 MESSAGE
  1. S:$G(RABUF(72,IENS,8,"I"))="Y" TMP=TMP_"E"
  1. S $P(STATUS,U,5)=TMP
  1. ;
  1. ;===
  1. Q STATUS
  1. ;
  1. ;***** RETURNS REQUIREMENTS FOR THE EXAM STATUS
  1. ;
  1. ; EXMSTIEN IEN of the current status (IEN in the file #72)
  1. ;
  1. ; [RAPROCIEN] Radiology procedure IEN (file #71). This parameter
  1. ; is required to determine exact nuclear medicine
  1. ; requirements (result pieces from 17 to 25).
  1. ;
  1. ; By default (+$G(RAPROCIEN)=0), this function cannot
  1. ; examine the SUPPRESS RADIOPHARM PROMPT field (2) of
  1. ; the RAD/NUC MED PROCEDURES file (#71) and might
  1. ; indicate that some nuclear medicine data is required
  1. ; even if it is not.
  1. ;
  1. ; Return Values:
  1. ; <0 Error descriptor (see $$ERROR^RAERR)
  1. ; ... Status requirements descriptor
  1. ; ^01: TECHNOLOGIST REQUIRED? {0|1}
  1. ; ^02: RESIDENT OR STAFF REQUIRED? {0|1}
  1. ; ^03: DETAILED PROCEDURE REQUIRED? {0|1}
  1. ; ^04: FILM ENTRY REQUIRED? {0|1}
  1. ; ^05: DIAGNOSTIC CODE REQUIRED? {0|1}
  1. ; ^06: CAMERA/EQUIP/RM REQUIRED? {0|1}
  1. ; ^07: reserved
  1. ; ^08: reserved
  1. ; ^09: reserved
  1. ; ^10: reserved
  1. ; ^11: REPORT ENTERED REQUIRED? {0|1}
  1. ; ^12: VERIFIED REPORT REQUIRED? {0|1}
  1. ; ^13: PROCEDURE MODIFIERS REQUIRED? {0|1}
  1. ; ^14: CPT MODIFIERS REQUIRED? {0|1}
  1. ; ^15: reserved
  1. ; ^16: IMPRESSION REQUIRED? {0|1}
  1. ; ^17: RADIOPHARMS/DOSAGES REQUIRED? {0|1}
  1. ; ^18: reserved
  1. ; ^19: ACTIVITY DRAWN REQUIRED? {0|1}
  1. ; ^20: DRAWN DT/TIME/PERSON REQUIRED? {0|1}
  1. ; ^21: ADM DT/TIME/PERSON REQUIRED? {0|1}
  1. ; ^22: reserved
  1. ; ^23: ROUTE/SITE REQUIRED? {0|1}
  1. ; ^24: LOT NO. REQUIRED? {0|1}
  1. ; ^25: VOLUME/FORM REQUIRED? {0|1}
  1. ;
  1. EXMSTREQ(EXMSTIEN,RAPROCIEN) ;
  1. Q:$D(^RA(72,+EXMSTIEN))<10 $$IPVE^RAERR("EXMSTIEN")
  1. Q:$G(RAPROCIEN)<0 $$IPVE^RAERR("RAPROCIEN")
  1. N BUF,I,IENS,RABUF,RAIMGTYI,RAMSG,RC,RESULT,TMP
  1. S RESULT="",RC=0
  1. ;
  1. ;=== General requirements
  1. S BUF=$G(^RA(72,+EXMSTIEN,.1))
  1. F I=1:1:6,11:1:14,16 S $P(RESULT,U,I)=($P(BUF,U,I)="Y")
  1. ;
  1. ;=== Nuclear Medicine requirements
  1. S BUF=$G(^RA(72,+EXMSTIEN,.5))
  1. ;--- If the exam status does not indicate that radiopharmaceuticals
  1. ; are required, then there is no need for any further checks.
  1. ;--- See the EN1^RASTREQN procedure for more details.
  1. I $P(BUF,U)="Y" D Q:RC<0 RC
  1. . ;--- Get the imaging type IEN from the exam status
  1. . S IENS=+EXMSTIEN_","
  1. . S RAIMGTYI=+$$GET1^DIQ(72,IENS,7,"I",,"RAMSG")
  1. . I $G(DIERR) S RC=$$DBS^RAERR("RAMSG",-9,72,IENS) Q
  1. . ;--- If the RADIOPHARMACEUTICALS USED? of the imaging type
  1. . ;--- is not set to Yes, then requirements are voided.
  1. . S IENS=RAIMGTYI_","
  1. . S TMP=$$GET1^DIQ(79.2,IENS,5,"I",,"RAMSG")
  1. . I $G(DIERR) S RC=$$DBS^RAERR("RAMSG",-9,79.2,IENS) Q
  1. . I TMP'="Y" S BUF="" Q
  1. . ;--- If a procedure is passed and its SUPPRESS RADIOPHARM PROMPT
  1. . ; field (2) in the RAD/NUC MED PROCEDURES file (#71) stores 1,
  1. . ;--- then the radiopharmaceutical requirements are voided.
  1. . I $G(RAPROCIEN)>0 D Q:RC<0
  1. . . S IENS=+RAPROCIEN_","
  1. . . D GETS^DIQ(71,IENS,"2;12","I","RABUF","RAMSG")
  1. . . I $G(DIERR) S RC=$$DBS^RAERR("RAMSG",-9,71,IENS) Q
  1. . . I +$G(RABUF(71,IENS,12,"I"))'=RAIMGTYI D Q
  1. . . . S RC=$$ERROR^RAERR(-55)
  1. . . S:$G(RABUF(71,IENS,2,"I")) BUF=""
  1. E S BUF=""
  1. F I=1,3,4,5,7,8,9 S $P(RESULT,U,16+I)=($P(BUF,U,I)="Y")
  1. ;
  1. ;===
  1. Q RESULT
  1. ;
  1. ;***** RETURNS THE STATUS THAT SHOULD BE USED AS "EXAMINED"
  1. ;
  1. ; EXMSTIEN IEN of the current status (IEN in the file #72)
  1. ;
  1. ; Return Values:
  1. ; <0 Error descriptor (see $$ERROR^RAERR)
  1. ; "" Requested exam status cannot be found. The current
  1. ; status is already at or past "EXAMINED".
  1. ; >0 Exam status descriptor (see the routine comment above)
  1. ;
  1. ; This function searches for a status that follows the one defined
  1. ; by the EXMSTIEN parameter and has "E" (Examined) in the VISTARAD
  1. ; CATEGORY field (9).
  1. ;
  1. GETEXMND(EXMSTIEN) ;
  1. Q $$NXTEXMST(+EXMSTIEN,"E")
  1. ;
  1. ;***** RETURNS THE NEXT EXAM STATUS
  1. ;
  1. ; EXMSTIEN IEN of the status record in the EXAMINATION STATUS
  1. ; file (#72).
  1. ;
  1. ; [VISTARADCAT] Internal value of the required VistA RAD category.
  1. ;
  1. ; Return Values:
  1. ; <0 Error descriptor (see $$ERROR^RAERR)
  1. ; "" Requested exam status cannot be found after the status
  1. ; referenced by the EXMSTIEN.
  1. ; >0 Exam status descriptor (see the routine comment above)
  1. ;
  1. NXTEXMST(EXMSTIEN,VISTARADCAT) ;
  1. N IEN72,IENS,ORDER,ORDI,RABUF,RAIMGTY,RAMSG,RC,TMP,X,XREF
  1. Q:$G(EXMSTIEN)'>0 $$IPVE^RAERR("EXMSTIEN")
  1. S RC=0
  1. ;=== Get the order number and type of imaging
  1. S IENS=+EXMSTIEN_","
  1. D GETS^DIQ(72,IENS,"3;7",,"RABUF","RAMSG")
  1. Q:$G(DIERR) $$DBS^RAERR("RAMSG",-9,72,IENS)
  1. S ORDER=+$G(RABUF(72,IENS,3))
  1. S RAIMGTY=$G(RABUF(72,IENS,7))
  1. K RABUF
  1. ;=== Search for the next status
  1. S XREF=$NA(^RA(72,"AA",RAIMGTY))
  1. I $G(VISTARADCAT)'="" D
  1. . S ORDI=""
  1. . F S ORDI=$O(@XREF@(ORDI)) Q:ORDI="" D Q:RC
  1. . . S IEN72=""
  1. . . F S IEN72=$O(@XREF@(ORDI,IEN72)) Q:IEN72="" D Q:RC
  1. . . . S TMP=$$GET1^DIQ(72,IEN72_",",9,"I",,"RAMSG")
  1. . . . I $G(DIERR) S RC=$$DBS^RAERR("RAMSG",-9,72,IEN72_",") Q
  1. . . . S:TMP=VISTARADCAT RC=$$EXMSTINF(IEN72)
  1. . ;--- If nothing has been found, then "E:Examined" category has
  1. . ;--- not been assigned to a record of this imaging type yet.
  1. . I 'RC S RC=$$ERROR^RAERR(-59,,VISTARADCAT,RAIMGTY) Q
  1. . ;--- Check if the new status follows the source one
  1. . S:$P(RC,U,3)'>ORDER RC=""
  1. E D
  1. . S ORDI=$O(@XREF@(ORDER)) Q:ORDI=""
  1. . S IEN72=$O(@XREF@(ORDI,"")) Q:IEN72=""
  1. . S RC=$$EXMSTINF(IEN72)
  1. ;===
  1. Q RC