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

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

Initial Import of BMX4

File size: 2.5 KB
Line 
1using System;
2using System.Collections.Generic;
3using System.Text;
4using IndianHealthService.BMXNet.Model;
5
6namespace IndianHealthService.BMXNet.EHR.Model
7{
8 internal class CiaContext : CiaObject, Context
9 {
10
11 internal static CiaContext CreateFrom(CiaSession aSession, IEhrEvents eventSource)
12 {
13 CiaContext answer = new CiaContext();
14
15 answer.Initialize(aSession);
16 answer.HookEvents(eventSource);
17
18 return answer;
19 }
20
21 private void Initialize(CiaSession aSession)
22 {
23 this.Session = aSession;
24 this.Patient = CiaPatient.FindCurrent(this.Session);
25 }
26
27 private CiaSession _session=null;
28
29 internal CiaSession Session
30 {
31 get { return _session; }
32 set { _session = value; }
33 }
34
35
36 public event EventHandler<ContextChangedArgs> Changed;
37
38 public event EventHandler<ContextChangingArgs> Changing;
39
40 internal void HookEvents(IEhrEvents eventSource)
41 {
42 eventSource.ContextChanged += new EventHandler<ContextChangedArgs>(aComponent_ContextChanged);
43 eventSource.ContextChanging += new EventHandler<ContextChangingArgs>(aComponent_ContextChanging);
44 }
45
46 private void aComponent_ContextChanging(object sender, ContextChangingArgs e)
47 {
48 if (this.Changing != null)
49 this.Changing.Invoke(sender, e);
50 }
51
52 void aComponent_ContextChanged(object sender, ContextChangedArgs e)
53 {
54 this.Patient = CiaPatient.FindCurrent(this.Session);
55
56 if (this.Changed != null)
57 this.Changed.Invoke(sender, e); ;
58 }
59
60 public Visit Visit
61 {
62 get { return CiaVisit.FindCurrent(this.Session); }
63 }
64
65 public bool HasUnlockedVisit
66 {
67 get {
68 Visit visit = this.Visit;
69 return visit != null && (!visit.IsLocked) && (!visit.IsStub);
70 }
71 }
72
73 Patient _patient = null;
74
75 public Patient Patient
76 {
77 get { return _patient; }
78 set { _patient = value; }
79 }
80
81 public bool HasPatient
82 {
83 get { return this.Patient != null; }
84 }
85
86 public bool HasVisit
87 {
88 get { return this.Visit != null; }
89 }
90
91 public User User
92 {
93 get { return this.Session.User; }
94 }
95
96 }
97}
Note: See TracBrowser for help on using the repository browser.