1: <?php
2: namespace Azalea\Selenium\EHR\UI\Patients;
3:
4: class PatientMedications extends PatientSection
5: {
6:
7: protected static $hash = "/patients/p/{pat_id}/medications";
8: protected static $selectorSection = ".patients-PatientMedications";
9:
10: 11: 12: 13: 14:
15:
16: protected static $PRINT_MEDICATION_LIST_BUTTON = '#btn_print_meds';
17: protected static $POPUP_CLOSE_BUTTON = '#document_popup_close';
18: protected static $POPUP_VIEW = '#document_popup';
19:
20:
21: protected static $MEDICATION_SECTION = '#medications_sec';
22: protected static $MEDICATION_SECTION_TOGGLE_BUTTON = '#medications_sec > div';
23: protected static $MEDICATION_SECTION_VIEW = '#medications_sec > .awa-section-target';
24: protected static $MEDICATION_SECTION_SEARCH = '#medications_sec .search';
25: protected static $MEDICATION_NONE_CHECKBOX = '#patient_medications_checkbox';
26:
27:
28: protected static $PRESCRIPTION_SECTION = '#prescriptions_sec';
29: protected static $PRESCRIPTION_SECTION_TOGGLE_BUTTON = '#prescriptions_sec > div';
30: protected static $PRESCRIPTION_SECTION_VIEW = '#prescriptions_sec > .awa-section-target';
31: protected static $PRESCRIPTION_SECTION_FILTER = '#prescriptions_sec .signed_fil';
32: protected static $PRESCRIPTION_SECTION_SEARCH = '#prescriptions_sec .search';
33:
34:
35: 36: 37: 38: 39:
40: public function clickPrintMedicationList()
41: {
42: $this->clickAndWait($this->byCss(self::$PRINT_MEDICATION_LIST_BUTTON), 2);
43: }
44:
45: 46: 47: 48: 49:
50: public function hasMedicationsSection()
51: {
52: return $this->displayed($this->byCss(self::$MEDICATION_NONE_CHECKBOX));
53: }
54:
55: public function openMedicationsSection()
56: {
57: $this->_sectionState(true, false);
58: }
59:
60: public function closeMedicationsSection()
61: {
62: $this->_sectionState(false, false);
63: }
64:
65: public function toggleMedicationsSection()
66: {
67: $this->clickAndWait($this->byCss(self::$MEDICATION_SECTION_TOGGLE_BUTTON), 2);
68: }
69:
70: public function setTextMedicationSearch($text)
71: {
72: $this->_setSearchText($text,false);
73: }
74:
75: public function getMedicationBrandAtIndex($index)
76: {
77: return $this->_getGridBrandAtIndex($index,false);
78: }
79:
80: 81: 82: 83: 84:
85: public function openPrescriptionsSection()
86: {
87: $this->_sectionState(true,true);
88: }
89:
90: public function closePrescriptionsSection()
91: {
92: $this->_sectionState(false, true);
93: }
94:
95: public function togglePrescriptionsSection()
96: {
97: $this->clickAndWait($this->byCss(self::$PRESCRIPTION_SECTION_TOGGLE_BUTTON), 2);
98: }
99:
100: public function setTextPrescriptionSearch($text)
101: {
102: $this->_setSearchText($text,true);
103: }
104:
105: public function getPrescriptionBrandAtIndex($index)
106: {
107: return $this->_getGridBrandAtIndex($index,true);
108: }
109:
110: 111: 112: 113:
114: public function verify($args = array())
115: {
116: if (parent::verify($args)) {
117: $this->byCss($this->getSelectorSection());
118: return true;
119: }
120: return false;
121: }
122:
123:
124:
125: 126: 127: 128: 129:
130: 131: 132: 133: 134:
135: private function _toggleSection($isPrescription=false)
136: {
137: $section = $isPrescription ? self::$PRESCRIPTION_SECTION_TOGGLE_BUTTON : self::$MEDICATION_SECTION_TOGGLE_BUTTON;
138: }
139:
140: 141: 142: 143: 144:
145: private function _setSearchText($text='', $isPrescription=false)
146: {
147: $section = $isPrescription ? self::$PRESCRIPTION_SECTION_SEARCH : self::$MEDICATION_SECTION_SEARCH;
148: $this->byCss($section)->value($text);
149: }
150:
151: 152: 153: 154: 155:
156: private function _getGridBrandAtIndex($index=0, $isPrescription=false)
157: {
158: $section = $isPrescription ? self::$PRESCRIPTION_SECTION : self::$MEDICATION_SECTION;
159: return $this->byCss($section.' tr[data-grid-row="'.$index.'"] > td')->text();
160: }
161:
162: 163: 164: 165: 166:
167: private function _sectionState($isOpen=true, $isPrescription=false)
168: {
169: $section = $isPrescription ? self::$PRESCRIPTION_SECTION_VIEW : self::$MEDICATION_SECTION_VIEW;
170: $sectionIsDisplayed = $this->displayed($section);
171: if($isOpen)
172: {
173: if($sectionIsDisplayed)
174: {
175: return;
176: }
177: $this->_toggleSection($isPrescription);
178: }
179: else
180: {
181: if($sectionIsDisplayed)
182: {
183: $this->_toggleSection($isPrescription);
184: }
185: }
186: }
187: }