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

AGMPIBGP.m

Go to the documentation of this file.
AGMPIBGP  ;IHS/SD/TPF - Patient Registration MPI INCOMING MESSAGE PROCESSOR
 ;;7.2;IHS PATIENT REGISTRATION;**1**;JAN 07, 2011
 ;BGP = BACKGROUND PROCESSOR
 Q
TSK ;EP - TASKMAN ENTRY POINT
 L +^AGMPIBGP:5 Q:'$T  ;DO NOT START IF ALREADY RUNNING
 N MSGDATE,MSGTYPE,MSGEVENT,MSGIEN
 S MSGDATE=""  ;DATE MSG PLACED IN HLB
 F  S MSGDATE=$O(^HLB("QUEUE","IN",MSGDATE)) Q:MSGDATE=""  D
 .S MSGTYPE=""
 .F  S MSGTYPE=$O(^HLB("QUEUE","IN",MSGDATE,"RPMS-MPI",MSGTYPE)) Q:MSGTYPE=""  D
 ..S MSGEVENT=""
 ..F  S MSGEVENT=$O(^HLB("QUEUE","IN",MSGDATE,"RPMS-MPI",MSGTYPE,MSGEVENT)) Q:MSGEVENT=""  D
 ...S MSGIEN=""
 ...F  S MSGIEN=$O(^HLB("QUEUE","IN",MSGDATE,"RPMS-MPI",MSGTYPE,MSGEVENT,MSGIEN)) Q:MSGIEN=""  D
 ....;^HLB(4,2)=^20100429083020.78-0700^^ACK~A08^134^T^2.4^^^NE^NE
 ....;ACCEPT TYPE ACKNOWLEDGEMENT
 ....S ACCTYACK=$P($G(^HLB(MSGIEN,2)),U,10)
 ....I ACCTYACK="NE" D MSGCMPLT(MSGIEN) D KILL Q  ;NO NEED TO PROCESS
 ....I ACCTYACK="" D  Q
 .....S ERROR="NO ENTRY FOR THIS MSG IN THE 'IN QUEUE' KILLING X-REF"
 .....D MSGERR("","",MSGIEN,ERROR)
 .....D KILL
 ....I MSGEVENT="A08" D PROC^AGMPIACK(MSGIEN) D KILL Q
 ....I MSGEVENT="A28" D PROC^AGMPIACK(MSGIEN) D KILL Q
 ....I MSGEVENT="Q02" D PROC^AGMPHLVQ(MSGIEN) D KILL Q
 ....I MSGEVENT="M05" D PROC^AGMPHMFN(MSGIEN) D KILL Q
 ....I MSGEVENT="A01" D PROC^AGMPHL01(MSGIEN) D KILL Q
 ....I MSGEVENT="A03" D PROC^AGMPHL03(MSGIEN) D KILL Q
 ....; REMAINING MESSAGE TYPES ENCOUNTERED NOT PROCESSED
 ....S ERROR="ENTRY FOR MESSAGE EVENT '"_MSGEVENT_"' NOT BEING PROCESSED."
 ....D MSGERR("","",MSGIEN,ERROR)
 ....D MSGCMPLT(MSGIEN)
 ....D KILL Q
 L -^AGMPIBGP  ;CLEAR RUNNING FLAG
 Q
KILL ;EP - CLEAR QUE
 K ^HLB("QUEUE","IN",MSGDATE,"RPMS-MPI",MSGTYPE,MSGEVENT,MSGIEN)
 Q
 ;
MSGERR(LOCALID,ACKIEN,HLMSGIEN,ERROR) ;EP - PROCESS ERROR ALERT
 S AGERROR="MSG IEN: "_HLMSGIEN_" :: "_ERROR
 D NOTIF^AGMPIHLO("",AGERROR)
 Q
 ;
MSGCMPLT(MSGID) ;EP - MARK MESSAGE SUCCESSFULLY COMPLETED. SET PURGE INFORMATION
 I MSGID="" Q
 N PDT,NODE
 S NODE=$G(^HLB(MSGID,0))
 I NODE="" Q
 ;IF A PURGE DATE ALREADY EXISTS, KILL THE OLD "AD" ENTRY TO MAINTAIN THE CROSS-REFERENCE'S INTEGRITY
 S PDT=$P(NODE,U,9)
 I PDT'="" K ^HLB("AD","OUT",PDT,MSGID)
 ;SET PURGE DATE TO SEVEN DAYS FROM NOW
 S X="N+7D",%DT="R" D ^%DT S PDT=Y
 S $P(NODE,U,9)=PDT
 ;SET STATUS TO SUCCESS
 S $P(NODE,U,20)="SU"
 S ^HLB(MSGID,0)=NODE
 I PDT]"" S ^HLB("AD","OUT",PDT,MSGID)=""
 Q