source: BMXNET_RPMS_dotNET_UTILITIES-BMX/branch/IHS BMX Framework/IndianHealthService.BMXNet.WinForm/Model/WinContext.cs@ 1146

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

Initial Import of BMX4

File size: 3.4 KB
Line 
1using System;
2using System.Collections.Generic;
3using System.Text;
4using IndianHealthService.BMXNet.Model;
5using System.Data;
6
7namespace 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
45internal WinVisit DesktopVisit
46{
47 get { return _desktopVisit; }
48 set { _desktopVisit = value; }
49}
50
51private WinPatient _desktopPatient;
52
53internal 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}
Note: See TracBrowser for help on using the repository browser.