DiscoverModule/lib/service.dart/service.dart

451 lines
14 KiB
Dart

import 'dart:convert';
import 'package:dio/dio.dart';
import 'package:discover_module/constants.dart';
import 'package:discover_module/hive_fun.dart';
import 'package:flutter/services.dart';
import 'package:hive_flutter/hive_flutter.dart';
const String curl = Constants.url;
class Callapi {
getallhcpdata() async {
const url = '$curl/users';
// final response = await Dio().get(url);
// final jsonresponse = response.data;
// final apihcpdata = Hive.box("hcpdata");
// if (apihcpdata.isEmpty) {
// print("alldata_is: , ${jsonresponse} ${jsonresponse.length}");
// for (int i = 0; i < jsonresponse.length; i++) {
// print("hcp:data_is: , ${jsonresponse[i]['email']}");
// HiveFunctions.storehcpdata({
// "id": jsonresponse[i]['id'],
// "name": jsonresponse[i]['name'],
// "email": jsonresponse[i]['email'],
// "summarry": jsonresponse[i]['summarry'],
// "addr": jsonresponse[i]['addr'],
// "license_no": jsonresponse[i]['license_no'],
// "p_suffix": jsonresponse[i]['p_suffix'],
// "speciality": jsonresponse[i]['speciality'],
// "sub_speciality": jsonresponse[i]['sub_speciality'],
// "phone_no": jsonresponse[i]['phone_no'],
// "rank": jsonresponse[i]['rank'],
// "score": jsonresponse[i]['score'],
// "events_count": jsonresponse[i]['events_count'],
// "affiliations_count": jsonresponse[i]['affiliations_count'],
// "publications_count": jsonresponse[i]['publications_count'],
// "img_path": jsonresponse[i]["img_path"],
// });
// }
// }
// return jsonresponse;
print("OfflineJsonnnn");
final String response = await rootBundle.loadString('assets/contact.json');
final data = await json.decode(response);
print("Data_isss: $data");
return data;
}
getsinglehcpdata() async {
// const url = 'http://127.0.0.1:8000/api/users/1';
// const url = 'http://192.168.2.143:8082/api/users/1';
// const url = 'http://192.168.172.50:8081/api/users/1';
const url = '$curl/users/1';
final responsehcp = await Dio().post(url);
final jsonresponse1 = responsehcp.data;
// final List<dynamic> Json = json.decode(responsehcp.data);
print("Singlejsondata : ${jsonresponse1}");
return jsonresponse1;
}
getaffiliationsdata(id) async {
print("Affiliation_iddd: ${id}");
// const url = '$curl/affiliations';
// final affiliationres = await Dio().get(url);
// final jsonresponse2 = affiliationres.data.take(2).toList();
// return jsonresponse2;
// final String response = await rootBundle.loadString('assets/section.json');
// final String response = await rootBundle.loadString('assets/section.json');
final String response = await Constants.response;
final Affiliation = await json.decode(response);
/////////////////////////////////////////////////////
final List<Map<String, dynamic>> filteredData = Affiliation['Affiliations']
.where((item) => item['user_id'] == id)
.cast<Map<String, dynamic>>()
.toList();
print("filteredDatafilteredDatafilteredData: ${filteredData}");
// Print filtered data
final List<dynamic> affiliations = Affiliation['Affiliations'];
print("Data_isss: $affiliations");
return filteredData;
}
getpublicationsdata(id) async {
print("getpublicationsdata_iddd: ${id}");
// const url = '$curl/publications';
// final affiliationres = await Dio().get(url);
// final jsonresponse2 = affiliationres.data.take(2).toList();
// return jsonresponse2;
final String response = await Constants.response;
final Publications = await json.decode(response);
final List<dynamic> publication = Publications['Publications'];
/////////////////////////////////////////////////////
final List<Map<String, dynamic>> filteredData = Publications['Publications']
.where((item) => item['user_id'] == id)
.cast<Map<String, dynamic>>()
.toList();
print("filteredDatafilteredDatafilteredData111: ${filteredData}");
// Print filtered data
print("publicationData_isss: $publication");
return filteredData;
}
geteventsdata(id) async {
// const url = '$curl/events';
// final events = await Dio().get(url);
// // final jsonEvent = events.data;
// final jsonEvent = events.data;
// print("All_event: $jsonEvent");
// final jsonEvent1 = events.data.take(2).toList();
// print("only few : $jsonEvent1");
// return jsonEvent1;
final String response = await Constants.response;
final Events = await json.decode(response);
final List<dynamic> event = Events['Events'];
/////////////////////////////////////////////////////
final List<Map<String, dynamic>> filteredData = Events['Events']
.where((item) => item['user_id'] == id)
.cast<Map<String, dynamic>>()
.toList();
print("filteredDatafilteredDatafilteredData111: ${filteredData}");
// Print filtered data
print("eventData_isss: $event");
return filteredData;
}
getallaffiliationsdata() async {
// const url = 'http://192.168.2.143:8082/api/affiliations';
//const url = 'http://192.168.172.50:8081/api/affiliations';
const url = '$curl/affiliations';
final events = await Dio().get(url);
// final jsonEvent = events.data;
final jsonEvent = events.data;
print("All_event: $jsonEvent");
return jsonEvent;
}
getallpublicationsdata() async {
// const url = 'http://192.168.2.143:8082/api/publications';
//const url = 'http://192.168.172.50:8081/api/publications';
const url = '$curl/publications';
final events = await Dio().get(url);
// final jsonEvent = events.data;
final jsonEvent = events.data;
print("All_event: $jsonEvent");
return jsonEvent;
}
allgeteventsdata() async {
//const url = 'http://192.168.2.143:8082/api/events';
//const url = 'http://192.168.172.50:8081/api/events';
const url = '$curl/events';
final events = await Dio().get(url);
// final jsonEvent = events.data;
final jsonEvent = events.data;
print("All_event: $jsonEvent");
return jsonEvent;
}
getalltrials(id) async {
print("TrialsssssAPIIIIIIIIII: $id");
// const url = '$curl/trails';
// final trials = await Dio().get(url);
// final jsontrials = trials.data;
// print("All_trialsss: $jsontrials");
// return jsontrials;
final String response = await Constants.response;
final Trials = await json.decode(response);
final List<dynamic> trials = Trials['Trials'];
/////////////////////////////////////////////////////
final List<Map<String, dynamic>> filteredData = Trials['Trials']
.where((item) => item['user_id'] == id)
.cast<Map<String, dynamic>>()
.toList();
print("TrialsssssAPIIIIIIIIIIilteredDatafilteredData111: ${filteredData}");
// Print filtered data
print("trialsData_isss: $trials");
return filteredData;
}
getallMedicalInsightdata() async {
// const url = 'http://127.0.0.1:8000/api/users';
// const url = 'http://192.168.2.143:8082/api/users';
// const url = 'http://192.168.172.50:8082/api/users';
// const url = 'http://192.168.172.50:8081/api/users';
const url = '$curl/medicalinsight';
final response = await Dio().get(url);
final jsonresponse = response.data;
return jsonresponse;
}
getSpeakerdata() async {
// const url = '$curl/speaker';
// final response = await Dio().get(url);
// final jsonresponse = response.data;
// return jsonresponse;
final String response = await Constants.response;
final Speaker = await json.decode(response);
final List<dynamic> speaker = Speaker['Speaker'];
print("speakerData_isss: $speaker");
return speaker;
}
getEngdata() async {
// const url = '$curl/engagement';
// final response = await Dio().get(url);
// final jsonresponse = response.data;
// return jsonresponse;
// }
final String response = await Constants.response;
final Engagement = await json.decode(response);
final List<dynamic> eng = Engagement['Engagement'];
print("engData_isss: $eng");
return eng;
}
getlocationsdata(id) async {
final String response = await Constants.response;
final Location = await json.decode(response);
final List<dynamic> event = Location['Location'];
/////////////////////////////////////////////////////
final List<Map<String, dynamic>> filteredData = Location['Location']
.where((item) => item['user_id'] == id)
.cast<Map<String, dynamic>>()
.toList();
print("LocationfilteredDatafilteredData111: ${filteredData}");
// Print filtered data
print("LocationeventData_isss: $event");
return filteredData;
}
getphonedata(id) async {
final String response = await Constants.response;
final PhoneNo = await json.decode(response);
final List<dynamic> event = PhoneNo['Location'];
/////////////////////////////////////////////////////
final List<Map<String, dynamic>> filteredData = PhoneNo['PhoneNo']
.where((item) => item['user_id'] == id)
.cast<Map<String, dynamic>>()
.toList();
print("PhoneNofilteredDatafilteredData111: ${filteredData}");
// Print filtered data
print("PhoneNoeventData_isss: $event");
return filteredData;
}
getemaildata(id) async {
final String response = await Constants.response;
final Email = await json.decode(response);
final List<dynamic> event = Email['Email'];
/////////////////////////////////////////////////////
final List<Map<String, dynamic>> filteredData = Email['Email']
.where((item) => item['user_id'] == id)
.cast<Map<String, dynamic>>()
.toList();
print("EmaililteredDatafilteredData111: ${filteredData}");
// Print filtered data
print("EmaileventData_isss: $event");
return filteredData;
}
getpatentdata(id) async {
final String response = await Constants.response;
final Patent = await json.decode(response);
final List<dynamic> event = Patent['Patent'];
/////////////////////////////////////////////////////
final List<Map<String, dynamic>> filteredData = Patent['Patent']
.where((item) => item['user_id'] == id)
.cast<Map<String, dynamic>>()
.toList();
print("PatenteredDatafilteredData111: ${filteredData}");
// Print filtered data
print("PatenttData_isss: $event");
return filteredData;
}
getcerlistdata(id) async {
final String response = await Constants.response;
final Certificate = await json.decode(response);
final List<dynamic> event = Certificate['Certificate'];
/////////////////////////////////////////////////////
final List<Map<String, dynamic>> filteredData = Certificate['Certificate']
.where((item) => item['user_id'] == id)
.cast<Map<String, dynamic>>()
.toList();
print("PatenteredDatafilteredData111: ${filteredData}");
// Print filtered data
print("PatenttData_isss: $event");
return filteredData;
}
getedulistdata(id) async {
final String response = await Constants.response;
final Education = await json.decode(response);
final List<dynamic> event = Education['Education'];
/////////////////////////////////////////////////////
final List<Map<String, dynamic>> filteredData = Education['Education']
.where((item) => item['user_id'] == id)
.cast<Map<String, dynamic>>()
.toList();
print("PatenteredDatafilteredData111: ${filteredData}");
// Print filtered data
print("PatenttData_isss: $event");
return filteredData;
}
getawarddata(id) async {
final String response = await Constants.response;
final Awards = await json.decode(response);
final List<dynamic> event = Awards['Awards'];
/////////////////////////////////////////////////////
final List<Map<String, dynamic>> filteredData = Awards['Awards']
.where((item) => item['user_id'] == id)
.cast<Map<String, dynamic>>()
.toList();
print("PatenteredDatafilteredData111: ${filteredData}");
// Print filtered data
print("PatenttData_isss: $event");
return filteredData;
}
gettrainingdata(id) async {
final String response = await Constants.response;
final Training = await json.decode(response);
final List<dynamic> event = Training['Training'];
/////////////////////////////////////////////////////
final List<Map<String, dynamic>> filteredData = Training['Training']
.where((item) => item['user_id'] == id)
.cast<Map<String, dynamic>>()
.toList();
print("PatenteredDatafilteredData111: ${filteredData}");
// Print filtered data
print("PatenttData_isss: $event");
return filteredData;
}
getnihdata(id) async {
final String response = await Constants.response;
final Nih = await json.decode(response);
final List<dynamic> event = Nih['NIHGrants'];
/////////////////////////////////////////////////////
final List<Map<String, dynamic>> filteredData = Nih['NIHGrants']
.where((item) => item['user_id'] == id)
.cast<Map<String, dynamic>>()
.toList();
print("PatenteredDatafilteredData111: ${filteredData}");
// Print filtered data
print("PatenttData_isss: $event");
return filteredData;
}
getprodata(id) async {
final String response = await Constants.response;
final Pro = await json.decode(response);
final List<dynamic> event = Pro['Procedure'];
/////////////////////////////////////////////////////
final List<Map<String, dynamic>> filteredData = Pro['Procedure']
.where((item) => item['user_id'] == id)
.cast<Map<String, dynamic>>()
.toList();
print("PatenteredDatafilteredData111: ${filteredData}");
// Print filtered data
print("PatenttData_isss: $event");
return filteredData;
}
}