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

HLOASUB.m

Go to the documentation of this file.
  1. HLOASUB ;IRMFO-ALB/CJM - Subscription Registry ;03/24/2004 14:43
  1. ;;1.6;HEALTH LEVEL SEVEN;**126**;Oct 13, 1995
  1. ;
  1. CREATE(OWNER,DESCRIP,ERROR) ;
  1. ;This API is used to create a new entry in the HLO Subscription Registry.
  1. ;Input:
  1. ; OWNER - (required) The name of the owning application. The name of the owner. It should be prefixed with the package namespace to ensure uniqueness.
  1. ; DESCRIPTION - (optional) a brief (1 line) description
  1. ;Output:
  1. ; Function returns new file 779.4 ien, or 0 if error
  1. ; ERROR (optional, pass by reference) an message on error
  1. ;
  1. N IEN,DATA
  1. K ERROR
  1. I '$L($G(OWNER)) S ERROR="OWNER NOT SPECIFIED" Q 0
  1. L +^HLD(779.4,0):60
  1. I '$T S ERROR="UNABLE TO LOCK THE HL7 SUBSCRIPTION REGISTRY" Q 0
  1. S IEN=$O(^HLD(779.4,":"),-1),IEN=IEN+1
  1. L -^HLD(779.4,0)
  1. S DATA(.01)=IEN
  1. S DATA(.02)=OWNER
  1. S DATA(.03)=$G(DESCRIP)
  1. Q $$ADD^HLOASUB1(779.4,,.DATA,.ERROR,IEN)
  1. ;
  1. ONLIST(IEN,LINKIEN,APPNAME,FAC1,FAC2,FAC3) ;
  1. ;Determines whether the recipient is already on the subscription list.
  1. ;Input:
  1. ; IEN - (required) ien of the subscription list
  1. ; LINKIEN - ien of the logical link
  1. ; APPNAME - receiving application
  1. ; FAC1 - component 1 of the receiving facility
  1. ; FAC2 - component 2
  1. ; FAC3 - component 3
  1. ;Output:
  1. ; Function returns 0 if not found, otherwise the ien in the subfile
  1. ;
  1. Q +$O(^HLD(779.4,IEN,2,"AD",APPNAME,LINKIEN,FAC1_FAC2_FAC3,0))
  1. ;
  1. ADD(IEN,WHO,ERROR) ;
  1. ;Adds a new recipient to the list of recipients for this Subscription Registry Entry.
  1. ;Input:
  1. ; IEN- the ien of the entry in the HL7 SUBSCRIPTION REGISTRY file.
  1. ; WHO (pass by reference) an array containing the information for a single new
  1. ; recipient to be added to the list. These subscripts are allowed:
  1. ;
  1. ; "RECEIVING APPLICATION" - (string, 60 char max, required)
  1. ;
  1. ; EXACTLY ONE of these parameters must be provided to identify the Receiving Facility:
  1. ;
  1. ; "FACILITY LINK IEN" - ien of the logical link
  1. ; "FACILITY LINK NAME" - name of the logical link
  1. ; "INSTITUTION IEN" - ptr to the INSTITUTION file
  1. ; "STATION NUMBER" - station # with suffix
  1. ;
  1. ; EXACTLY ONE of these MAY be provided - optionally - to identify the interface engine to route the message through:
  1. ;
  1. ; "IE LINK IEN" - ptr to a logical link for the interface engine
  1. ; "IE LINK NAME" - name of the logical link for the interface engine
  1. ;
  1. ;
  1. ;Output:
  1. ; Function returns on success the ien of the recipient on the RECIPIENTS multiple , or 0 on failure
  1. ; WHO - left undefined when this function returns
  1. ; ERROR (optional, pass by reference) These error messages may be returned:
  1. ;SUBSCRIPTION REGISTRY ENTRY NOT FOUND
  1. ;RECEIVING FACILTY LOGICAL LINK NOT FOUND
  1. ;RECEIVING APPLICATION NOT FOUND
  1. ;INTERFACE ENGINE LOGICAL LINK PROVIDED BUT NOT FOUND
  1. ;FAILED TO ACTIVATE SUBSCRIBER
  1. ;
  1. N PARMS,SUBIEN,DATA,DA,OK
  1. K ERROR
  1. S OK=0
  1. D
  1. .I '$G(IEN) S ERROR="SUBSCRIPITION REGISTRY ENTRY NOT FOUND" Q
  1. .Q:'$$CHECKWHO^HLOASUB1(.WHO,.PARMS,.ERROR)
  1. .S SUBIEN=$$ONLIST(IEN,PARMS("LINK IEN"),PARMS("RECEIVING APPLICATION"),PARMS("RECEIVING FACILITY",1),PARMS("RECEIVING FACILITY",2),PARMS("RECEIVING FACILITY",3))
  1. .I SUBIEN S OK=1 D Q
  1. ..S DA=SUBIEN,DA(1)=IEN
  1. ..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"
  1. .;
  1. .S DA(1)=IEN
  1. .S DATA(.01)=PARMS("RECEIVING APPLICATION")
  1. .S DATA(.02)=PARMS("LINK IEN")
  1. .S DATA(.03)=PARMS("RECEIVING FACILITY",1)
  1. .S DATA(.04)=PARMS("RECEIVING FACILITY",2)
  1. .S DATA(.05)=PARMS("RECEIVING FACILITY",3)
  1. .S DATA(1.01)=$$NOW^XLFDT
  1. .S OK=$$ADD^HLOASUB1(779.41,.DA,.DATA,.ERROR)
  1. K WHO
  1. Q OK
  1. ;
  1. NEXT(IEN,RECIP) ;
  1. ;gets the next recipient on the list. It ignores recipients
  1. ;that have a value for the DT/TM DELETED field.
  1. ;Input:
  1. ; IEN (required) - the IEN assigned to this subscription
  1. ; RECIP - if empty, it gets the first recipient on the list, else it uses the value of RECIP("SUBIEN") to find the next recipient
  1. ;Output:
  1. ;RECIP(pass by reference, required) - returns the next recipient on the list. These subscripts are returned:
  1. ; "LINK IEN"
  1. ; "LINK NAME"
  1. ; "RECEIVING APPLICATION"
  1. ; ("RECEIVING FACILITY",1) - Component 1
  1. ; ("RECEIVING FACILITY",2) - Component 2
  1. ; ("RECEIVING FACILITY",3) - Component 2
  1. ; "SUBIEN" - the ien in the multiple, used to find the next on the list.
  1. ;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 ""
  1. ;
  1. N LAST,NEXT,NODE
  1. S LAST=+$G(RECIP("SUBIEN"))
  1. Q:(LAST=-1) 0
  1. Q:'$G(IEN) 0
  1. S NEXT=$O(^HLD(779.4,IEN,2,"AC",LAST))
  1. I 'NEXT D Q 0
  1. .S RECIP("RECEIVING APPLICATION")=""
  1. .S RECIP("LINK IEN")=""
  1. .S RECIP("LINK NAME")=""
  1. .S RECIP("RECEIVING FACILITY",1)=""
  1. .S RECIP("RECEIVING FACILITY",2)=""
  1. .S RECIP("RECEIVING FACILITY",3)=""
  1. .S RECIP("SUBIEN")=-1
  1. ;
  1. S RECIP("SUBIEN")=NEXT
  1. S NODE=$G(^HLD(779.4,IEN,2,NEXT,0))
  1. S RECIP("LINK IEN")=$P(NODE,"^",2)
  1. S RECIP("LINK NAME")=$S($P(NODE,"^",2):$P($G(^HLCS(870,$P(NODE,"^",2),0)),"^"),1:"")
  1. S RECIP("RECEIVING APPLICATION")=$P(NODE,"^")
  1. S RECIP("RECEIVING FACILITY",1)=$P(NODE,"^",3)
  1. S RECIP("RECEIVING FACILITY",2)=$P(NODE,"^",4)
  1. S RECIP("RECEIVING FACILITY",3)=$P(NODE,"^",5)
  1. Q NEXT
  1. ;
  1. 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
  1. ; date/time
  1. ;Input:
  1. ; IEN - the ien of the HL7 Subscription Registry entry (required)
  1. ; 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.
  1. ;Output:
  1. ; Function returns 1 on success, 0 on failure
  1. ; WHO - left undefined when the function returns
  1. ;
  1. N SUBIEN,DATA,DA,OK
  1. S OK=0
  1. D
  1. .S SUBIEN=0
  1. .Q:'$G(IEN)
  1. .I $G(WHO("SUBIEN")) D
  1. ..S SUBIEN=WHO("SUBIEN")
  1. .E D
  1. ..N PARMS
  1. ..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))
  1. .I 'SUBIEN S OK=1 Q
  1. .S DA(1)=IEN,DA=SUBIEN
  1. .S DATA(1.02)=$$NOW^XLFDT
  1. .S OK=$$UPD^HLOASUB1(779.41,.DA,.DATA)
  1. K WHO
  1. Q OK
  1. ;
  1. DELETE(IEN) ;Deletes the entry in the HL7 Subscription Registry.
  1. Q $$DELETE^HLOASUB1(779.4,$G(IEN))