AGMPHL01 ; IHS/SD/TPF - MPI ADT-A01 ACK PROCESSOR FOR HLO ; 12/15/2007
;;7.2;IHS PATIENT REGISTRATION;**1,6**;JAN 07, 2011;Build 23
Q
;
PROC(HLMSGIEN) ;EP - CALLED FROM AGMPIBGP
N DATA,HLMSTATE,MSGID,MSGSEG,ICNEUID,RETCODE,NEXTSEG,RESEND,ORGHLMSG
D PARSE(.DATA,HLMSGIEN,.HLMSTATE)
D MSGCMPLT^AGMPIBGP(HLMSGIEN) ;SET THE ACK SUCCESSFUL
;NOW DO THE ORIGINATING MESSAGE
S ORGHLMSG=HLMSGIEN ;PRESERVE HLMSGIEN THAT WAS PASSED
S HLMSGIEN=$P($G(DATA(1,3,1,1,1))," ",2) ;MSG ID OF THE MSG THIS ACK IS RESPONDING TO
I HLMSGIEN="" D Q
.S ERROR="NO ORIGINATING MSG ID FOUND FOR HLMSGIEN '"_ORGHLMSG_"'"
.D NOTIF^AGMPIHLO(ORGHLMSG,ERROR)
S HLMSGIEN=$P($G(^HLB(HLMSGIEN,0)),U,2) ;GET THE CORRECT ORIGINATING MESSAGE
D MSGCMPLT^AGMPIBGP(HLMSGIEN)
Q
PARSE(DATA,MIEN,HLMSTATE) ;EP
N SEG,CNT
Q:'$$STARTMSG^HLOPRS(.HLMSTATE,MIEN)
M DATA("HDR")=HLMSTATE("HDR")
S CNT=0
F Q:'$$NEXTSEG^HLOPRS(.HLMSTATE,.SEG) D
.S CNT=CNT+1
.M DATA(CNT)=SEG
Q
;THIS CALL HANDLES CHECKINS (A01) AND CHECKOUTS (A03)
CREATE(SDAMEVT,DFN,SDT,SUCCESS) ;EP - CREATE AND PLACE IN OUTGOING QUEUE
;CALLED BY PROTOCOL 'AGMP MPI CHECKIN CHECKOUT' WHICH SUBSCRIBES
;TO PROTOCOL 'BSDAM APPOINTMENT EVENTS' FOR CHECK INS AND CHECK OUTS
;DFN
;SDT = APPOINTMENT DATE
;SDAMEVT = EVENT
; 1 = make appt
; 2 = cancel appt
; 3 = no-show
; 4 = check-in
; 5 = check-out
;
Q:(U_4_U_5_U)'[(U_SDAMEVT_U) ;ONLY CARE ABOUT CHECKINS AND CHECKOUTS
;
I $$DEMOPAT^AGMPHLU($G(DFN)) Q ; 9/13/2017 - GCD - CR 7713 - Don't upload demo patients.
;
S SDT=$$CONDT^AGMPHLU(SDT) ;CONVERT DATE FOR MPI
I SDAMEVT=4 D CREATMSG^AGMPIHLO(DFN,"A01",,.SUCCESS) I 1 ;I 1 USED TO RESTORE THE VALUE OF $T AFTER THE CALL
E D CREATMSG^AGMPIHLO(DFN,"A03",,.SUCCESS)
I 'SUCCESS D
.S AGERROR="MPI DFN="_DFN_" :: "_"ERROR WHEN CREATING "_$S(SDAMEVT=4:"A01",1:"A03")
.D NOTIF^AGMPIHLO(DFN,AGERROR)
Q
AGMPHL01 ; IHS/SD/TPF - MPI ADT-A01 ACK PROCESSOR FOR HLO ; 12/15/2007
+1 ;;7.2;IHS PATIENT REGISTRATION;**1,6**;JAN 07, 2011;Build 23
+2 QUIT
+3 ;
PROC(HLMSGIEN) ;EP - CALLED FROM AGMPIBGP
+1 NEW DATA,HLMSTATE,MSGID,MSGSEG,ICNEUID,RETCODE,NEXTSEG,RESEND,ORGHLMSG
+2 DO PARSE(.DATA,HLMSGIEN,.HLMSTATE)
+3 ;SET THE ACK SUCCESSFUL
DO MSGCMPLT^AGMPIBGP(HLMSGIEN)
+4 ;NOW DO THE ORIGINATING MESSAGE
+5 ;PRESERVE HLMSGIEN THAT WAS PASSED
SET ORGHLMSG=HLMSGIEN
+6 ;MSG ID OF THE MSG THIS ACK IS RESPONDING TO
SET HLMSGIEN=$PIECE($GET(DATA(1,3,1,1,1))," ",2)
+7 IF HLMSGIEN=""
Begin DoDot:1
+8 SET ERROR="NO ORIGINATING MSG ID FOUND FOR HLMSGIEN '"_ORGHLMSG_"'"
+9 DO NOTIF^AGMPIHLO(ORGHLMSG,ERROR)
End DoDot:1
QUIT
+10 ;GET THE CORRECT ORIGINATING MESSAGE
SET HLMSGIEN=$PIECE($GET(^HLB(HLMSGIEN,0)),U,2)
+11 DO MSGCMPLT^AGMPIBGP(HLMSGIEN)
+12 QUIT
PARSE(DATA,MIEN,HLMSTATE) ;EP
+1 NEW SEG,CNT
+2 IF '$$STARTMSG^HLOPRS(.HLMSTATE,MIEN)
QUIT
+3 MERGE DATA("HDR")=HLMSTATE("HDR")
+4 SET CNT=0
+5 FOR
IF '$$NEXTSEG^HLOPRS(.HLMSTATE,.SEG)
QUIT
Begin DoDot:1
+6 SET CNT=CNT+1
+7 MERGE DATA(CNT)=SEG
End DoDot:1
+8 QUIT
+9 ;THIS CALL HANDLES CHECKINS (A01) AND CHECKOUTS (A03)
CREATE(SDAMEVT,DFN,SDT,SUCCESS) ;EP - CREATE AND PLACE IN OUTGOING QUEUE
+1 ;CALLED BY PROTOCOL 'AGMP MPI CHECKIN CHECKOUT' WHICH SUBSCRIBES
+2 ;TO PROTOCOL 'BSDAM APPOINTMENT EVENTS' FOR CHECK INS AND CHECK OUTS
+3 ;DFN
+4 ;SDT = APPOINTMENT DATE
+5 ;SDAMEVT = EVENT
+6 ; 1 = make appt
+7 ; 2 = cancel appt
+8 ; 3 = no-show
+9 ; 4 = check-in
+10 ; 5 = check-out
+11 ;
+12 ;ONLY CARE ABOUT CHECKINS AND CHECKOUTS
IF (U_4_U_5_U)'[(U_SDAMEVT_U)
QUIT
+13 ;
+14 ; 9/13/2017 - GCD - CR 7713 - Don't upload demo patients.
IF $$DEMOPAT^AGMPHLU($GET(DFN))
QUIT
+15 ;
+16 ;CONVERT DATE FOR MPI
SET SDT=$$CONDT^AGMPHLU(SDT)
+17 ;I 1 USED TO RESTORE THE VALUE OF $T AFTER THE CALL
IF SDAMEVT=4
DO CREATMSG^AGMPIHLO(DFN,"A01",,.SUCCESS)
IF 1
+18 IF '$TEST
DO CREATMSG^AGMPIHLO(DFN,"A03",,.SUCCESS)
+19 IF 'SUCCESS
Begin DoDot:1
+20 SET AGERROR="MPI DFN="_DFN_" :: "_"ERROR WHEN CREATING "_$SELECT(SDAMEVT=4:"A01",1:"A03")
+21 DO NOTIF^AGMPIHLO(DFN,AGERROR)
End DoDot:1
+22 QUIT