MAGDHLTA ;WOIFO/MLH/PMK - IHE-based ADT interface for PACS - trigger events - A01, A02, A03, A08, A47 ;16 Mar 2017 12:41 PM
;;3.0;IMAGING;**49,183**;Mar 19, 2002;Build 11;Apr 07, 2011
;; Per VHA Directive 2004-038, this routine should not be modified.
;; +---------------------------------------------------------------+
;; | Property of the US Government. |
;; | No permission to copy or redistribute this software is given. |
;; | Use of unreleased versions of this software requires the user |
;; | to execute a written test agreement with the VistA Imaging |
;; | Development Office of the Department of Veterans Affairs, |
;; | telephone (301) 734-0100. |
;; | The Food and Drug Administration classifies this software as |
;; | a medical device. As such, it may not be changed in any way. |
;; | Modifications to this software may result in an adulterated |
;; | medical device under 21CFR820, the use of which is considered |
;; | to be a violation of US Federal Statutes. |
;; +---------------------------------------------------------------+
;;
Q
;
A01 ; GOTO entry point from MAGDHLT - patient admission
; INPUT: XDFN patient's internal entry number on PATIENT File (#2)
; XOCCURRED date/time of the admission in FileMan format
; function return: result of message generation from call to GENERATE^HLMA
;
N HL ; -------- HL7 initialization function status return
N HLA ; ------- array of HL7 message segments
N MSGA01A ; --- A01 message array
N MSG ; ------- message status
N RESULT ; ---- status message returned by message generator
;
D INIT^HLFNC2("MAG CPACS A01",.HL)
I $G(HL) Q -1_U_$P(HL,"^",2) ; error
;
; build a dummy MSH segment for the $$MAKE^MAG7UM function
S MSGA01A(1,0)="MSH"
S MSGA01A(1,1,1,1,1)=HLFS
S MSGA01A(1,2,1,1,1)=HLECH
S MSGA01A(1,9,1,1,1)="ADT"
S MSGA01A(1,9,1,2,1)="A01"
;
S MSG=$$EVN^MAGDHLS("A01",$$NOW^XLFDT,XOCCURRED,"MSGA01A")
S MSG=$$PID^MAGDHLS(XDFN,"MSGA01A")
S MSG=$$PV1^MAGDHLS(XDFN,"A01",XOCCURRED,"MSGA01A")
S MSG=$$ROL^MAGDHLS(XDFN,"MSGA01A")
S MSG=$$OBXADT^MAGDHLS(XDFN,"MSGA01A")
S MSG=$$AL1^MAGDHLS(XDFN,"MSGA01A")
S MSG=$$DG1^MAGDHLS(XDFN,"MSGA01A")
;
; assemble message into segments
S MSG=$$MAKE^MAG7UM("MSGA01A",$NA(HLA("HLS")))
K HLA("HLS",1) ; remove dummy MSH segment
;
; send message to receiver and gateway
D GENERATE^HLMA("MAG CPACS A01","LM",1,.RESULT) ; generate & send message
D LOGGW^MAGDHLL("ADT") ; log message to gateway
Q $S($P($G(RESULT),U,2,$L(RESULT,U))="":0,1:-1_U_RESULT)
;
A02 ; GOTO entry point from MAGDHLT - patient transfer
; INPUT: XDFN patient's internal entry number on PATIENT File (#2)
; XOCCURRED date/time of the admission in FileMan format
; function return: result of message generation from call to GENERATE^HLMA
;
N HL ; -------- HL7 initialization function status return
N HLA ; ------- array of HL7 message segments
N MSGA02A ; --- A02 message array
N MSG ; ------- message status
N RESULT ; ---- status message returned by message generator
;
D INIT^HLFNC2("MAG CPACS A02",.HL)
I $G(HL) Q -1_U_$P(HL,"^",2) ; error
;
; build a dummy MSH segment for the $$MAKE^MAG7UM function
S MSGA02A(1,0)="MSH"
S MSGA02A(1,1,1,1,1)=HLFS
S MSGA02A(1,2,1,1,1)=HLECH
S MSGA02A(1,9,1,1,1)="ADT"
S MSGA02A(1,9,1,2,1)="A02"
;
; get patient movement event information and build EVN segment
S MSG=$$EVN^MAGDHLS("A02",$$NOW^XLFDT,XOCCURRED,"MSGA02A")
S MSG=$$PID^MAGDHLS(XDFN,"MSGA02A")
S MSG=$$PV1^MAGDHLS(XDFN,"A02",XOCCURRED,"MSGA02A")
S MSG=$$ROL^MAGDHLS(XDFN,"MSGA02A")
;
; assemble message into segments
S MSG=$$MAKE^MAG7UM("MSGA02A",$NA(HLA("HLS")))
K HLA("HLS",1) ; remove dummy MSH segment
;
; send message to receiver and gateway
D GENERATE^HLMA("MAG CPACS A02","LM",1,.RESULT) ; generate & send message
D LOGGW^MAGDHLL("ADT") ; log message to gateway
Q $S($P($G(RESULT),U,2,$L(RESULT,U))="":0,1:-1_U_RESULT)
;
A03 ; GOTO entry point from MAGDHLT - patient discharge
; INPUT: XDFN patient's internal entry number on PATIENT File (#2)
; XOCCURRED date/time of the admission in FileMan format
; function return: result of message generation from call to GENERATE^HLMA
;
N HL ; -------- HL7 initialization function status return
N HLA ; ------- array of HL7 message segments
N MSGA03A ; --- A03 message array
N MSG ; ------- message status
N RESULT ; ---- status message returned by message generator
;
D INIT^HLFNC2("MAG CPACS A03",.HL)
I $G(HL) Q -1_U_$P(HL,"^",2) ; error
;
; build a dummy MSH segment for the $$MAKE^MAG7UM function
S MSGA03A(1,0)="MSH"
S MSGA03A(1,1,1,1,1)=HLFS
S MSGA03A(1,2,1,1,1)=HLECH
S MSGA03A(1,9,1,1,1)="ADT"
S MSGA03A(1,9,1,2,1)="A03"
;
; get patient movement event information and build EVN segment
S MSG=$$EVN^MAGDHLS("A03",$$NOW^XLFDT,XOCCURRED,"MSGA03A")
S MSG=$$PID^MAGDHLS(XDFN,"MSGA03A")
S MSG=$$PV1^MAGDHLS(XDFN,"A03",XOCCURRED,"MSGA03A")
S MSG=$$ROL^MAGDHLS(XDFN,"MSGA03A")
S MSG=$$DG1^MAGDHLS(XDFN,"MSGA03A")
;
; assemble message into segments
S MSG=$$MAKE^MAG7UM("MSGA03A",$NA(HLA("HLS")))
K HLA("HLS",1) ; remove dummy MSH segment
;
; send message to receiver and gateway
D GENERATE^HLMA("MAG CPACS A03","LM",1,.RESULT) ; generate & send message
D LOGGW^MAGDHLL("ADT") ; log message to gateway
Q $S($P($G(RESULT),U,2,$L(RESULT,U))="":0,1:-1_U_RESULT)
;
A08 ; GOTO entry point from MAGDHLT - patient information update - P183 PMK 3/9/17
; INPUT: XDFN patient's internal entry number on PATIENT File (#2)
; function return: result of message generation from call to GENERATE^HLMA
;
N HL ; -------- HL7 initialization function status return
N HLA ; ------- array of HL7 message segments
N MSGA08A ; --- A08 message array
N MSG ; ------- message status
N NOW ; ------- current date and time
N RESULT ; ---- status message returned by message generator
;
D INIT^HLFNC2("MAG CPACS A08",.HL)
I $G(HL) Q -1_U_$P(HL,"^",2) ; error
;
; build a dummy MSH segment for the $$MAKE^MAG7UM function
S MSGA08A(1,0)="MSH"
S MSGA08A(1,1,1,1,1)=HLFS
S MSGA08A(1,2,1,1,1)=HLECH
S MSGA08A(1,9,1,1,1)="ADT"
S MSGA08A(1,9,1,2,1)="A08"
;
S NOW=$$NOW^XLFDT
I '$D(XOCCURRED) S XOCCURRED=NOW ; XOCCURRED only set for ADT A47/A08 pair
;
S MSG=$$EVN^MAGDHLS("A08",NOW,XOCCURRED,"MSGA08A")
S MSG=$$PID^MAGDHLS(XDFN,"MSGA08A")
S MSG=$$PV1^MAGDHLS(XDFN,"A08",XOCCURRED,"MSGA08A")
S MSG=$$ROL^MAGDHLS(XDFN,"MSGA08A")
S MSG=$$OBXADT^MAGDHLS(XDFN,"MSGA08A")
S MSG=$$AL1^MAGDHLS(XDFN,"MSGA08A")
S MSG=$$DG1^MAGDHLS(XDFN,"MSGA08A")
;
; Update the PID-3 and PID-19 fields to contain the new SSN at time of change
I $D(NEWSSN) D ; NEWSSN is only set for ADT A47/A08 pair
. S MSGA08A(3,3,1,1,1)=NEWSSN ; PID-3
. S MSGA08A(3,19,1,1,1)=NEWSSN ; PID-19
. Q
;
; assemble message into segments
S MSG=$$MAKE^MAG7UM("MSGA08A",$NA(HLA("HLS")))
K HLA("HLS",1) ; remove dummy MSH segment
; send message to receiver and gateway
D GENERATE^HLMA("MAG CPACS A08","LM",1,.RESULT) ; generate & send message
D LOGGW^MAGDHLL("ADT") ; log message to gateway
Q $S($P($G(RESULT),U,2,$L(RESULT,U))="":0,1:-1_U_RESULT)
;
A47 ; GOTO entry point from MAGDHLT - change patient identifier list - P183 PMK 3/9/17
; INPUT: XDFN patient's internal entry number on PATIENT File (#2)
; OLDSSN patient's previous SSN
; function return: result of message generation from call to GENERATE^HLMA
;
N HL ; -------- HL7 initialization function status return
N HLA ; ------- array of HL7 message segments
N MSGA47A ; --- A47 message array
N MSG ; ------- message status
N NOW ; ------- current date and time
N RESULT ; ---- status message returned by message generator
;
D INIT^HLFNC2("MAG CPACS A47",.HL)
I $G(HL) Q -1_U_$P(HL,"^",2) ; error
;
; build a dummy MSH segment for the $$MAKE^MAG7UM function
S MSGA47A(1,0)="MSH"
S MSGA47A(1,1,1,1,1)=HLFS
S MSGA47A(1,2,1,1,1)=HLECH
S MSGA47A(1,9,1,1,1)="ADT"
S MSGA47A(1,9,1,2,1)="A47"
;
S NOW=$$NOW^XLFDT
;
S MSG=$$EVN^MAGDHLS("A47",NOW,XOCCURRED,"MSGA47A")
S MSG=$$PID^MAGDHLS(XDFN,"MSGA47A")
S MSG=$$MRG^MAGDHLS(OLDSSN,"MSGA47A")
;
; Update the PID-3 and PID-19 fields to contain the new SSN at time of change
S MSGA47A(3,3,1,1,1)=NEWSSN ; PID-3
S MSGA47A(3,19,1,1,1)=NEWSSN ; PID-19
;
; assemble message into segments
S MSG=$$MAKE^MAG7UM("MSGA47A",$NA(HLA("HLS")))
K HLA("HLS",1) ; remove dummy MSH segment
;
; send message to receiver and gateway
D GENERATE^HLMA("MAG CPACS A47","LM",1,.RESULT) ; generate & send message
D LOGGW^MAGDHLL("ADT") ; log message to gateway
Q $S($P($G(RESULT),U,2,$L(RESULT,U))="":0,1:-1_U_RESULT)
--- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HMAGDHLTA 8928 printed Dec 13, 2024@02:00:03 Page 2
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
+2 ;; Per VHA Directive 2004-038, this routine should not be modified.
+3 ;; +---------------------------------------------------------------+
+4 ;; | Property of the US Government. |
+5 ;; | No permission to copy or redistribute this software is given. |
+6 ;; | Use of unreleased versions of this software requires the user |
+7 ;; | to execute a written test agreement with the VistA Imaging |
+8 ;; | Development Office of the Department of Veterans Affairs, |
+9 ;; | telephone (301) 734-0100. |
+10 ;; | The Food and Drug Administration classifies this software as |
+11 ;; | a medical device. As such, it may not be changed in any way. |
+12 ;; | Modifications to this software may result in an adulterated |
+13 ;; | medical device under 21CFR820, the use of which is considered |
+14 ;; | to be a violation of US Federal Statutes. |
+15 ;; +---------------------------------------------------------------+
+16 ;;
+17 QUIT
+18 ;
A01 ; GOTO entry point from MAGDHLT - patient admission
+1 ; INPUT: XDFN patient's internal entry number on PATIENT File (#2)
+2 ; XOCCURRED date/time of the admission in FileMan format
+3 ; function return: result of message generation from call to GENERATE^HLMA
+4 ;
+5 ; -------- HL7 initialization function status return
NEW HL
+6 ; ------- array of HL7 message segments
NEW HLA
+7 ; --- A01 message array
NEW MSGA01A
+8 ; ------- message status
NEW MSG
+9 ; ---- status message returned by message generator
NEW RESULT
+10 ;
+11 DO INIT^HLFNC2("MAG CPACS A01",.HL)
+12 ; error
IF $GET(HL)
QUIT -1_U_$PIECE(HL,"^",2)
+13 ;
+14 ; build a dummy MSH segment for the $$MAKE^MAG7UM function
+15 SET MSGA01A(1,0)="MSH"
+16 SET MSGA01A(1,1,1,1,1)=HLFS
+17 SET MSGA01A(1,2,1,1,1)=HLECH
+18 SET MSGA01A(1,9,1,1,1)="ADT"
+19 SET MSGA01A(1,9,1,2,1)="A01"
+20 ;
+21 SET MSG=$$EVN^MAGDHLS("A01",$$NOW^XLFDT,XOCCURRED,"MSGA01A")
+22 SET MSG=$$PID^MAGDHLS(XDFN,"MSGA01A")
+23 SET MSG=$$PV1^MAGDHLS(XDFN,"A01",XOCCURRED,"MSGA01A")
+24 SET MSG=$$ROL^MAGDHLS(XDFN,"MSGA01A")
+25 SET MSG=$$OBXADT^MAGDHLS(XDFN,"MSGA01A")
+26 SET MSG=$$AL1^MAGDHLS(XDFN,"MSGA01A")
+27 SET MSG=$$DG1^MAGDHLS(XDFN,"MSGA01A")
+28 ;
+29 ; assemble message into segments
+30 SET MSG=$$MAKE^MAG7UM("MSGA01A",$NAME(HLA("HLS")))
+31 ; remove dummy MSH segment
KILL HLA("HLS",1)
+32 ;
+33 ; send message to receiver and gateway
+34 ; generate & send message
DO GENERATE^HLMA("MAG CPACS A01","LM",1,.RESULT)
+35 ; log message to gateway
DO LOGGW^MAGDHLL("ADT")
+36 QUIT $SELECT($PIECE($GET(RESULT),U,2,$LENGTH(RESULT,U))="":0,1:-1_U_RESULT)
+37 ;
A02 ; GOTO entry point from MAGDHLT - patient transfer
+1 ; INPUT: XDFN patient's internal entry number on PATIENT File (#2)
+2 ; XOCCURRED date/time of the admission in FileMan format
+3 ; function return: result of message generation from call to GENERATE^HLMA
+4 ;
+5 ; -------- HL7 initialization function status return
NEW HL
+6 ; ------- array of HL7 message segments
NEW HLA
+7 ; --- A02 message array
NEW MSGA02A
+8 ; ------- message status
NEW MSG
+9 ; ---- status message returned by message generator
NEW RESULT
+10 ;
+11 DO INIT^HLFNC2("MAG CPACS A02",.HL)
+12 ; error
IF $GET(HL)
QUIT -1_U_$PIECE(HL,"^",2)
+13 ;
+14 ; build a dummy MSH segment for the $$MAKE^MAG7UM function
+15 SET MSGA02A(1,0)="MSH"
+16 SET MSGA02A(1,1,1,1,1)=HLFS
+17 SET MSGA02A(1,2,1,1,1)=HLECH
+18 SET MSGA02A(1,9,1,1,1)="ADT"
+19 SET MSGA02A(1,9,1,2,1)="A02"
+20 ;
+21 ; get patient movement event information and build EVN segment
+22 SET MSG=$$EVN^MAGDHLS("A02",$$NOW^XLFDT,XOCCURRED,"MSGA02A")
+23 SET MSG=$$PID^MAGDHLS(XDFN,"MSGA02A")
+24 SET MSG=$$PV1^MAGDHLS(XDFN,"A02",XOCCURRED,"MSGA02A")
+25 SET MSG=$$ROL^MAGDHLS(XDFN,"MSGA02A")
+26 ;
+27 ; assemble message into segments
+28 SET MSG=$$MAKE^MAG7UM("MSGA02A",$NAME(HLA("HLS")))
+29 ; remove dummy MSH segment
KILL HLA("HLS",1)
+30 ;
+31 ; send message to receiver and gateway
+32 ; generate & send message
DO GENERATE^HLMA("MAG CPACS A02","LM",1,.RESULT)
+33 ; log message to gateway
DO LOGGW^MAGDHLL("ADT")
+34 QUIT $SELECT($PIECE($GET(RESULT),U,2,$LENGTH(RESULT,U))="":0,1:-1_U_RESULT)
+35 ;
A03 ; GOTO entry point from MAGDHLT - patient discharge
+1 ; INPUT: XDFN patient's internal entry number on PATIENT File (#2)
+2 ; XOCCURRED date/time of the admission in FileMan format
+3 ; function return: result of message generation from call to GENERATE^HLMA
+4 ;
+5 ; -------- HL7 initialization function status return
NEW HL
+6 ; ------- array of HL7 message segments
NEW HLA
+7 ; --- A03 message array
NEW MSGA03A
+8 ; ------- message status
NEW MSG
+9 ; ---- status message returned by message generator
NEW RESULT
+10 ;
+11 DO INIT^HLFNC2("MAG CPACS A03",.HL)
+12 ; error
IF $GET(HL)
QUIT -1_U_$PIECE(HL,"^",2)
+13 ;
+14 ; build a dummy MSH segment for the $$MAKE^MAG7UM function
+15 SET MSGA03A(1,0)="MSH"
+16 SET MSGA03A(1,1,1,1,1)=HLFS
+17 SET MSGA03A(1,2,1,1,1)=HLECH
+18 SET MSGA03A(1,9,1,1,1)="ADT"
+19 SET MSGA03A(1,9,1,2,1)="A03"
+20 ;
+21 ; get patient movement event information and build EVN segment
+22 SET MSG=$$EVN^MAGDHLS("A03",$$NOW^XLFDT,XOCCURRED,"MSGA03A")
+23 SET MSG=$$PID^MAGDHLS(XDFN,"MSGA03A")
+24 SET MSG=$$PV1^MAGDHLS(XDFN,"A03",XOCCURRED,"MSGA03A")
+25 SET MSG=$$ROL^MAGDHLS(XDFN,"MSGA03A")
+26 SET MSG=$$DG1^MAGDHLS(XDFN,"MSGA03A")
+27 ;
+28 ; assemble message into segments
+29 SET MSG=$$MAKE^MAG7UM("MSGA03A",$NAME(HLA("HLS")))
+30 ; remove dummy MSH segment
KILL HLA("HLS",1)
+31 ;
+32 ; send message to receiver and gateway
+33 ; generate & send message
DO GENERATE^HLMA("MAG CPACS A03","LM",1,.RESULT)
+34 ; log message to gateway
DO LOGGW^MAGDHLL("ADT")
+35 QUIT $SELECT($PIECE($GET(RESULT),U,2,$LENGTH(RESULT,U))="":0,1:-1_U_RESULT)
+36 ;
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)
+2 ; function return: result of message generation from call to GENERATE^HLMA
+3 ;
+4 ; -------- HL7 initialization function status return
NEW HL
+5 ; ------- array of HL7 message segments
NEW HLA
+6 ; --- A08 message array
NEW MSGA08A
+7 ; ------- message status
NEW MSG
+8 ; ------- current date and time
NEW NOW
+9 ; ---- status message returned by message generator
NEW RESULT
+10 ;
+11 DO INIT^HLFNC2("MAG CPACS A08",.HL)
+12 ; error
IF $GET(HL)
QUIT -1_U_$PIECE(HL,"^",2)
+13 ;
+14 ; build a dummy MSH segment for the $$MAKE^MAG7UM function
+15 SET MSGA08A(1,0)="MSH"
+16 SET MSGA08A(1,1,1,1,1)=HLFS
+17 SET MSGA08A(1,2,1,1,1)=HLECH
+18 SET MSGA08A(1,9,1,1,1)="ADT"
+19 SET MSGA08A(1,9,1,2,1)="A08"
+20 ;
+21 SET NOW=$$NOW^XLFDT
+22 ; XOCCURRED only set for ADT A47/A08 pair
IF '$DATA(XOCCURRED)
SET XOCCURRED=NOW
+23 ;
+24 SET MSG=$$EVN^MAGDHLS("A08",NOW,XOCCURRED,"MSGA08A")
+25 SET MSG=$$PID^MAGDHLS(XDFN,"MSGA08A")
+26 SET MSG=$$PV1^MAGDHLS(XDFN,"A08",XOCCURRED,"MSGA08A")
+27 SET MSG=$$ROL^MAGDHLS(XDFN,"MSGA08A")
+28 SET MSG=$$OBXADT^MAGDHLS(XDFN,"MSGA08A")
+29 SET MSG=$$AL1^MAGDHLS(XDFN,"MSGA08A")
+30 SET MSG=$$DG1^MAGDHLS(XDFN,"MSGA08A")
+31 ;
+32 ; Update the PID-3 and PID-19 fields to contain the new SSN at time of change
+33 ; NEWSSN is only set for ADT A47/A08 pair
IF $DATA(NEWSSN)
Begin DoDot:1
+34 ; PID-3
SET MSGA08A(3,3,1,1,1)=NEWSSN
+35 ; PID-19
SET MSGA08A(3,19,1,1,1)=NEWSSN
+36 QUIT
End DoDot:1
+37 ;
+38 ; assemble message into segments
+39 SET MSG=$$MAKE^MAG7UM("MSGA08A",$NAME(HLA("HLS")))
+40 ; remove dummy MSH segment
KILL HLA("HLS",1)
+41 ; send message to receiver and gateway
+42 ; generate & send message
DO GENERATE^HLMA("MAG CPACS A08","LM",1,.RESULT)
+43 ; log message to gateway
DO LOGGW^MAGDHLL("ADT")
+44 QUIT $SELECT($PIECE($GET(RESULT),U,2,$LENGTH(RESULT,U))="":0,1:-1_U_RESULT)
+45 ;
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)
+2 ; OLDSSN patient's previous SSN
+3 ; function return: result of message generation from call to GENERATE^HLMA
+4 ;
+5 ; -------- HL7 initialization function status return
NEW HL
+6 ; ------- array of HL7 message segments
NEW HLA
+7 ; --- A47 message array
NEW MSGA47A
+8 ; ------- message status
NEW MSG
+9 ; ------- current date and time
NEW NOW
+10 ; ---- status message returned by message generator
NEW RESULT
+11 ;
+12 DO INIT^HLFNC2("MAG CPACS A47",.HL)
+13 ; error
IF $GET(HL)
QUIT -1_U_$PIECE(HL,"^",2)
+14 ;
+15 ; build a dummy MSH segment for the $$MAKE^MAG7UM function
+16 SET MSGA47A(1,0)="MSH"
+17 SET MSGA47A(1,1,1,1,1)=HLFS
+18 SET MSGA47A(1,2,1,1,1)=HLECH
+19 SET MSGA47A(1,9,1,1,1)="ADT"
+20 SET MSGA47A(1,9,1,2,1)="A47"
+21 ;
+22 SET NOW=$$NOW^XLFDT
+23 ;
+24 SET MSG=$$EVN^MAGDHLS("A47",NOW,XOCCURRED,"MSGA47A")
+25 SET MSG=$$PID^MAGDHLS(XDFN,"MSGA47A")
+26 SET MSG=$$MRG^MAGDHLS(OLDSSN,"MSGA47A")
+27 ;
+28 ; Update the PID-3 and PID-19 fields to contain the new SSN at time of change
+29 ; PID-3
SET MSGA47A(3,3,1,1,1)=NEWSSN
+30 ; PID-19
SET MSGA47A(3,19,1,1,1)=NEWSSN
+31 ;
+32 ; assemble message into segments
+33 SET MSG=$$MAKE^MAG7UM("MSGA47A",$NAME(HLA("HLS")))
+34 ; remove dummy MSH segment
KILL HLA("HLS",1)
+35 ;
+36 ; send message to receiver and gateway
+37 ; generate & send message
DO GENERATE^HLMA("MAG CPACS A47","LM",1,.RESULT)
+38 ; log message to gateway
DO LOGGW^MAGDHLL("ADT")
+39 QUIT $SELECT($PIECE($GET(RESULT),U,2,$LENGTH(RESULT,U))="":0,1:-1_U_RESULT)