XUHUIHL7 ;OAKCIOFO/JG - HL7 GENERATION ROUTINE [ 07/29/2004 9:01 AM ]
;;8.0;KERNEL;**239**;JUL 10, 1995
; Supported by IA#3589
; This routine generates an HL7 MFN Staff message based on data
; passed by the XUHUI FIELD CHANGE EVENT protocol to the XUHUI SEND HL7
; MSG protocol. This data is based on change in value of fields in the
; NEW PERSON (#200) file and in the the KEY (#200.051) multiple.
; The following fields are monitored for the NEW PERSON file:
; .01 NAME
; 9.2 TERMINATION DATE
; 5 DOB
; 9 SSN
; The Provider key is monitored for the KEY subfile.
;
; Input:
; XUHUIXR - Name of xref being passed by protocols
; "AXUHUI": file 200 updated;
; "AXUHUIKEY": file 200.051 updated
; XUHUIA - "S": logic executed; "K": kill logic executed
; XUHUIX2 - X2 array with file 200 content
; XUHUIDA - DA array
;
; Output: none
; Postcondition:
; - An HL7 MFN message is generated that contains the structure
; MSH MFI MFE STF
;
N XUHUIERR,NAME,SSN,DOB,TERMDATE,ACTIVE
Q:XUHUIXR'["AXUHUI"
I XUHUIXR="AXUHUI" D F200
I XUHUIXR="AXUHUIKEY" D FKEY
Q:$G(XUHUIERR)
D SENDMSG
Q
;
F200 ; NEW PERSON file was updated
; XUHUIX2(1)=NAME
; XUHUIX2(2)=TERMINATION DATE
; XUHUIX2(3)=DOB
; XUHUIX2(4)=SSN
; XUHUIDA=file 200 ien
I '$D(XUHUIX2) S XUHUIERR="1^no XUHUIX2 array" Q
S IEN=XUHUIDA
; TERMINATION DATE determines Active/Inactive
S ACTIVE=$S($G(XUHUIX2(2))]"":"I",1:"A")
; get newest values for name, ssn, dob, and termination date
S NAME=$S($G(XUHUIX2(1))="":"""""",1:XUHUIX2(1))
S SSN=$S($G(XUHUIX2(4))="":"""""",1:XUHUIX2(4))
S DOB=$$FMTHL7^XLFDT($G(XUHUIX2(3)))
S DOB=$S(DOB="":"""""",1:DOB)
S TERMDATE=$$FMTHL7^XLFDT($G(XUHUIX2(2)))
S TERMDATE=$S(TERMDATE="":"""""",1:TERMDATE)
Q
;
FKEY ; PROVIDER key was updated
; XUHUIDA(1)=file 200 ien
; XUHUIA= S or K
I '$G(XUHUIDA(1)) S XUHUIERR="1^no IEN" Q
S IEN=XUHUIDA(1) ; ien of provider staff
; XUHUIA determines Active/Inactive
S ACTIVE=$S($G(XUHUIA)="K":"I",1:"A")
; get newest values for name, ssn, dob, and termination date
S NAME=$$GET1^DIQ(200,IEN_",","NAME")
S NAME=$S(NAME="":"""""",1:NAME)
S SSN=$$GET1^DIQ(200,IEN_",","SSN")
S SSN=$S(SSN="":"""""",1:SSN)
S DOB=$$GET1^DIQ(200,IEN_",","DOB","I")
S DOB=$S(DOB="":"""""",1:$$FMTHL7^XLFDT(DOB))
S TERMDATE=$$GET1^DIQ(200,IEN_",","TERMINATION DATE","I")
S TERMDATE=$S(TERMDATE="":"""""",1:$$FMTHL7^XLFDT(TERMDATE))
Q
;
SENDMSG ; initialize HL variables
N HL,NOW,RESULT
D INIT^HLFNC2("XUHUI MFN",.HL)
I $G(HL) D Q ; error occurred
. S XUHUIERR="1^HL init"
S HLFS=$G(HL("FS")) S:HLFS="" HLFS="^"
S HLCS=$E(HL("ECH"),1)
;
; create message
S NOW=$$FMTHL7^XLFDT($$NOW^XLFDT)
; MFI^PRA^VA KERNEL^UPD^entered date^^NE
S HLA("HLS",1)="MFI"_HLFS_"PRA"_HLFS_"VA KERNEL"_HLFS_"UPD"_HLFS_NOW_HLFS_HLFS_"NE"
; MFE^MUP^^^ien~IEN~NEW PERSON
S HLA("HLS",2)="MFE"_HLFS_"MUP"_HLFS_HLFS_HLFS_IEN_HLCS_"IEN"_HLCS_"NEW PERSON"
; STF^ssn~NEW PERSON~SSN^^name^^^dob^active/inactive^^^^^^inactive date
S HLA("HLS",3)="STF"_HLFS_IEN_HLCS_"IEN"_HLCS_"NEW PERSON"_HLFS_SSN_HLCS_HLCS_HLCS_"SSN"_HLFS_NAME_HLFS_HLFS_HLFS_DOB_HLFS_ACTIVE_HLFS_HLFS_HLFS_HLFS_HLFS_HLFS_TERMDATE
; generate message
D GENERATE^HLMA("XUHUI MFN","LM",1,.RESULT,"",.HL)
I +$P(RESULT,U,2) D Q
. S XUHUIERR="1^HL Generate"
Q
;
XUHUIHL7 ;OAKCIOFO/JG - HL7 GENERATION ROUTINE [ 07/29/2004 9:01 AM ]
+1 ;;8.0;KERNEL;**239**;JUL 10, 1995
+2 ; Supported by IA#3589
+3 ; This routine generates an HL7 MFN Staff message based on data
+4 ; passed by the XUHUI FIELD CHANGE EVENT protocol to the XUHUI SEND HL7
+5 ; MSG protocol. This data is based on change in value of fields in the
+6 ; NEW PERSON (#200) file and in the the KEY (#200.051) multiple.
+7 ; The following fields are monitored for the NEW PERSON file:
+8 ; .01 NAME
+9 ; 9.2 TERMINATION DATE
+10 ; 5 DOB
+11 ; 9 SSN
+12 ; The Provider key is monitored for the KEY subfile.
+13 ;
+14 ; Input:
+15 ; XUHUIXR - Name of xref being passed by protocols
+16 ; "AXUHUI": file 200 updated;
+17 ; "AXUHUIKEY": file 200.051 updated
+18 ; XUHUIA - "S": logic executed; "K": kill logic executed
+19 ; XUHUIX2 - X2 array with file 200 content
+20 ; XUHUIDA - DA array
+21 ;
+22 ; Output: none
+23 ; Postcondition:
+24 ; - An HL7 MFN message is generated that contains the structure
+25 ; MSH MFI MFE STF
+26 ;
+27 NEW XUHUIERR,NAME,SSN,DOB,TERMDATE,ACTIVE
+28 IF XUHUIXR'["AXUHUI"
QUIT
+29 IF XUHUIXR="AXUHUI"
DO F200
+30 IF XUHUIXR="AXUHUIKEY"
DO FKEY
+31 IF $GET(XUHUIERR)
QUIT
+32 DO SENDMSG
+33 QUIT
+34 ;
F200 ; NEW PERSON file was updated
+1 ; XUHUIX2(1)=NAME
+2 ; XUHUIX2(2)=TERMINATION DATE
+3 ; XUHUIX2(3)=DOB
+4 ; XUHUIX2(4)=SSN
+5 ; XUHUIDA=file 200 ien
+6 IF '$DATA(XUHUIX2)
SET XUHUIERR="1^no XUHUIX2 array"
QUIT
+7 SET IEN=XUHUIDA
+8 ; TERMINATION DATE determines Active/Inactive
+9 SET ACTIVE=$SELECT($GET(XUHUIX2(2))]"":"I",1:"A")
+10 ; get newest values for name, ssn, dob, and termination date
+11 SET NAME=$SELECT($GET(XUHUIX2(1))="":"""""",1:XUHUIX2(1))
+12 SET SSN=$SELECT($GET(XUHUIX2(4))="":"""""",1:XUHUIX2(4))
+13 SET DOB=$$FMTHL7^XLFDT($GET(XUHUIX2(3)))
+14 SET DOB=$SELECT(DOB="":"""""",1:DOB)
+15 SET TERMDATE=$$FMTHL7^XLFDT($GET(XUHUIX2(2)))
+16 SET TERMDATE=$SELECT(TERMDATE="":"""""",1:TERMDATE)
+17 QUIT
+18 ;
FKEY ; PROVIDER key was updated
+1 ; XUHUIDA(1)=file 200 ien
+2 ; XUHUIA= S or K
+3 IF '$GET(XUHUIDA(1))
SET XUHUIERR="1^no IEN"
QUIT
+4 ; ien of provider staff
SET IEN=XUHUIDA(1)
+5 ; XUHUIA determines Active/Inactive
+6 SET ACTIVE=$SELECT($GET(XUHUIA)="K":"I",1:"A")
+7 ; get newest values for name, ssn, dob, and termination date
+8 SET NAME=$$GET1^DIQ(200,IEN_",","NAME")
+9 SET NAME=$SELECT(NAME="":"""""",1:NAME)
+10 SET SSN=$$GET1^DIQ(200,IEN_",","SSN")
+11 SET SSN=$SELECT(SSN="":"""""",1:SSN)
+12 SET DOB=$$GET1^DIQ(200,IEN_",","DOB","I")
+13 SET DOB=$SELECT(DOB="":"""""",1:$$FMTHL7^XLFDT(DOB))
+14 SET TERMDATE=$$GET1^DIQ(200,IEN_",","TERMINATION DATE","I")
+15 SET TERMDATE=$SELECT(TERMDATE="":"""""",1:$$FMTHL7^XLFDT(TERMDATE))
+16 QUIT
+17 ;
SENDMSG ; initialize HL variables
+1 NEW HL,NOW,RESULT
+2 DO INIT^HLFNC2("XUHUI MFN",.HL)
+3 ; error occurred
IF $GET(HL)
Begin DoDot:1
+4 SET XUHUIERR="1^HL init"
End DoDot:1
QUIT
+5 SET HLFS=$GET(HL("FS"))
IF HLFS=""
SET HLFS="^"
+6 SET HLCS=$EXTRACT(HL("ECH"),1)
+7 ;
+8 ; create message
+9 SET NOW=$$FMTHL7^XLFDT($$NOW^XLFDT)
+10 ; MFI^PRA^VA KERNEL^UPD^entered date^^NE
+11 SET HLA("HLS",1)="MFI"_HLFS_"PRA"_HLFS_"VA KERNEL"_HLFS_"UPD"_HLFS_NOW_HLFS_HLFS_"NE"
+12 ; MFE^MUP^^^ien~IEN~NEW PERSON
+13 SET HLA("HLS",2)="MFE"_HLFS_"MUP"_HLFS_HLFS_HLFS_IEN_HLCS_"IEN"_HLCS_"NEW PERSON"
+14 ; STF^ssn~NEW PERSON~SSN^^name^^^dob^active/inactive^^^^^^inactive date
+15 SET HLA("HLS",3)="STF"_HLFS_IEN_HLCS_"IEN"_HLCS_"NEW PERSON"_HLFS_SSN_HLCS_HLCS_HLCS_"SSN"_HLFS_NAME_HLFS_HLFS_HLFS_DOB_HLFS_ACTIVE_HLFS_HLFS_HLFS_HLFS_HLFS_HLFS_TERMDATE
+16 ; generate message
+17 DO GENERATE^HLMA("XUHUI MFN","LM",1,.RESULT,"",.HL)
+18 IF +$PIECE(RESULT,U,2)
Begin DoDot:1
+19 SET XUHUIERR="1^HL Generate"
End DoDot:1
QUIT
+20 QUIT
+21 ;