source: FOIAVistA/trunk/r/PATIENT_DATA_EXCHANGE-VAQ/VAQPAR11.m@ 674

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

initial load of FOIAVistA 6/30/08 version

File size: 4.2 KB
Line 
1VAQPAR11 ;ALB/JRP - MESSAGE PARSING;10-MAY-93
2 ;;1.5;PATIENT DATA EXCHANGE;;NOV 17, 1993
3DATA10(ARRAY,BLOCK,BLOCKNUM) ;PARSE DATA BLOCKS FOR 1.0 MESSAGE
4 ;INPUT : ARRAY - Array containing pre-parsed version 1.0 transmission
5 ; (full global reference)
6 ; BLOCK - Version 1.0 block name (MIN,MAS,PHA)
7 ; BLOCKNUM - Block sequence number (defaults to 1)
8 ; (As defined by MailMan)
9 ; XMFROM, XMREC, XMZ
10 ; (Declared in SERVER^VAQADM2)
11 ; XMER, XMRG, XMPOS
12 ;OUTPUT : XMER - Exit condition
13 ; 0 = Success
14 ; -1^Error_Text = Error
15 ; Parsed array will be same as parsed array for version
16 ; 1.5 message and have the format:
17 ; ARRAY(2,"DATA",BLOCKNUM,Line)
18 ;
19 ;CHECK INPUT
20 I ($G(ARRAY)="") S XMER="-1^Did not pass reference to parsing array" Q
21 I ('$D(@ARRAY@(1))) S XMER="-1^Parsing array did not contain pre-parsed transmission" Q
22 I ($G(BLOCK)="") S XMER="-1^Did not pass data block name" Q
23 I ((BLOCK'="MIN")&(BLOCK'="MAS")&(BLOCK'="PHA")) S XMER="-1^Did not pass valid version 1.0 data block name" Q
24 S:($G(BLOCKNUM)="") BLOCKNUM=1
25 ;DECLARE VARIABLES
26 N LINE,X,Y,TMP,OFFSET,FILE,FIELD,FIELDS,VALUES,SEQ,TMPARR
27 N FLDCNT,VALCNT,LOOP1,LOOP2,REPCNT,ID,PATNAME,RXNUM,VALUE
28 ;GET PATIENT'S NAME
29 S PATNAME=$G(@ARRAY@(2,"PATIENT",1,3))
30 I (PATNAME="") S XMER="-1^Patient's name was not contained in the transmission" Q
31 ;SET UP TEMPORARY PARSING ARRAY
32 S TMP=$P(ARRAY,"(",1)
33 S X=$P(ARRAY,"(",2)
34 S Y=$P(X,")",1)
35 S:(Y="") TMPARR=TMP_"("_3_")"
36 S:(Y'="") TMPARR=TMP_"("_Y_","_3_")"
37 K @TMPARR
38 S XMER=0
39 ;LINE 1
40 S @ARRAY@(2,"DATA",BLOCKNUM,1)="$DATA"
41 S X="PDX*"_BLOCK
42 S:(BLOCK="PHA") X="PDX*MPL"
43 S @ARRAY@(2,"DATA",BLOCKNUM,2)=X
44 ;PRE-PARSE DATA BLOCK
45 S OFFSET=""
46 F S OFFSET=$O(@ARRAY@(1,BLOCK,OFFSET)) Q:(OFFSET="") D
47 .S TMP=$G(@ARRAY@(1,BLOCK,OFFSET))
48 .Q:(TMP="")
49 .S FILE=$P(TMP,"^",1)
50 .S FIELDS=$P(TMP,"^",2)
51 .S VALUES=$P(TMP,"^",3,($L(TMP,"^")))
52 .S RXNUM=""
53 .I (FILE=52.1) D
54 ..S RXNUM=$P(FIELDS,"~",2)
55 ..S FIELDS=$P(FIELDS,"~",1)
56 .I ((FILE=52)&($P(FIELDS,";",1)=.01)) D
57 ..S RXNUM=$P(VALUES,"^",1)
58 .S FLDCNT=$L(FIELDS,";")
59 .S VALCNT=$L(VALUES,"^")
60 .S REPCNT=(VALCNT\FLDCNT)-1
61 .S:(REPCNT<0) REPCNT=0
62 .F LOOP1=0:1:REPCNT D
63 ..F LOOP2=1:1:FLDCNT D
64 ...S FIELD=$P(FIELDS,";",LOOP2)
65 ...S VALUE=$P(VALUES,"^",((LOOP1*FLDCNT)+LOOP2))
66 ...;CONVERT DATES
67 ...S:($P($G(^DD(FILE,FIELD,0)),"^",2)["D") VALUE=$$DOBFMT^VAQUTL99(VALUE,1)
68 ...;CONVERT STATES
69 ...I ((+$P($P($G(^DD(FILE,FIELD,0)),"^",2),"P",2))=5) D
70 ....Q:(VALUE="")
71 ....S X=$O(^DIC(5,"C",VALUE,""))
72 ....I (X="") S VALUE="" Q
73 ....S VALUE=$P($G(^DIC(5,X,0)),"^",1)
74 ...S SEQ=""
75 ...F Q:($O(@TMPARR@("VALUE",FILE,FIELD,SEQ))="") S SEQ=$O(@TMPARR@("VALUE",FILE,FIELD,SEQ)) Q:((FILE=52)&(FIELD=.01)&($G(@TMPARR@("VALUE",FILE,FIELD,SEQ))=VALUE))
76 ...S SEQ=$S((SEQ=""):0,((FILE=52)&(FIELD=.01)&($G(@TMPARR@("VALUE",FILE,FIELD,SEQ))=VALUE)):SEQ,1:SEQ+1)
77 ...S @TMPARR@("VALUE",FILE,FIELD,SEQ)=VALUE
78 ...I (BLOCK="MIN") S ID=PATNAME
79 ...I (BLOCK="PHA") D
80 ....I (FILE=52) S ID=$S((FIELD=.01):PATNAME,1:RXNUM) Q
81 ....I (FILE=52.1) S ID=RXNUM Q
82 ....I ((FILE=2)!(FILE=55)) S ID=PATNAME Q
83 ....I (FIELD=.01) S ID=PATNAME Q
84 ....S ID=$G(@TMPARR@("VALUE",FILE,.01,SEQ))
85 ...I (BLOCK="MAS") D
86 ....I (FILE=2) S ID=PATNAME Q
87 ....I (FILE=2.98) S ID=$S((FIELD=.001):PATNAME,1:$G(@TMPARR@("VALUE",2.98,.001,SEQ))) Q
88 ....I (FIELD=.01) S ID=PATNAME Q
89 ....I (FILE=36) S ID=$G(@TMPARR@("VALUE",2.312,.01,SEQ)) Q
90 ....S ID=$G(@TMPARR@("VALUE",FILE,.01,SEQ))
91 ...S @TMPARR@("ID",FILE,FIELD,SEQ)=ID
92 ;STORE INTO PARSE ARRAY
93 S LINE=3
94 S FILE=""
95 F S FILE=$O(@TMPARR@("VALUE",FILE)) Q:(FILE="") D
96 .S FIELD=""
97 .F S FIELD=$O(@TMPARR@("VALUE",FILE,FIELD)) Q:(FIELD="") D
98 ..S VALUES=0
99 ..F Q:($O(@TMPARR@("VALUE",FILE,FIELD,VALUES))="") S VALUES=$O(@TMPARR@("VALUE",FILE,FIELD,VALUES))
100 ..S VALUES=VALUES+1
101 ..S @ARRAY@(2,"DATA",BLOCKNUM,LINE)=0_"^"_FILE_"^"_FIELD_"^"_VALUES
102 ..S LINE=LINE+1
103 ..S SEQ=""
104 ..F S SEQ=$O(@TMPARR@("VALUE",FILE,FIELD,SEQ)) Q:(SEQ="") D
105 ...S VALUE=$G(@TMPARR@("VALUE",FILE,FIELD,SEQ))
106 ...S @ARRAY@(2,"DATA",BLOCKNUM,LINE)=VALUE
107 ...S LINE=LINE+1
108 ...S ID=$G(@TMPARR@("ID",FILE,FIELD,SEQ))
109 ...S @ARRAY@(2,"DATA",BLOCKNUM,LINE)=ID
110 ...S LINE=LINE+1
111 ;DONE
112 S @ARRAY@(2,"DATA",BLOCKNUM,LINE)="$$DATA"
113 K @TMPARR
114 Q
Note: See TracBrowser for help on using the repository browser.