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

RAMAGHL.m

Go to the documentation of this file.
  1. RAMAGHL ;HCIOFO/SG - ORDERS/EXAMS API (HL7 UTILITIES) ; 2/25/09 3:30pm
  1. ;;5.0;Radiology/Nuclear Medicine;**90**;Mar 16, 1998;Build 20
  1. ;
  1. ; This routine uses the following IAs:
  1. ;
  1. ; #872 Access to the file #101 (controlled)
  1. ;
  1. Q
  1. ;
  1. ;***** RETURNS THE LIST OF ACTIVE HL7 APPLICATIONS
  1. ;
  1. ; .APPLST Reference to a local variable where the list
  1. ; of active HL7 applications associated with the
  1. ; RA REG*, RA EXAMINED*, RA CANCEL*, and RA RPT*
  1. ; HL7 protocols (as receiving applications) will
  1. ; be returned to.
  1. ; APPLST(
  1. ; HL7AppIEN) HL7 application name
  1. ;
  1. ; Return values:
  1. ; <0 Error descriptor (see $$ERROR^RAERR)
  1. ; 0 Ok
  1. ;
  1. APPLST(APPLST) ;
  1. N IEN,NAME,PART,PIEN,PL,RAMSG,ROOT,SUBSLST
  1. K APPLST
  1. ;--- Build the list of subscriber IENs
  1. S ROOT=$$ROOT^DILFD(101,,1)
  1. F PART="RA REG","RA EXAMINED","RA CANCEL","RA RPT" D
  1. . S NAME=$O(@ROOT@("B",PART),-1),PL=$L(PART)
  1. . F S NAME=$O(@ROOT@("B",NAME)) Q:$E(NAME,1,PL)'=PART D
  1. . . S PIEN=0
  1. . . F S PIEN=$O(@ROOT@("B",NAME,PIEN)) Q:PIEN'>0 D
  1. . . . S IEN=0
  1. . . . F S IEN=$O(@ROOT@(PIEN,775,IEN)) Q:IEN'>0 D
  1. . . . . S SUBSLST(+@ROOT@(PIEN,775,IEN,0))=""
  1. ;--- Build the list of receiving application IENs
  1. S PIEN=0
  1. F S PIEN=$O(SUBSLST(PIEN)) Q:PIEN'>0 D
  1. . S IEN=+$$GET1^DIQ(101,PIEN_",",770.2,"I",,"RAMSG")
  1. . S:IEN>0 APPLST(IEN)=""
  1. ;--- Check if the applications are active and get their names
  1. S IEN=0
  1. F S IEN=$O(APPLST(IEN)) Q:IEN'>0 D
  1. . I $P($$GETAPP^HLCS2(IEN),U,2)="i" K APPLST(IEN) Q
  1. . S APPLST(IEN)=$$GET1^DIQ(771,IEN_",",.01,,,"RAMSG")
  1. ;---
  1. Q 0
  1. ;
  1. ;***** SENDS "EXAMINED" HL7 MESSAGES (ORM)
  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. ; [RAFLAGS] Flags that control the execution (can be combined):
  1. ;
  1. ; S Do not send the message to speech recognition
  1. ; (dictation) systems
  1. ;
  1. ; Return values:
  1. ; <0 Error descriptor (see $$ERROR^RAERR)
  1. ; 0 Ok
  1. ;
  1. EXAMINED(RACASE,RAFLAGS) ;
  1. N RACNI,RADFN,RADTI,RAEXEDT,RASSS,RASSSX,RC,TMP
  1. S RADFN=$P(RACASE,U),RADTI=$P(RACASE,U,2),RACNI=$P(RACASE,U,3)
  1. S RAFLAGS=$G(RAFLAGS)
  1. ;
  1. ;--- Exclude speech recognition (dictation) systems if necessary
  1. I RAFLAGS["S" S RC=$$SPRSUBS(.RASSSX) Q:RC $S(RC<0:RC,1:0)
  1. ;
  1. ;--- Generate and send the message
  1. S RAEXEDT=1 D EXM^RAHLRPC
  1. Q 0
  1. ;
  1. ;***** SENDS "REPORT" HL7 MESSAGES (ORU)
  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. ; [RAFLAGS] Flags that control the execution (can be combined):
  1. ;
  1. ; S Do not send the message to speech recognition
  1. ; (dictation) systems
  1. ;
  1. ; Return values:
  1. ; <0 Error descriptor (see $$ERROR^RAERR)
  1. ; 0 Ok
  1. ;
  1. REPORT(RACASE,RAFLAGS) ;
  1. N RACNI,RADFN,RADTI,RAMSG,RASSS,RASSSX,RC,RPTIEN,TMP
  1. S RADFN=$P(RACASE,U),RADTI=$P(RACASE,U,2),RACNI=$P(RACASE,U,3)
  1. S RAFLAGS=$G(RAFLAGS)
  1. ;
  1. ;--- Get the report IEN
  1. S TMP=$$EXAMIENS^RAMAGU04(RACASE)
  1. S RPTIEN=$$GET1^DIQ(70.03,TMP,17,"I",,"RAMSG")
  1. Q:$G(DIERR) $$DBS^RAERR("RAMSG",-9,70.03,TMP)
  1. Q:RPTIEN'>0 0 ; No report yet
  1. ;
  1. ;--- Send messages only for verified or released reports
  1. S TMP=$$RPTSTAT^RAMAGU12(RPTIEN) Q:TMP<0 TMP
  1. S TMP=$P(TMP,U) Q:(TMP'="V")&(TMP'="R")&(TMP'="EF") 0
  1. ;
  1. ;--- Exclude speech recognition (dictation) systems if necessary
  1. I RAFLAGS["S" S RC=$$SPRSUBS(.RASSSX) Q:RC $S(RC<0:RC,1:0)
  1. ;
  1. ;--- Generate and send the message
  1. D RPT^RAHLRPC
  1. Q 0
  1. ;
  1. ;***** COMPILES A LIST OF SPEACH RECOGNITION SUBSCRIBERS
  1. ;
  1. ; .RASSSX Reference to a local array where the list of
  1. ; speech recognition subscribers is returned to:
  1. ;
  1. ; RASSSX(EvtDrvrIEN,SubscriberIEN) = EvtDrvrName
  1. ;
  1. ; EvtDrvrIEN and SubscriberIEN are record numbers
  1. ; in the PROTOCOL file (#101).
  1. ;
  1. ; [.RASSS] Reference to a local array where the list of
  1. ; related HL7 applications is returned to:
  1. ;
  1. ; RASSS(HL7AppIEN) = ""
  1. ;
  1. ; HL7AppIEN is a record number in the HL7
  1. ; APPLICATION PARAMETER file (#771).
  1. ;
  1. ; Return values:
  1. ; <0 Error descriptor (see $$ERROR^RAERR)
  1. ; 0 Ok
  1. ; >0 Nowhere to send
  1. ;
  1. SPRSUBS(RASSSX,RASSS) ;
  1. N APPLST,IEN,RABUF,RAMSG,RC
  1. K RASSS,RASSSX
  1. S RC=$$APPLST(.APPLST) Q:RC<0 RC
  1. ;--- Select only those HL7 applications that do not have
  1. ; 'S:Speech Recognition' in the APPLICATION TYPE field of
  1. ;--- the RAD/NUC MED HL7 APPLICATION EXCEPTION file (#79.7).
  1. S IEN=0
  1. F S IEN=$O(APPLST(IEN)) Q:IEN'>0 D
  1. . I $D(^RA(79.7,IEN,0)) D Q:RC="S"
  1. . . S RC=$$GET1^DIQ(79.7,IEN_",",1.3,"I",,"RAMSG")
  1. . S RASSS(IEN)=""
  1. ;--- Quit if all recipients should be skipped
  1. Q:$D(RASSS)<10 1
  1. ;--- Build the list of excluded subscriber protocols
  1. D GETSUB^RAHLRS1(.RASSS,.RASSSX)
  1. Q 0