source: BMXNET_RPMS_dotNET_UTILITIES-BMX/branch/BMX41000/IHS BMX Framework/IndianHealthService.BMXNet.EHR/Model/CiaVisit.cs@ 1240

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

Initial Import of BMX4

File size: 6.6 KB
Line 
1using System;
2using System.Collections.Generic;
3using System.Text;
4using IndianHealthService.BMXNet.Model;
5using System.Reflection;
6
7namespace IndianHealthService.BMXNet.EHR.Model
8{
9
10 internal class CiaVisit : CiaObject, Visit
11 {
12 //Work around for incorrect encounter dll
13 public static void InitialzeAccessToCSSEncounter()
14 {
15 Assembly encounter = Assembly.LoadFrom("Interop.CSS_Encounter.dll");
16 if (encounter == null)
17 return;
18
19 foreach (Type each in encounter.GetExportedTypes())
20 {
21 if (each.Name.Equals("ICSS_Encounter"))
22 {
23 LockedMethod = each.GetMethod("get_Locked");
24 PrepareMethod = each.GetMethod("Prepare");
25 }
26 }
27 }
28
29 public static MethodInfo LockedMethod = null;
30 public static MethodInfo PrepareMethod = null;
31
32 public static CiaVisit FindCurrent(CiaSession aSession)
33 {
34 if (aSession.CssEncounter.VisitStr == null)
35 {
36 return null;
37 }
38 else
39 {
40 CiaVisit answer = new CiaVisit();
41 answer.CiaSession = aSession;
42 return answer;
43 }
44 }
45
46 private CiaSession _ciaSession = null;
47
48 public CiaSession CiaSession
49 {
50 get { return _ciaSession; }
51 set
52 {
53 _ciaSession = value;
54 this.RefreshStateFromCssEncounter();
55 }
56 }
57
58
59 protected void RefreshStateFromCssEncounter()
60 {
61
62 this.VisitString = this.CiaSession.CssEncounter.VisitStr;
63
64 String[] peices = this.VisitString.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries);
65 this.Ien = (peices.Length == 4) ? peices[3] : null;
66
67 this.DateTime = this.CiaSession.CssEncounter.DateTime;
68 this.LocationName = this.CiaSession.CssEncounter.LocationName;
69 this.ProviderName = this.CiaSession.CssEncounter.ProviderName;
70 this.IsLocked = this.SafeLocked();
71
72 }
73
74
75 protected bool SafeLocked()
76 {
77 return LockedMethod == null ? false : this.RiskyLocked();
78 }
79
80
81 private bool RiskyLocked()
82 {
83 try
84 {
85 return (bool)LockedMethod.Invoke(this.CiaSession.CssEncounter, null);
86 }
87 catch
88 {
89 return false;
90 }
91 }
92
93 private bool _isLocked = false;
94
95 public bool IsLocked
96 {
97 get { return _isLocked; }
98 set { _isLocked = value; }
99 }
100
101 private String _visitString = null;
102
103 public String VisitString
104 {
105 get { return _visitString; }
106 set { _visitString = value; }
107 }
108
109 private String _clinic = null;
110
111 public String Clinic
112 {
113 get { return _clinic; }
114 set { _clinic = value; }
115 }
116 private String _providerName;
117
118 public String ProviderName
119 {
120 get { return _providerName; }
121 set { _providerName = value; }
122 }
123 private String _locationName;
124
125 public String LocationName
126 {
127 get { return _locationName; }
128 set { _locationName = value; }
129 }
130 private DateTime _dateTime;
131
132 public DateTime DateTime
133 {
134 get { return _dateTime; }
135 set { _dateTime = value; }
136 }
137
138 public bool IsStub
139 {
140 get
141 {
142 if (this.Ien == null)
143 {
144 this.RefreshStateFromCssEncounter();
145 }
146 return this.Ien == null;
147 }
148 }
149
150 public bool IsFutureAppointment
151 {
152 get
153 {
154 return DateTime.Today < new DateTime(this.DateTime.Year, this.DateTime.Month, this.DateTime.Day);
155 }
156 }
157
158 public bool Create()
159 {
160 return this.Create(true);
161 }
162
163
164 public bool Create(bool showGuiToCreate)
165 {
166 if (this.IsStub)
167 {
168 if (showGuiToCreate)
169 {
170 this.RiskyPrepare();
171 }
172 else
173 {
174 this.RiskyPrepareNoDialog();
175 }
176 this.RefreshStateFromCssEncounter();
177 }
178
179 return !this.IsStub;
180 }
181
182 private bool RiskyPrepareNoDialog()
183 {
184 try
185 {
186 //We do not want reference to TxOptionFlags enum
187 //ofAll = 0,
188 //ofProvider = 1,
189 //ofSuppress = 2,
190 //ofNotLocked = 4,
191 //ofValidateOnly = 8,
192 //ofPromptOnInvalid = 16,
193 //ofForceVisit = 32,
194 //CSS_Encounter.TxOptionFlags flags = CSS_Encounter.TxOptionFlags.ofForceVisit | CSS_Encounter.TxOptionFlags.ofNotLocked;
195 int flags = 32 | 4;
196 return (bool)PrepareMethod.Invoke(this.CiaSession.CssEncounter, new object[] { flags });
197 }
198 catch
199 {
200 return false;
201 }
202 }
203
204 private bool RiskyPrepare()
205 {
206 try
207 {
208 //We do not want reference to TxOptionFlags enum
209 //ofAll = 0,
210 //ofProvider = 1,
211 //ofSuppress = 2,
212 //ofNotLocked = 4,
213 //ofValidateOnly = 8,
214 //ofPromptOnInvalid = 16,
215 //ofForceVisit = 32,
216 //CSS_Encounter.TxOptionFlags flags = CSS_Encounter.TxOptionFlags.ofPromptOnInvalid | CSS_Encounter.TxOptionFlags.ofForceVisit | CSS_Encounter.TxOptionFlags.ofNotLocked;
217 int flags = 16 | 32 | 4;
218 return (bool)PrepareMethod.Invoke(this.CiaSession.CssEncounter, new object[] { flags });
219 }
220 catch
221 {
222 return false;
223 }
224 }
225
226 public override string ToString()
227 {
228 return this.Label;
229 }
230
231 public String Label
232 {
233
234 get { return this.DateTime.ToShortDateString() + " " + this.Clinic + ", " + this.ProviderName; }
235 }
236 }
237}
Note: See TracBrowser for help on using the repository browser.