source: BMXNET_RPMS_dotNET_UTILITIES-BMX/branch/IHS BMX Framework/IndianHealthService.BMXNet.WinForm/DesktopFramework.cs@ 1193

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

Initial Import of BMX4

File size: 4.1 KB
Line 
1using System;
2using System.Collections.Generic;
3using System.Text;
4using IndianHealthService.BMXNet.Model;
5
6namespace IndianHealthService.BMXNet.WinForm
7{
8 public class DesktopFramework
9 {
10 private BMXNetSession _bmx = null;
11
12 public BMXNetSession Bmx
13 {
14 get { return _bmx; }
15 }
16
17 private DesktopSession _brokerSession = null;
18
19 public DesktopSession FrameworkSession
20 {
21 get { return _brokerSession; }
22 set { _brokerSession = value; }
23 }
24
25 private List<DesktopSession> _sessions = new List<DesktopSession>();
26
27 public List<DesktopSession> Sessions
28 {
29 get { return _sessions; }
30 set { _sessions = value; }
31 }
32
33 public static DesktopFramework OpenOn(BMXNetSession aSession)
34 {
35 DesktopFramework broker = new DesktopFramework();
36
37 broker.Start(aSession);
38
39 return broker;
40 }
41
42 internal void Start(BMXNetSession aSession)
43 {
44 this._bmx = aSession;
45
46 DesktopUser user = new DesktopUser();
47 user.Name = aSession.UserName;
48 user.Ien = aSession.DUZ;
49 this._user = user;
50
51 this.FrameworkSession = (DesktopSession)this.OpenDesktopSession();
52 }
53
54
55 protected DesktopSession OpenDesktopSession()
56 {
57 DesktopSession session = new DesktopSession();
58
59 this.Sessions.Add(session);
60 session.Open(this, this.ConstructDesktopContext());
61
62 return session;
63 }
64
65 private DesktopContext ConstructDesktopContext()
66 {
67 DesktopContext answer = new DesktopContext();
68
69 if (this.FrameworkSession != null)
70 {
71 answer.ChangePatient(this.FrameworkSession.Context.Patient);
72 answer.ChangeVisit(this.FrameworkSession.Context.Visit);
73 }
74
75 return answer;
76 }
77
78
79 public DesktopSession OpenSession()
80 {
81 return this.OpenDesktopSession();
82 }
83
84 private EventRegistry _eventRegistry = new EventRegistry();
85
86 internal EventRegistry EventRegistry
87 {
88 get { return _eventRegistry; }
89 set { _eventRegistry = value; }
90 }
91
92 public bool ChangePatient(Patient aPatient, bool force)
93 {
94 bool canChange = true;
95
96 foreach (DesktopSession each in this.Sessions)
97 {
98 canChange = canChange && each.DesktopContext.RequestCanChangePatient(aPatient, force);
99 }
100
101 if (canChange)
102 {
103 foreach (DesktopSession each in this.Sessions)
104 {
105 each.DesktopContext.ChangePatient(aPatient);
106 }
107 }
108
109 return canChange;
110 }
111
112 public bool ChangeVisit(Visit aVisit, bool force)
113 {
114 bool canChange = true;
115
116 foreach (DesktopSession each in this.Sessions)
117 {
118 canChange = canChange && each.DesktopContext.RequestCanChangeVisit(aVisit, force);
119 }
120
121 if (canChange)
122 {
123 foreach (DesktopSession each in this.Sessions)
124 {
125 each.DesktopContext.ChangeVisit(aVisit);
126 }
127 }
128
129 return canChange;
130 }
131
132
133 public bool ChangeVisit(Visit aVisit)
134 {
135 return this.ChangeVisit(aVisit,false);
136 }
137
138 public bool ChangePatient(Patient aPatient)
139 {
140 return this.ChangePatient(aPatient,false);
141 }
142
143
144 private DesktopContext _context = null;
145
146 public DesktopContext Context
147 {
148 get { return _context; }
149 set { _context = value; }
150 }
151
152 private User _user = null;
153
154 public User User
155 {
156 get { return _user; }
157 }
158
159
160 }
161}
Note: See TracBrowser for help on using the repository browser.