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

VAFCMSG0.m

Go to the documentation of this file.
  1. VAFCMSG0 ;ALB/JRP-ADT/R MESSAGE BUILDING ;12-SEP-1996
  1. ;;5.3;Registration;**91,149**;Jun 06, 1996
  1. ;
  1. BCSTADT(DFN,EVNTHL7,EVNTDATE,EVNTINFO) ;Entry point for transmitting HL7 ADT
  1. ; messages for a given patient
  1. ;
  1. ;Input : DFN - Pointer to entry in PATIENT file (#2) to build
  1. ; message for
  1. ; EVNTHL7 - HL7 ADT event to build message for (Defaults to A08)
  1. ; Currently supported event type:
  1. ; A04, A08, A28
  1. ; EVNTDATE - Date/time event occurred in FileMan format
  1. ; - Defaults to current date/time (NOW)
  1. ; EVNTINFO - Array containing further event information needed
  1. ; when building HL7 segments/message. Use and
  1. ; subscripting of array is determined by segment
  1. ; and/or message being built.
  1. ; - Defaults to ^TMP("VAFCMSG",$J,"EVNTINFO")
  1. ; Current subscripts include:
  1. ; EVNTINFO("PIVOT") = Pointer to ADT/HL7 PIVOT
  1. ; file (#391.71)
  1. ; EVNTINFO("REASON",X) = Event reason codes
  1. ; EVNTINFO("USER") = User associated with the event
  1. ;Output : Message ID = ADT-Axx message built and transmitted
  1. ; ErrorCode^ErrorText = Error generating ADT-Axx message
  1. ;Notes : The global array ^TMP("HLS",$J) will be initialized (KILLed)
  1. ; : The following information will be placed into and killed
  1. ; from the event information array:
  1. ; EVNTINFO("DFN") = Pointer to PATIENT file (#2)
  1. ; EVNTINFO("EVENT") = Event type
  1. ; EVNTINFO("DATE") = Event date/time
  1. ;
  1. ;Check input
  1. S DFN=+$G(DFN)
  1. Q:('$D(^DPT(DFN,0))) "-1^Could not find entry in PATIENT file"
  1. S EVNTHL7=$G(EVNTHL7)
  1. S:(EVNTHL7="") EVNTHL7="A08"
  1. S EVNTDATE=+$G(EVNTDATE)
  1. S:('EVNTDATE) EVNTDATE=$$NOW^VAFCMSG5()
  1. S EVNTINFO=$G(EVNTINFO)
  1. S:(EVNTINFO="") EVNTINFO="^TMP(""VAFCMSG"","_$J_",""EVNTINFO"")"
  1. ;Declare variables
  1. N TMP,GLOREF,OK,RETURN
  1. ;Initialize global location for building HL7 messages
  1. S GLOREF="^TMP(""HLS"","_$J_")"
  1. K @GLOREF
  1. ;Check for supported event
  1. S OK=0
  1. F TMP="A04","A08","A28" I TMP=EVNTHL7 S OK=1 Q
  1. Q:('OK) "-1^Event type not supported"
  1. ;Put patient, event type, and event date/time into info array
  1. S @EVNTINFO@("DFN")=DFN
  1. S @EVNTINFO@("EVENT")=EVNTHL7
  1. S @EVNTINFO@("DATE")=EVNTDATE
  1. ;Build ADT-Axx message
  1. S RETURN=$$BLDMSG^VAFCMSG1(DFN,EVNTHL7,EVNTDATE,EVNTINFO,GLOREF,1)
  1. ;Error
  1. I (RETURN<0) D Q RETURN
  1. .K @GLOREF,@EVNTINFO@("DFN"),@EVNTINFO@("EVENT"),@EVNTINFO@("DATE")
  1. ;Broadcast ADT-Axx message
  1. S RETURN=$$SNDMSG^VAFCMSG2(EVNTHL7)
  1. ;If message id returned, stuff in pivot file
  1. I +RETURN>0 D MESSAGE^VAFCDD01(@EVNTINFO@("PIVOT"),+RETURN)
  1. ;Error
  1. I (RETURN<0) D Q RETURN
  1. .K @GLOREF,@EVNTINFO@("DFN"),@EVNTINFO@("EVENT"),@EVNTINFO@("DATE")
  1. ;Done - Clean up and return output of $$SNDMSG()
  1. K @GLOREF,@EVNTINFO@("DFN"),@EVNTINFO@("EVENT"),@EVNTINFO@("DATE")
  1. Q RETURN