- INTQRY ;DS/SAIC; 21 May 99 15:57; Utilities for GIS query/response
- ;;3.01;BHL IHS Interfaces with GIS;;JUL 01, 2001
- ;COPYRIGHT 1991-2000 SAIC
- ;
- Q
- ;
- UPDTUIF(INTSK,INTSKDT,INUIF) ; Insert the INHF TASK NUMBER and
- ; TASK DATE/TIME into the Univ Interface file.
- ; "AT" xref ^INTHU("AT",INTSK,UIF)="" is created by FileMan
- ;
- ; Input:
- ; INTSK (req) = GIS Format Background Controller Task Number
- ; INTSKDT (req) = date/time task submitted to Format Controller
- ; in FileMan format CYYMMDD.HHMMSS
- ; INUIF (req) = IEN for the message in Univ. Interface file
- ;
- N DA,DIE,DR
- S INTSK=$G(INTSK),INTSKDT=$G(INTSKDT),INUIF=$G(INUIF)
- Q:'INTSK
- Q:'INTSKDT
- Q:'INUIF
- S DR="4.01////"_INTSK_";"_"4.02////"_INTSKDT,DIE="^INTHU(",DA=INUIF
- D ^DIE
- Q
- ;
- SRCH(INTSK,INUIFARY,INSTATUS) ; Search for query responses
- ;
- ; Input:
- ; INTSK (req) = IEN for a given task number
- ; INUIFARY = Passed by ref, this function builds the list of
- ; all query responses with their status or if
- ; complete, ACK_UIF MESSAGE ID.
- ; 'E' for ERROR
- ; ACK_UIF MESSAGE ID, of the response entry
- ; in the Univ Interface File.
- ; INSTATUS = Passed by ref, if exists, we return
- ; the activity status codes with their date/time in
- ; the following format:
- ; INSTATUS(MSGID,STATUS)=FileMan DATE/TIME
- ; Output:
- ; zero, if no pending responses
- ; INACK^INNOACK where INACK is the number of responses received
- ; INNOACK is the number of pending responses
- ;
- ;
- N INACK,INACKUIF,INDATA,INDEST,INMSGDIR,INNOACK,INSTAT,INUIFIEN
- ;
- S INTSK=$G(INTSK) Q:'INTSK 0
- K INUIFARY
- ; If no pending query response, return zero
- I '$D(^INTHU("AT",INTSK)) Q 0
- S (INUIFIEN,INNOACK,INACK)=0
- F S INUIFIEN=$O(^INTHU("AT",INTSK,INUIFIEN)) Q:'INUIFIEN D
- .;
- .; build an array for all query responses, data level will have the
- .; status if still waiting for a response, otherwise it will contain
- .; the ACK_UIF MESSAGE ID that points back to the reply entry in the
- .; Universal Interface File.
- .;
- . S INDATA=$G(^INTHU(INUIFIEN,0)),INACKUIF=$P(INDATA,U,18),INSTAT=$P(INDATA,U,3)
- . I INSTAT'="C"!('INACKUIF) D Q
- .. S INNOACK=INNOACK+1,INUIFARY(INUIFIEN)=INSTAT
- .. D STATUS(INUIFIEN,.INSTATUS)
- . S INDEST=+$P(INDATA,U,2)
- . I $P($G(^INRHD(INDEST,0)),U)="HL REPLICATOR" D Q
- ..; Special processing for replicated messages
- .. N INACT,INACT0,INUIFPTR,INACKUIF
- ..; Loop thru the activity log multiple and get the replicant UIF
- .. S INACT=0 F S INACT=$O(^INTHU(INUIFIEN,1,INACT)) Q:'INACT D
- ... S INACT0=$G(^INTHU(INUIFIEN,1,INACT,0)) Q:'$L(INACT0)
- ... Q:$P(INACT0,U,2)'="R"
- ... S INUIFPTR=$P(INACT0,U,3) Q:'INUIFPTR
- ... Q:'$G(^INTHU(INUIFPTR,0))
- ... S INACKUIF=$P(^INTHU(INUIFPTR,0),U,18)
- ... S INUIFARY(INUIFPTR)=$$GETMSGID(INACKUIF),INACK=INACK+1
- ... D STATUS(INUIFIEN,.INSTATUS)
- . S INMSGID=$$GETMSGID(INACKUIF),INUIFARY(INUIFIEN)=INMSGID,INACK=INACK+1
- . D STATUS(INUIFIEN,.INSTATUS)
- Q INACK_"^"_INNOACK
- ;
- STATUS(INUIFIEN,INSTATUS) ; return detail activity info in INSTATUS array
- ; in the following format:
- ;
- ; INSTATUS(MESSAGEID,"C") = FileMan Date/Time (Completed)
- ; INSTATUS(MESSAGEID,"S") = FileMan Date/Time (Sent)
- ; INSTATUS(MESSAGEID,"T") = FileMan Date/Time (Format Controller Task)
- ; INSTATUS(MESSAGEID,"SEQUENCE") = Sequence Number
- ;
- N INACT,INACT0,INMSGID,INSEQ,INSTAT
- ;
- K INSTATUS
- S INUIFIEN=$G(INUIFIEN),INMSGID=$$GETMSGID(INUIFIEN) Q:'$L(INMSGID)
- S INSEQ=$P($G(^INTHU(INUIFIEN,0)),U,17)
- I $L(INSEQ) S INSTATUS(INMSGID,"SEQUENCE")=INSEQ
- S INSTATUS(INMSGID,"T")=$P($G(^INTHU(INUIFIEN,4)),U,2)
- ; Loop thru the activity log multiple and get the activity info
- S INACT=0 F S INACT=$O(^INTHU(INUIFIEN,1,INACT)) Q:'INACT D
- . S INACT0=$G(^INTHU(INUIFIEN,1,INACT,0)) Q:'$L(INACT0)
- . S INSTAT=$P(INACT0,U,2) Q:'$L(INSTAT)
- . I "AECS"[INSTAT,'$D(INSTATUS(INMSGID,INSTAT)) S INSTATUS(INMSGID,INSTAT)=$P(INACT0,U)
- ;
- Q
- ;
- GETMSGID(INUIF) ; Return the message id for a given UIF
- ;
- S INUIF=$G(INUIF) Q:'INUIF ""
- Q $P($G(^INTHU(INUIF,0)),U,5)
- ;
- TASKNUM(INSEQ) ; return the task number for a given incoming sequence number
- ;
- ; Input:
- ; INSEQ (req) = Sequence number of an incoming message
- ; Output:
- ; Task Number of the original sending message
- ; NULL, if not successful
- ;
- N INUIF,INUIFR
- S INSEQ=$G(INSEQ)
- Q:'$L(INSEQ) ""
- ; get the UIF entry number for the responding message
- S INUIFR=$O(^INTHU("D",INSEQ,"")) Q:'INUIFR ""
- ; get the UIF entry number of the parent message
- S INUIF=$P($G(^INTHU(INUIFR,0)),U,7) Q:'INUIF ""
- ; return the task number of the sending message
- Q $P($G(^INTHU(INUIF,4)),U)
- ;
- INTQRY ;DS/SAIC; 21 May 99 15:57; Utilities for GIS query/response
- +1 ;;3.01;BHL IHS Interfaces with GIS;;JUL 01, 2001
- +2 ;COPYRIGHT 1991-2000 SAIC
- +3 ;
- +4 QUIT
- +5 ;
- UPDTUIF(INTSK,INTSKDT,INUIF) ; Insert the INHF TASK NUMBER and
- +1 ; TASK DATE/TIME into the Univ Interface file.
- +2 ; "AT" xref ^INTHU("AT",INTSK,UIF)="" is created by FileMan
- +3 ;
- +4 ; Input:
- +5 ; INTSK (req) = GIS Format Background Controller Task Number
- +6 ; INTSKDT (req) = date/time task submitted to Format Controller
- +7 ; in FileMan format CYYMMDD.HHMMSS
- +8 ; INUIF (req) = IEN for the message in Univ. Interface file
- +9 ;
- +10 NEW DA,DIE,DR
- +11 SET INTSK=$GET(INTSK)
- SET INTSKDT=$GET(INTSKDT)
- SET INUIF=$GET(INUIF)
- +12 IF 'INTSK
- QUIT
- +13 IF 'INTSKDT
- QUIT
- +14 IF 'INUIF
- QUIT
- +15 SET DR="4.01////"_INTSK_";"_"4.02////"_INTSKDT
- SET DIE="^INTHU("
- SET DA=INUIF
- +16 DO ^DIE
- +17 QUIT
- +18 ;
- SRCH(INTSK,INUIFARY,INSTATUS) ; Search for query responses
- +1 ;
- +2 ; Input:
- +3 ; INTSK (req) = IEN for a given task number
- +4 ; INUIFARY = Passed by ref, this function builds the list of
- +5 ; all query responses with their status or if
- +6 ; complete, ACK_UIF MESSAGE ID.
- +7 ; 'E' for ERROR
- +8 ; ACK_UIF MESSAGE ID, of the response entry
- +9 ; in the Univ Interface File.
- +10 ; INSTATUS = Passed by ref, if exists, we return
- +11 ; the activity status codes with their date/time in
- +12 ; the following format:
- +13 ; INSTATUS(MSGID,STATUS)=FileMan DATE/TIME
- +14 ; Output:
- +15 ; zero, if no pending responses
- +16 ; INACK^INNOACK where INACK is the number of responses received
- +17 ; INNOACK is the number of pending responses
- +18 ;
- +19 ;
- +20 NEW INACK,INACKUIF,INDATA,INDEST,INMSGDIR,INNOACK,INSTAT,INUIFIEN
- +21 ;
- +22 SET INTSK=$GET(INTSK)
- IF 'INTSK
- QUIT 0
- +23 KILL INUIFARY
- +24 ; If no pending query response, return zero
- +25 IF '$DATA(^INTHU("AT",INTSK))
- QUIT 0
- +26 SET (INUIFIEN,INNOACK,INACK)=0
- +27 FOR
- SET INUIFIEN=$ORDER(^INTHU("AT",INTSK,INUIFIEN))
- IF 'INUIFIEN
- QUIT
- Begin DoDot:1
- +28 ;
- +29 ; build an array for all query responses, data level will have the
- +30 ; status if still waiting for a response, otherwise it will contain
- +31 ; the ACK_UIF MESSAGE ID that points back to the reply entry in the
- +32 ; Universal Interface File.
- +33 ;
- +34 SET INDATA=$GET(^INTHU(INUIFIEN,0))
- SET INACKUIF=$PIECE(INDATA,U,18)
- SET INSTAT=$PIECE(INDATA,U,3)
- +35 IF INSTAT'="C"!('INACKUIF)
- Begin DoDot:2
- +36 SET INNOACK=INNOACK+1
- SET INUIFARY(INUIFIEN)=INSTAT
- +37 DO STATUS(INUIFIEN,.INSTATUS)
- End DoDot:2
- QUIT
- +38 SET INDEST=+$PIECE(INDATA,U,2)
- +39 IF $PIECE($GET(^INRHD(INDEST,0)),U)="HL REPLICATOR"
- Begin DoDot:2
- +40 ; Special processing for replicated messages
- +41 NEW INACT,INACT0,INUIFPTR,INACKUIF
- +42 ; Loop thru the activity log multiple and get the replicant UIF
- +43 SET INACT=0
- FOR
- SET INACT=$ORDER(^INTHU(INUIFIEN,1,INACT))
- IF 'INACT
- QUIT
- Begin DoDot:3
- +44 SET INACT0=$GET(^INTHU(INUIFIEN,1,INACT,0))
- IF '$LENGTH(INACT0)
- QUIT
- +45 IF $PIECE(INACT0,U,2)'="R"
- QUIT
- +46 SET INUIFPTR=$PIECE(INACT0,U,3)
- IF 'INUIFPTR
- QUIT
- +47 IF '$GET(^INTHU(INUIFPTR,0))
- QUIT
- +48 SET INACKUIF=$PIECE(^INTHU(INUIFPTR,0),U,18)
- +49 SET INUIFARY(INUIFPTR)=$$GETMSGID(INACKUIF)
- SET INACK=INACK+1
- +50 DO STATUS(INUIFIEN,.INSTATUS)
- End DoDot:3
- End DoDot:2
- QUIT
- +51 SET INMSGID=$$GETMSGID(INACKUIF)
- SET INUIFARY(INUIFIEN)=INMSGID
- SET INACK=INACK+1
- +52 DO STATUS(INUIFIEN,.INSTATUS)
- End DoDot:1
- +53 QUIT INACK_"^"_INNOACK
- +54 ;
- STATUS(INUIFIEN,INSTATUS) ; return detail activity info in INSTATUS array
- +1 ; in the following format:
- +2 ;
- +3 ; INSTATUS(MESSAGEID,"C") = FileMan Date/Time (Completed)
- +4 ; INSTATUS(MESSAGEID,"S") = FileMan Date/Time (Sent)
- +5 ; INSTATUS(MESSAGEID,"T") = FileMan Date/Time (Format Controller Task)
- +6 ; INSTATUS(MESSAGEID,"SEQUENCE") = Sequence Number
- +7 ;
- +8 NEW INACT,INACT0,INMSGID,INSEQ,INSTAT
- +9 ;
- +10 KILL INSTATUS
- +11 SET INUIFIEN=$GET(INUIFIEN)
- SET INMSGID=$$GETMSGID(INUIFIEN)
- IF '$LENGTH(INMSGID)
- QUIT
- +12 SET INSEQ=$PIECE($GET(^INTHU(INUIFIEN,0)),U,17)
- +13 IF $LENGTH(INSEQ)
- SET INSTATUS(INMSGID,"SEQUENCE")=INSEQ
- +14 SET INSTATUS(INMSGID,"T")=$PIECE($GET(^INTHU(INUIFIEN,4)),U,2)
- +15 ; Loop thru the activity log multiple and get the activity info
- +16 SET INACT=0
- FOR
- SET INACT=$ORDER(^INTHU(INUIFIEN,1,INACT))
- IF 'INACT
- QUIT
- Begin DoDot:1
- +17 SET INACT0=$GET(^INTHU(INUIFIEN,1,INACT,0))
- IF '$LENGTH(INACT0)
- QUIT
- +18 SET INSTAT=$PIECE(INACT0,U,2)
- IF '$LENGTH(INSTAT)
- QUIT
- +19 IF "AECS"[INSTAT
- IF '$DATA(INSTATUS(INMSGID,INSTAT))
- SET INSTATUS(INMSGID,INSTAT)=$PIECE(INACT0,U)
- End DoDot:1
- +20 ;
- +21 QUIT
- +22 ;
- GETMSGID(INUIF) ; Return the message id for a given UIF
- +1 ;
- +2 SET INUIF=$GET(INUIF)
- IF 'INUIF
- QUIT ""
- +3 QUIT $PIECE($GET(^INTHU(INUIF,0)),U,5)
- +4 ;
- TASKNUM(INSEQ) ; return the task number for a given incoming sequence number
- +1 ;
- +2 ; Input:
- +3 ; INSEQ (req) = Sequence number of an incoming message
- +4 ; Output:
- +5 ; Task Number of the original sending message
- +6 ; NULL, if not successful
- +7 ;
- +8 NEW INUIF,INUIFR
- +9 SET INSEQ=$GET(INSEQ)
- +10 IF '$LENGTH(INSEQ)
- QUIT ""
- +11 ; get the UIF entry number for the responding message
- +12 SET INUIFR=$ORDER(^INTHU("D",INSEQ,""))
- IF 'INUIFR
- QUIT ""
- +13 ; get the UIF entry number of the parent message
- +14 SET INUIF=$PIECE($GET(^INTHU(INUIFR,0)),U,7)
- IF 'INUIF
- QUIT ""
- +15 ; return the task number of the sending message
- +16 QUIT $PIECE($GET(^INTHU(INUIF,4)),U)
- +17 ;