VAQDBIP3 ;ALB/JRP - MINIMUM PATIENT INFO EXTRACTION;9-MAR-93
;;1.5;PATIENT DATA EXCHANGE;;NOV 17, 1993
MINXTRCT(TRAN,DFN,ARRAY) ;EXTRACT MINIMUM (EXTRACTION ARRAY)
;INPUT : TRAN - Pointer to VAQ - TRANSACTION file
; DFN - Pointer to patient in PATIENT file
; ARRAY - Where to store information (full global reference)
;OUTPUT : 0 - Extraction was successfull
; -1^Error_Text - Extraction was not successfull
;NOTE : If the minimum patient information can not be extracted,
; the "VALUE" and "ID" nodes in ARRAY will be deleted.
; : 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
;
;CHECK INPUT
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"
Q:($G(ARRAY)="") "-1^Did not pass output array"
;DECLARE VARIABLES
N ERROR,TMP,LOOP,ENCPTR,KEY1,KEY2,SENDER
;DETERMINE IF ENCRYPTION IS ON - SAVE POINTER TO ENCRYPTION METHOD
S:('TRAN) ENCPTR=$$NCRYPTON^VAQUTL2(0)
S:(TRAN) ENCPTR=$$TRANENC^VAQUTL3(TRAN,1)
;DETERMINE PRIMARY KEY
I (TRAN) S SENDER=$$SENDER^VAQCON2(TRAN) Q:($P(SENDER,"^",1)="-1") "-1^Could not determine encryption keys"
S:(TRAN) SENDER=$P(SENDER,"^",1)
S:(TRAN) KEY1=$$NAMEKEY^VAQUTL3(SENDER,1)
S:('TRAN) KEY1=$$DUZKEY^VAQUTL3($G(DUZ),1)
;DETERMINE SECONDARY KEY
S:(TRAN) KEY2=$$NAMEKEY^VAQUTL3(SENDER,0)
S:('TRAN) KEY2=$$DUZKEY^VAQUTL3($G(DUZ),0)
I (ENCPTR) Q:((KEY1="")!(KEY2="")) "-1^Could not determine encryption keys"
S ERROR=0
;EXTRACT INFORMATION
F LOOP=1:1 D Q:(ERROR)
.S TMP=$T(MIN+LOOP^VAQDBII1)
.I ($P(TMP,";;",2)="") S ERROR=1 Q
.S ERROR=$$XTRCT^VAQDBIP2(TMP,DFN,"",ARRAY,ENCPTR,KEY1,KEY2)
.I ERROR D Q
..S TMP=$$KILLARR^VAQUTL1(ARRAY,"VALUE")
..S TMP=$$KILLARR^VAQUTL1(ARRAY,"ID")
Q:(ERROR<0) ERROR
Q 0
--- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HVAQDBIP3 2401 printed Dec 13, 2024@02:25:10 Page 2
VAQDBIP3 ;ALB/JRP - MINIMUM PATIENT INFO EXTRACTION;9-MAR-93
+1 ;;1.5;PATIENT DATA EXCHANGE;;NOV 17, 1993
MINXTRCT(TRAN,DFN,ARRAY) ;EXTRACT MINIMUM (EXTRACTION ARRAY)
+1 ;INPUT : TRAN - Pointer to VAQ - TRANSACTION file
+2 ; DFN - Pointer to patient in PATIENT file
+3 ; ARRAY - Where to store information (full global reference)
+4 ;OUTPUT : 0 - Extraction was successfull
+5 ; -1^Error_Text - Extraction was not successfull
+6 ;NOTE : If the minimum patient information can not be extracted,
+7 ; the "VALUE" and "ID" nodes in ARRAY will be deleted.
+8 ; : If TRAN is passed
+9 ; The patient pointer of the transaction will be used
+10 ; Encryption will be based on the transaction
+11 ; If DFN is passed
+12 ; Encryption will be based on the site parameter
+13 ; : Pointer to transaction takes precedence over DFN ... if
+14 ; TRAN>0 the DFN will be based on the transaction
+15 ;
+16 ;CHECK INPUT
+17 SET TRAN=+$GET(TRAN)
+18 SET DFN=+$GET(DFN)
+19 if (('TRAN)&('DFN))
QUIT "-1^Did not pass pointer to transaction or patient"
+20 IF (TRAN)
if ('$DATA(^VAT(394.61,TRAN)))
QUIT "-1^Did not pass valid pointer to VAQ - TRANSACTION file"
+21 IF (TRAN)
SET DFN=+$PIECE($GET(^VAT(394.61,TRAN,0)),"^",3)
if ('DFN)
QUIT "-1^Transaction did not contain pointer to PATIENT file"
+22 if ('$DATA(^DPT(DFN)))
QUIT "-1^Did not pass valid pointer to PATIENT file"
+23 if ($GET(ARRAY)="")
QUIT "-1^Did not pass output array"
+24 ;DECLARE VARIABLES
+25 NEW ERROR,TMP,LOOP,ENCPTR,KEY1,KEY2,SENDER
+26 ;DETERMINE IF ENCRYPTION IS ON - SAVE POINTER TO ENCRYPTION METHOD
+27 if ('TRAN)
SET ENCPTR=$$NCRYPTON^VAQUTL2(0)
+28 if (TRAN)
SET ENCPTR=$$TRANENC^VAQUTL3(TRAN,1)
+29 ;DETERMINE PRIMARY KEY
+30 IF (TRAN)
SET SENDER=$$SENDER^VAQCON2(TRAN)
if ($PIECE(SENDER,"^",1)="-1")
QUIT "-1^Could not determine encryption keys"
+31 if (TRAN)
SET SENDER=$PIECE(SENDER,"^",1)
+32 if (TRAN)
SET KEY1=$$NAMEKEY^VAQUTL3(SENDER,1)
+33 if ('TRAN)
SET KEY1=$$DUZKEY^VAQUTL3($GET(DUZ),1)
+34 ;DETERMINE SECONDARY KEY
+35 if (TRAN)
SET KEY2=$$NAMEKEY^VAQUTL3(SENDER,0)
+36 if ('TRAN)
SET KEY2=$$DUZKEY^VAQUTL3($GET(DUZ),0)
+37 IF (ENCPTR)
if ((KEY1="")!(KEY2=""))
QUIT "-1^Could not determine encryption keys"
+38 SET ERROR=0
+39 ;EXTRACT INFORMATION
+40 FOR LOOP=1:1
Begin DoDot:1
+41 SET TMP=$TEXT(MIN+LOOP^VAQDBII1)
+42 IF ($PIECE(TMP,";;",2)="")
SET ERROR=1
QUIT
+43 SET ERROR=$$XTRCT^VAQDBIP2(TMP,DFN,"",ARRAY,ENCPTR,KEY1,KEY2)
+44 IF ERROR
Begin DoDot:2
+45 SET TMP=$$KILLARR^VAQUTL1(ARRAY,"VALUE")
+46 SET TMP=$$KILLARR^VAQUTL1(ARRAY,"ID")
End DoDot:2
QUIT
End DoDot:1
if (ERROR)
QUIT
+47 if (ERROR<0)
QUIT ERROR
+48 QUIT 0