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

HLOMSG1.m

Go to the documentation of this file.
  1. HLOMSG1 ;ALB/CJM-HL7 - APIs for files 777/778 (CONTINUED) ;02/04/2004
  1. ;;1.6;HEALTH LEVEL SEVEN;**126**;Oct 13, 1995
  1. ;
  1. FINDMSG(MSGID,LIST) ;
  1. ;Given a message id, this function finds the file 778 entries having that message id. The count is returned as the function value. If the message
  1. ;is within a batch, it might be in the subfile. The list of found
  1. ;records is in the format LIST(1)=<IEN>^<SUBIEN>,LIST(2)=<IEN>^<SUBIEN>,
  1. ;etc., where SUBIEN="" if the message is not within a batch.
  1. ;
  1. N COUNT,MSG
  1. K LIST
  1. Q:$G(MSGID)="" 0
  1. S (MSG,COUNT)=0
  1. F S MSG=$O(^HLB("B",MSGID,MSG)) Q:'MSG S COUNT=COUNT+1,LIST(COUNT)=MSG
  1. S MSG=""
  1. F S MSG=$O(^HLB("AE",MSGID,MSG)) Q:MSG="" S COUNT=COUNT+1,LIST(COUNT)=MSG
  1. Q COUNT
  1. ;
  1. ACKTOIEN(MSGID,ACKTO) ;
  1. ;finds the ien of the initial message
  1. ;Input:
  1. ; MSGID - the msg id of the ack message
  1. ; ACKTO - msgid of the original message
  1. ;Output: Function returns "" if not found, otherwise the IEN, or, if the message is in a batch, the <ien>^<subien>
  1. ;
  1. N LIST,RETURN
  1. S RETURN=""
  1. I $$FINDMSG(ACKTO,.LIST) D
  1. .N COUNT
  1. .S COUNT=0
  1. .F S COUNT=$O(LIST(COUNT)) Q:'COUNT D Q:RETURN
  1. ..N IEN,SUBIEN
  1. ..S IEN=$P(LIST(COUNT),"^"),SUBIEN=$P(LIST(COUNT),"^",2)
  1. ..I 'SUBIEN D
  1. ...I $P($G(^HLB(IEN,0)),"^",7)=MSGID S RETURN=IEN
  1. ..E D
  1. ...I $P($G(^HLB(IEN,3,SUBIEN,0)),"^",4)=MSGID S RETURN=IEN_"^"_SUBIEN
  1. Q RETURN
  1. ;
  1. ;
  1. ACKBYIEN(MSGID,ACKBY) ;
  1. ;finds the ien of the ack message
  1. ;Input:
  1. ; MSGID - the msg id of the initial message
  1. ; ACKBY - msgid of the ack message
  1. ;Output: Function returns "" if not found, otherwise the IEN, or, if the message is in a batch, the <ien>^<subien>
  1. ;
  1. N LIST,RETURN
  1. S RETURN=""
  1. I $$FINDMSG(ACKBY,.LIST) D
  1. .N COUNT
  1. .S COUNT=0
  1. .F S COUNT=$O(LIST(COUNT)) Q:'COUNT D Q:RETURN
  1. ..N IEN,SUBIEN
  1. ..S IEN=$P(LIST(COUNT),"^"),SUBIEN=$P(LIST(COUNT),"^",2)
  1. ..I 'SUBIEN D
  1. ...I $P($G(^HLB(IEN,0)),"^",3)=MSGID S RETURN=IEN
  1. ..E D
  1. ...I $P($G(^HLB(IEN,3,SUBIEN,0)),"^",3)=MSGID S RETURN=IEN_"^"_SUBIEN
  1. Q RETURN
  1. ;
  1. GETMSGB(MSG,SUBIEN,SUBMSG) ;
  1. ;gets a message from within a batch
  1. ;Input:
  1. ; MSG (required, pass by reference) from $$GETMSG
  1. ; SUBIEN - the subrecord #
  1. ;Output:
  1. ; SUBMSG (pass by reference) These subscripts are returned:
  1. ; "ACK BY" - if this msg was app acked, the msg id if this msg that was app
  1. ; "ACK TO" - if this msg is an app ack, the msg id of msg being acked
  1. ; "EVENT" - HL7 Event
  1. ; "HDR",1) - fields 1-6 of the header segment
  1. ; "HDR",2) - fields 7-End of the header segment
  1. ; "ID" - Message Control ID
  1. ; "MESSAGE TYPE" - HL7 Message Type
  1. ; "STATUS" - completion status for the individual message
  1. ;
  1. N NODE
  1. S NODE=$G(^HLB(MSG("IEN"),3,SUBIEN,0))
  1. S SUBMSG("ID")=$P(NODE,"^",2)
  1. S SUBMSG("ACK TO")=$P(NODE,"^",3)
  1. S SUBMSG("ACK BY")=$P(NODE,"^",4)
  1. S SUBMSG("STATUS")=$P(NODE,"^",5)
  1. S SUBMSG("HDR",1)=$G(^HLB(MSG("IEN"),3,SUBIEN,1)),SUBMSG("HDR",2)=$G(^(2))
  1. S NODE=$G(^HLA(MSG("BODY"),2,SUBIEN,0))
  1. S SUBMSG("MESSAGE TYPE")=$P(NODE,"^",2)
  1. S SUBMSG("EVENT")=$P(NODE,"^",3)
  1. Q