import 'dart:ui'; import 'package:hmg_qline/constants/app_constants.dart'; import 'package:hmg_qline/models/kiosk_language_config_model.dart'; import 'package:hmg_qline/models/kiosk_queue_model.dart'; import 'package:hmg_qline/utilities/enums.dart'; import 'package:hmg_qline/utilities/extensions.dart'; class GlobalConfigurationsModel { int? id; int? configType; String? description; int? counterStart; int? counterEnd; int concurrentCallDelaySec = 1; int? voiceType; String? voiceTypeText; LanguageEnum screenLanguageEnum = LanguageEnum.english; String? screenLanguageText; TextDirection textDirection = TextDirection.ltr; LanguageEnum voiceLanguageEnum = LanguageEnum.english; String? voiceLanguageText; int screenMaxDisplayPatients = 16; bool? isNotiReq; int? prioritySMS; int? priorityWhatsApp; int? priorityEmail; String ticketNoText = "Ticket Number"; String pleaseVisitCounterTextEn = "Please Visit Counter"; String pleaseVisitCounterTextAr = "Please Visit Counter"; int? roomNo; bool? isRoomNoRequired; String? roomTextEng; String? counterTextEng; String? queueNoTextEng; String? callForTextEng; String? roomTextArb; String? counterTextArb; String? queueNoTextArb; String? callForTextArb; String? currentServeTextEng = "Current Serving"; String? currentServeTextArb; String maxText = ""; String minText = ""; String nextPrayerTextEng = "Next Prayer"; String nextPrayerTextArb = "الصلاة القادمة"; String weatherText = "Weather"; String? fajarTextEng; String? dhuhrTextEng; String? asarTextEng; String? maghribTextEng; String? ishaTextEng; String? fajarTextArb; String? dhuhrTextArb; String? asarTextArb; String? maghribTextArb; String? ishaTextArb; bool? isActive; int? createdBy; String? createdOn; dynamic editedBy; dynamic editedOn; bool isToneReq = false; bool isVoiceReq = false; ScreenOrientationEnum orientationTypeEnum = ScreenOrientationEnum.portraitUp; bool? isTurnOn; int? waitingAreaType; int? gender; bool isWeatherReq = false; bool isPrayerTimeReq = false; bool isRssFeedReq = false; QTypeEnum qTypeEnum = QTypeEnum.appointment; ScreenTypeEnum screenTypeEnum = ScreenTypeEnum.waitingAreaScreen; int? projectID; double? projectLatitude; double? projectLongitude; int? cityKey; List? kioskQueueList; List? kioskLanguageConfigList; bool isFromTakhasusiMain = false; bool globalClinicPrefixReq = false; bool clinicPrefixReq = true; String vitalSignTextEng = "Vital Sign"; String doctorTextEng = "Doctor"; String procedureTextEng = "Procedure"; String vaccinationTextEng = "Vaccination"; String nebulizationTextEng = "Nebulization"; String callForVitalSignTextEng = "Call for Vital Sign"; String callForDoctorTextEng = "Call for Doctor"; String callForProcedureTextEng = "Call for Procedure"; String callForVaccinationTextEng = "Call for Vaccination"; String callForNebulizationTextEng = "Call for Nebulization"; String vitalSignTextArb = "العلامات الحيوية"; String doctorTextArb = "الطبيب"; String procedureTextArb = "الإجراء"; String vaccinationTextArb = "التطعيم"; String nebulizationTextArb = "البخاخة"; String callForVitalSignTextArb = "الرجاء التوجّه إلى غرفة العلامات الحيوية"; String callForDoctorTextArb = "الرجاء التوجّه إلى غرفة الطبيب"; String callForProcedureTextArb = "الرجاء التوجّه إلى غرفة الإجراء"; String callForVaccinationTextArb = "الرجاء التوجّه إلى غرفة التطعيم"; String callForNebulizationTextArb = "الرجاء التوجّه إلى غرفة البخاخة"; static String defaultIfNullOrEmpty(dynamic value, String def) { if (value == null) return def; if (value is String && value.trim().isEmpty) return def; return value.toString(); } GlobalConfigurationsModel({ this.id, this.configType, this.description, this.counterStart, this.counterEnd, this.concurrentCallDelaySec = 1, this.voiceType, this.voiceTypeText, this.screenLanguageEnum = LanguageEnum.english, this.screenLanguageText, this.textDirection = TextDirection.ltr, this.voiceLanguageEnum = LanguageEnum.english, this.voiceLanguageText, this.screenMaxDisplayPatients = 16, this.isNotiReq, this.prioritySMS, this.priorityWhatsApp, this.priorityEmail, this.ticketNoText = "Ticket Number", this.pleaseVisitCounterTextEn = "Please Visit Counter", this.pleaseVisitCounterTextAr = "يرجى زيارة الكاونتر", this.roomTextEng, this.roomNo, this.isRoomNoRequired = true, this.counterTextEng, this.queueNoTextEng, this.callForTextEng, this.counterTextArb, this.queueNoTextArb, this.callForTextArb, this.currentServeTextEng = "Current Serving", this.currentServeTextArb, this.maxText = "", this.minText = "", this.nextPrayerTextEng = "Next Prayer", this.nextPrayerTextArb = "الصلاة القادمة", this.weatherText = "Weather", this.fajarTextEng, this.dhuhrTextEng, this.asarTextEng, this.maghribTextEng, this.ishaTextEng, this.fajarTextArb, this.dhuhrTextArb, this.asarTextArb, this.maghribTextArb, this.ishaTextArb, this.isActive, this.createdBy, this.createdOn, this.editedBy, this.editedOn, this.isToneReq = false, this.isVoiceReq = false, this.orientationTypeEnum = ScreenOrientationEnum.portraitUp, this.isTurnOn, this.waitingAreaType, this.gender, this.isWeatherReq = false, this.isPrayerTimeReq = false, this.isRssFeedReq = false, this.qTypeEnum = QTypeEnum.appointment, this.screenTypeEnum = ScreenTypeEnum.waitingAreaScreen, this.projectID, this.projectLatitude, this.projectLongitude, this.cityKey, this.kioskQueueList, this.kioskLanguageConfigList, this.isFromTakhasusiMain = false, this.globalClinicPrefixReq = false, this.clinicPrefixReq = true, this.vitalSignTextEng = "Vital Sign", this.doctorTextEng = "Doctor", this.procedureTextEng = "Procedure", this.vaccinationTextEng = "Vaccination", this.nebulizationTextEng = "Nebulization", this.callForVitalSignTextEng = "Call for Vital Sign", this.callForDoctorTextEng = "Call for Doctor", this.callForProcedureTextEng = "Call for Procedure", this.callForVaccinationTextEng = "Call for Vaccination", this.callForNebulizationTextEng = "Call for Nebulization", this.vitalSignTextArb = "العلامات الحيوية", this.doctorTextArb = "الطبيب", this.procedureTextArb = "الإجراء", this.vaccinationTextArb = "التطعيم", this.nebulizationTextArb = "البخاخة", this.callForVitalSignTextArb = "استدعاء للعلامات الحيوية", this.callForDoctorTextArb = "الرجاء التوجّه إلى غرفة الطبيب", this.callForProcedureTextArb = "الرجاء التوجّه إلى غرفة الإجراء", this.callForVaccinationTextArb = "الرجاء التوجّه إلى غرفة التطعيم", this.callForNebulizationTextArb = "الرجاء التوجّه إلى غرفة البخاخة", }); GlobalConfigurationsModel.fromJson({required Map json, int qType = 1, int screenType = 1}) { id = json['id'] ?? 0; configType = json['configType'] ?? 0; description = defaultIfNullOrEmpty(json['description'], ""); counterStart = json['counterStart'] ?? 0; counterEnd = json['counterEnd'] ?? 0; concurrentCallDelaySec = json['concurrentCallDelaySec'] ?? 1; voiceType = json['voiceType'] ?? 0; voiceTypeText = defaultIfNullOrEmpty(json['voiceTypeText'], ""); screenLanguageEnum = ((json['screenLanguage'] ?? 1) as int).toLanguageEnum(); screenLanguageText = defaultIfNullOrEmpty(json['screenLanguageText'], "English"); textDirection = json['textDirection'] == 2 ? TextDirection.rtl : TextDirection.ltr; voiceLanguageEnum = ((json['voiceLanguage'] ?? 1) as int).toLanguageEnum(); voiceLanguageText = defaultIfNullOrEmpty(json['voiceLanguageText'], "English"); screenMaxDisplayPatients = json['screenMaxDisplayPatients'] ?? 16; isNotiReq = json['isNotiReq'] ?? false; prioritySMS = json['prioritySMS'] ?? 0; priorityWhatsApp = json['priorityWhatsApp'] ?? 0; priorityEmail = json['priorityEmail'] ?? 0; ticketNoText = defaultIfNullOrEmpty(json['ticketNoText'], "Ticket Number"); pleaseVisitCounterTextEn = defaultIfNullOrEmpty(json['pleaseVisitCounterText'], "Please Visit Counter"); pleaseVisitCounterTextAr = defaultIfNullOrEmpty(json['pleaseVisitCounterTextAr'], "يرجى زيارة الكاونتر"); roomNo = json['roomNo'] ?? 0; isRoomNoRequired = json['isRoomNoReq'] ?? true; queueNoTextEng = defaultIfNullOrEmpty(json['queueNoText'], "Queue Number"); callForTextEng = defaultIfNullOrEmpty(json['callForText'], "Please Proceed"); counterTextEng = defaultIfNullOrEmpty(json['counterText'], "Counter"); roomTextEng = defaultIfNullOrEmpty(json['roomText'], "Room"); queueNoTextArb = defaultIfNullOrEmpty(json['queueNoTextAr'], "الرقم"); callForTextArb = defaultIfNullOrEmpty(json['callForTextAr'], "التوجه إلى"); counterTextArb = defaultIfNullOrEmpty(json['counterTextAr'], "الكاونتر"); roomTextArb = defaultIfNullOrEmpty(json['roomTextAr'], "الغرفة"); currentServeTextEng = defaultIfNullOrEmpty(json['currentServeText'], "Current Serving"); currentServeTextArb = defaultIfNullOrEmpty(json['currentServeTextAr'], "يتم خدمة"); maxText = defaultIfNullOrEmpty(json['maxText'], ""); minText = defaultIfNullOrEmpty(json['minText'], ""); nextPrayerTextEng = defaultIfNullOrEmpty(json['nextPrayerText'], "Next Prayer"); nextPrayerTextArb = defaultIfNullOrEmpty(json['nextPrayerTextArb'], "الصلاة القادمة"); weatherText = defaultIfNullOrEmpty(json['weatherText'], "Weather"); fajarTextEng = defaultIfNullOrEmpty(json['fajarText'], "Fajr"); dhuhrTextEng = defaultIfNullOrEmpty(json['dhuhrText'], "Dhuhr"); asarTextEng = defaultIfNullOrEmpty(json['asarText'], "Asar"); maghribTextEng = defaultIfNullOrEmpty(json['maghribText'], "Maghrib"); ishaTextEng = defaultIfNullOrEmpty(json['ishaText'], "Isha"); fajarTextArb = defaultIfNullOrEmpty(json['fajarTextAr'], AppStrings.prayersArray[0]); dhuhrTextArb = defaultIfNullOrEmpty(json['dhuhrTextAr'], AppStrings.prayersArray[1]); asarTextArb = defaultIfNullOrEmpty(json['asarTextAr'], AppStrings.prayersArray[2]); maghribTextArb = defaultIfNullOrEmpty(json['maghribTextAr'], AppStrings.prayersArray[3]); ishaTextArb = defaultIfNullOrEmpty(json['ishaTextAr'], AppStrings.prayersArray[4]); isActive = json['isActive'] ?? true; createdBy = json['createdBy'] ?? 0; createdOn = defaultIfNullOrEmpty(json['createdOn'], ""); editedBy = json['editedBy']; editedOn = json['editedOn']; isToneReq = json['isToneReq'] ?? false; isVoiceReq = json['isVoiceReq'] ?? false; orientationTypeEnum = ((json['orientationType'] ?? 1) as int).toScreenOrientationEnum(); isTurnOn = json['isTurnOn'] ?? true; waitingAreaType = json['waitingAreaType'] ?? 0; gender = json['gender'] ?? 0; isWeatherReq = json['isWeatherReq'] ?? false; isPrayerTimeReq = json['isPrayerTimeReq'] ?? false; isRssFeedReq = json['isRssFeedReq'] ?? false; qTypeEnum = ((json['qType'] ?? qType) as int).toQTypeEnum(); screenTypeEnum = ((json['screenType'] ?? screenType) as int).toScreenTypeEnum(); projectID = json['projectID'] ?? 0; projectLatitude = json['projectLatitude']?.toDouble() ?? 0.0; projectLongitude = json['projectLongitude']?.toDouble() ?? 0.0; cityKey = json['cityKey'] ?? 0; if (json['kioskQueue'] != null) { kioskQueueList = List.from(json['kioskQueue'].map((kioskQueueJson) => KioskQueueModel.fromJson(kioskQueueJson))); } else { kioskQueueList = []; } if (json['kioskConfig'] != null) { kioskLanguageConfigList = List.from(json['kioskConfig'].map((kioskQueueJson) => KioskLanguageConfigModel.fromJson(kioskQueueJson))); } else { kioskLanguageConfigList = []; } isFromTakhasusiMain = false; globalClinicPrefixReq = json['globalClinicPrefixReq'] ?? false; clinicPrefixReq = json['clinicPrefixReq'] ?? true; vitalSignTextEng = defaultIfNullOrEmpty(json['vitalSignText'], "Vital Sign"); doctorTextEng = defaultIfNullOrEmpty(json['doctorText'], "Doctor"); procedureTextEng = defaultIfNullOrEmpty(json['procedureText'], "Procedure"); vaccinationTextEng = defaultIfNullOrEmpty(json['vaccinationText'], "Vaccination"); nebulizationTextEng = defaultIfNullOrEmpty(json['nebulizationText'], "Nebulization"); callForVitalSignTextEng = defaultIfNullOrEmpty(json['callForVitalSignText'], "Call for Vital Sign"); callForDoctorTextEng = defaultIfNullOrEmpty(json['callForDoctorText'], "Call for Doctor"); callForProcedureTextEng = defaultIfNullOrEmpty(json['callForProcedureText'], "Call for Procedure"); callForVaccinationTextEng = defaultIfNullOrEmpty(json['callForVaccinationText'], "Call for Vaccination"); callForNebulizationTextEng = defaultIfNullOrEmpty(json['callForNebulizationText'], "Call for Nebulization"); vitalSignTextArb = defaultIfNullOrEmpty(json['vitalSignTextAr'], "العلامات الحيوية"); doctorTextArb = defaultIfNullOrEmpty(json['doctorTextAr'], "الطبيب"); procedureTextArb = defaultIfNullOrEmpty(json['procedureTextAr'], "الإجراء"); vaccinationTextArb = defaultIfNullOrEmpty(json['vaccinationTextAr'], "التطعيم"); nebulizationTextArb = defaultIfNullOrEmpty(json['nebulizationTextAr'], "البخاخة"); callForVitalSignTextArb = defaultIfNullOrEmpty(json['callForVitalSignTextAr'], "الرجاء التوجّه إلى غرفة العلامات الحيوية"); callForDoctorTextArb = defaultIfNullOrEmpty(json['callForDoctorTextAr'], "الرجاء التوجّه إلى غرفة الطبيب"); callForProcedureTextArb = defaultIfNullOrEmpty(json['callForProcedureTextAr'], "الرجاء التوجّه إلى غرفة الإجراء"); callForVaccinationTextArb = defaultIfNullOrEmpty(json['callForVaccinationTextAr'], "الرجاء التوجّه إلى غرفة التطعيم"); callForNebulizationTextArb = defaultIfNullOrEmpty(json['callForNebulizationTextAr'], "الرجاء التوجّه إلى غرفة البخاخة"); } bool isClinicPrefixAdded(String ticketNo) { // Check if the ticket has format: "XXX W-XX" where XXX is any 3 letters followed by space and W- final hasClinicPrefix = RegExp(r'^[A-Za-z]{3} W-').hasMatch(ticketNo); return hasClinicPrefix; } @override String toString() { return 'GlobalConfigurationsModel{id: $id, isFromTakhasusiMain: $isFromTakhasusiMain, configType: $configType, description: $description, counterStart: $counterStart, counterEnd: $counterEnd, concurrentCallDelaySec: $concurrentCallDelaySec, voiceType: $voiceType, voiceTypeText: $voiceTypeText, screenLanguageEnum: $screenLanguageEnum, screenLanguageText: $screenLanguageText, textDirection: $textDirection, voiceLanguageEnum: $voiceLanguageEnum, voiceLanguageText: $voiceLanguageText, screenMaxDisplayPatients: $screenMaxDisplayPatients, isNotiReq: $isNotiReq, prioritySMS: $prioritySMS, priorityWhatsApp: $priorityWhatsApp, priorityEmail: $priorityEmail, ticketNoText: $ticketNoText, pleaseVisitCounterTextEn: $pleaseVisitCounterTextEn,pleaseVisitCounterTextAr: $pleaseVisitCounterTextAr, roomText: $roomTextEng, roomNo: $roomNo, isRoomNoRequired: $isRoomNoRequired, counterText: $counterTextEng, queueNoText: $queueNoTextEng, callForText: $callForTextEng, currentServeTextArb: $currentServeTextArb,, currentServeTextEng: $currentServeTextEng, maxText: $maxText, minText: $minText, nextPrayerTextEng: $nextPrayerTextEng, nextPrayerTextArb: $nextPrayerTextArb, weatherText: $weatherText, fajarText: $fajarTextEng, dhuhrText: $dhuhrTextEng, asarText: $asarTextEng, maghribText: $maghribTextEng, ishaText: $ishaTextEng, isActive: $isActive, createdBy: $createdBy, createdOn: $createdOn, editedBy: $editedBy, editedOn: $editedOn, isToneReq: $isToneReq, isVoiceReq: $isVoiceReq, orientationTypeEnum: $orientationTypeEnum, isTurnOn: $isTurnOn, waitingAreaType: $waitingAreaType, gender: $gender, isWeatherReq: $isWeatherReq, isPrayerTimeReq: $isPrayerTimeReq, isRssFeedReq: $isRssFeedReq, qTypeEnum: $qTypeEnum, screenTypeEnum: $screenTypeEnum, projectID: $projectID, projectLatitude: $projectLatitude, projectLongitude: $projectLongitude, cityKey: $cityKey, kioskQueueList: $kioskQueueList, kioskLanguageConfigList: $kioskLanguageConfigList, vitalSignText: $vitalSignTextEng, doctorText: $doctorTextEng, procedureText: $procedureTextEng, vaccinationText: $vaccinationTextEng, nebulizationText: $nebulizationTextEng, callForVitalSignText: $callForVitalSignTextEng, callForDoctorText: $callForDoctorTextEng, callForProcedureText: $callForProcedureTextEng, callForVaccinationText: $callForVaccinationTextEng, callForNebulizationText: $callForNebulizationTextEng, vitalSignTextArb: $vitalSignTextArb, doctorTextArb: $doctorTextArb, procedureTextArb: $procedureTextArb, vaccinationTextArb: $vaccinationTextArb, nebulizationTextArb: $nebulizationTextArb, callForVitalSignTextArb: $callForVitalSignTextArb, callForDoctorTextArb: $callForDoctorTextArb, callForProcedureTextArb: $callForProcedureTextArb, callForVaccinationTextArb: $callForVaccinationTextArb, callForNebulizationTextArb: $callForNebulizationTextArb}'; } }