- HLOASUB ;IRMFO-ALB/CJM - Subscription Registry ;03/24/2004 14:43
- ;;1.6;HEALTH LEVEL SEVEN;**126**;Oct 13, 1995
- ;
- CREATE(OWNER,DESCRIP,ERROR) ;
- ;This API is used to create a new entry in the HLO Subscription Registry.
- ;Input:
- ; OWNER - (required) The name of the owning application. The name of the owner. It should be prefixed with the package namespace to ensure uniqueness.
- ; DESCRIPTION - (optional) a brief (1 line) description
- ;Output:
- ; Function returns new file 779.4 ien, or 0 if error
- ; ERROR (optional, pass by reference) an message on error
- ;
- N IEN,DATA
- K ERROR
- I '$L($G(OWNER)) S ERROR="OWNER NOT SPECIFIED" Q 0
- L +^HLD(779.4,0):60
- I '$T S ERROR="UNABLE TO LOCK THE HL7 SUBSCRIPTION REGISTRY" Q 0
- S IEN=$O(^HLD(779.4,":"),-1),IEN=IEN+1
- L -^HLD(779.4,0)
- S DATA(.01)=IEN
- S DATA(.02)=OWNER
- S DATA(.03)=$G(DESCRIP)
- Q $$ADD^HLOASUB1(779.4,,.DATA,.ERROR,IEN)
- ;
- ONLIST(IEN,LINKIEN,APPNAME,FAC1,FAC2,FAC3) ;
- ;Determines whether the recipient is already on the subscription list.
- ;Input:
- ; IEN - (required) ien of the subscription list
- ; LINKIEN - ien of the logical link
- ; APPNAME - receiving application
- ; FAC1 - component 1 of the receiving facility
- ; FAC2 - component 2
- ; FAC3 - component 3
- ;Output:
- ; Function returns 0 if not found, otherwise the ien in the subfile
- ;
- Q +$O(^HLD(779.4,IEN,2,"AD",APPNAME,LINKIEN,FAC1_FAC2_FAC3,0))
- ;
- ADD(IEN,WHO,ERROR) ;
- ;Adds a new recipient to the list of recipients for this Subscription Registry Entry.
- ;Input:
- ; IEN- the ien of the entry in the HL7 SUBSCRIPTION REGISTRY file.
- ; WHO (pass by reference) an array containing the information for a single new
- ; recipient to be added to the list. These subscripts are allowed:
- ;
- ; "RECEIVING APPLICATION" - (string, 60 char max, required)
- ;
- ; EXACTLY ONE of these parameters must be provided to identify the Receiving Facility:
- ;
- ; "FACILITY LINK IEN" - ien of the logical link
- ; "FACILITY LINK NAME" - name of the logical link
- ; "INSTITUTION IEN" - ptr to the INSTITUTION file
- ; "STATION NUMBER" - station # with suffix
- ;
- ; EXACTLY ONE of these MAY be provided - optionally - to identify the interface engine to route the message through:
- ;
- ; "IE LINK IEN" - ptr to a logical link for the interface engine
- ; "IE LINK NAME" - name of the logical link for the interface engine
- ;
- ;
- ;Output:
- ; Function returns on success the ien of the recipient on the RECIPIENTS multiple , or 0 on failure
- ; WHO - left undefined when this function returns
- ; ERROR (optional, pass by reference) These error messages may be returned:
- ;SUBSCRIPTION REGISTRY ENTRY NOT FOUND
- ;RECEIVING FACILTY LOGICAL LINK NOT FOUND
- ;RECEIVING APPLICATION NOT FOUND
- ;INTERFACE ENGINE LOGICAL LINK PROVIDED BUT NOT FOUND
- ;FAILED TO ACTIVATE SUBSCRIBER
- ;
- N PARMS,SUBIEN,DATA,DA,OK
- K ERROR
- S OK=0
- D
- .I '$G(IEN) S ERROR="SUBSCRIPITION REGISTRY ENTRY NOT FOUND" Q
- .Q:'$$CHECKWHO^HLOASUB1(.WHO,.PARMS,.ERROR)
- .S SUBIEN=$$ONLIST(IEN,PARMS("LINK IEN"),PARMS("RECEIVING APPLICATION"),PARMS("RECEIVING FACILITY",1),PARMS("RECEIVING FACILITY",2),PARMS("RECEIVING FACILITY",3))
- .I SUBIEN S OK=1 D Q
- ..S DA=SUBIEN,DA(1)=IEN
- ..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"
- .;
- .S DA(1)=IEN
- .S DATA(.01)=PARMS("RECEIVING APPLICATION")
- .S DATA(.02)=PARMS("LINK IEN")
- .S DATA(.03)=PARMS("RECEIVING FACILITY",1)
- .S DATA(.04)=PARMS("RECEIVING FACILITY",2)
- .S DATA(.05)=PARMS("RECEIVING FACILITY",3)
- .S DATA(1.01)=$$NOW^XLFDT
- .S OK=$$ADD^HLOASUB1(779.41,.DA,.DATA,.ERROR)
- K WHO
- Q OK
- ;
- NEXT(IEN,RECIP) ;
- ;gets the next recipient on the list. It ignores recipients
- ;that have a value for the DT/TM DELETED field.
- ;Input:
- ; IEN (required) - the IEN assigned to this subscription
- ; RECIP - if empty, it gets the first recipient on the list, else it uses the value of RECIP("SUBIEN") to find the next recipient
- ;Output:
- ;RECIP(pass by reference, required) - returns the next recipient on the list. These subscripts are returned:
- ; "LINK IEN"
- ; "LINK NAME"
- ; "RECEIVING APPLICATION"
- ; ("RECEIVING FACILITY",1) - Component 1
- ; ("RECEIVING FACILITY",2) - Component 2
- ; ("RECEIVING FACILITY",3) - Component 2
- ; "SUBIEN" - the ien in the multiple, used to find the next on the list.
- ;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 ""
- ;
- N LAST,NEXT,NODE
- S LAST=+$G(RECIP("SUBIEN"))
- Q:(LAST=-1) 0
- Q:'$G(IEN) 0
- S NEXT=$O(^HLD(779.4,IEN,2,"AC",LAST))
- I 'NEXT D Q 0
- .S RECIP("RECEIVING APPLICATION")=""
- .S RECIP("LINK IEN")=""
- .S RECIP("LINK NAME")=""
- .S RECIP("RECEIVING FACILITY",1)=""
- .S RECIP("RECEIVING FACILITY",2)=""
- .S RECIP("RECEIVING FACILITY",3)=""
- .S RECIP("SUBIEN")=-1
- ;
- S RECIP("SUBIEN")=NEXT
- S NODE=$G(^HLD(779.4,IEN,2,NEXT,0))
- S RECIP("LINK IEN")=$P(NODE,"^",2)
- S RECIP("LINK NAME")=$S($P(NODE,"^",2):$P($G(^HLCS(870,$P(NODE,"^",2),0)),"^"),1:"")
- S RECIP("RECEIVING APPLICATION")=$P(NODE,"^")
- S RECIP("RECEIVING FACILITY",1)=$P(NODE,"^",3)
- S RECIP("RECEIVING FACILITY",2)=$P(NODE,"^",4)
- S RECIP("RECEIVING FACILITY",3)=$P(NODE,"^",5)
- Q NEXT
- ;
- END(IEN,WHO) ;will terminate a recipient from the list.The sub-record isn't
- ;deleted, but the DATE/TIME TERMINATED field is entered with the current
- ; date/time
- ;Input:
- ; IEN - the ien of the HL7 Subscription Registry entry (required)
- ; 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.
- ;Output:
- ; Function returns 1 on success, 0 on failure
- ; WHO - left undefined when the function returns
- ;
- N SUBIEN,DATA,DA,OK
- S OK=0
- D
- .S SUBIEN=0
- .Q:'$G(IEN)
- .I $G(WHO("SUBIEN")) D
- ..S SUBIEN=WHO("SUBIEN")
- .E D
- ..N PARMS
- ..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))
- .I 'SUBIEN S OK=1 Q
- .S DA(1)=IEN,DA=SUBIEN
- .S DATA(1.02)=$$NOW^XLFDT
- .S OK=$$UPD^HLOASUB1(779.41,.DA,.DATA)
- K WHO
- Q OK
- ;
- DELETE(IEN) ;Deletes the entry in the HL7 Subscription Registry.
- Q $$DELETE^HLOASUB1(779.4,$G(IEN))
- HLOASUB ;IRMFO-ALB/CJM - Subscription Registry ;03/24/2004 14:43
- +1 ;;1.6;HEALTH LEVEL SEVEN;**126**;Oct 13, 1995
- +2 ;
- CREATE(OWNER,DESCRIP,ERROR) ;
- +1 ;This API is used to create a new entry in the HLO Subscription Registry.
- +2 ;Input:
- +3 ; OWNER - (required) The name of the owning application. The name of the owner. It should be prefixed with the package namespace to ensure uniqueness.
- +4 ; DESCRIPTION - (optional) a brief (1 line) description
- +5 ;Output:
- +6 ; Function returns new file 779.4 ien, or 0 if error
- +7 ; ERROR (optional, pass by reference) an message on error
- +8 ;
- +9 NEW IEN,DATA
- +10 KILL ERROR
- +11 IF '$LENGTH($GET(OWNER))
- SET ERROR="OWNER NOT SPECIFIED"
- QUIT 0
- +12 LOCK +^HLD(779.4,0):60
- +13 IF '$TEST
- SET ERROR="UNABLE TO LOCK THE HL7 SUBSCRIPTION REGISTRY"
- QUIT 0
- +14 SET IEN=$ORDER(^HLD(779.4,":"),-1)
- SET IEN=IEN+1
- +15 LOCK -^HLD(779.4,0)
- +16 SET DATA(.01)=IEN
- +17 SET DATA(.02)=OWNER
- +18 SET DATA(.03)=$GET(DESCRIP)
- +19 QUIT $$ADD^HLOASUB1(779.4,,.DATA,.ERROR,IEN)
- +20 ;
- ONLIST(IEN,LINKIEN,APPNAME,FAC1,FAC2,FAC3) ;
- +1 ;Determines whether the recipient is already on the subscription list.
- +2 ;Input:
- +3 ; IEN - (required) ien of the subscription list
- +4 ; LINKIEN - ien of the logical link
- +5 ; APPNAME - receiving application
- +6 ; FAC1 - component 1 of the receiving facility
- +7 ; FAC2 - component 2
- +8 ; FAC3 - component 3
- +9 ;Output:
- +10 ; Function returns 0 if not found, otherwise the ien in the subfile
- +11 ;
- +12 QUIT +$ORDER(^HLD(779.4,IEN,2,"AD",APPNAME,LINKIEN,FAC1_FAC2_FAC3,0))
- +13 ;
- ADD(IEN,WHO,ERROR) ;
- +1 ;Adds a new recipient to the list of recipients for this Subscription Registry Entry.
- +2 ;Input:
- +3 ; IEN- the ien of the entry in the HL7 SUBSCRIPTION REGISTRY file.
- +4 ; WHO (pass by reference) an array containing the information for a single new
- +5 ; recipient to be added to the list. These subscripts are allowed:
- +6 ;
- +7 ; "RECEIVING APPLICATION" - (string, 60 char max, required)
- +8 ;
- +9 ; EXACTLY ONE of these parameters must be provided to identify the Receiving Facility:
- +10 ;
- +11 ; "FACILITY LINK IEN" - ien of the logical link
- +12 ; "FACILITY LINK NAME" - name of the logical link
- +13 ; "INSTITUTION IEN" - ptr to the INSTITUTION file
- +14 ; "STATION NUMBER" - station # with suffix
- +15 ;
- +16 ; EXACTLY ONE of these MAY be provided - optionally - to identify the interface engine to route the message through:
- +17 ;
- +18 ; "IE LINK IEN" - ptr to a logical link for the interface engine
- +19 ; "IE LINK NAME" - name of the logical link for the interface engine
- +20 ;
- +21 ;
- +22 ;Output:
- +23 ; Function returns on success the ien of the recipient on the RECIPIENTS multiple , or 0 on failure
- +24 ; WHO - left undefined when this function returns
- +25 ; ERROR (optional, pass by reference) These error messages may be returned:
- +26 ;SUBSCRIPTION REGISTRY ENTRY NOT FOUND
- +27 ;RECEIVING FACILTY LOGICAL LINK NOT FOUND
- +28 ;RECEIVING APPLICATION NOT FOUND
- +29 ;INTERFACE ENGINE LOGICAL LINK PROVIDED BUT NOT FOUND
- +30 ;FAILED TO ACTIVATE SUBSCRIBER
- +31 ;
- +32 NEW PARMS,SUBIEN,DATA,DA,OK
- +33 KILL ERROR
- +34 SET OK=0
- +35 Begin DoDot:1
- +36 IF '$GET(IEN)
- SET ERROR="SUBSCRIPITION REGISTRY ENTRY NOT FOUND"
- QUIT
- +37 IF '$$CHECKWHO^HLOASUB1(.WHO,.PARMS,.ERROR)
- QUIT
- +38 SET SUBIEN=$$ONLIST(IEN,PARMS("LINK IEN"),PARMS("RECEIVING APPLICATION"),PARMS("RECEIVING FACILITY",1),PARMS("RECEIVING FACILITY",2),PARMS("RECEIVING FACILITY",3))
- +39 IF SUBIEN
- SET OK=1
- Begin DoDot:2
- +40 SET DA=SUBIEN
- SET DA(1)=IEN
- +41 IF $PIECE(^HLD(779.4,IEN,2,SUBIEN,1),"^",2)
- SET DATA(1.01)=$$NOW^XLFDT
- SET DATA(1.02)=""
- SET OK=$$UPD^HLOASUB1(779.41,.DA,.DATA)
- IF 'OK
- SET ERROR="FAILED TO ACTIVATE SUBSCRIBER"
- End DoDot:2
- QUIT
- +42 ;
- +43 SET DA(1)=IEN
- +44 SET DATA(.01)=PARMS("RECEIVING APPLICATION")
- +45 SET DATA(.02)=PARMS("LINK IEN")
- +46 SET DATA(.03)=PARMS("RECEIVING FACILITY",1)
- +47 SET DATA(.04)=PARMS("RECEIVING FACILITY",2)
- +48 SET DATA(.05)=PARMS("RECEIVING FACILITY",3)
- +49 SET DATA(1.01)=$$NOW^XLFDT
- +50 SET OK=$$ADD^HLOASUB1(779.41,.DA,.DATA,.ERROR)
- End DoDot:1
- +51 KILL WHO
- +52 QUIT OK
- +53 ;
- NEXT(IEN,RECIP) ;
- +1 ;gets the next recipient on the list. It ignores recipients
- +2 ;that have a value for the DT/TM DELETED field.
- +3 ;Input:
- +4 ; IEN (required) - the IEN assigned to this subscription
- +5 ; RECIP - if empty, it gets the first recipient on the list, else it uses the value of RECIP("SUBIEN") to find the next recipient
- +6 ;Output:
- +7 ;RECIP(pass by reference, required) - returns the next recipient on the list. These subscripts are returned:
- +8 ; "LINK IEN"
- +9 ; "LINK NAME"
- +10 ; "RECEIVING APPLICATION"
- +11 ; ("RECEIVING FACILITY",1) - Component 1
- +12 ; ("RECEIVING FACILITY",2) - Component 2
- +13 ; ("RECEIVING FACILITY",3) - Component 2
- +14 ; "SUBIEN" - the ien in the multiple, used to find the next on the list.
- +15 ;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 ""
- +16 ;
- +17 NEW LAST,NEXT,NODE
- +18 SET LAST=+$GET(RECIP("SUBIEN"))
- +19 IF (LAST=-1)
- QUIT 0
- +20 IF '$GET(IEN)
- QUIT 0
- +21 SET NEXT=$ORDER(^HLD(779.4,IEN,2,"AC",LAST))
- +22 IF 'NEXT
- Begin DoDot:1
- +23 SET RECIP("RECEIVING APPLICATION")=""
- +24 SET RECIP("LINK IEN")=""
- +25 SET RECIP("LINK NAME")=""
- +26 SET RECIP("RECEIVING FACILITY",1)=""
- +27 SET RECIP("RECEIVING FACILITY",2)=""
- +28 SET RECIP("RECEIVING FACILITY",3)=""
- +29 SET RECIP("SUBIEN")=-1
- End DoDot:1
- QUIT 0
- +30 ;
- +31 SET RECIP("SUBIEN")=NEXT
- +32 SET NODE=$GET(^HLD(779.4,IEN,2,NEXT,0))
- +33 SET RECIP("LINK IEN")=$PIECE(NODE,"^",2)
- +34 SET RECIP("LINK NAME")=$SELECT($PIECE(NODE,"^",2):$PIECE($GET(^HLCS(870,$PIECE(NODE,"^",2),0)),"^"),1:"")
- +35 SET RECIP("RECEIVING APPLICATION")=$PIECE(NODE,"^")
- +36 SET RECIP("RECEIVING FACILITY",1)=$PIECE(NODE,"^",3)
- +37 SET RECIP("RECEIVING FACILITY",2)=$PIECE(NODE,"^",4)
- +38 SET RECIP("RECEIVING FACILITY",3)=$PIECE(NODE,"^",5)
- +39 QUIT NEXT
- +40 ;
- END(IEN,WHO) ;will terminate a recipient from the list.The sub-record isn't
- +1 ;deleted, but the DATE/TIME TERMINATED field is entered with the current
- +2 ; date/time
- +3 ;Input:
- +4 ; IEN - the ien of the HL7 Subscription Registry entry (required)
- +5 ; 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.
- +6 ;Output:
- +7 ; Function returns 1 on success, 0 on failure
- +8 ; WHO - left undefined when the function returns
- +9 ;
- +10 NEW SUBIEN,DATA,DA,OK
- +11 SET OK=0
- +12 Begin DoDot:1
- +13 SET SUBIEN=0
- +14 IF '$GET(IEN)
- QUIT
- +15 IF $GET(WHO("SUBIEN"))
- Begin DoDot:2
- +16 SET SUBIEN=WHO("SUBIEN")
- End DoDot:2
- +17 IF '$TEST
- Begin DoDot:2
- +18 NEW PARMS
- +19 IF $$CHECKWHO^HLOASUB1(.WHO,.PARMS)
- SET SUBIEN=$$ONLIST(IEN,PARMS("LINK IEN"),PARMS("RECEIVING APPLICATION"),PARMS("RECEIVING FACILITY",1),PARMS("RECEIVING FACILITY",2),PARMS("RECEIVING FACILITY",3))
- End DoDot:2
- +20 IF 'SUBIEN
- SET OK=1
- QUIT
- +21 SET DA(1)=IEN
- SET DA=SUBIEN
- +22 SET DATA(1.02)=$$NOW^XLFDT
- +23 SET OK=$$UPD^HLOASUB1(779.41,.DA,.DATA)
- End DoDot:1
- +24 KILL WHO
- +25 QUIT OK
- +26 ;
- DELETE(IEN) ;Deletes the entry in the HL7 Subscription Registry.
- +1 QUIT $$DELETE^HLOASUB1(779.4,$GET(IEN))