source: BMXNET_RPMS_dotNET_UTILITIES-BMX/trunk/cs/bmx_0200scr/BMX2/BMXNetTest/frmVisitDemo.cs@ 1211

Last change on this file since 1211 was 815, checked in by Sam Habiel, 14 years ago

Initial commit of C# Source Code. Now to try to get it to compile.

File size: 8.7 KB
Line 
1using System;
2using System.Drawing;
3using System.Collections;
4using System.ComponentModel;
5using System.Windows.Forms;
6using System.Data;
7
8namespace IndianHealthService.BMXNet
9{
10 /// <summary>
11 /// Summary description for frmVisitDemo.
12 /// </summary>
13 public class frmVisitDemo : System.Windows.Forms.Form
14 {
15 private System.Windows.Forms.TextBox txtPatName;
16 private System.Windows.Forms.Label label1;
17 private System.Windows.Forms.Button cmdViewVisitInfo;
18 private System.Windows.Forms.Panel panel1;
19 private System.Windows.Forms.Panel panel2;
20 private System.Windows.Forms.DataGrid dataGrid1;
21
22 private System.ComponentModel.Container components = null;
23
24 public frmVisitDemo()
25 {
26 InitializeComponent();
27 }
28
29 /// <summary>
30 /// Clean up any resources being used.
31 /// </summary>
32 protected override void Dispose( bool disposing )
33 {
34 if( disposing )
35 {
36 if(components != null)
37 {
38 components.Dispose();
39 }
40 }
41 base.Dispose( disposing );
42 }
43
44 #region Windows Form Designer generated code
45 /// <summary>
46 /// Required method for Designer support - do not modify
47 /// the contents of this method with the code editor.
48 /// </summary>
49 private void InitializeComponent()
50 {
51 this.txtPatName = new System.Windows.Forms.TextBox();
52 this.label1 = new System.Windows.Forms.Label();
53 this.cmdViewVisitInfo = new System.Windows.Forms.Button();
54 this.panel1 = new System.Windows.Forms.Panel();
55 this.panel2 = new System.Windows.Forms.Panel();
56 this.dataGrid1 = new System.Windows.Forms.DataGrid();
57 this.panel1.SuspendLayout();
58 this.panel2.SuspendLayout();
59 ((System.ComponentModel.ISupportInitialize)(this.dataGrid1)).BeginInit();
60 this.SuspendLayout();
61 //
62 // txtPatName
63 //
64 this.txtPatName.Location = new System.Drawing.Point(120, 24);
65 this.txtPatName.Name = "txtPatName";
66 this.txtPatName.Size = new System.Drawing.Size(152, 20);
67 this.txtPatName.TabIndex = 0;
68 this.txtPatName.Text = "W";
69 //
70 // label1
71 //
72 this.label1.Location = new System.Drawing.Point(16, 16);
73 this.label1.Name = "label1";
74 this.label1.Size = new System.Drawing.Size(104, 24);
75 this.label1.TabIndex = 1;
76 this.label1.Text = "First few characters of patient name:";
77 //
78 // cmdViewVisitInfo
79 //
80 this.cmdViewVisitInfo.Location = new System.Drawing.Point(304, 24);
81 this.cmdViewVisitInfo.Name = "cmdViewVisitInfo";
82 this.cmdViewVisitInfo.Size = new System.Drawing.Size(112, 24);
83 this.cmdViewVisitInfo.TabIndex = 2;
84 this.cmdViewVisitInfo.Text = "View Patient Visits";
85 this.cmdViewVisitInfo.Click += new System.EventHandler(this.cmdViewVisitInfo_Click);
86 //
87 // panel1
88 //
89 this.panel1.Controls.Add(this.cmdViewVisitInfo);
90 this.panel1.Controls.Add(this.txtPatName);
91 this.panel1.Controls.Add(this.label1);
92 this.panel1.Dock = System.Windows.Forms.DockStyle.Top;
93 this.panel1.Location = new System.Drawing.Point(0, 0);
94 this.panel1.Name = "panel1";
95 this.panel1.Size = new System.Drawing.Size(584, 72);
96 this.panel1.TabIndex = 3;
97 //
98 // panel2
99 //
100 this.panel2.Controls.Add(this.dataGrid1);
101 this.panel2.Dock = System.Windows.Forms.DockStyle.Fill;
102 this.panel2.Location = new System.Drawing.Point(0, 72);
103 this.panel2.Name = "panel2";
104 this.panel2.Size = new System.Drawing.Size(584, 246);
105 this.panel2.TabIndex = 4;
106 //
107 // dataGrid1
108 //
109 this.dataGrid1.AccessibleName = "DataGrid";
110 this.dataGrid1.AccessibleRole = System.Windows.Forms.AccessibleRole.Table;
111 this.dataGrid1.DataMember = "";
112 this.dataGrid1.Dock = System.Windows.Forms.DockStyle.Fill;
113 this.dataGrid1.HeaderForeColor = System.Drawing.SystemColors.ControlText;
114 this.dataGrid1.Location = new System.Drawing.Point(0, 0);
115 this.dataGrid1.Name = "dataGrid1";
116 this.dataGrid1.Size = new System.Drawing.Size(584, 246);
117 this.dataGrid1.TabIndex = 0;
118 //
119 // frmVisitDemo
120 //
121 this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
122 this.ClientSize = new System.Drawing.Size(584, 318);
123 this.Controls.Add(this.panel2);
124 this.Controls.Add(this.panel1);
125 this.Name = "frmVisitDemo";
126 this.Text = "frmVisitDemo";
127 this.panel1.ResumeLayout(false);
128 this.panel2.ResumeLayout(false);
129 ((System.ComponentModel.ISupportInitialize)(this.dataGrid1)).EndInit();
130 this.ResumeLayout(false);
131
132 }
133 #endregion
134
135 #region Fields
136 BMXNetConnectInfo m_ci;
137 #endregion Fields
138
139
140 public void InitializePage(BMXNetConnectInfo ci)
141 {
142 m_ci = ci;
143 CreateGridStyles();
144 }
145
146 private void cmdViewVisitInfo_Click(object sender, System.EventArgs e)
147 {
148 if (m_ci.Connected == false)
149 {
150 MessageBox.Show("Must connect to RPMS first");
151 return;
152 }
153 try
154 {
155 //Declare new dataset and connection variables
156 DataSet m_dsGlobal = new DataSet("Global");
157
158 //Retrieve RPMS Records from PATIENT file
159 string sCmd = "SELECT BMXIEN DFN, NAME, AGE, SEX, DOB FROM PATIENT WHERE NAME LIKE '" + txtPatName.Text + "%'";
160 m_ci.RPMSDataTable(sCmd, "Patient", m_dsGlobal);
161
162 //Build Primary Key for Patient table
163 DataTable dtGroups = m_dsGlobal.Tables["Patient"];
164 DataColumn dcKey = dtGroups.Columns["DFN"];
165 DataColumn[] dcKeys = new DataColumn[1];
166 dcKeys[0] = dcKey;
167 dtGroups.PrimaryKey = dcKeys;
168
169 //Retrieve RPMS Records from VISIT file
170 sCmd = @"SELECT INTERNAL[PATIENT_NAME] PDFN, BMXIEN VDFN, VISIT/ADMIT_DATE&TIME, CLINIC, LOC._OF_ENCOUNTER FROM VISIT WHERE PATIENT_NAME LIKE '" + txtPatName.Text + "%'";
171 m_ci.RPMSDataTable(sCmd, "Visit", m_dsGlobal);
172
173 //Build Primary Key for Visit table
174 DataTable dtAGTypes = m_dsGlobal.Tables["Visit"];
175 DataColumn dcGTKey = dtAGTypes.Columns["VDFN"];
176 DataColumn[] dcGTKeys = new DataColumn[1];
177 dcGTKeys[0] = dcGTKey;
178 dtAGTypes.PrimaryKey = dcGTKeys;
179
180 //Build Data Relationship between Patient and Visit tables
181 DataRelation dr = new DataRelation("PatientVisit", //Relation Name
182 m_dsGlobal.Tables["Patient"].Columns["DFN"], //Parent
183 m_dsGlobal.Tables["Visit"].Columns["PDFN"]); //Child
184 m_dsGlobal.Relations.Add(dr);
185
186 this.dataGrid1.DataSource = m_dsGlobal.Tables["Patient"];
187 }
188 catch (Exception ex)
189 {
190 MessageBox.Show(ex.Message, "BMXNetTest Error");
191 }
192 }
193
194 private void CreateGridStyles()
195 {
196 //Create DataGridTableStyle for Patient table
197 DataGridTableStyle tsRU = new DataGridTableStyle();
198 tsRU.MappingName = "Patient";
199 tsRU.ReadOnly = true;
200
201 // Add DFN column style.
202 DataGridColumnStyle colDFN = new DataGridTextBoxColumn();
203 colDFN.MappingName = "DFN";
204 colDFN.HeaderText = "DFN";
205 colDFN.Width = 0;
206 tsRU.GridColumnStyles.Add(colDFN);
207
208 // Add NAME column style.
209 DataGridColumnStyle colRUID = new DataGridTextBoxColumn();
210 colRUID.MappingName = "NAME";
211 colRUID.HeaderText = "Patient Name";
212 colRUID.Width = 250;
213 tsRU.GridColumnStyles.Add(colRUID);
214
215 // Add AGE column style.
216 DataGridColumnStyle colRUserID = new DataGridTextBoxColumn();
217 colRUserID.MappingName = "AGE";
218 colRUserID.HeaderText = "Age";
219 colRUserID.Width = 50;
220 tsRU.GridColumnStyles.Add(colRUserID);
221
222 // Add SEX column style.
223 DataGridColumnStyle colSex = new DataGridTextBoxColumn();
224 colSex.MappingName = "SEX";
225 colSex.HeaderText = "Sex";
226 colSex.Width = 50;
227 tsRU.GridColumnStyles.Add(colSex);
228
229 // Add DOB column style.
230 DataGridColumnStyle colDOB = new DataGridTextBoxColumn();
231 colDOB.MappingName = "DOB";
232 colDOB.HeaderText = "Date of Birth";
233 colDOB.Width = 100;
234 tsRU.GridColumnStyles.Add(colDOB);
235
236 this.dataGrid1.TableStyles.Add(tsRU);
237
238 //Create DataGridTableStyle for Visit table
239 DataGridTableStyle tsVisit = new DataGridTableStyle();
240 tsVisit.MappingName = "Visit";
241 tsVisit.ReadOnly = true;
242
243 // Add VISIT/ADMIT_DATE&TIME column style
244 DataGridColumnStyle colVDate = new DataGridTextBoxColumn();
245 colVDate.MappingName = "VISIT/ADMIT_DATE&TIME";
246 colVDate.HeaderText = "Visit Date & Time";
247 colVDate.Width = 150;
248 tsVisit.GridColumnStyles.Add(colVDate);
249
250 // Add LOC._OF_ENCOUNTER column style
251 DataGridColumnStyle colLocation = new DataGridTextBoxColumn();
252 colLocation.MappingName = "LOC._OF_ENCOUNTER";
253 colLocation.HeaderText = "Location of Encounter";
254 colLocation.Width = 200;
255 tsVisit.GridColumnStyles.Add(colLocation);
256
257 // Add CLINIC column style
258 DataGridColumnStyle colClinic = new DataGridTextBoxColumn();
259 colClinic.MappingName = "CLINIC";
260 colClinic.HeaderText = "Clinic";
261 colClinic.Width = 100;
262 tsVisit.GridColumnStyles.Add(colClinic);
263
264 this.dataGrid1.TableStyles.Add(tsVisit);
265
266 }
267
268 }
269}
Note: See TracBrowser for help on using the repository browser.