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