source: FOIAVistA/trunk/r/HEALTH_LEVEL_SEVEN-HL/HLOASUB.m@ 1607

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

initial load of FOIAVistA 6/30/08 version

File size: 6.2 KB
Line 
1HLOASUB ;IRMFO-ALB/CJM - Subscription Registry ;03/24/2004 14:43
2 ;;1.6;HEALTH LEVEL SEVEN;**126**;Oct 13, 1995
3 ;
4CREATE(OWNER,DESCRIP,ERROR) ;
5 ;This API is used to create a new entry in the HLO Subscription Registry.
6 ;Input:
7 ; OWNER - (required) The name of the owning application. The name of the owner. It should be prefixed with the package namespace to ensure uniqueness.
8 ; DESCRIPTION - (optional) a brief (1 line) description
9 ;Output:
10 ; Function returns new file 779.4 ien, or 0 if error
11 ; ERROR (optional, pass by reference) an message on error
12 ;
13 N IEN,DATA
14 K ERROR
15 I '$L($G(OWNER)) S ERROR="OWNER NOT SPECIFIED" Q 0
16 L +^HLD(779.4,0):60
17 I '$T S ERROR="UNABLE TO LOCK THE HL7 SUBSCRIPTION REGISTRY" Q 0
18 S IEN=$O(^HLD(779.4,":"),-1),IEN=IEN+1
19 L -^HLD(779.4,0)
20 S DATA(.01)=IEN
21 S DATA(.02)=OWNER
22 S DATA(.03)=$G(DESCRIP)
23 Q $$ADD^HLOASUB1(779.4,,.DATA,.ERROR,IEN)
24 ;
25ONLIST(IEN,LINKIEN,APPNAME,FAC1,FAC2,FAC3) ;
26 ;Determines whether the recipient is already on the subscription list.
27 ;Input:
28 ; IEN - (required) ien of the subscription list
29 ; LINKIEN - ien of the logical link
30 ; APPNAME - receiving application
31 ; FAC1 - component 1 of the receiving facility
32 ; FAC2 - component 2
33 ; FAC3 - component 3
34 ;Output:
35 ; Function returns 0 if not found, otherwise the ien in the subfile
36 ;
37 Q +$O(^HLD(779.4,IEN,2,"AD",APPNAME,LINKIEN,FAC1_FAC2_FAC3,0))
38 ;
39ADD(IEN,WHO,ERROR) ;
40 ;Adds a new recipient to the list of recipients for this Subscription Registry Entry.
41 ;Input:
42 ; IEN- the ien of the entry in the HL7 SUBSCRIPTION REGISTRY file.
43 ; WHO (pass by reference) an array containing the information for a single new
44 ; recipient to be added to the list. These subscripts are allowed:
45 ;
46 ; "RECEIVING APPLICATION" - (string, 60 char max, required)
47 ;
48 ; EXACTLY ONE of these parameters must be provided to identify the Receiving Facility:
49 ;
50 ; "FACILITY LINK IEN" - ien of the logical link
51 ; "FACILITY LINK NAME" - name of the logical link
52 ; "INSTITUTION IEN" - ptr to the INSTITUTION file
53 ; "STATION NUMBER" - station # with suffix
54 ;
55 ; EXACTLY ONE of these MAY be provided - optionally - to identify the interface engine to route the message through:
56 ;
57 ; "IE LINK IEN" - ptr to a logical link for the interface engine
58 ; "IE LINK NAME" - name of the logical link for the interface engine
59 ;
60 ;
61 ;Output:
62 ; Function returns on success the ien of the recipient on the RECIPIENTS multiple , or 0 on failure
63 ; WHO - left undefined when this function returns
64 ; ERROR (optional, pass by reference) These error messages may be returned:
65 ;SUBSCRIPTION REGISTRY ENTRY NOT FOUND
66 ;RECEIVING FACILTY LOGICAL LINK NOT FOUND
67 ;RECEIVING APPLICATION NOT FOUND
68 ;INTERFACE ENGINE LOGICAL LINK PROVIDED BUT NOT FOUND
69 ;FAILED TO ACTIVATE SUBSCRIBER
70 ;
71 N PARMS,SUBIEN,DATA,DA,OK
72 K ERROR
73 S OK=0
74 D
75 .I '$G(IEN) S ERROR="SUBSCRIPITION REGISTRY ENTRY NOT FOUND" Q
76 .Q:'$$CHECKWHO^HLOASUB1(.WHO,.PARMS,.ERROR)
77 .S SUBIEN=$$ONLIST(IEN,PARMS("LINK IEN"),PARMS("RECEIVING APPLICATION"),PARMS("RECEIVING FACILITY",1),PARMS("RECEIVING FACILITY",2),PARMS("RECEIVING FACILITY",3))
78 .I SUBIEN S OK=1 D Q
79 ..S DA=SUBIEN,DA(1)=IEN
80 ..I $P(^HLD(779.4,IEN,2,SUBIEN,1),"^",2) S DATA(1.01)=$$NOW^XLFDT,DATA(1.02)="" S OK=$$UPD^HLOASUB1(779.41,.DA,.DATA) I 'OK S ERROR="FAILED TO ACTIVATE SUBSCRIBER"
81 .;
82 .S DA(1)=IEN
83 .S DATA(.01)=PARMS("RECEIVING APPLICATION")
84 .S DATA(.02)=PARMS("LINK IEN")
85 .S DATA(.03)=PARMS("RECEIVING FACILITY",1)
86 .S DATA(.04)=PARMS("RECEIVING FACILITY",2)
87 .S DATA(.05)=PARMS("RECEIVING FACILITY",3)
88 .S DATA(1.01)=$$NOW^XLFDT
89 .S OK=$$ADD^HLOASUB1(779.41,.DA,.DATA,.ERROR)
90 K WHO
91 Q OK
92 ;
93NEXT(IEN,RECIP) ;
94 ;gets the next recipient on the list. It ignores recipients
95 ;that have a value for the DT/TM DELETED field.
96 ;Input:
97 ; IEN (required) - the IEN assigned to this subscription
98 ; RECIP - if empty, it gets the first recipient on the list, else it uses the value of RECIP("SUBIEN") to find the next recipient
99 ;Output:
100 ;RECIP(pass by reference, required) - returns the next recipient on the list. These subscripts are returned:
101 ; "LINK IEN"
102 ; "LINK NAME"
103 ; "RECEIVING APPLICATION"
104 ; ("RECEIVING FACILITY",1) - Component 1
105 ; ("RECEIVING FACILITY",2) - Component 2
106 ; ("RECEIVING FACILITY",3) - Component 2
107 ; "SUBIEN" - the ien in the multiple, used to find the next on the list.
108 ;Function Value - IEN in the subfile on success, 0 if there are no more recipients found on the list (in which case, set "SUBIEN"=-1, set all other subscripts to ""
109 ;
110 N LAST,NEXT,NODE
111 S LAST=+$G(RECIP("SUBIEN"))
112 Q:(LAST=-1) 0
113 Q:'$G(IEN) 0
114 S NEXT=$O(^HLD(779.4,IEN,2,"AC",LAST))
115 I 'NEXT D Q 0
116 .S RECIP("RECEIVING APPLICATION")=""
117 .S RECIP("LINK IEN")=""
118 .S RECIP("LINK NAME")=""
119 .S RECIP("RECEIVING FACILITY",1)=""
120 .S RECIP("RECEIVING FACILITY",2)=""
121 .S RECIP("RECEIVING FACILITY",3)=""
122 .S RECIP("SUBIEN")=-1
123 ;
124 S RECIP("SUBIEN")=NEXT
125 S NODE=$G(^HLD(779.4,IEN,2,NEXT,0))
126 S RECIP("LINK IEN")=$P(NODE,"^",2)
127 S RECIP("LINK NAME")=$S($P(NODE,"^",2):$P($G(^HLCS(870,$P(NODE,"^",2),0)),"^"),1:"")
128 S RECIP("RECEIVING APPLICATION")=$P(NODE,"^")
129 S RECIP("RECEIVING FACILITY",1)=$P(NODE,"^",3)
130 S RECIP("RECEIVING FACILITY",2)=$P(NODE,"^",4)
131 S RECIP("RECEIVING FACILITY",3)=$P(NODE,"^",5)
132 Q NEXT
133 ;
134END(IEN,WHO) ;will terminate a recipient from the list.The sub-record isn't
135 ;deleted, but the DATE/TIME TERMINATED field is entered with the current
136 ; date/time
137 ;Input:
138 ; IEN - the ien of the HL7 Subscription Registry entry (required)
139 ; WHO - (required, pass by reference) If WHO("SUBIEN") is defined, then it should be the ien of the sub-record to be terminated. Otherwise, set the parameters as per $$ADD.
140 ;Output:
141 ; Function returns 1 on success, 0 on failure
142 ; WHO - left undefined when the function returns
143 ;
144 N SUBIEN,DATA,DA,OK
145 S OK=0
146 D
147 .S SUBIEN=0
148 .Q:'$G(IEN)
149 .I $G(WHO("SUBIEN")) D
150 ..S SUBIEN=WHO("SUBIEN")
151 .E D
152 ..N PARMS
153 ..S:$$CHECKWHO^HLOASUB1(.WHO,.PARMS) SUBIEN=$$ONLIST(IEN,PARMS("LINK IEN"),PARMS("RECEIVING APPLICATION"),PARMS("RECEIVING FACILITY",1),PARMS("RECEIVING FACILITY",2),PARMS("RECEIVING FACILITY",3))
154 .I 'SUBIEN S OK=1 Q
155 .S DA(1)=IEN,DA=SUBIEN
156 .S DATA(1.02)=$$NOW^XLFDT
157 .S OK=$$UPD^HLOASUB1(779.41,.DA,.DATA)
158 K WHO
159 Q OK
160 ;
161DELETE(IEN) ;Deletes the entry in the HL7 Subscription Registry.
162 Q $$DELETE^HLOASUB1(779.4,$G(IEN))
Note: See TracBrowser for help on using the repository browser.