source: WorldVistAEHR/trunk/r/HEALTH_LEVEL_SEVEN-HL/HLOMSG1.m@ 1776

Last change on this file since 1776 was 613, checked in by George Lilly, 15 years ago

initial load of WorldVistAEHR

File size: 3.0 KB
Line 
1HLOMSG1 ;ALB/CJM-HL7 - APIs for files 777/778 (CONTINUED) ;02/04/2004
2 ;;1.6;HEALTH LEVEL SEVEN;**126**;Oct 13, 1995
3 ;
4FINDMSG(MSGID,LIST) ;
5 ;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
6 ;is within a batch, it might be in the subfile. The list of found
7 ;records is in the format LIST(1)=<IEN>^<SUBIEN>,LIST(2)=<IEN>^<SUBIEN>,
8 ;etc., where SUBIEN="" if the message is not within a batch.
9 ;
10 N COUNT,MSG
11 K LIST
12 Q:$G(MSGID)="" 0
13 S (MSG,COUNT)=0
14 F S MSG=$O(^HLB("B",MSGID,MSG)) Q:'MSG S COUNT=COUNT+1,LIST(COUNT)=MSG
15 S MSG=""
16 F S MSG=$O(^HLB("AE",MSGID,MSG)) Q:MSG="" S COUNT=COUNT+1,LIST(COUNT)=MSG
17 Q COUNT
18 ;
19ACKTOIEN(MSGID,ACKTO) ;
20 ;finds the ien of the initial message
21 ;Input:
22 ; MSGID - the msg id of the ack message
23 ; ACKTO - msgid of the original message
24 ;Output: Function returns "" if not found, otherwise the IEN, or, if the message is in a batch, the <ien>^<subien>
25 ;
26 N LIST,RETURN
27 S RETURN=""
28 I $$FINDMSG(ACKTO,.LIST) D
29 .N COUNT
30 .S COUNT=0
31 .F S COUNT=$O(LIST(COUNT)) Q:'COUNT D Q:RETURN
32 ..N IEN,SUBIEN
33 ..S IEN=$P(LIST(COUNT),"^"),SUBIEN=$P(LIST(COUNT),"^",2)
34 ..I 'SUBIEN D
35 ...I $P($G(^HLB(IEN,0)),"^",7)=MSGID S RETURN=IEN
36 ..E D
37 ...I $P($G(^HLB(IEN,3,SUBIEN,0)),"^",4)=MSGID S RETURN=IEN_"^"_SUBIEN
38 Q RETURN
39 ;
40 ;
41ACKBYIEN(MSGID,ACKBY) ;
42 ;finds the ien of the ack message
43 ;Input:
44 ; MSGID - the msg id of the initial message
45 ; ACKBY - msgid of the ack message
46 ;Output: Function returns "" if not found, otherwise the IEN, or, if the message is in a batch, the <ien>^<subien>
47 ;
48 N LIST,RETURN
49 S RETURN=""
50 I $$FINDMSG(ACKBY,.LIST) D
51 .N COUNT
52 .S COUNT=0
53 .F S COUNT=$O(LIST(COUNT)) Q:'COUNT D Q:RETURN
54 ..N IEN,SUBIEN
55 ..S IEN=$P(LIST(COUNT),"^"),SUBIEN=$P(LIST(COUNT),"^",2)
56 ..I 'SUBIEN D
57 ...I $P($G(^HLB(IEN,0)),"^",3)=MSGID S RETURN=IEN
58 ..E D
59 ...I $P($G(^HLB(IEN,3,SUBIEN,0)),"^",3)=MSGID S RETURN=IEN_"^"_SUBIEN
60 Q RETURN
61 ;
62GETMSGB(MSG,SUBIEN,SUBMSG) ;
63 ;gets a message from within a batch
64 ;Input:
65 ; MSG (required, pass by reference) from $$GETMSG
66 ; SUBIEN - the subrecord #
67 ;Output:
68 ; SUBMSG (pass by reference) These subscripts are returned:
69 ; "ACK BY" - if this msg was app acked, the msg id if this msg that was app
70 ; "ACK TO" - if this msg is an app ack, the msg id of msg being acked
71 ; "EVENT" - HL7 Event
72 ; "HDR",1) - fields 1-6 of the header segment
73 ; "HDR",2) - fields 7-End of the header segment
74 ; "ID" - Message Control ID
75 ; "MESSAGE TYPE" - HL7 Message Type
76 ; "STATUS" - completion status for the individual message
77 ;
78 N NODE
79 S NODE=$G(^HLB(MSG("IEN"),3,SUBIEN,0))
80 S SUBMSG("ID")=$P(NODE,"^",2)
81 S SUBMSG("ACK TO")=$P(NODE,"^",3)
82 S SUBMSG("ACK BY")=$P(NODE,"^",4)
83 S SUBMSG("STATUS")=$P(NODE,"^",5)
84 S SUBMSG("HDR",1)=$G(^HLB(MSG("IEN"),3,SUBIEN,1)),SUBMSG("HDR",2)=$G(^(2))
85 S NODE=$G(^HLA(MSG("BODY"),2,SUBIEN,0))
86 S SUBMSG("MESSAGE TYPE")=$P(NODE,"^",2)
87 S SUBMSG("EVENT")=$P(NODE,"^",3)
88 Q
Note: See TracBrowser for help on using the repository browser.