source: EDIS/trunk/java/tracking-ui-core/src/main/flex/gov/va/med/edp/model/LogEdit.as@ 1227

Last change on this file since 1227 was 1227, checked in by George Lilly, 13 years ago

initial load of EDIS 1.0

File size: 4.3 KB
Line 
1package gov.va.med.edp.model
2{
3 import gov.va.med.edp.factory.SessionFactory;
4 import gov.va.med.edp.util.Vista;
5 import gov.va.med.edp.vo.LogEntryVO;
6 import gov.va.med.edp.vo.LookupStringVO;
7
8 import mx.collections.ArrayCollection;
9
10 [Bindable]
11 public class LogEdit
12 {
13 public var entry: LogEntryVO;
14 public var undo: LogEntryVO;
15
16 public var processedSensitivePatient:Boolean = false;
17 public var patientSelected: Boolean = false;
18 public var dirty: Boolean = false;
19 public var message: String = "No visit currently selected.";
20 public var choiceTS: String = "";
21 public var removeMessage: String = "";
22
23 public var arrivals: ArrayCollection;
24 public var clinics: ArrayCollection;
25 public var statuses: ArrayCollection;
26 public var acuities: ArrayCollection;
27 public var delays: ArrayCollection;
28 public var dispositions: ArrayCollection;
29
30 // initialize site defined lists to empty array in case site fails to configure
31 public var beds: ArrayCollection = new ArrayCollection();
32 public var providers: ArrayCollection = new ArrayCollection();
33 public var residents: ArrayCollection = new ArrayCollection();
34 public var nurses: ArrayCollection = new ArrayCollection();
35
36
37 public function setEntry(value: LogEntryVO): void
38 {
39 entry = value;
40 message = "";
41 }
42
43 /* called if entry is no longer open */
44 public function resetEntry(): void
45 {
46 entry = null;
47 this.dirty = false;
48 this.message = "No visit currently selected.";
49 }
50
51 public function setChoices(xml:XML):void
52 {
53 // make sure the choices are set up before setting the logEntry
54 choiceTS = xml.@ts;
55
56 if (xml.hasOwnProperty("bedList")) {
57 beds = SessionFactory.buildLookupStringListFromXML(xml.bedList.bed);
58 }
59 if (xml.hasOwnProperty("mdList")) {
60 providers = SessionFactory.buildLookupStringListFromXML(xml.mdList.md);
61 }
62 if (xml.hasOwnProperty("resList")) {
63 residents = SessionFactory.buildLookupStringListFromXML(xml.resList.res);
64 }
65 if (xml.hasOwnProperty("nurseList")) {
66 nurses = SessionFactory.buildLookupStringListFromXML(xml.nurseList.nurse);
67 }
68 if (xml.hasOwnProperty("arrivalList")) {
69 arrivals = SessionFactory.buildLookupStringListFromXML(xml.arrivalList.arrival);
70 }
71 if (xml.hasOwnProperty("clinicList")) {
72 clinics = SessionFactory.buildLookupStringListFromXML(xml.clinicList.clinic);
73 }
74 if (xml.hasOwnProperty("acuityList")) {
75 acuities = SessionFactory.buildLookupStringListFromXML(xml.acuityList.acuity);
76 }
77 if (xml.hasOwnProperty("statusList")) {
78 statuses = SessionFactory.buildLookupStringListFromXML(xml.statusList.status);
79 }
80 if (xml.hasOwnProperty("delayList")) {
81 delays = SessionFactory.buildLookupStringListFromXML(xml.delayList.delay);
82 }
83 if (xml.hasOwnProperty("dispositionList")) {
84 dispositions = SessionFactory.buildLookupStringListFromXML(xml.dispositionList.disposition);
85 }
86
87 // add selections to the comboboxes for the persons in the current record, if necessary
88 insertValues(providers, xml.persons.provider[0]);
89 insertValues(nurses, xml.persons.nurse[0]);
90 insertValues(residents, xml.persons.resident[0]);
91 insertValues(arrivals, xml.selected.arrival[0]);
92 insertValues(clinics, xml.clinics.clinic[0]);
93 insertValues(statuses, xml.selected.status[0]);
94 insertValues(delays, xml.selected.delay[0]);
95 insertValues(dispositions, xml.selected.disposition[0]);
96 }
97
98 private function insertValues(collection: ArrayCollection, xml:XML): void
99 {
100 if (collection == null) return;
101 removeTransients(collection);
102
103 if (xml == null) return;
104 if (xml.@data == "") return;
105
106 var index:int = Vista.locateIndex(collection, xml.@data);
107 if (index < 0) {
108 var lookup: LookupStringVO = new LookupStringVO;
109 lookup.data = xml.@data;
110 lookup.label = xml.@label;
111 lookup.transient = true;
112 ArrayCollection(collection).addItemAt(lookup, collection.length);
113 // TODO: add to the end of the list then sort the collection
114 }
115 }
116
117 private function removeTransients(collection: ArrayCollection): void
118 {
119 for (var i: int = 0; i < collection.length; i++) {
120 var lookupItem: LookupStringVO = collection[i];
121 if (lookupItem.transient) {
122 collection.removeItemAt(i);
123 }
124 }
125 }
126
127 }
128}
Note: See TracBrowser for help on using the repository browser.