DGPFLMT5 ;ALB/RBS - PRF TRANSMIT REJECT MESSAGE PROCESSING ; 7/12/06 09:30am
 ;;5.3;Registration;**650**;Aug 13, 1993;Build 3
 ;
 ;no direct entry
 QUIT
 ;
 ;
EN(DGVALMY) ;Entry point to retransmit rejected messages
 ;This function will retransmit all user selected "RJ" Rejected status
 ;entries of the PRF HL7 TRANSMISSION LOG (#26.17) file to the
 ;Treating Facility that rejected it.
 ;
 ;   Input:
 ;       DGVALMY - VALMY array of user selections, pass by reference
 ;
 ;  Output:
 ;       Function value - 1 on success, 0 on failure
 ;
 ;- Use the 0 node sort file for all retransmission processing:
 ;  ^TMP("DGPFSORT",$J,0,<assignment ien>,<site ien>,<HL7 log ien>)=""
 ;  Each patient's PRF Assignment record is grouped with all of the
 ;  Treating Facilities that logged a rejected HL7 transmission entry.
 ;
 N DGAIEN   ;assignment ien
 N DGFAC    ;destination station number
 N DGHLIEN  ;loop var
 N DGNODE   ;"IDX" data string
 N DGRSLT   ;function value
 N DGSEL    ;user selection
 N DGSITE   ;site transmitted to ien
 ;
 ;set screen to full scroll region
 D FULL^VALM1
 W !
 ;
 ;- Use the "IDX" selection entry to get the assignment info
 ;  <assignment ien>^<site ien>^<HL7 log ien>^<patient dfn>^<patient name>^<site name>
 ;
 S DGRSLT=0
 I $O(DGVALMY(""))'="" D
 . S DGSEL=0
 . F  S DGSEL=$O(DGVALMY(DGSEL)) Q:'DGSEL  D
 . . S DGNODE=$G(^TMP("DGPFLMT",$J,"IDX",DGSEL,DGSEL))
 . . Q:'DGNODE
 . . S DGAIEN=$P(DGNODE,U,1)
 . . Q:'DGAIEN
 . . S DGSITE=$P(DGNODE,U,2)
 . . Q:'DGSITE
 . . ;
 . . ;- retransmit assignment -
 . . ;  display patient name and site transmitted to failure & success
 . . ;
 . . I '$$XMIT(DGAIEN,DGSITE) D  Q
 . . . W !,">>>",?5,DGSEL,". ",$P(DGNODE,U,5),"...failed to retransmit to...",$P(DGNODE,U,6)
 . . E  W !?5,DGSEL,". ",$P(DGNODE,U,5),"...was retransmitted to...",$P(DGNODE,U,6)
 . . ;
 . . ;- Now set all of the Assignment's HL7 transmission log entry's
 . . ;  to "RT" RE-TRANSMITTED status.
 . . ;- loop ^TMP("DGPFSORT",$J,0,DGAIEN,DGSITE,n) nodes
 . . S DGHLIEN=0
 . . F  S DGHLIEN=$O(^TMP("DGPFSORT",$J,0,DGAIEN,DGSITE,DGHLIEN)) Q:'DGHLIEN  D
 . . . ;- update HL7 transmission log entry status
 . . . ;
 . . . D STOSTAT^DGPFHLL(26.17,DGHLIEN,"RT")
 . . ;
 . . S DGRSLT=1
 ;
 Q DGRSLT
 ;
XMIT(DGAIEN,DGSITE) ;call out to retransmit
 ;This function is used to call the PRF (ORU~R01) function to transmit
 ;a patient's Assignment record and all History records to a single
 ;Treating Facility.
 ;
 ;  Supported DBIA #2171:  $$STA^XUAF4
 ;    This supported DBIA is used to access the Kernel API to convert
 ;    a station number to an INSTITUTION (#4) file IEN.
 ;
 ;   Input: (required)
 ;       DGAIEN - assignment ien
 ;       DGSITE - site transmitted to ien
 ;
 ;  Output:
 ;       Function value - 1 on success, 0 on failure
 ;
 N DGFAC    ;destination station number array
 N DGHIENS  ;array of assignment history ien's
 N DGRSLT   ;function value
 S DGRSLT=0
 ;
 I +$G(DGAIEN)>0 D
 . K DGFAC,DGHIENS
 . ;
 . ;convert institution# to station#
 . S DGFAC(1)=$$STA^XUAF4(DGSITE)
 . Q:'DGFAC(1)
 . ;
 . ;get all assignment history ien's
 . Q:'$$GETALLDT^DGPFAAH(DGAIEN,.DGHIENS)
 . ;
 . ;build and transmit the new message
 . Q:'$$SNDORU^DGPFHLS(DGAIEN,.DGHIENS,.DGFAC)
 . ;
 . S DGRSLT=1
 ;
 Q DGRSLT
 
--- Routine Detail   --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HDGPFLMT5   3362     printed  Sep 23, 2025@20:24:19                                                                                                                                                                                                    Page 2
DGPFLMT5  ;ALB/RBS - PRF TRANSMIT REJECT MESSAGE PROCESSING ; 7/12/06 09:30am
 +1       ;;5.3;Registration;**650**;Aug 13, 1993;Build 3
 +2       ;
 +3       ;no direct entry
 +4        QUIT 
 +5       ;
 +6       ;
EN(DGVALMY) ;Entry point to retransmit rejected messages
 +1       ;This function will retransmit all user selected "RJ" Rejected status
 +2       ;entries of the PRF HL7 TRANSMISSION LOG (#26.17) file to the
 +3       ;Treating Facility that rejected it.
 +4       ;
 +5       ;   Input:
 +6       ;       DGVALMY - VALMY array of user selections, pass by reference
 +7       ;
 +8       ;  Output:
 +9       ;       Function value - 1 on success, 0 on failure
 +10      ;
 +11      ;- Use the 0 node sort file for all retransmission processing:
 +12      ;  ^TMP("DGPFSORT",$J,0,<assignment ien>,<site ien>,<HL7 log ien>)=""
 +13      ;  Each patient's PRF Assignment record is grouped with all of the
 +14      ;  Treating Facilities that logged a rejected HL7 transmission entry.
 +15      ;
 +16      ;assignment ien
           NEW DGAIEN
 +17      ;destination station number
           NEW DGFAC
 +18      ;loop var
           NEW DGHLIEN
 +19      ;"IDX" data string
           NEW DGNODE
 +20      ;function value
           NEW DGRSLT
 +21      ;user selection
           NEW DGSEL
 +22      ;site transmitted to ien
           NEW DGSITE
 +23      ;
 +24      ;set screen to full scroll region
 +25       DO FULL^VALM1
 +26       WRITE !
 +27      ;
 +28      ;- Use the "IDX" selection entry to get the assignment info
 +29      ;  <assignment ien>^<site ien>^<HL7 log ien>^<patient dfn>^<patient name>^<site name>
 +30      ;
 +31       SET DGRSLT=0
 +32       IF $ORDER(DGVALMY(""))'=""
               Begin DoDot:1
 +33               SET DGSEL=0
 +34               FOR 
                       SET DGSEL=$ORDER(DGVALMY(DGSEL))
                       if 'DGSEL
                           QUIT 
                       Begin DoDot:2
 +35                       SET DGNODE=$GET(^TMP("DGPFLMT",$JOB,"IDX",DGSEL,DGSEL))
 +36                       if 'DGNODE
                               QUIT 
 +37                       SET DGAIEN=$PIECE(DGNODE,U,1)
 +38                       if 'DGAIEN
                               QUIT 
 +39                       SET DGSITE=$PIECE(DGNODE,U,2)
 +40                       if 'DGSITE
                               QUIT 
 +41      ;
 +42      ;- retransmit assignment -
 +43      ;  display patient name and site transmitted to failure & success
 +44      ;
 +45                       IF '$$XMIT(DGAIEN,DGSITE)
                               Begin DoDot:3
 +46                               WRITE !,">>>",?5,DGSEL,". ",$PIECE(DGNODE,U,5),"...failed to retransmit to...",$PIECE(DGNODE,U,6)
                               End DoDot:3
                               QUIT 
 +47                      IF '$TEST
                               WRITE !?5,DGSEL,". ",$PIECE(DGNODE,U,5),"...was retransmitted to...",$PIECE(DGNODE,U,6)
 +48      ;
 +49      ;- Now set all of the Assignment's HL7 transmission log entry's
 +50      ;  to "RT" RE-TRANSMITTED status.
 +51      ;- loop ^TMP("DGPFSORT",$J,0,DGAIEN,DGSITE,n) nodes
 +52                       SET DGHLIEN=0
 +53                       FOR 
                               SET DGHLIEN=$ORDER(^TMP("DGPFSORT",$JOB,0,DGAIEN,DGSITE,DGHLIEN))
                               if 'DGHLIEN
                                   QUIT 
                               Begin DoDot:3
 +54      ;- update HL7 transmission log entry status
 +55      ;
 +56                               DO STOSTAT^DGPFHLL(26.17,DGHLIEN,"RT")
                               End DoDot:3
 +57      ;
 +58                       SET DGRSLT=1
                       End DoDot:2
               End DoDot:1
 +59      ;
 +60       QUIT DGRSLT
 +61      ;
XMIT(DGAIEN,DGSITE) ;call out to retransmit
 +1       ;This function is used to call the PRF (ORU~R01) function to transmit
 +2       ;a patient's Assignment record and all History records to a single
 +3       ;Treating Facility.
 +4       ;
 +5       ;  Supported DBIA #2171:  $$STA^XUAF4
 +6       ;    This supported DBIA is used to access the Kernel API to convert
 +7       ;    a station number to an INSTITUTION (#4) file IEN.
 +8       ;
 +9       ;   Input: (required)
 +10      ;       DGAIEN - assignment ien
 +11      ;       DGSITE - site transmitted to ien
 +12      ;
 +13      ;  Output:
 +14      ;       Function value - 1 on success, 0 on failure
 +15      ;
 +16      ;destination station number array
           NEW DGFAC
 +17      ;array of assignment history ien's
           NEW DGHIENS
 +18      ;function value
           NEW DGRSLT
 +19       SET DGRSLT=0
 +20      ;
 +21       IF +$GET(DGAIEN)>0
               Begin DoDot:1
 +22               KILL DGFAC,DGHIENS
 +23      ;
 +24      ;convert institution# to station#
 +25               SET DGFAC(1)=$$STA^XUAF4(DGSITE)
 +26               if 'DGFAC(1)
                       QUIT 
 +27      ;
 +28      ;get all assignment history ien's
 +29               if '$$GETALLDT^DGPFAAH(DGAIEN,.DGHIENS)
                       QUIT 
 +30      ;
 +31      ;build and transmit the new message
 +32               if '$$SNDORU^DGPFHLS(DGAIEN,.DGHIENS,.DGFAC)
                       QUIT 
 +33      ;
 +34               SET DGRSLT=1
               End DoDot:1
 +35      ;
 +36       QUIT DGRSLT