- VAFCMSG0 ;ALB/JRP-ADT/R MESSAGE BUILDING ;12-SEP-1996
- ;;5.3;Registration;**91,149**;Jun 06, 1996
- ;
- BCSTADT(DFN,EVNTHL7,EVNTDATE,EVNTINFO) ;Entry point for transmitting HL7 ADT
- ; messages for a given patient
- ;
- ;Input : DFN - Pointer to entry in PATIENT file (#2) to build
- ; message for
- ; EVNTHL7 - HL7 ADT event to build message for (Defaults to A08)
- ; Currently supported event type:
- ; A04, A08, A28
- ; EVNTDATE - Date/time event occurred in FileMan format
- ; - Defaults to current date/time (NOW)
- ; EVNTINFO - Array containing further event information needed
- ; when building HL7 segments/message. Use and
- ; subscripting of array is determined by segment
- ; and/or message being built.
- ; - Defaults to ^TMP("VAFCMSG",$J,"EVNTINFO")
- ; Current subscripts include:
- ; EVNTINFO("PIVOT") = Pointer to ADT/HL7 PIVOT
- ; file (#391.71)
- ; EVNTINFO("REASON",X) = Event reason codes
- ; EVNTINFO("USER") = User associated with the event
- ;Output : Message ID = ADT-Axx message built and transmitted
- ; ErrorCode^ErrorText = Error generating ADT-Axx message
- ;Notes : The global array ^TMP("HLS",$J) will be initialized (KILLed)
- ; : The following information will be placed into and killed
- ; from the event information array:
- ; EVNTINFO("DFN") = Pointer to PATIENT file (#2)
- ; EVNTINFO("EVENT") = Event type
- ; EVNTINFO("DATE") = Event date/time
- ;
- ;Check input
- S DFN=+$G(DFN)
- Q:('$D(^DPT(DFN,0))) "-1^Could not find entry in PATIENT file"
- S EVNTHL7=$G(EVNTHL7)
- S:(EVNTHL7="") EVNTHL7="A08"
- S EVNTDATE=+$G(EVNTDATE)
- S:('EVNTDATE) EVNTDATE=$$NOW^VAFCMSG5()
- S EVNTINFO=$G(EVNTINFO)
- S:(EVNTINFO="") EVNTINFO="^TMP(""VAFCMSG"","_$J_",""EVNTINFO"")"
- ;Declare variables
- N TMP,GLOREF,OK,RETURN
- ;Initialize global location for building HL7 messages
- S GLOREF="^TMP(""HLS"","_$J_")"
- K @GLOREF
- ;Check for supported event
- S OK=0
- F TMP="A04","A08","A28" I TMP=EVNTHL7 S OK=1 Q
- Q:('OK) "-1^Event type not supported"
- ;Put patient, event type, and event date/time into info array
- S @EVNTINFO@("DFN")=DFN
- S @EVNTINFO@("EVENT")=EVNTHL7
- S @EVNTINFO@("DATE")=EVNTDATE
- ;Build ADT-Axx message
- S RETURN=$$BLDMSG^VAFCMSG1(DFN,EVNTHL7,EVNTDATE,EVNTINFO,GLOREF,1)
- ;Error
- I (RETURN<0) D Q RETURN
- .K @GLOREF,@EVNTINFO@("DFN"),@EVNTINFO@("EVENT"),@EVNTINFO@("DATE")
- ;Broadcast ADT-Axx message
- S RETURN=$$SNDMSG^VAFCMSG2(EVNTHL7)
- ;If message id returned, stuff in pivot file
- I +RETURN>0 D MESSAGE^VAFCDD01(@EVNTINFO@("PIVOT"),+RETURN)
- ;Error
- I (RETURN<0) D Q RETURN
- .K @GLOREF,@EVNTINFO@("DFN"),@EVNTINFO@("EVENT"),@EVNTINFO@("DATE")
- ;Done - Clean up and return output of $$SNDMSG()
- K @GLOREF,@EVNTINFO@("DFN"),@EVNTINFO@("EVENT"),@EVNTINFO@("DATE")
- Q RETURN
- --- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HVAFCMSG0 3089 printed Mar 13, 2025@22:06:41 Page 2
- VAFCMSG0 ;ALB/JRP-ADT/R MESSAGE BUILDING ;12-SEP-1996
- +1 ;;5.3;Registration;**91,149**;Jun 06, 1996
- +2 ;
- BCSTADT(DFN,EVNTHL7,EVNTDATE,EVNTINFO) ;Entry point for transmitting HL7 ADT
- +1 ; messages for a given patient
- +2 ;
- +3 ;Input : DFN - Pointer to entry in PATIENT file (#2) to build
- +4 ; message for
- +5 ; EVNTHL7 - HL7 ADT event to build message for (Defaults to A08)
- +6 ; Currently supported event type:
- +7 ; A04, A08, A28
- +8 ; EVNTDATE - Date/time event occurred in FileMan format
- +9 ; - Defaults to current date/time (NOW)
- +10 ; EVNTINFO - Array containing further event information needed
- +11 ; when building HL7 segments/message. Use and
- +12 ; subscripting of array is determined by segment
- +13 ; and/or message being built.
- +14 ; - Defaults to ^TMP("VAFCMSG",$J,"EVNTINFO")
- +15 ; Current subscripts include:
- +16 ; EVNTINFO("PIVOT") = Pointer to ADT/HL7 PIVOT
- +17 ; file (#391.71)
- +18 ; EVNTINFO("REASON",X) = Event reason codes
- +19 ; EVNTINFO("USER") = User associated with the event
- +20 ;Output : Message ID = ADT-Axx message built and transmitted
- +21 ; ErrorCode^ErrorText = Error generating ADT-Axx message
- +22 ;Notes : The global array ^TMP("HLS",$J) will be initialized (KILLed)
- +23 ; : The following information will be placed into and killed
- +24 ; from the event information array:
- +25 ; EVNTINFO("DFN") = Pointer to PATIENT file (#2)
- +26 ; EVNTINFO("EVENT") = Event type
- +27 ; EVNTINFO("DATE") = Event date/time
- +28 ;
- +29 ;Check input
- +30 SET DFN=+$GET(DFN)
- +31 if ('$DATA(^DPT(DFN,0)))
- QUIT "-1^Could not find entry in PATIENT file"
- +32 SET EVNTHL7=$GET(EVNTHL7)
- +33 if (EVNTHL7="")
- SET EVNTHL7="A08"
- +34 SET EVNTDATE=+$GET(EVNTDATE)
- +35 if ('EVNTDATE)
- SET EVNTDATE=$$NOW^VAFCMSG5()
- +36 SET EVNTINFO=$GET(EVNTINFO)
- +37 if (EVNTINFO="")
- SET EVNTINFO="^TMP(""VAFCMSG"","_$JOB_",""EVNTINFO"")"
- +38 ;Declare variables
- +39 NEW TMP,GLOREF,OK,RETURN
- +40 ;Initialize global location for building HL7 messages
- +41 SET GLOREF="^TMP(""HLS"","_$JOB_")"
- +42 KILL @GLOREF
- +43 ;Check for supported event
- +44 SET OK=0
- +45 FOR TMP="A04","A08","A28"
- IF TMP=EVNTHL7
- SET OK=1
- QUIT
- +46 if ('OK)
- QUIT "-1^Event type not supported"
- +47 ;Put patient, event type, and event date/time into info array
- +48 SET @EVNTINFO@("DFN")=DFN
- +49 SET @EVNTINFO@("EVENT")=EVNTHL7
- +50 SET @EVNTINFO@("DATE")=EVNTDATE
- +51 ;Build ADT-Axx message
- +52 SET RETURN=$$BLDMSG^VAFCMSG1(DFN,EVNTHL7,EVNTDATE,EVNTINFO,GLOREF,1)
- +53 ;Error
- +54 IF (RETURN<0)
- Begin DoDot:1
- +55 KILL @GLOREF,@EVNTINFO@("DFN"),@EVNTINFO@("EVENT"),@EVNTINFO@("DATE")
- End DoDot:1
- QUIT RETURN
- +56 ;Broadcast ADT-Axx message
- +57 SET RETURN=$$SNDMSG^VAFCMSG2(EVNTHL7)
- +58 ;If message id returned, stuff in pivot file
- +59 IF +RETURN>0
- DO MESSAGE^VAFCDD01(@EVNTINFO@("PIVOT"),+RETURN)
- +60 ;Error
- +61 IF (RETURN<0)
- Begin DoDot:1
- +62 KILL @GLOREF,@EVNTINFO@("DFN"),@EVNTINFO@("EVENT"),@EVNTINFO@("DATE")
- End DoDot:1
- QUIT RETURN
- +63 ;Done - Clean up and return output of $$SNDMSG()
- +64 KILL @GLOREF,@EVNTINFO@("DFN"),@EVNTINFO@("EVENT"),@EVNTINFO@("DATE")
- +65 QUIT RETURN