VAQPSE01 ;ALB/JRP,JFP - EXPORTED PDX ROUTINE;9-FEB-94
;;1.5;PATIENT DATA EXCHANGE;**1**;NOV 17, 1993
GMTSPDX ; SLC/JER,SBW - PDX Health Summary Driver ;12/29/93 16:41
;;2.5;Health Summary;**8**;Dec 16, 1992
GET(TRAN,DFN,SEGPTR,ROOT,GMTSLCNT,GMTSDLM,GMTSNDM) ; Get HS for PDX
; Data retrieved from HS is return in ROOT parmeter reference passing.
; Function returns 2 piece variable delimited with "^".
; Piece 1 = tot line cnt of data extract to ROOT.
; Piece 2 = contains entry line cnt (GMTSLCNT) + Piece 1
; Note: Currently Data begins with GMTSLCNT + 1 and
; Piece 2 is last node # of ROOT
; : If TRAN is passed
; The patient pointer of the transaction will be used
; Encryption will be based on the transaction
; If DFN is passed
; Encryption will be based on the site parameter
; : Pointer to transaction takes precedence over DFN ... if
; TRAN>0 the DFN will be based on the transaction
;
;DETERMINE TRUE DFN
S TRAN=+$G(TRAN)
S DFN=+$G(DFN)
Q:(('TRAN)&('DFN)) "-1^Did not pass pointer to transaction or patient"
I (TRAN) Q:('$D(^VAT(394.61,TRAN))) "-1^Did not pass valid pointer to VAQ - TRANSACTION file"
I (TRAN) S DFN=+$P($G(^VAT(394.61,TRAN,0)),"^",3) Q:('DFN) "-1^Transaction did not contain pointer to PATIENT file"
Q:('$D(^DPT(DFN))) "-1^Did not pass valid pointer to PATIENT file"
;
; Scope FM local variables that don't get cleaned up by %ZIS
; SPOOLER call
N C,D0,DA,DI,DIE,DIC,DQ,DR,GMTS,GMTS1,GMTS2,GMTSAGE,GMTSDOB,GMTSDTM
N GMTSDUZ,GMTSLO,GMTSLPG,GMTSPNM,GMTSRB,GMTSSN,GMTSSPL,GMTSWARD,GMTSY
N SEX,SPLDOC,VADM,VAERR,VAIN,X,Y,ZISIOST
N %,%X,%XX,%Y,%YY,%Z4,%ZDA,%ZS,%ZY,POP
S GMTSDUZ=$G(DUZ),GMTSSPL=$P($G(^GMT(142.99,1,0)),U,4),DUZ=.5
I GMTSSPL']"" S GMTSY="-1^No Spool Device allocated" G GETX
;CONVERT SEGPTR TO ENTRY IN HEALTH SUMMARY COMPONENT FILE
S X=+$P($G(^VAT(394.71,SEGPTR,0)),"^",4)
I ('X) S GMTSY="-1^Unable to convert PDX data segment to Health Summary component" G GETX
S SEGPTR=X
;DETERMINE IF COMPONENT HAS BEEN DISABLED
S X=$G(^GMT(142.1,SEGPTR,0))
I (($P(X,"^",6)="T")!($P(X,"^",6)="P")) D G GETX
.;DISABLED
.S GMTSY=$P(X,"^",8)
.I (GMTSY'="") S GMTSY="-1^"_GMTSY Q
.S GMTSY="-1^Component has been disabled "
.S GMTSY=GMTSY_$S($P(X,"^",6)="T":"(temporary)",1:"(permanent)")
;OPEN SPOOL DEVICE
S IOP=GMTSSPL_";HSPDX"_DFN D ^%ZIS
I POP S GMTSY="-1^Spool open failed" G GETX
D ONECOMP(DFN,SEGPTR,$G(GMTSDLM),$G(GMTSNDM)) ; Write component
S SPLDOC=$G(IO("SPOOL")) D ^%ZISC
I +SPLDOC D
. N SPLSTAT,SPLPTR,GMTSDOC
. ; Wait until spool document is "ready" (ONLY CHECK EVERY 5 SECONDS)
. F S SPLSTAT=$P($G(^XMB(3.51,SPLDOC,0)),U,3) Q:SPLSTAT="r" H 5
. S GMTSDOC=$G(^XMB(3.51,SPLDOC,0)),SPLPTR=$P(GMTSDOC,U,10)
. I '+SPLPTR!('+$P(GMTSDOC,U,9)) S GMTSY="-1^No data available" Q
. S GMTSY=$$XFER(SPLPTR,ROOT,GMTSDOC,+$G(GMTSLCNT))
. D DSDOC^ZISPL(SPLPTR),DSD^ZISPL(SPLDOC)
.;CHECK TO SEE IF ENCRYPTION IS ON
.S:(TRAN) X=$$TRANENC^VAQUTL3(TRAN,0)
.S:('TRAN) X=$$NCRYPTON^VAQUTL2(0)
.S:(X) X=$$ENCDSP^VAQHSH(TRAN,ROOT,X,(GMTSLCNT+1),+GMTSY)
E S GMTSY="-1^Spool document not created"
GETX S DUZ=+$G(GMTSDUZ)
Q $G(GMTSY)
ONECOMP(DFN,SEGPTR,GMTSDLM,GMTSNDM) ; Print a single HS component to IO
N GMTSEG,GMTSEGI,GMTSEGC,GMTSTITL
S GMTSTITL="PDX TRANSMISSION"
S GMTSEG(1)=1_U_SEGPTR_U_$G(GMTSNDM)_U_$G(GMTSDLM)
S (GMTSEGI(SEGPTR),GMTSEGC)=1
D EN^GMTS1
Q
XFER(SPLDAT,ROOT,GMTSDOC,GMTSLCNT) ; Transfer text from SPOOL DOC to ROOT
N GMTSI,GMTSL,GMTSREC,GMTSPRT,GMTSX S (GMTSI,GMTSL)=0,GMTSPRT=1
F S GMTSI=$O(^XMBS(3.519,SPLDAT,2,GMTSI)) Q:+GMTSI'>0 D Q:$E(GMTSREC,1,7)="*** END"
. S GMTSREC=$G(^XMBS(3.519,SPLDAT,2,GMTSI,0))
. ;Don't transfer data until a line with 3 hyphens or ** DECEASED **
. ;is found nor after "*** END" is found
. I (GMTSL=0&($E(GMTSREC,1,3)="---")!(GMTSREC["** DECEASED **"))!((GMTSL>0)&($E(GMTSREC,1,7)'="*** END")) D
. . I GMTSREC["|TOP|" S GMTSPRT=0
. . S:GMTSPRT GMTSL=GMTSL+1,GMTSLCNT=GMTSLCNT+1,@ROOT@("DISPLAY",GMTSLCNT,0)=GMTSREC
. . I GMTSREC["(continued)" S GMTSPRT=1
I +GMTSL,$P(GMTSDOC,U,11) D ;incomplete report indicator
. S GMTSL=GMTSL+1,@ROOT@("DISPLAY",GMTSL,0)="*** Data is incomplete ***"
I '+GMTSL S GMTSL="-1^Text transfer from Spool Document failed"
Q $G(GMTSL)_U_$G(GMTSLCNT)
--- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HVAQPSE01 4372 printed Dec 13, 2024@02:26:15 Page 2
VAQPSE01 ;ALB/JRP,JFP - EXPORTED PDX ROUTINE;9-FEB-94
+1 ;;1.5;PATIENT DATA EXCHANGE;**1**;NOV 17, 1993
GMTSPDX ; SLC/JER,SBW - PDX Health Summary Driver ;12/29/93 16:41
+1 ;;2.5;Health Summary;**8**;Dec 16, 1992
GET(TRAN,DFN,SEGPTR,ROOT,GMTSLCNT,GMTSDLM,GMTSNDM) ; Get HS for PDX
+1 ; Data retrieved from HS is return in ROOT parmeter reference passing.
+2 ; Function returns 2 piece variable delimited with "^".
+3 ; Piece 1 = tot line cnt of data extract to ROOT.
+4 ; Piece 2 = contains entry line cnt (GMTSLCNT) + Piece 1
+5 ; Note: Currently Data begins with GMTSLCNT + 1 and
+6 ; Piece 2 is last node # of ROOT
+7 ; : If TRAN is passed
+8 ; The patient pointer of the transaction will be used
+9 ; Encryption will be based on the transaction
+10 ; If DFN is passed
+11 ; Encryption will be based on the site parameter
+12 ; : Pointer to transaction takes precedence over DFN ... if
+13 ; TRAN>0 the DFN will be based on the transaction
+14 ;
+15 ;DETERMINE TRUE DFN
+16 SET TRAN=+$GET(TRAN)
+17 SET DFN=+$GET(DFN)
+18 if (('TRAN)&('DFN))
QUIT "-1^Did not pass pointer to transaction or patient"
+19 IF (TRAN)
if ('$DATA(^VAT(394.61,TRAN)))
QUIT "-1^Did not pass valid pointer to VAQ - TRANSACTION file"
+20 IF (TRAN)
SET DFN=+$PIECE($GET(^VAT(394.61,TRAN,0)),"^",3)
if ('DFN)
QUIT "-1^Transaction did not contain pointer to PATIENT file"
+21 if ('$DATA(^DPT(DFN)))
QUIT "-1^Did not pass valid pointer to PATIENT file"
+22 ;
+23 ; Scope FM local variables that don't get cleaned up by %ZIS
+24 ; SPOOLER call
+25 NEW C,D0,DA,DI,DIE,DIC,DQ,DR,GMTS,GMTS1,GMTS2,GMTSAGE,GMTSDOB,GMTSDTM
+26 NEW GMTSDUZ,GMTSLO,GMTSLPG,GMTSPNM,GMTSRB,GMTSSN,GMTSSPL,GMTSWARD,GMTSY
+27 NEW SEX,SPLDOC,VADM,VAERR,VAIN,X,Y,ZISIOST
+28 NEW %,%X,%XX,%Y,%YY,%Z4,%ZDA,%ZS,%ZY,POP
+29 SET GMTSDUZ=$GET(DUZ)
SET GMTSSPL=$PIECE($GET(^GMT(142.99,1,0)),U,4)
SET DUZ=.5
+30 IF GMTSSPL']""
SET GMTSY="-1^No Spool Device allocated"
GOTO GETX
+31 ;CONVERT SEGPTR TO ENTRY IN HEALTH SUMMARY COMPONENT FILE
+32 SET X=+$PIECE($GET(^VAT(394.71,SEGPTR,0)),"^",4)
+33 IF ('X)
SET GMTSY="-1^Unable to convert PDX data segment to Health Summary component"
GOTO GETX
+34 SET SEGPTR=X
+35 ;DETERMINE IF COMPONENT HAS BEEN DISABLED
+36 SET X=$GET(^GMT(142.1,SEGPTR,0))
+37 IF (($PIECE(X,"^",6)="T")!($PIECE(X,"^",6)="P"))
Begin DoDot:1
+38 ;DISABLED
+39 SET GMTSY=$PIECE(X,"^",8)
+40 IF (GMTSY'="")
SET GMTSY="-1^"_GMTSY
QUIT
+41 SET GMTSY="-1^Component has been disabled "
+42 SET GMTSY=GMTSY_$SELECT($PIECE(X,"^",6)="T":"(temporary)",1:"(permanent)")
End DoDot:1
GOTO GETX
+43 ;OPEN SPOOL DEVICE
+44 SET IOP=GMTSSPL_";HSPDX"_DFN
DO ^%ZIS
+45 IF POP
SET GMTSY="-1^Spool open failed"
GOTO GETX
+46 ; Write component
DO ONECOMP(DFN,SEGPTR,$GET(GMTSDLM),$GET(GMTSNDM))
+47 SET SPLDOC=$GET(IO("SPOOL"))
DO ^%ZISC
+48 IF +SPLDOC
Begin DoDot:1
+49 NEW SPLSTAT,SPLPTR,GMTSDOC
+50 ; Wait until spool document is "ready" (ONLY CHECK EVERY 5 SECONDS)
+51 FOR
SET SPLSTAT=$PIECE($GET(^XMB(3.51,SPLDOC,0)),U,3)
if SPLSTAT="r"
QUIT
HANG 5
+52 SET GMTSDOC=$GET(^XMB(3.51,SPLDOC,0))
SET SPLPTR=$PIECE(GMTSDOC,U,10)
+53 IF '+SPLPTR!('+$PIECE(GMTSDOC,U,9))
SET GMTSY="-1^No data available"
QUIT
+54 SET GMTSY=$$XFER(SPLPTR,ROOT,GMTSDOC,+$GET(GMTSLCNT))
+55 DO DSDOC^ZISPL(SPLPTR)
DO DSD^ZISPL(SPLDOC)
+56 ;CHECK TO SEE IF ENCRYPTION IS ON
+57 if (TRAN)
SET X=$$TRANENC^VAQUTL3(TRAN,0)
+58 if ('TRAN)
SET X=$$NCRYPTON^VAQUTL2(0)
+59 if (X)
SET X=$$ENCDSP^VAQHSH(TRAN,ROOT,X,(GMTSLCNT+1),+GMTSY)
End DoDot:1
+60 IF '$TEST
SET GMTSY="-1^Spool document not created"
GETX SET DUZ=+$GET(GMTSDUZ)
+1 QUIT $GET(GMTSY)
ONECOMP(DFN,SEGPTR,GMTSDLM,GMTSNDM) ; Print a single HS component to IO
+1 NEW GMTSEG,GMTSEGI,GMTSEGC,GMTSTITL
+2 SET GMTSTITL="PDX TRANSMISSION"
+3 SET GMTSEG(1)=1_U_SEGPTR_U_$GET(GMTSNDM)_U_$GET(GMTSDLM)
+4 SET (GMTSEGI(SEGPTR),GMTSEGC)=1
+5 DO EN^GMTS1
+6 QUIT
XFER(SPLDAT,ROOT,GMTSDOC,GMTSLCNT) ; Transfer text from SPOOL DOC to ROOT
+1 NEW GMTSI,GMTSL,GMTSREC,GMTSPRT,GMTSX
SET (GMTSI,GMTSL)=0
SET GMTSPRT=1
+2 FOR
SET GMTSI=$ORDER(^XMBS(3.519,SPLDAT,2,GMTSI))
if +GMTSI'>0
QUIT
Begin DoDot:1
+3 SET GMTSREC=$GET(^XMBS(3.519,SPLDAT,2,GMTSI,0))
+4 ;Don't transfer data until a line with 3 hyphens or ** DECEASED **
+5 ;is found nor after "*** END" is found
+6 IF (GMTSL=0&($EXTRACT(GMTSREC,1,3)="---")!(GMTSREC["** DECEASED **"))!((GMTSL>0)&($EXTRACT(GMTSREC,1,7)'="*** END"))
Begin DoDot:2
+7 IF GMTSREC["|TOP|"
SET GMTSPRT=0
+8 if GMTSPRT
SET GMTSL=GMTSL+1
SET GMTSLCNT=GMTSLCNT+1
SET @ROOT@("DISPLAY",GMTSLCNT,0)=GMTSREC
+9 IF GMTSREC["(continued)"
SET GMTSPRT=1
End DoDot:2
End DoDot:1
if $EXTRACT(GMTSREC,1,7)="*** END"
QUIT
+10 ;incomplete report indicator
IF +GMTSL
IF $PIECE(GMTSDOC,U,11)
Begin DoDot:1
+11 SET GMTSL=GMTSL+1
SET @ROOT@("DISPLAY",GMTSL,0)="*** Data is incomplete ***"
End DoDot:1
+12 IF '+GMTSL
SET GMTSL="-1^Text transfer from Spool Document failed"
+13 QUIT $GET(GMTSL)_U_$GET(GMTSLCNT)