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

MAGDHLTA.m

Go to the documentation of this file.
  1. MAGDHLTA ;WOIFO/MLH/PMK - IHE-based ADT interface for PACS - trigger events - A01, A02, A03, A08, A47 ;16 Mar 2017 12:41 PM
  1. ;;3.0;IMAGING;**49,183**;Mar 19, 2002;Build 11;Apr 07, 2011
  1. ;; Per VHA Directive 2004-038, this routine should not be modified.
  1. ;; +---------------------------------------------------------------+
  1. ;; | Property of the US Government. |
  1. ;; | No permission to copy or redistribute this software is given. |
  1. ;; | Use of unreleased versions of this software requires the user |
  1. ;; | to execute a written test agreement with the VistA Imaging |
  1. ;; | Development Office of the Department of Veterans Affairs, |
  1. ;; | telephone (301) 734-0100. |
  1. ;; | The Food and Drug Administration classifies this software as |
  1. ;; | a medical device. As such, it may not be changed in any way. |
  1. ;; | Modifications to this software may result in an adulterated |
  1. ;; | medical device under 21CFR820, the use of which is considered |
  1. ;; | to be a violation of US Federal Statutes. |
  1. ;; +---------------------------------------------------------------+
  1. ;;
  1. Q
  1. ;
  1. A01 ; GOTO entry point from MAGDHLT - patient admission
  1. ; INPUT: XDFN patient's internal entry number on PATIENT File (#2)
  1. ; XOCCURRED date/time of the admission in FileMan format
  1. ; function return: result of message generation from call to GENERATE^HLMA
  1. ;
  1. N HL ; -------- HL7 initialization function status return
  1. N HLA ; ------- array of HL7 message segments
  1. N MSGA01A ; --- A01 message array
  1. N MSG ; ------- message status
  1. N RESULT ; ---- status message returned by message generator
  1. ;
  1. D INIT^HLFNC2("MAG CPACS A01",.HL)
  1. I $G(HL) Q -1_U_$P(HL,"^",2) ; error
  1. ;
  1. ; build a dummy MSH segment for the $$MAKE^MAG7UM function
  1. S MSGA01A(1,0)="MSH"
  1. S MSGA01A(1,1,1,1,1)=HLFS
  1. S MSGA01A(1,2,1,1,1)=HLECH
  1. S MSGA01A(1,9,1,1,1)="ADT"
  1. S MSGA01A(1,9,1,2,1)="A01"
  1. ;
  1. S MSG=$$EVN^MAGDHLS("A01",$$NOW^XLFDT,XOCCURRED,"MSGA01A")
  1. S MSG=$$PID^MAGDHLS(XDFN,"MSGA01A")
  1. S MSG=$$PV1^MAGDHLS(XDFN,"A01",XOCCURRED,"MSGA01A")
  1. S MSG=$$ROL^MAGDHLS(XDFN,"MSGA01A")
  1. S MSG=$$OBXADT^MAGDHLS(XDFN,"MSGA01A")
  1. S MSG=$$AL1^MAGDHLS(XDFN,"MSGA01A")
  1. S MSG=$$DG1^MAGDHLS(XDFN,"MSGA01A")
  1. ;
  1. ; assemble message into segments
  1. S MSG=$$MAKE^MAG7UM("MSGA01A",$NA(HLA("HLS")))
  1. K HLA("HLS",1) ; remove dummy MSH segment
  1. ;
  1. ; send message to receiver and gateway
  1. D GENERATE^HLMA("MAG CPACS A01","LM",1,.RESULT) ; generate & send message
  1. D LOGGW^MAGDHLL("ADT") ; log message to gateway
  1. Q $S($P($G(RESULT),U,2,$L(RESULT,U))="":0,1:-1_U_RESULT)
  1. ;
  1. A02 ; GOTO entry point from MAGDHLT - patient transfer
  1. ; INPUT: XDFN patient's internal entry number on PATIENT File (#2)
  1. ; XOCCURRED date/time of the admission in FileMan format
  1. ; function return: result of message generation from call to GENERATE^HLMA
  1. ;
  1. N HL ; -------- HL7 initialization function status return
  1. N HLA ; ------- array of HL7 message segments
  1. N MSGA02A ; --- A02 message array
  1. N MSG ; ------- message status
  1. N RESULT ; ---- status message returned by message generator
  1. ;
  1. D INIT^HLFNC2("MAG CPACS A02",.HL)
  1. I $G(HL) Q -1_U_$P(HL,"^",2) ; error
  1. ;
  1. ; build a dummy MSH segment for the $$MAKE^MAG7UM function
  1. S MSGA02A(1,0)="MSH"
  1. S MSGA02A(1,1,1,1,1)=HLFS
  1. S MSGA02A(1,2,1,1,1)=HLECH
  1. S MSGA02A(1,9,1,1,1)="ADT"
  1. S MSGA02A(1,9,1,2,1)="A02"
  1. ;
  1. ; get patient movement event information and build EVN segment
  1. S MSG=$$EVN^MAGDHLS("A02",$$NOW^XLFDT,XOCCURRED,"MSGA02A")
  1. S MSG=$$PID^MAGDHLS(XDFN,"MSGA02A")
  1. S MSG=$$PV1^MAGDHLS(XDFN,"A02",XOCCURRED,"MSGA02A")
  1. S MSG=$$ROL^MAGDHLS(XDFN,"MSGA02A")
  1. ;
  1. ; assemble message into segments
  1. S MSG=$$MAKE^MAG7UM("MSGA02A",$NA(HLA("HLS")))
  1. K HLA("HLS",1) ; remove dummy MSH segment
  1. ;
  1. ; send message to receiver and gateway
  1. D GENERATE^HLMA("MAG CPACS A02","LM",1,.RESULT) ; generate & send message
  1. D LOGGW^MAGDHLL("ADT") ; log message to gateway
  1. Q $S($P($G(RESULT),U,2,$L(RESULT,U))="":0,1:-1_U_RESULT)
  1. ;
  1. A03 ; GOTO entry point from MAGDHLT - patient discharge
  1. ; INPUT: XDFN patient's internal entry number on PATIENT File (#2)
  1. ; XOCCURRED date/time of the admission in FileMan format
  1. ; function return: result of message generation from call to GENERATE^HLMA
  1. ;
  1. N HL ; -------- HL7 initialization function status return
  1. N HLA ; ------- array of HL7 message segments
  1. N MSGA03A ; --- A03 message array
  1. N MSG ; ------- message status
  1. N RESULT ; ---- status message returned by message generator
  1. ;
  1. D INIT^HLFNC2("MAG CPACS A03",.HL)
  1. I $G(HL) Q -1_U_$P(HL,"^",2) ; error
  1. ;
  1. ; build a dummy MSH segment for the $$MAKE^MAG7UM function
  1. S MSGA03A(1,0)="MSH"
  1. S MSGA03A(1,1,1,1,1)=HLFS
  1. S MSGA03A(1,2,1,1,1)=HLECH
  1. S MSGA03A(1,9,1,1,1)="ADT"
  1. S MSGA03A(1,9,1,2,1)="A03"
  1. ;
  1. ; get patient movement event information and build EVN segment
  1. S MSG=$$EVN^MAGDHLS("A03",$$NOW^XLFDT,XOCCURRED,"MSGA03A")
  1. S MSG=$$PID^MAGDHLS(XDFN,"MSGA03A")
  1. S MSG=$$PV1^MAGDHLS(XDFN,"A03",XOCCURRED,"MSGA03A")
  1. S MSG=$$ROL^MAGDHLS(XDFN,"MSGA03A")
  1. S MSG=$$DG1^MAGDHLS(XDFN,"MSGA03A")
  1. ;
  1. ; assemble message into segments
  1. S MSG=$$MAKE^MAG7UM("MSGA03A",$NA(HLA("HLS")))
  1. K HLA("HLS",1) ; remove dummy MSH segment
  1. ;
  1. ; send message to receiver and gateway
  1. D GENERATE^HLMA("MAG CPACS A03","LM",1,.RESULT) ; generate & send message
  1. D LOGGW^MAGDHLL("ADT") ; log message to gateway
  1. Q $S($P($G(RESULT),U,2,$L(RESULT,U))="":0,1:-1_U_RESULT)
  1. ;
  1. A08 ; GOTO entry point from MAGDHLT - patient information update - P183 PMK 3/9/17
  1. ; INPUT: XDFN patient's internal entry number on PATIENT File (#2)
  1. ; function return: result of message generation from call to GENERATE^HLMA
  1. ;
  1. N HL ; -------- HL7 initialization function status return
  1. N HLA ; ------- array of HL7 message segments
  1. N MSGA08A ; --- A08 message array
  1. N MSG ; ------- message status
  1. N NOW ; ------- current date and time
  1. N RESULT ; ---- status message returned by message generator
  1. ;
  1. D INIT^HLFNC2("MAG CPACS A08",.HL)
  1. I $G(HL) Q -1_U_$P(HL,"^",2) ; error
  1. ;
  1. ; build a dummy MSH segment for the $$MAKE^MAG7UM function
  1. S MSGA08A(1,0)="MSH"
  1. S MSGA08A(1,1,1,1,1)=HLFS
  1. S MSGA08A(1,2,1,1,1)=HLECH
  1. S MSGA08A(1,9,1,1,1)="ADT"
  1. S MSGA08A(1,9,1,2,1)="A08"
  1. ;
  1. S NOW=$$NOW^XLFDT
  1. I '$D(XOCCURRED) S XOCCURRED=NOW ; XOCCURRED only set for ADT A47/A08 pair
  1. ;
  1. S MSG=$$EVN^MAGDHLS("A08",NOW,XOCCURRED,"MSGA08A")
  1. S MSG=$$PID^MAGDHLS(XDFN,"MSGA08A")
  1. S MSG=$$PV1^MAGDHLS(XDFN,"A08",XOCCURRED,"MSGA08A")
  1. S MSG=$$ROL^MAGDHLS(XDFN,"MSGA08A")
  1. S MSG=$$OBXADT^MAGDHLS(XDFN,"MSGA08A")
  1. S MSG=$$AL1^MAGDHLS(XDFN,"MSGA08A")
  1. S MSG=$$DG1^MAGDHLS(XDFN,"MSGA08A")
  1. ;
  1. ; Update the PID-3 and PID-19 fields to contain the new SSN at time of change
  1. I $D(NEWSSN) D ; NEWSSN is only set for ADT A47/A08 pair
  1. . S MSGA08A(3,3,1,1,1)=NEWSSN ; PID-3
  1. . S MSGA08A(3,19,1,1,1)=NEWSSN ; PID-19
  1. . Q
  1. ;
  1. ; assemble message into segments
  1. S MSG=$$MAKE^MAG7UM("MSGA08A",$NA(HLA("HLS")))
  1. K HLA("HLS",1) ; remove dummy MSH segment
  1. ; send message to receiver and gateway
  1. D GENERATE^HLMA("MAG CPACS A08","LM",1,.RESULT) ; generate & send message
  1. D LOGGW^MAGDHLL("ADT") ; log message to gateway
  1. Q $S($P($G(RESULT),U,2,$L(RESULT,U))="":0,1:-1_U_RESULT)
  1. ;
  1. A47 ; GOTO entry point from MAGDHLT - change patient identifier list - P183 PMK 3/9/17
  1. ; INPUT: XDFN patient's internal entry number on PATIENT File (#2)
  1. ; OLDSSN patient's previous SSN
  1. ; function return: result of message generation from call to GENERATE^HLMA
  1. ;
  1. N HL ; -------- HL7 initialization function status return
  1. N HLA ; ------- array of HL7 message segments
  1. N MSGA47A ; --- A47 message array
  1. N MSG ; ------- message status
  1. N NOW ; ------- current date and time
  1. N RESULT ; ---- status message returned by message generator
  1. ;
  1. D INIT^HLFNC2("MAG CPACS A47",.HL)
  1. I $G(HL) Q -1_U_$P(HL,"^",2) ; error
  1. ;
  1. ; build a dummy MSH segment for the $$MAKE^MAG7UM function
  1. S MSGA47A(1,0)="MSH"
  1. S MSGA47A(1,1,1,1,1)=HLFS
  1. S MSGA47A(1,2,1,1,1)=HLECH
  1. S MSGA47A(1,9,1,1,1)="ADT"
  1. S MSGA47A(1,9,1,2,1)="A47"
  1. ;
  1. S NOW=$$NOW^XLFDT
  1. ;
  1. S MSG=$$EVN^MAGDHLS("A47",NOW,XOCCURRED,"MSGA47A")
  1. S MSG=$$PID^MAGDHLS(XDFN,"MSGA47A")
  1. S MSG=$$MRG^MAGDHLS(OLDSSN,"MSGA47A")
  1. ;
  1. ; Update the PID-3 and PID-19 fields to contain the new SSN at time of change
  1. S MSGA47A(3,3,1,1,1)=NEWSSN ; PID-3
  1. S MSGA47A(3,19,1,1,1)=NEWSSN ; PID-19
  1. ;
  1. ; assemble message into segments
  1. S MSG=$$MAKE^MAG7UM("MSGA47A",$NA(HLA("HLS")))
  1. K HLA("HLS",1) ; remove dummy MSH segment
  1. ;
  1. ; send message to receiver and gateway
  1. D GENERATE^HLMA("MAG CPACS A47","LM",1,.RESULT) ; generate & send message
  1. D LOGGW^MAGDHLL("ADT") ; log message to gateway
  1. Q $S($P($G(RESULT),U,2,$L(RESULT,U))="":0,1:-1_U_RESULT)