import com.imt.intimamedia.events.patient.CreateAppointmentEvent; import com.imt.intimamedia.events.patient.CreatePatientEvent; import com.imt.intimamedia.events.patient.SearchAppointmentsEvent; import com.imt.intimamedia.events.patient.SearchPatientEvent; import com.imt.intimamedia.events.patient.UpdateAppointmentEvent; import com.imt.intimamedia.events.patient.UpdatePatientEvent; import com.imt.intimamedia.events.measures.GetCTPAEvent; import com.imt.intimamedia.helpers.AES; import com.imt.intimamedia.helpers.ComboBoxHelper; import com.imt.intimamedia.helpers.FlashHelper; import com.imt.intimamedia.helpers.FormatString; import com.imt.intimamedia.helpers.HelpUtils; import com.imt.intimamedia.model.ApplicationModelLocator; import com.imt.intimamedia.views.common.ImtToaster; import com.imt.intimamedia.views.physician.measure.MeasureView; import com.imt.intimamedia.views.physician.patient.PatientView; import com.imt.intimamedia.vo.AppointmentVo; import com.imt.intimamedia.vo.AtsVo; import com.imt.intimamedia.vo.CvExaminatorVo; import com.imt.intimamedia.vo.FamilyHistoryVo; import com.imt.intimamedia.vo.PatientVo; import com.imt.intimamedia.vo.PersonalHistoryVo; import com.imt.intimamedia.vo.TobaccoVo; import flash.display.Stage; import flash.events.Event; import flash.events.FocusEvent; import flash.events.KeyboardEvent; import flash.events.MouseEvent; import flash.events.TextEvent; import flash.ui.Mouse; import flash.utils.ByteArray; import mx.collections.ArrayCollection; import mx.controls.Alert; import mx.controls.ComboBox; import mx.controls.Image; import mx.controls.dataGridClasses.DataGridColumn; import mx.core.Application; import mx.core.UIComponent; import mx.events.DataGridEvent; import mx.events.ListEvent; import mx.events.ValidationResultEvent; import mx.formatters.DateFormatter; import mx.managers.CursorManager; import mx.resources.ResourceManager; import mx.utils.ObjectUtil; import mx.validators.Validator; private var _viewMessageSearch : Boolean = false; private var _viewMessageDisplay : Boolean = false; [Bindable] private var _model : ApplicationModelLocator = ApplicationModelLocator.getInstance(); [Bindable] private var _minYearOfBirth : int = new Date().fullYear - 100; [Bindable] private var _maxYearOfBirth : int = new Date().fullYear - 2; [Bindable] private var _currentYear : int = new Date().fullYear; [Bindable] private var _disabledRangesDateOfBirth : Array = [ {rangeEnd: new Date(new Date().fullYear - 110, new Date().getMonth(), new Date().getDate())}, {rangeStart: new Date()} ]; [Bindable] //private var _disabledRangesVisitDate : Array = [ {rangeStart: new Date(new Date().fullYear, new Date().getMonth(), new Date().getDate()+1)} ]; private var _disabledRangesVisitDate : Array = [ {rangeEnd: new Date(new Date().fullYear, new Date().getMonth(), new Date().getDate())}, {rangeStart: new Date(new Date().fullYear, new Date().getMonth(), new Date().getDate())} ]; [Bindable] private var _currentPatientVisit : String = "1"; private function creationCompleteHandler() : void { loadKeyboardListeners(); searchPatientHelp.source = 'images/help/' + ResourceManager.getInstance().getString('labels', 'lang') + '/patientSearch.png'; createPatientHelp.source = 'images/help/' + ResourceManager.getInstance().getString('labels', 'lang') + '/patientCreate.png'; patientTabHelp.source = 'images/help/' + ResourceManager.getInstance().getString('labels', 'lang') + '/patientTab.png'; } private function navigationNext() : void { var parent : PatientView = this.parentDocument as PatientView; parent.selectView(parent.atsStart, parent.atsEnd, parent.atsBox, parent.atsLinkButton, 1) } private function showInformation( zone : String ) : void { } private function loadKeyboardListeners() : void { firstNameTextInput.addEventListener(KeyboardEvent.KEY_UP, translateFirstCharToUpperCase); lastNameTextInput.addEventListener(KeyboardEvent.KEY_DOWN, translateToUpperCase); lastNameTextInput.addEventListener(KeyboardEvent.KEY_UP, checkTranslateToUpperCase); } public function showHelp(image : Image) : void { if (ApplicationModelLocator.getInstance().application.menuPhysician.selectedIndex == 0 && ApplicationModelLocator.getInstance().application.menuPhysician.patient.patientView.selectedIndex == 0) HelpUtils.loadPatientHelp(image); else HelpUtils.showHelp(this, image, zoomHelpAdd, zoomHelpRemove); } private function patientFileController() : PatientVo { var toastMessage : ImtToaster; var validators : Array = [ firstNameValidator, lastNameValidator, sexValidator, dateOfBirthValidator ]; var validatorsError : Array = Validator.validateAll( validators ); if (dateOfBirthDateField.errorString) { dateOfBirthDateText.setStyle("color", "#7c0b13"); dateOfBirthDateText.setStyle("fontWeight", "bold"); } else { dateOfBirthDateText.setStyle("color", "#555557"); dateOfBirthDateText.setStyle("fontWeight", "normal"); } if (firstNameTextInput.errorString) { firstNameLabel.setStyle("color", "#7c0b13"); firstNameLabel.setStyle("fontWeight", "bold"); } else { firstNameLabel.setStyle("color", "#555557"); firstNameLabel.setStyle("fontWeight", "normal"); } if (lastNameTextInput.errorString) { lastNameLabel.setStyle("color", "#7c0b13"); lastNameLabel.setStyle("fontWeight", "bold"); } else { lastNameLabel.setStyle("color", "#555557"); lastNameLabel.setStyle("fontWeight", "normal"); } if (!sexRadioButtonGroup.selectedValue) { sexLabel.setStyle("color", "#7c0b13"); sexLabel.setStyle("fontWeight", "bold"); } else { sexLabel.setStyle("color", "#555557"); sexLabel.setStyle("fontWeight", "normal"); } if( validatorsError.length != 0 || !isDateOfBirthValid()) { toastMessage = new ImtToaster(); toastMessage.titleMessage = ResourceManager.getInstance().getString('labels', 'error.allFieldsTitle'); toastMessage.timeToLive = 7; toastMessage.message = ResourceManager.getInstance().getString('labels', 'error.allFieldsCreatePatient'); toastMessage.level = ImtToaster.WARNING; _model.toaster.toast( toastMessage ); return null; } var patientVo : PatientVo = new PatientVo(); patientVo.uid = uidPatientLabel.text; patientVo.firstName = firstNameTextInput.text; patientVo.lastName = lastNameTextInput.text; patientVo.sex = sexRadioButtonGroup.selectedValue as String; patientVo.birthDate = dateOfBirthDateField.selectedDate; patientVo.birthDate.setHours(12,0,0,0); patientVo.lastVisit = new Date(); for each (var currentPatient : PatientVo in _model.listOfPatients) { if (currentPatient.firstName.toLowerCase() == patientVo.firstName.toLowerCase() && currentPatient.lastName.toLowerCase() == patientVo.lastName.toLowerCase() && currentPatient.birthDate.toDateString() == patientVo.birthDate.toDateString()) { toastMessage = new ImtToaster(); toastMessage.titleMessage = ResourceManager.getInstance().getString('labels', 'warning.use'); toastMessage.message = ResourceManager.getInstance().getString('labels', 'error.patientAlreadyExists'); toastMessage.level = ImtToaster.WARNING; _model.toaster.toast( toastMessage ); return null; } } if ( ethnicGroupComboBox.selectedItem != null ) patientVo.ethnicGroup = ethnicGroupComboBox.selectedItem.code; return patientVo; } private function createPatient() : void { Application.application.menuPhysician.acquire.label = ResourceManager.getInstance().getString('labels', 'physicianAcquire'); // reset patient data and appointment resetAppointment(); resetPatientData(); // not an existing patient but a new patient _model.noAppointmentSelected = false; _model.enabledAcquire = false; _model.enabledMeasure = false; _model.enabledReport = false; _model.patientActive = false; _model.updatePatient = false; _model.viewPatient = false; _model.acquireViewLoaded = false; _model.appointmentSelected = null; // reset acquire and measure pages if needed Application.application.menuPhysician.acquire.clearPage(); Application.application.menuPhysician.generalMeasure.measures.clearPage(); var newPatient : PatientVo = patientFileController(); if (!newPatient) return; var appointmentVo : AppointmentVo = new AppointmentVo(); appointmentVo.number = 1; appointmentVo.date = visitDateField.selectedDate; appointmentVo.date.setHours(12,0,0,0); _model.patientSelected = newPatient; _model.patientActive = true; new CreatePatientEvent( newPatient, appointmentVo, _model.connectedUser.person.id, this ).dispatch(); this.parentDocument.selectView(this.parentDocument.atsStart, this.parentDocument.atsEnd, this.parentDocument.atsBox, this.parentDocument.atsLinkButton, 1); } public function createPatientCompleted() : void { var toastMessage : ImtToaster = new ImtToaster(); toastMessage = new ImtToaster(); toastMessage.titleMessage = ResourceManager.getInstance().getString('labels', 'patient.createdTitle'); toastMessage.message = ResourceManager.getInstance().getString('labels', 'patient.createdMessage'); toastMessage.level = ImtToaster.VALIDATION; _model.toaster.toast( toastMessage ); _model.patientName = firstNameTextInput.text + " " + lastNameTextInput.text; firstNameValidator.enabled = false; lastNameValidator.enabled = false; sexValidator.enabled = false; dateOfBirthValidator.enabled = false; firstNameValidator.enabled = true; lastNameValidator.enabled = true; sexValidator.enabled = true; dateOfBirthValidator.enabled = true; uidPatientLabel.text = FormatString.generateRandomUID(); _model.appointmentNumber = 1; visitNumberLabel.text = _currentPatientVisit = _model.appointmentNumber.toString(); _model.enabledAcquire = true; // refresh patient list new SearchPatientEvent( "", this ).dispatch(); new SearchAppointmentsEvent( _model.patientSelected.uid, this ).dispatch(); } private function searchPatient() : void { var toastMessage : ImtToaster; var searchCriteria : String = criteria.text; criteria.text = ResourceManager.getInstance().getString('labels', 'search.patient.info'); if (searchCriteria.length > 0 && searchCriteria != ResourceManager.getInstance().getString('labels', 'search.patient.info')) { var keyWords : Array = searchCriteria.split(' '); if (keyWords.length > 2) { toastMessage = new ImtToaster(); toastMessage.titleMessage = ResourceManager.getInstance().getString('labels', 'patient.searchTitle'); toastMessage.message = ResourceManager.getInstance().getString('labels', 'patient.searchMessageError'); toastMessage.level = ImtToaster.ERROR; _model.toaster.toast( toastMessage ); } _model.listOfDisplayedPatients.removeAll(); for each (var patient : PatientVo in _model.listOfPatients) { if ( ( keyWords.length == 2 && patient.firstName.toLowerCase() == (keyWords[0] as String).toLowerCase() && patient.lastName.toLowerCase() == (keyWords[1] as String).toLowerCase() ) || ( keyWords.length == 2 && patient.firstName.toLowerCase() == (keyWords[1] as String).toLowerCase() && patient.lastName.toLowerCase() == (keyWords[0] as String).toLowerCase() ) || ( keyWords.length == 1 && patient.firstName.toLowerCase() == (keyWords[0] as String).toLowerCase() ) || ( keyWords.length == 1 && patient.lastName.toLowerCase() == (keyWords[0] as String).toLowerCase() ) ) { _model.listOfDisplayedPatients.addItem(patient); } } } else { _model.listOfDisplayedPatients.removeAll(); _model.listOfDisplayedPatients.addAll(_model.listOfPatients); } searchButton.setFocus(); } private function selectPatient( event : ListEvent ) : void { actionOnSearch.visible = true; _model.patientSelected = event.currentTarget.selectedItem as PatientVo; // to do later //_patientSelectedIndex = event.currentTarget.selectedIndex; _model.patientName = _model.patientSelected.firstName + " " + _model.patientSelected.lastName; _model.patientActive = true; _model.updatePatient = false; _model.enabledAcquire = false; _model.enabledMeasure = false; _model.enabledReport = false; _model.noAppointmentSelected = true; resetPatientData(); if (_model.patientSelected.uid) { //dg.enabled = false; new SearchAppointmentsEvent( _model.patientSelected.uid, this ).dispatch(); } } private function modifyPatient() : void { _model.updatePatient = true; firstNameTextInput.text = _model.patientSelected.firstName; lastNameTextInput.text = _model.patientSelected.lastName; sexRadioButtonGroup.selectedValue = _model.patientSelected.sex; dateOfBirthDateField.text = dateFormatter.format(_model.patientSelected.birthDate); dateOfBirthDateField.selectedDate = _model.patientSelected.birthDate; } private function updatePatient() : void { var patientVo : PatientVo = patientFileController(); if (!patientVo) return; patientVo.id = _model.patientSelected.id; _model.patientSelected.firstName = patientVo.firstName; _model.patientSelected.lastName = patientVo.lastName; _model.patientSelected.birthCountry = patientVo.birthCountry; _model.patientSelected.birthDate = patientVo.birthDate; _model.patientSelected.ethnicGroup = patientVo.ethnicGroup; _model.patientSelected.sex = patientVo.sex; new UpdatePatientEvent(_model.patientSelected, this).dispatch(); } public function updatePatientComplete() : void { _model.updatePatient = false; } private function prepareCreateAppointment( event : Event ) : void { if ( _model.patientSelected.uid == "" ) { var toastMessage : ImtToaster = new ImtToaster(); toastMessage.titleMessage = ResourceManager.getInstance().getString('labels', 'warning.use'); toastMessage.message = ResourceManager.getInstance().getString('labels', 'warning.choosePatient'); toastMessage.timeToLive = 6; toastMessage.level = ImtToaster.WARNING; ApplicationModelLocator.getInstance().toaster.toast( toastMessage ); return; } _model.patientActive = true; _model.updatePatient = false; _model.viewPatient = false; _model.enabledAcquire = false; _model.enabledMeasure = false; _model.enabledReport = false; _model.acquireViewLoaded = false; _model.cptMesuresVisite = 0; Application.application.menuPhysician.acquire.label = ResourceManager.getInstance().getString('labels', 'physicianAcquire'); _model.appointmentNumber++; // to do : decide if we keep prepareCreateAppointment or not createAppointment(); } public function createAppointment() : void { // create an appointment so reset acquire and measure pages if needed Application.application.menuPhysician.acquire.clearPage(); Application.application.menuPhysician.generalMeasure.measures.clearPage(); var appointmentVo : AppointmentVo = new AppointmentVo(); appointmentVo.patientId = _model.patientSelected.id; appointmentVo.number = _model.appointmentNumber; appointmentVo.date = visitDateField.selectedDate; appointmentVo.date.setHours(12,0,0,0); _currentPatientVisit = _model.appointmentNumber.toString(); _model.noAppointmentSelected = false; _model.acquireViewLoaded = false; new CreateAppointmentEvent( appointmentVo, _model.patientSelected.uid, this ).dispatch(); } public function createAppointmentComplete() : void { FlashHelper.resetAll(); var toastMessage : ImtToaster = new ImtToaster(); toastMessage = new ImtToaster(); toastMessage.titleMessage = ResourceManager.getInstance().getString('labels', 'patient.addAppointmentTitle'); toastMessage.message = ResourceManager.getInstance().getString('labels', 'patient.addAppointmentMessage'); toastMessage.timeToLive = 7; toastMessage.level = ImtToaster.VALIDATION; _model.toaster.toast( toastMessage ); dateOfBirthDateField.text = ""; _model.patientName = _model.patientSelected.firstName + " " + _model.patientSelected.lastName; _model.enabledAcquire = true; _model.enabledMeasure = false; _model.enabledReport = false; // to do later //_appointmentSelectedIndex = -1; // appointmentNumber - 1 => last appointment (or current appointment) // appointmentNumber - 2 => previous appointment if (_model.appointmentNumber > 1) { var previousAppointmentVo : AppointmentVo = _model.listOfAppointments.getItemAt(_model.appointmentNumber-2) as AppointmentVo; // copy previous appointment in treatmentCollection _model.appointmentSelected.treatmentCollection.addAll(previousAppointmentVo.treatmentCollection); var parent : PatientView = this.parentDocument as PatientView; // load appointment data from previous appointment _model.appointmentSelected.height = previousAppointmentVo.height; _model.appointmentSelected.weight = previousAppointmentVo.weight; var newAppointment : Boolean = true; parent.loadAppointmentData(previousAppointmentVo, newAppointment); updateAppointment(); } this.parentDocument.selectView(this.parentDocument.atsStart, this.parentDocument.atsEnd, this.parentDocument.atsBox, this.parentDocument.atsLinkButton, 1); //new SearchAppointmentsEvent( _model.patientSelected.uid, this ).dispatch(); } private function selectAppointment( event : ListEvent ) : void { _model.appointmentSelected = event.currentTarget.selectedItem as AppointmentVo; // to do later //_appointmentSelectedIndex = event.currentTarget.selectedIndex; visitDateField.selectedDate = event.currentTarget.selectedItem.date; dateAppointment.text = dateFormatter.format(event.currentTarget.selectedItem.date); _model.appointmentNumber = event.currentTarget.selectedItem.number; visitNumberLabel.text = _currentPatientVisit = event.currentTarget.selectedItem.number; if (!_model.appointmentSelected.type) { recoverLastAppointment(false); return; } _model.patientActive = true; _model.updatePatient = false; _model.viewPatient = true; _model.enabledAcquire = true; _model.enabledMeasure = true; _model.enabledReport = true; _model.noAppointmentSelected = false; _model.acquireViewLoaded = false; // select an appointment so reset acquire and measure pages if needed Application.application.menuPhysician.acquire.clearPage(); Application.application.menuPhysician.acquire.label = ResourceManager.getInstance().getString('labels', 'physicianDisplay'); Application.application.menuPhysician.generalMeasure.measures.clearPage(); Application.application.menuPhysician.report.clearReportConfiguration(); var parent : PatientView = this.parentDocument as PatientView; parent.loadAppointmentData(_model.appointmentSelected, false); } public function recoverLastAppointment(displayToaster : Boolean) : void { if (displayToaster) { var toastMessage : ImtToaster = new ImtToaster(); toastMessage.titleMessage = ResourceManager.getInstance().getString('labels', 'information'); toastMessage.message = ResourceManager.getInstance().getString('labels', 'goToLastIncompleteAppointment'); toastMessage.timeToLive = 7; toastMessage.level = ImtToaster.WARNING; ApplicationModelLocator.getInstance().toaster.toast( toastMessage ); } _model.patientActive = true; _model.updatePatient = false; _model.viewPatient = false; _model.enabledAcquire = true; _model.enabledMeasure = false; _model.enabledReport = false; _model.noAppointmentSelected = false; _model.acquireViewLoaded = false; var lastAppointmentId : int = 0; var lastAppointmentNumber : int = 0; var lastAppointmentVo : AppointmentVo = null; for each (var appointmentVo : AppointmentVo in _model.listOfAppointments) { if (lastAppointmentId < appointmentVo.id) { lastAppointmentId = appointmentVo.id; lastAppointmentNumber = appointmentVo.number; lastAppointmentVo = appointmentVo; } } _model.appointmentNumber = lastAppointmentNumber; _model.appointmentSelected = lastAppointmentVo; _model.patientName = _model.patientSelected.firstName + " " + _model.patientSelected.lastName; _model.appointmentSelected.livingCountry = appointmentVo.livingCountry; visitDateField.selectedDate = new Date(); lastAppointmentVo.date = new Date(); visitNumberLabel.text = _model.appointmentNumber.toString(); _currentPatientVisit = _model.appointmentNumber.toString(); var idx : int = -1; for( var i : int = 0; i < _model.countries.length; i++ ) { if( _model.countries.getItemAt(i).code == appointmentVo.livingCountry ) { idx = i; break; } } // select an appointment so reset acquire and measure pages if needed Application.application.menuPhysician.acquire.clearPage(); Application.application.menuPhysician.generalMeasure.measures.clearPage(); Application.application.menuPhysician.acquire.label = ResourceManager.getInstance().getString('labels', 'physicianAcquire'); var parent : PatientView = this.parentDocument as PatientView; parent.loadAppointmentData(lastAppointmentVo, false); this.parentDocument.selectView(this.parentDocument.atsStart, this.parentDocument.atsEnd, this.parentDocument.atsBox, this.parentDocument.atsLinkButton, 1); } public function updateAppointment() : void { if (!_model.viewPatient && _model.appointmentSelected && _model.appointmentSelected.id > 0) { _model.application.menuPhysician.patient.updateAts(); _model.application.menuPhysician.patient.updateCve(); _model.application.menuPhysician.patient.updatePersonalHistory(); _model.application.menuPhysician.patient.updateFamilyHistory(); // be more smart in the future : when save patient informations ? new UpdateAppointmentEvent( _model.appointmentSelected, _model.patientSelected.uid ).dispatch(); } } public function updatePatientFile() : void { _currentPatientVisit = _model.appointmentNumber.toString(); var idx : int = -1; for( var i : int = 0; i < _model.countries.length; i++ ) { if( _model.countries.getItemAt(i).code == _model.appointmentSelected.livingCountry ) { idx = i; break; } } _model.appointmentSelected.livingCountry = _model.appointmentSelected.livingCountry; visitNumberLabel.text = _model.appointmentNumber.toString(); dateAppointment.text = dateFormatter.format( _model.appointmentSelected.date ); } public function resetView() : void { firstNameTextInput.text = ""; lastNameTextInput.text = ""; sexRadioButtonGroup.selection = null; dateOfBirthDateField.selectedDate = null; ethnicGroupComboBox.selectedIndex = -1; visitDateField.selectedDate = new Date(); criteria.text = ""; _currentPatientVisit = "1"; dateOfBirthDateText.setStyle("color", "#555557"); dateOfBirthDateText.setStyle("fontWeight", "normal"); dateOfBirthDateText.errorString = ""; firstNameLabel.setStyle("color", "#555557"); firstNameLabel.setStyle("fontWeight", "normal"); firstNameTextInput.errorString = ""; lastNameLabel.setStyle("color", "#555557"); lastNameLabel.setStyle("fontWeight", "normal"); lastNameTextInput.errorString = ""; sexLabel.setStyle("color", "#555557"); sexLabel.setStyle("fontWeight", "normal"); _model.patientActive = false; _model.updatePatient = false; _model.viewPatient = false; actionOnSearch.visible = false; _model.appointmentNumber = 1; } public function resetPatientData() : void { var parent : PatientView = this.parentDocument as PatientView; parent.resetPatientData(); } public function resetAppointment() : void { _model.appointmentSelected = new AppointmentVo(); _model.appointmentSelected.ats = new AtsVo(); _model.appointmentSelected.cvExaminator = new CvExaminatorVo(); _model.appointmentSelected.familyHistory = new FamilyHistoryVo(); _model.appointmentSelected.personalHistory = new PersonalHistoryVo(); _model.appointmentSelected.tobacco = new TobaccoVo(); _model.appointmentSelected.treatments = new Array(); } private function formatBirthDate( item : Object, column : DataGridColumn ) : String { var dateFormatter : DateFormatter = new DateFormatter(); dateFormatter.formatString = ResourceManager.getInstance().getString( 'labels', 'date' ); return dateFormatter.format( item.birthDate ); } private function formatLastVisit( item : Object, column : DataGridColumn ) : String { var dateFormatter : DateFormatter = new DateFormatter(); dateFormatter.formatString = ResourceManager.getInstance().getString( 'labels', 'date' ); return dateFormatter.format( item.lastVisit ); } private function formatAppointment( item : Object ) : String { var dateFormatter : DateFormatter = new DateFormatter(); dateFormatter.formatString = ResourceManager.getInstance().getString( 'labels', 'date' ); var zone : String = ""; switch (item.type) { case 'CL': case 'CR': zone = ' (' + ResourceManager.getInstance().getString( 'labels', 'carotids' ) + ')'; break; case 'AR': case 'AL': zone = ' (' + ResourceManager.getInstance().getString( 'labels', 'arms' ) + ')'; break; case 'LL': case 'LR': zone = ' (' + ResourceManager.getInstance().getString( 'labels', 'legs' ) + ')'; break; case 'BO': zone = ' (' + ResourceManager.getInstance().getString( 'labels', 'body' ) + ')'; break; default: break; } return dateFormatter.format( item.date ) + zone; } private function resetCreatePatientForm() : void { _model.enabledAcquire = false; _model.enabledMeasure = false; _model.enabledReport = false; _model.cptMesuresVisite = 0; resetPatientData(); resetView(); } private function removeSearchPatientText() : void { criteria.text = ""; } public function setSearchPatientText() : void { searchButton.setFocus(); criteria.text = ResourceManager.getInstance().getString('labels', 'search.patient.info'); } private function translateFirstCharToUpperCase( e : KeyboardEvent ) : void { if (firstNameTextInput.text.length == 1) { if (e.keyCode > 64 && e.keyCode < 91) { var b:String = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'; firstNameTextInput.text = b.charAt(e.keyCode - 65); } } else { var firstCharFirstName : String = firstNameTextInput.text.substr(0, 1); var firstNameLessFirstChar : String = firstNameTextInput.text.substr(1, firstNameTextInput.text.length); firstNameTextInput.text = firstCharFirstName.toUpperCase() + firstNameLessFirstChar; } } private function checkTranslateToUpperCase( e : KeyboardEvent ) : void { lastNameTextInput.text = lastNameTextInput.text.toUpperCase(); } private function translateToUpperCase( e : KeyboardEvent ) : void { var lastName : String = ""; if (lastNameTextInput.text.length > 1) lastName = lastNameTextInput.text.substr(0, lastNameTextInput.text.length); else lastName = lastNameTextInput.text; if (e.keyCode > 64 && e.keyCode < 91) { var b:String = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'; lastName += b.charAt(e.keyCode - 65); } lastNameTextInput.text = lastName; lastNameTextInput.width = 160; } private function setFieldError() : void { lastNameValidator.requiredFieldError = ResourceManager.getInstance().getString('labels', 'required'); firstNameValidator.requiredFieldError = ResourceManager.getInstance().getString('labels', 'required'); dateOfBirthValidator.requiredFieldError = ResourceManager.getInstance().getString('labels', 'required'); dateOfBirthValidator.formatError = ResourceManager.getInstance().getString('labels', 'errorField'); dateOfBirthValidator.invalidCharError = ResourceManager.getInstance().getString('labels', 'errorField'); dateOfBirthValidator.invalidCharError = ResourceManager.getInstance().getString('labels', 'errorField'); dateOfBirthValidator.wrongDayError = ResourceManager.getInstance().getString('labels', 'errorField'); dateOfBirthValidator.wrongLengthError = ResourceManager.getInstance().getString('labels', 'errorField'); dateOfBirthValidator.wrongMonthError = ResourceManager.getInstance().getString('labels', 'errorField'); dateOfBirthValidator.wrongYearError = ResourceManager.getInstance().getString('labels', 'errorField'); } private function initListeners() : void { setFieldError(); lastNameValidator.addEventListener(ValidationResultEvent.VALID, stringValidatorHandler); firstNameValidator.addEventListener(ValidationResultEvent.VALID, stringValidatorHandler); dateOfBirthValidator.addEventListener(ValidationResultEvent.VALID, stringValidatorHandler); } public function updateErrorStrings() : void { setFieldError(); if (lastNameTextInput.errorString) lastNameTextInput.errorString = ResourceManager.getInstance().getString('labels', 'errorField'); if (firstNameTextInput.errorString) firstNameTextInput.errorString = ResourceManager.getInstance().getString('labels', 'errorField'); if (dateOfBirthDateField.errorString) dateOfBirthDateField.errorString = ResourceManager.getInstance().getString('labels', 'errorField'); } private function stringValidatorHandler(event : ValidationResultEvent) : void { if (event.target.errorString) event.target.errorString = null; } private function isDateOfBirthValid() : Boolean { var date : Date = new Date(); if (ObjectUtil.compare(date, dateOfBirthDateField.selectedDate) < 0 || dateOfBirthDateField.selectedDate.getFullYear() < _minYearOfBirth || dateOfBirthDateField.selectedDate.getFullYear() > _maxYearOfBirth) { var toastMessage : ImtToaster = new ImtToaster(); toastMessage.titleMessage = ResourceManager.getInstance().getString('labels', 'warning.use'); if (dateOfBirthDateField.selectedDate.getFullYear() < _minYearOfBirth) toastMessage.message = ResourceManager.getInstance().getString('labels', 'tooEarlyDate', [_minYearOfBirth]); else if (dateOfBirthDateField.selectedDate.getFullYear() > _maxYearOfBirth) toastMessage.message = ResourceManager.getInstance().getString('labels', 'tooLateDate', [_maxYearOfBirth]); else toastMessage.message = ResourceManager.getInstance().getString('labels', 'dateError'); toastMessage.timeToLive = 7; toastMessage.level = ImtToaster.WARNING; ApplicationModelLocator.getInstance().toaster.toast( toastMessage ); dateOfBirthDateField.text = ""; dateOfBirthDateField.errorString = ResourceManager.getInstance().getString('labels', 'errorField'); dateOfBirthDateField.selectedDate = null; return false; } return true; } // to do later, to highlight current patient /*public function updatePatientDatagrid() : void { if (_patientSelectedIndex != -1) { dg.invalidateDisplayList(); dg.selectedIndex = _patientSelectedIndex; dg.selectedIndices = [_patientSelectedIndex]; dg.validateNow(); dg.scrollToIndex(_patientSelectedIndex); } comboBoxAppointmentSelected.selectedIndex = _appointmentSelectedIndex; }*/