source: WorldVistAEHR/trunk/r/PATIENT_DATA_EXCHANGE-VAQ/VAQUPD2.m@ 1005

Last change on this file since 1005 was 613, checked in by George Lilly, 15 years ago

initial load of WorldVistAEHR

File size: 3.8 KB
Line 
1VAQUPD2 ;ALB/JRP - EXTRACT SEGMENT FROM DATA FILE;08-APR-1993
2 ;;1.5;PATIENT DATA EXCHANGE;;NOV 17, 1993
3TRNDSP(TRANPTR,ROOT,OFFSET) ;BUILD DISPLAY FOR ALL SEGMENTS IN A TRANSACTION
4 ;INPUT : TRANPTR - Pointer to VAQ - TRANSACTION file
5 ; ROOT - Where to store the information (full global reference)
6 ; Defaluts to ^TMP("VAQ",$J)
7 ; OFFSET - Where to begin placing information (defaults to 0)
8 ;OUTPUT : N - Number of lines in display
9 ; -1^Error_Text - Error
10 ;NOTES : ROOT will be returned in the format
11 ; ROOT("DISPLAY",Line_Number,0)
12 ; : Deletion of the outupt array before calling this routine
13 ; is the responsiblity of the calling application.
14 ;
15 ;CHECK INPUT
16 S TRANPTR=+$G(TRANPTR)
17 Q:('TRANPTR) "-1^Pointer to VAQ - TRANSACTION file not passed"
18 Q:('$D(^VAT(394.61,TRANPTR))) "-1^Transaction did not exist"
19 S ROOT=$G(ROOT)
20 S:(ROOT="") ROOT="^TMP(""VAQ"","_$J_")"
21 S OFFSET=+$G(OFFSET)
22 ;DECLARE VARIABLES
23 N SEG,LINE,LINECNT,X
24 S LINE=OFFSET
25 Q:('$D(^VAT(394.61,TRANPTR,"SEG"))) "-1^Transaction did not contain any data segments"
26 S SEG=0
27 ;LOOP THROUGH EACH DATA SEGMENT CONTAINED IN TRANSACTION
28 F S SEG=+$O(^VAT(394.61,TRANPTR,"SEG","B",SEG)) Q:('SEG) D
29 .;PUT DISPLAY INTO OUTPUT ARRAY
30 .S LINECNT=$$BLDDSP(TRANPTR,SEG,ROOT,LINE)
31 .Q:(LINECNT<1)
32 .S LINE=LINE+LINECNT
33 .;PUT WHITE SPACE AFTER EACH SEGMENT
34 .F X=1:1:3 S @ROOT@("DISPLAY",LINE,0)="",LINE=LINE+1
35 Q (LINE-OFFSET)
36 ;
37BLDDSP(TRAN,SEGPTR,ROOT,OFFSET) ;BUILD DISPLAYABLE SEGMENT FROM DATA FILE
38 ;INPUT : TRAN - Pointer to VAQ - TRANSACTION file
39 ; SEGPTR - Pointer to VAQ - DATA SEGMENT file
40 ; ROOT - Where to store the display array (full global ref)
41 ; OFFSET - Where to begin placing information (defaults to 0)
42 ;OUTPUT : n - Number of lines in display
43 ; -1^Error_Text - Error
44 ;NOTES : ROOT will contain the display ready segment in the format
45 ; ROOT("DISPLAY",LineNumber,0)=Line of display
46 ; : It is the responsibility of the calling module to delete
47 ; ROOT before and after the call.
48 ;
49 ;CHECK INPUT
50 S TRAN=+$G(TRAN)
51 S SEGPTR=+$G(SEGPTR)
52 Q:(('TRAN)!('SEGPTR)) "-1^Did not pass pointer to transaction or segment"
53 S OFFSET=+$G(OFFSET)
54 Q:('$D(^VAT(394.61,TRAN))) "-1^Did not pass valid transaction"
55 Q:('$D(^VAT(394.71,SEGPTR))) "-1^Did not pass a valid segment"
56 Q:($G(ROOT)="") "-1^Did not pass reference to output array"
57 ;DECLARE VARIABLES
58 N TMP,XTRCT,MTHD,MINPTR,GETMIN
59 S XTRCT="^TMP(""VAQ-SEG"","_$J_","_TRAN_","_SEGPTR_")"
60 K @XTRCT
61 ;SEGMENT NOT PASSED IN PDX
62 Q:('$D(^VAT(394.62,"A-SEGMENT",TRAN,SEGPTR))) "-1^Transaction did not contain information for segment"
63 ;DISPLAY READY
64 S TMP=$D(^VAT(394.62,"A-DISPLAY",TRAN,SEGPTR))
65 Q:(TMP) $$EXTARR^VAQUPD25(TRAN,SEGPTR,ROOT,OFFSET)
66 ;GET METHOD TO BUILD DISPLAY ARRAY
67 S MTHD=$G(^VAT(394.71,SEGPTR,"DRTN"))
68 Q:(MTHD="") "-1^Display method did not exist for segment"
69 ;GET EXTRACTION ARRAY
70 S TMP=$$EXTARR^VAQUPD25(TRAN,SEGPTR,XTRCT)
71 I (TMP) K @XTRCT Q TMP
72 ;DETERMINE IF MINIMUM DATA NEEDS TO BE PLACED IN EXTRACTION ARRAY
73 ; THIS IS DONE FOR INFO FROM A 1.0 SITE
74 S TMP=$P($G(^VAT(394.71,SEGPTR,0)),"^",2)
75 S GETMIN=$S((TMP="PDX*MPL"):1,(TMP="PDX*MPS"):1,1:0)
76 I ((GETMIN)&((+$P($G(^VAT(394.61,TRAN,0)),"^",7))=1)) D I (TMP) K @XTRCT Q TMP
77 .;GET POINTER TO MINIMUM SEGMENT
78 .S MINPTR=+$O(^VAT(394.71,"C","PDX*MIN",""))
79 .I ('MINPTR) S TMP="-1^Version 1.0 transaction did not contain minimum patient information" Q
80 .;MIN SEGMENT NOT PASSED IN PDX
81 .I ('$D(^VAT(394.62,"A-SEGMENT",TRAN,MINPTR))) S TMP="-1^Version 1.0 transaction did not contain minimum patient information" Q
82 .;PUT MINIMUM DATA INTO EXTRACTION ARRAY
83 .S TMP=$$EXTARR^VAQUPD25(TRAN,MINPTR,XTRCT)
84 .S:(TMP) TMP="-1^Unable to extract minimum patient information from version 1.0 transaction"
85 ;BUILD DISPLAY
86 X ("S TMP="_MTHD)
87 K @XTRCT
88 Q TMP
Note: See TracBrowser for help on using the repository browser.