source: FOIAVistA/trunk/r/ENROLLMENT_APPLICATION_SYSTEM-EAS/EASEZU1.m@ 1765

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

initial load of FOIAVistA 6/30/08 version

File size: 5.4 KB
Line 
1EASEZU1 ;ALB/jap - Utilities for 1010EZ Processing ;10/12/00 13:08
2 ;;1.0;ENROLLMENT APPLICATION SYSTEM;;Mar 15, 2001
3 ;
4KEY711(EASKEY) ;get file #711 record associated with key
5 ;input EASKEY = character string equal to a 1010EZ Assigned Data Name OR Data Key
6 ;output KEYIEN = pointer to file #711 for the 1010EZ data element is 1st piece;
7 ; format: ien^Assigned Data Name^Data Key
8 ; returns ".1" if EASKEY is invalid, i.e., data element is unknown
9 ;
10 N N,KEYIEN,X,XX,Y,DA,DIE,DR
11 S KEYIEN=""
12 ;key passed in is Data Key
13 I EASKEY[".",EASKEY[";" D
14 .S KEYIEN=$O(^EAS(711,"C",EASKEY,0)) Q:'KEYIEN
15 .S X=$P(^EAS(711,KEYIEN,0),U,1)
16 .S KEYIEN=KEYIEN_U_X_U_EASKEY
17 ;key passed in is Assigned Data Name
18 I KEYIEN="" D
19 .S KEYIEN=$O(^EAS(711,"AB",EASKEY,0)) Q:'KEYIEN
20 .S X=$P(^EAS(711,KEYIEN,0),U,2)
21 .S KEYIEN=KEYIEN_U_EASKEY_U_X
22 I KEYIEN="" S KEYIEN=".1"
23 Q KEYIEN
24 ;
25DATA712(EASAPP,EASKEY,EASMM) ;get 1010EZ data associated with data key
26 ;input EASAPP = ien to #712 for Application
27 ; EASKEY = IEN to file #711;
28 ; OR KEYIEN returned by KEY711^EASEZU1
29 ; EASMM = multiple number; default is 1; optional
30 ; pertains to data elements that may be multiple,
31 ; i.e., additional child dependents
32 ;
33 ;output RTR = piece 1 - 1010EZ data associated with Data Key for this Application;
34 ; piece 2 - subrecord ien associated with Data Key for this Application;
35 ; returns ^ if data item not found in this Application
36 ;
37 N N,OUT,KEYIEN,MULTIPLE,X,RTR,IN,UP
38 I '$D(^EAS(712,EASAPP,0)) Q U
39 ;this is the "unknown" data element
40 I EASKEY=.1 Q U
41 I '$G(EASMM) S EASMM=1
42 S KEYIEN=+EASKEY
43 S OUT=0,N=0,X="",RTR=U
44 F S N=$O(^EAS(712,EASAPP,10,"B",KEYIEN,N)) Q:'N D Q:OUT
45 .S MULTIPLE=$P($G(^EAS(712,EASAPP,10,N,0)),U,2)
46 .I MULTIPLE=EASMM D
47 ..;use 'updated' data if present
48 ..S X=$G(^EAS(712,EASAPP,10,N,1)),IN=$P(X,U,1),UP=$P(X,U,2)
49 ..S RTR=$S(UP'="":UP,1:IN),RTR=RTR_U_N,OUT=1
50 Q RTR
51 ;
52LINKUP(EASAPP,EASAEL,EASLINK) ;place link into a file #712 Data Element subrecord
53 ;input EASAPP = ien to #712 for Application
54 ; EASAEL = ien to Data Elements subrecord in #712
55 ; EASLINK = file ien OR file_ien;subfile_ien to link 1010EZ data
56 ; with existing Patient database record
57 ;exit if record/subrecord not valid in #712
58 N DA,DR,DIE,X,Y
59 Q:'EASAPP Q:'$D(^EAS(712,EASAPP,0))
60 Q:'EASAEL Q:'$D(^EAS(712,EASAPP,10,EASAEL,0))
61 ;place link in Data Element subrecord of #712
62 S DA(1)=EASAPP,DA=EASAEL,DR(1)=10
63 S DIE="^EAS(712,EASAPP,10,"
64 S DR="2.1///^S X=EASLINK;"
65 D ^DIE
66 Q
67 ;
68ADD71201(EASAPP,KEYIEN,LINK,MULTIPLE) ;add another subrecord to #712.01
69 ;used in cases where Patient data exists but 1010EZ data does not;
70 ;this new subrecord will hold the VistA database ien(s)
71 ;
72 ;input EASAPP = ien to file #712
73 ; KEYIEN = ien to file #711 for data element
74 ; LINK = ien(s) in VistA database;
75 ; format: ien_main_file;ien_subfile
76 ; MULTIPLE = default is 1; (optional)
77 ; currently only needed for additional child dependents
78 ; associated with Section IIB of the form.
79 ;output NEWIEN = ien to new subrecord in sibfile #712.01
80 N NEWIEN,LASTIEN,DA,DIC,DIE,DR,DLAYGO,DINUM,X,Y
81 Q:'KEYIEN
82 Q:LINK=""
83 S LASTIEN=$O(^EAS(712,EASAPP,10,9999),-1),NEWIEN=LASTIEN+1
84 ;create subrecord
85 S DIC="^EAS(712,EASAPP,10,",DIC(0)="L",DLAYGO="",X=KEYIEN,DINUM=NEWIEN
86 S DA(1)=EASAPP,DIC("P")=$P(^DD(712,10,0),U,2)
87 K DD,DO D FILE^DICN
88 ;file data element link
89 S DIE="^EAS(712,EASAPP,10,",DA=NEWIEN,DA(1)=EASAPP,DR(1)="10;"
90 S MULTIPLE=$G(MULTIPLE) S:'MULTIPLE MULTIPLE=1
91 S DR=".1///^S X=MULTIPLE;2.1///^S X=LINK;"
92 D ^DIE
93 Q
94 ;
95GETANY(EASAPP,EASDFN,EASAEL,EASKEY) ;get data from VistA database for any field related to 1010EZ
96 ;input EASAPP = ien to #712 for Application
97 ; EASDFN = ien to #2 for Applicant
98 ; either EASAEL or EASKEY must be non-null
99 ; EASAEL = ien to Data Elements subrecord in #712; optional
100 ; EASKEY = data key from Data Elements subrecord in #712; optional
101 ;
102 ;output RTR = data obtained from Patient database; external format
103 ; OR -1 if invalid input
104 ;
105 ;the "link" below is a pointer (ien) to file or subfile record that
106 ; was previously found to contain data which potentially matches
107 ; 1010EZ data
108 ;
109 N X,LINK,N,FILE,SUBFILE,FIELD,ARRAY,DIQ,DA,DR,DIC,RTR
110 S EASKEY=$G(EASKEY),N=0
111 I 'EASAEL,EASKEY="" Q -1
112 I 'EASAEL,EASKEY'="" D
113 .S EASAEL=$P($$DATA712(EASAPP,EASKEY),U,2) Q:'EASAEL
114 .S N=$O(^EAS(711,"C",EASKEY,0))
115 I EASKEY="",EASAEL S N=$P($G(^EAS(712,EASAPP,10,EASAEL,0)),U,1)
116 I 'N Q -1
117 ;database parameters in #711
118 S X=$G(^EAS(711,N,1)),FILE=$P(X,U,1),SUBFILE=$P(X,U,2),FIELD=$P(X,U,3)
119 ;get link ien if other than file #2
120 S LINK=$P($G(^EAS(712,EASAPP,10,EASAEL,2)),U,2)
121 ;if data location is main file #2, then link is dfn
122 I FILE=2,(SUBFILE=2!SUBFILE="") S LINK=EASDFN
123 ;
124 ;if no link to database, quit
125 I 'LINK Q -1
126 ;otherwise setup FM call & use link to get data
127 I (SUBFILE="")!(SUBFILE=FILE) D
128 .;data in main file
129 .S DIQ="ARRAY",DIQ(0)="E",DA=LINK,DR=FIELD,DIC=FILE
130 .D EN^DIQ1
131 .S RTR=$G(ARRAY(FILE,LINK,FIELD,"E"))
132 I SUBFILE'="",SUBFILE'=FILE D
133 .;data in subfile
134 .;in this case LINK = file_ien;subfile_ien
135 .S DIQ="ARRAY",DIQ(0)="E",DA=$P(LINK,";",1),DIC=FILE
136 .;get field # for subfile
137 .S DR=$O(^DD(FILE,"SB",SUBFILE,0))
138 .S DR(SUBFILE)=FIELD,DA(SUBFILE)=$P(LINK,";",2)
139 .D EN^DIQ1
140 .S RTR=$G(ARRAY(SUBFILE,$P(LINK,";",2),FIELD,"E"))
141 Q RTR
Note: See TracBrowser for help on using the repository browser.