01: package com.xoetrope.medical.forms;
02:
03: import com.xoetrope.swing.XCheckList;
04: import net.xoetrope.swing.XComboBox;
05: import net.xoetrope.swing.XDialog;
06: import net.xoetrope.swing.XTextArea;
07: import net.xoetrope.xui.data.XBaseModel;
08: import net.xoetrope.xui.data.XModel;
09:
10: /**
11: *
12: * @author kingsley.elmes
13: */
14:
15: // adds functionality to Current Outcome and Response dialogs and Prior Outcome and Response dialogs
16: public class Outcome extends XDialog {
17: public static final int CURRENT_OUTCOME = 1;
18: public static final int PRIOR_OUTCOME = 2;
19: public static final int CURRENT_RESPONSE = 3;
20: public static final int PRIOR_RESPONSE = 4;
21:
22: private XBaseModel mdl;
23: private XComboBox responder;
24: private XCheckList sideeffectslist;
25: private XTextArea selected;
26: private int dlgType, row;
27:
28: public Outcome() {
29: }
30:
31: public void pageActivated() {
32: // row attribute which specifies which row of table has been selected
33: row = ((XModel) rootModel.get("selectedAedRow"))
34: .getAttribValueAsInt(XBaseModel.VALUE_ATTRIBUTE);
35:
36: // reference XUI components used in dialog
37: responder = (XComboBox) findComponent("responderbox");
38: sideeffectslist = (XCheckList) findComponent("sideeffectslist");
39: selected = (XTextArea) findComponent("listresult");
40: }
41:
42: public String getTitle() {
43: // obtain integer from root model which specifies
44: // which type of dialog being created
45: mdl = (XBaseModel) rootModel.get("dlgType");
46: dlgType = Integer.parseInt(mdl.get().toString());
47:
48: if ((dlgType == CURRENT_OUTCOME) || (dlgType == PRIOR_OUTCOME))
49: return "Outcome";
50: else
51: return "Response";
52: }
53:
54: public void okClick() {
55: // Get selected item from ComboBox object
56: String content = responder.getSelectedItem().toString();
57:
58: // Get selected items from CheckList object
59: String[] sideeffects = sideeffectslist.getSelectedItems();
60:
61: // Append side-effects to content string
62: for (int i = 0; i < sideeffects.length; i++) {
63: content = content + ", " + sideeffects[i];
64: }
65:
66: // Append comments to content string
67: content = content + ". " + selected.getText();
68:
69: // Update Current AED table
70: if ((dlgType == CURRENT_OUTCOME)
71: || (dlgType == CURRENT_RESPONSE)) {
72: XBaseModel rowModel = (XBaseModel) rootModel
73: .get("currentAED");
74: XBaseModel child = (XBaseModel) rowModel.get(row);
75: child.set("8", content);
76: } else {
77: // update Prior AED table
78: XBaseModel rowModel = (XBaseModel) rootModel
79: .get("priorAED");
80: XBaseModel child = (XBaseModel) rowModel.get(row);
81: child.set("9", content);
82: }
83:
84: closeDlg();
85: }
86: }
|