1 | using System;
|
---|
2 | using System.Collections.Generic;
|
---|
3 | using System.Text;
|
---|
4 | using IndianHealthService.Model;
|
---|
5 | using System.Data;
|
---|
6 |
|
---|
7 | namespace IndianHealthService.BMXNet.Desktop
|
---|
8 | {
|
---|
9 | public class DesktopPatientContext : DesktopObject, PatientContext
|
---|
10 | {
|
---|
11 |
|
---|
12 |
|
---|
13 |
|
---|
14 | internal static DesktopPatientContext CreateFrom(DesktopSession aSession)
|
---|
15 | {
|
---|
16 | DesktopPatientContext answer = new DesktopPatientContext();
|
---|
17 |
|
---|
18 |
|
---|
19 | return answer;
|
---|
20 | }
|
---|
21 |
|
---|
22 |
|
---|
23 | #region PatientContext Members
|
---|
24 |
|
---|
25 | public event EventHandler<ContextChangedArgs> Changed;
|
---|
26 |
|
---|
27 | public event EventHandler<ContextChangingArgs> Changing;
|
---|
28 |
|
---|
29 |
|
---|
30 |
|
---|
31 |
|
---|
32 | public bool HasPatient
|
---|
33 | {
|
---|
34 | get { return this.Patient != null; }
|
---|
35 | }
|
---|
36 |
|
---|
37 | public bool HasEncounter
|
---|
38 | {
|
---|
39 | get { return this.Encounter != null; }
|
---|
40 | }
|
---|
41 |
|
---|
42 | #endregion
|
---|
43 |
|
---|
44 |
|
---|
45 | private User _user = null;
|
---|
46 |
|
---|
47 | public User User
|
---|
48 | {
|
---|
49 | get { return _user; }
|
---|
50 | set { _user = value; }
|
---|
51 | }
|
---|
52 |
|
---|
53 |
|
---|
54 | Patient _patient = null;
|
---|
55 |
|
---|
56 |
|
---|
57 | private Encounter _encounter = null;
|
---|
58 |
|
---|
59 | public Encounter Encounter
|
---|
60 | {
|
---|
61 | get { return _encounter; }
|
---|
62 | }
|
---|
63 |
|
---|
64 | public Patient Patient
|
---|
65 | {
|
---|
66 | get { return _patient; }
|
---|
67 | }
|
---|
68 |
|
---|
69 | public bool ChangePatient(Patient aPatient, bool force)
|
---|
70 | {
|
---|
71 | if (this.Changing != null)
|
---|
72 | {
|
---|
73 | ContextChangingArgs args = new ContextChangingArgs();
|
---|
74 | args.IsPatientChange = true;
|
---|
75 | args.Cancel = false;
|
---|
76 | args.BeforeContext = this;
|
---|
77 | this.Changing.Invoke(this, args);
|
---|
78 |
|
---|
79 | if (args.Cancel && (!force))
|
---|
80 | {
|
---|
81 | return false;
|
---|
82 | }
|
---|
83 | }
|
---|
84 |
|
---|
85 |
|
---|
86 | this._patient = aPatient;
|
---|
87 | this._encounter = null;
|
---|
88 | if (this.Changed != null)
|
---|
89 | {
|
---|
90 | ContextChangedArgs args = new ContextChangedArgs();
|
---|
91 | args.IsPatientChange = true;
|
---|
92 | args.AfterContext = this;
|
---|
93 | this.Changed.Invoke(this, args);
|
---|
94 | }
|
---|
95 | return true;
|
---|
96 | }
|
---|
97 |
|
---|
98 |
|
---|
99 | public bool ChangeEncounter(Encounter anEncounter, bool force)
|
---|
100 | {
|
---|
101 | if (this.Changing != null)
|
---|
102 | {
|
---|
103 | ContextChangingArgs args = new ContextChangingArgs();
|
---|
104 | args.IsVisitChange = true;
|
---|
105 | args.Cancel = false;
|
---|
106 | args.BeforeContext = this;
|
---|
107 | this.Changing.Invoke(this, args);
|
---|
108 |
|
---|
109 | if (args.Cancel && (!force))
|
---|
110 | {
|
---|
111 | return false;
|
---|
112 | }
|
---|
113 | }
|
---|
114 |
|
---|
115 |
|
---|
116 | this._encounter = anEncounter;
|
---|
117 | if (this.Changed != null)
|
---|
118 | {
|
---|
119 | ContextChangedArgs args = new ContextChangedArgs();
|
---|
120 | args.IsVisitChange = true;
|
---|
121 | args.AfterContext = this;
|
---|
122 | this.Changed.Invoke(this, args);
|
---|
123 | }
|
---|
124 | return true;
|
---|
125 | }
|
---|
126 |
|
---|
127 |
|
---|
128 | public bool ChangeEncounter(Encounter aEncounter)
|
---|
129 | {
|
---|
130 | return this.ChangeEncounter(aEncounter, false);
|
---|
131 | }
|
---|
132 |
|
---|
133 | public bool ChangePatient(Patient aPatient)
|
---|
134 | {
|
---|
135 | return this.ChangePatient(aPatient, false);
|
---|
136 | }
|
---|
137 |
|
---|
138 | public bool AlertAll()
|
---|
139 | {
|
---|
140 | return this.ChangePatient(this.Patient);
|
---|
141 | }
|
---|
142 |
|
---|
143 | }
|
---|
144 | }
|
---|