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

RAMAG02.m

Go to the documentation of this file.
  1. RAMAG02 ;HCIOFO/SG - ORDERS/EXAMS API (EXAM REQUEST) ; 4/8/08 3:28pm
  1. ;;5.0;Radiology/Nuclear Medicine;**90**;Mar 16, 1998;Build 20
  1. ;
  1. Q
  1. ;
  1. ;##### ORDERS/REQUESTS AN EXAM
  1. ;
  1. ; .RAPARAMS Reference to the API descriptor
  1. ; (see the ^RA01 routine for details).
  1. ;
  1. ; RADFN Patient IEN (DFN).
  1. ;
  1. ; RAMLC IEN of the imaging location (file #79.1).
  1. ;
  1. ; RAPROC 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. ;
  1. ; RADTE Desired date for the exam (FileMan). If time is
  1. ; provided, it is ignored. The date must be exact.
  1. ;
  1. ; RACAT Exam category: internal value for the CATEGORY
  1. ; OF EXAM field (4) of the RAD/NUC MED ORDERS
  1. ; file (#75.1).
  1. ;
  1. ; REQLOC IEN of the requesting location in the HOSPITAL
  1. ; LOCATION file (#44).
  1. ;
  1. ; For the inpatient exam category, location should
  1. ; be either an operating room or a ward.
  1. ;
  1. ; For the outpatient exam category, location should
  1. ; be either an operating room or a clinic.
  1. ;
  1. ; REQPHYS IEN of the requesting physician in the NEW PERSON
  1. ; file (#200).
  1. ;
  1. ; This user should be active and have the PROVIDER
  1. ; key.
  1. ;
  1. ; RAREASON Reason for study (see the REASON FOR STUDY
  1. ; field (1.1) of the file #75.1).
  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. ; "CLINHIST", Text for the CLINICAL HISTORY FOR EXAM field (400)
  1. ; Seq#) of the file #75.1.
  1. ; Required: No
  1. ; Default: undefined
  1. ;
  1. ; "ISOLPROC") Internal value for the ISOLATION PROCEDURES
  1. ; field (24) of the file #75.1.
  1. ; Required: Yes
  1. ; Default: "n" (NO)
  1. ;
  1. ; "PREGNANT") Internal value for the PREGNANT field (13)
  1. ; of the file #75.1.
  1. ; Required: Only for female patients
  1. ; Default: undefined for male patients,
  1. ; "u" for female patients.
  1. ;
  1. ; "PREOPDT") Internal date value (FileMan) for the PRE-OP
  1. ; SCHEDULED DATE/TIME field (12) of the file #75.1.
  1. ; If seconds are provided, they are ignored. The
  1. ; date must be exact.
  1. ; Required: No
  1. ; Default: undefined
  1. ;
  1. ; "REQNATURE") Internal value for the NATURE OF (NEW) ORDER
  1. ; ACTIVITY field (26) of the file #75.1.
  1. ; Required: Yes
  1. ; Default: "s" (SERVICE CORRECTION)
  1. ;
  1. ; "REQURG") Internal value for the REQUEST URGENCY field (6)
  1. ; of the file #75.1.
  1. ; Required: Yes
  1. ; Default: "9" (ROUTINE)
  1. ;
  1. ; "TRANSPMODE") Internal value for the MODE OF TRANSPORT
  1. ; field (19) of the file #75.1.
  1. ; Required: Yes
  1. ; Default: "w" (WHEEL CHAIR) if RACAT="I",
  1. ; "a" (AMBULATORY) otherwise
  1. ;
  1. ; Return values:
  1. ; <0 Error descriptor (see $$ERROR^RAERR)
  1. ; >0 IEN of the order in the file #75.1
  1. ;
  1. ORDER(RAPARAMS,RADFN,RAMLC,RAPROC,RADTE,RACAT,REQLOC,REQPHYS,RAREASON,RAMISC) ;
  1. N RAIMGTYI ; Imaging type IEN (file #79.2)
  1. N RAMDIV ; Radiology division IEN (file #79)
  1. ;
  1. N RAOIFN,RC,VA,VADM
  1. D:$G(RAPARAMS("DEBUG"))>1
  1. . D W^RAMAGU11("$$ORDER^RAMAG02","!!")
  1. . D VARS^RAMAGU11("RADFN,RAMLC,RAPROC")
  1. . D VARS^RAMAGU11("RADTE,RACAT,REQLOC,REQPHYS")
  1. . D VARS^RAMAGU11("RAREASON")
  1. . D ZW^RAUTL22("RAMISC")
  1. ;--- Validate parameters
  1. S RC=$$VALIDATE^RAMAG02A() Q:RC<0 RC
  1. ;
  1. ;--- Make sure that the patient is registered
  1. S RC=$$RAPTREG^RAMAGU04(RADFN) Q:RC<0 RC
  1. ;
  1. ;--- Request the exam
  1. S RAOIFN=$$ORD^RAMAG02A() Q:RAOIFN<0 RAOIFN
  1. ;
  1. ;--- Generate the HL7 message to create the OE/RR record
  1. D ZOERRHL7(RADFN,+RAPROC,RAOIFN,+REQLOC)
  1. ;
  1. ;--- Return IEN of the order
  1. Q RAOIFN
  1. ;
  1. ;+++++ GENERATES OE/RR HL7 MESSAGE
  1. ;
  1. ; RADFN Patient IEN (DFN)
  1. ; RAPIFN Radiology procedure IEN
  1. ; RAOIFN IEN of the order in file #75.1
  1. ; RALIFN Requesting location IEN in file #44
  1. ;
  1. ; NOTE: This is an internal procedure. Do not call it from
  1. ; outside of this routine.
  1. ;
  1. ZOERRHL7(RADFN,RAPIFN,RAOIFN,RALIFN) ;
  1. N DA,DE,DIC,DIDEL,DIE,DINUM,DLAYGO,DQ,DR,DTOUT,DUOUT,I,ORIFN,ORIT,ORL,ORPCL,ORPK,ORPURG,ORSTRT,ORSTS,ORTX,ORVP,RABLNK,RAMOD,RAORD0,RAPRCD,RASEX,X,Y
  1. ;--- Prepare "old style" parameters for an old
  1. ;--- version of the OE/RR (just in case)
  1. S RASEX=$P($G(VADM(5)),U) ; Patient's sex ("F" or "M")
  1. S RAORD0=^RAO(75.1,RAOIFN,0) ; 0-node of the order
  1. ;--- Generate the HL7 message to create the OE/RR record
  1. D SETORD^RAORDU
  1. Q