200 lines
6.1 KiB
Dart
200 lines
6.1 KiB
Dart
import 'dart:async';
|
|
|
|
import 'dart:math';
|
|
|
|
import 'package:flutter/cupertino.dart';
|
|
import 'package:flutter/material.dart';
|
|
import 'package:hive_flutter/hive_flutter.dart';
|
|
import 'package:konectar_events/model/allsessionnotesmodel.dart';
|
|
import 'package:konectar_events/model/events_speakers_k1.dart';
|
|
import 'package:konectar_events/model/eventsdetailmodel.dart';
|
|
import 'package:konectar_events/model/eventspeakers.dart';
|
|
import 'package:konectar_events/model/sessionnotesmodel.dart';
|
|
import 'package:konectar_events/model/sessionstopics_model.dart';
|
|
import 'package:konectar_events/model/topics_cloud_model.dart';
|
|
import 'package:konectar_events/utils/apicall.dart';
|
|
import 'package:konectar_events/utils/constants.dart';
|
|
import 'package:konectar_events/viewmodel/hive_repository.dart';
|
|
import 'package:konectar_events/widgets/word_cloud.dart';
|
|
|
|
class HcpProfileProvider extends ChangeNotifier {
|
|
List<SessionNotesModel> sessionNotesList = [];
|
|
List<SessionNotesModel> allSessionNotesHiveList = [];
|
|
int totalTopics = 0;
|
|
int totalSessions = 0;
|
|
int totalNotes = 0;
|
|
List<SessionsTopicsData> sessionTopics = [];
|
|
List<AllSessionNotesResponse> allSessionNotes = [];
|
|
late Box<SessionNotesModel> box;
|
|
bool enableSessions = false;
|
|
bool enableNotes = false;
|
|
bool enableMedInsights = false;
|
|
var tabs = [
|
|
Tab(text: "Sessions"),
|
|
Tab(text: "Notes"),
|
|
Tab(text: "Medical Insights"),
|
|
// Tab(text: "Medical Insights"),
|
|
];
|
|
initConfigModules() async {
|
|
enableSessions = await HiveOperations.checkIfApiExists(
|
|
EventsConstants.showEventsTopicsAndSession, EventsConstants.moduleName);
|
|
enableNotes = await HiveOperations.checkIfApiExists(
|
|
EventsConstants.saveEventsTopicNote, EventsConstants.moduleName);
|
|
enableMedInsights = await HiveOperations.checkIfApiExists(
|
|
EventsConstants.medInsightApi, EventsConstants.moduleName);
|
|
tabs.clear();
|
|
if (!enableSessions) {
|
|
tabs.clear();
|
|
} else {
|
|
if (enableSessions) {
|
|
tabs.add(Tab(
|
|
text: "Sessions",
|
|
));
|
|
}
|
|
if (enableNotes) {
|
|
tabs.add(Tab(
|
|
text: "Notes",
|
|
));
|
|
}
|
|
if (enableMedInsights) {
|
|
tabs.add(Tab(
|
|
text: "Medical Insights",
|
|
));
|
|
}
|
|
}
|
|
notifyListeners();
|
|
}
|
|
|
|
String getUserLoc(EventSpeakersData detail) {
|
|
List<String> loc = [];
|
|
if (detail.orgName != null && detail.orgName != "") {
|
|
loc.add(detail.orgName!);
|
|
}
|
|
if (detail.city != null && detail.city != "") {
|
|
loc.add(detail.city!);
|
|
}
|
|
|
|
if (detail.country != null && detail.country != "") {
|
|
loc.add(detail.country!);
|
|
}
|
|
return loc.join(' , ');
|
|
// return 'hdgkhjagshjdgashjdgkjhsagdkjgasljkdgsajkgdhjksaghdjkasgdkjgaskjdlsak';
|
|
}
|
|
|
|
Future<void> getSessionTopics(EventSpeakersData detail) async {
|
|
sessionTopics = await ApiCall().getSessionsTopics(detail.eid!,
|
|
detail.kolId == "0" ? detail.hcpPinAlias! : detail.kolId!, detail.kId!);
|
|
totalSessions = sessionTopics.length;
|
|
getCounts();
|
|
notifyListeners();
|
|
}
|
|
|
|
Future<dynamic> submitSessionNotes(
|
|
EventSpeakersData detail,
|
|
SessionsTopicsData sessionsTopicsData,
|
|
String notes,
|
|
String? selectedfilepath,
|
|
String? selectedfilename) async {
|
|
var data = await ApiCall()
|
|
.addSessionNotes(
|
|
sessionsTopicsData.kolEventsId!,
|
|
sessionsTopicsData.kolId!,
|
|
sessionsTopicsData.eventAttendeesId!,
|
|
detail.kId!,
|
|
notes,
|
|
selectedfilepath,
|
|
selectedfilename,
|
|
sessionsTopicsData.id ?? "",
|
|
)
|
|
.then(
|
|
(value) {
|
|
getSessionTopics(detail);
|
|
},
|
|
);
|
|
return data;
|
|
}
|
|
|
|
getCounts() {
|
|
// List<String> topics = eventsdetail.eventTopics!.split("|");
|
|
// totalTopics = topics.length;
|
|
|
|
// totalSessions = int.parse(eventsdetail.numSess ?? "1");
|
|
// totalNotes = sessionNotesList.length;
|
|
int total = 0;
|
|
int totalT = 0;
|
|
if (sessionTopics.isNotEmpty) {
|
|
for (var obj in sessionTopics) {
|
|
print("Notes_count : ${obj.noteCount}");
|
|
total = total + int.parse(obj.noteCount ?? "0");
|
|
totalT = totalT + obj.eventTopics!.split("|").length ?? 0;
|
|
}
|
|
}
|
|
totalNotes = total;
|
|
totalTopics = totalT;
|
|
totalSessions = sessionTopics.length;
|
|
notifyListeners();
|
|
}
|
|
|
|
addSessionNotes(SessionNotesModel sessionNotesModel) async {
|
|
// sessionNotesList.add(sessionNotesModel);
|
|
await saveSessionData(sessionNotesModel);
|
|
notifyListeners();
|
|
}
|
|
|
|
List<SessionNotesModel> getSessionNotesList(
|
|
String eid, EventSpeakersData eventsdetail) {
|
|
print("Check hcp id");
|
|
print("$eid,${eventsdetail.id}");
|
|
sessionNotesList = sessionNotesList
|
|
.where(
|
|
(element) => element.eventid == eid,
|
|
)
|
|
.toList();
|
|
sessionNotesList = sessionNotesList.where((element) {
|
|
print("Check hcp id each");
|
|
print("${element.hcpid}");
|
|
if (element.hcpid == null) {
|
|
print("search");
|
|
|
|
String fname = element.hcpname!.split(" ")[0];
|
|
String lname = element.hcpname!.split(" ").last;
|
|
print("${element.hcpname}");
|
|
return fname.toLowerCase() == eventsdetail.kolFullName!.toLowerCase() &&
|
|
lname.toLowerCase() == eventsdetail.kolFullName!.toLowerCase();
|
|
} else {
|
|
return element.hcpid == eventsdetail.id;
|
|
}
|
|
}).toList();
|
|
totalNotes = sessionNotesList.length;
|
|
return sessionNotesList;
|
|
}
|
|
|
|
getAllSessionNotesList(String eid) async {
|
|
print("Check hcp id");
|
|
// print("$eid,$hcpid");
|
|
await getSessionData();
|
|
allSessionNotesHiveList =
|
|
sessionNotesList.where((element) => element.eventid == eid).toList();
|
|
notifyListeners();
|
|
}
|
|
|
|
FutureOr saveSessionData(SessionNotesModel notesModel) async {
|
|
box = await Hive.openBox<SessionNotesModel>('SessionNotesModelBox');
|
|
|
|
box.add(notesModel);
|
|
await getSessionData();
|
|
|
|
notifyListeners();
|
|
}
|
|
|
|
FutureOr getSessionData() async {
|
|
box = await Hive.openBox<SessionNotesModel>('SessionNotesModelBox');
|
|
Iterable<SessionNotesModel> data = box.values;
|
|
sessionNotesList = data.toList();
|
|
notifyListeners();
|
|
// for (var obj in data) {
|
|
// sessionNotesList = new.fromJson(obj.toJson());
|
|
// }
|
|
}
|
|
}
|