NotesWhat is notes.io?

Notes brand slogan

Notes - notes.io

# vital Notes Api
import 'dart:async';
import 'dart:convert';
import 'package:flutter/foundation.dart';
import 'package:http/http.dart' as http;
import 'package:http_interceptor/http_interceptor.dart';
import 'package:json_store/json_store.dart';
import 'package:vitalnotes_app/interceptor/vitalnotes_interceptor.dart';
import 'package:vitalnotes_app/models/conditions/condition_model.dart';
import 'package:vitalnotes_app/models/conditions/current_conditions.dart';
import 'package:vitalnotes_app/models/meds/doctor_model.dart';
import 'package:vitalnotes_app/models/meds/dosage_model.dart';
import 'package:vitalnotes_app/models/meds/form_model.dart';
import 'package:vitalnotes_app/models/meds/many_model.dart';
import 'package:vitalnotes_app/models/meds/medicines_model.dart';
import 'package:vitalnotes_app/models/meds/often_model.dart';
import 'package:vitalnotes_app/models/meds/patient_doctor.dart';
import 'package:vitalnotes_app/models/meds/patient_family_members.dart';
import 'package:vitalnotes_app/models/meds/patient_medicine_model.dart';
import 'package:vitalnotes_app/models/meds/route_model.dart';
import 'package:vitalnotes_app/models/meds/strength_model.dart';
import 'package:vitalnotes_app/utils/app_services.dart';

class MedicalProfile with ChangeNotifier {
InterceptedClient client = InterceptedClient.build(
interceptors: [VitalNotesInterceptor()],
retryPolicy: ExpiredTokenRetryPolicy());

Future<void> getAllMedicines() async {
final url = AppServices.getAllMedicines;
try {
final response = await client.get(Uri.parse(url));
final responseData = json.decode(response.body);
if (response.statusCode == 200) {
if (responseData['result'] != null) {
notifyListeners();
JsonStore().setItem("medicineList", responseData);
var types = new MedicinesModel.fromMap(responseData);
_medicinesStreamController.add(types);
}
}
} catch (error) {
throw (error);
}
}

final _medicinesStreamController =
StreamController<MedicinesModel>.broadcast();

Stream<MedicinesModel> get detailsProfileStream =>
_medicinesStreamController.stream;

void refreshUserDetails() {
getAllMedicines();
}

Future<FormModel> getAllForms(String applicationNumber) async {
final url = AppServices.getAllForms;
try {
final response = await client.post(Uri.parse(url),
body: json.encode({"medicine_name": applicationNumber}));
final responseData = json.decode(response.body);
if (response.statusCode == 200) {
if (responseData['result'] != null) {
notifyListeners();
var types = new FormModel.fromJson(responseData);
return types;
} else {
return null;
}
} else {
return null;
}
} catch (error) {
throw (error);
}
}

Future<RouteModel> getAllRoutes() async {
final url = AppServices.getAllRoutes;
try {
final response = await client.get(Uri.parse(url));
final responseData = json.decode(response.body);
if (response.statusCode == 200) {
if (responseData['result'] != null) {
notifyListeners();
var types = new RouteModel.fromMap(responseData);
return types;
} else {
return null;
}
} else {
return null;
}
} catch (error) {
throw (error);
}
}

Future<ManyModel> getAllHowMany() async {
final url = AppServices.getAllMany;
try {
final response = await client.get(Uri.parse(url));
final responseData = json.decode(response.body);
if (response.statusCode == 200) {
if (responseData['result'] != null) {
notifyListeners();
var types = new ManyModel.fromMap(responseData);
return types;
} else {
return null;
}
} else {
return null;
}
} catch (error) {
throw (error);
}
}

Future<OftenModel> getAllHowOften() async {
final url = AppServices.getAllOften;
try {
final response = await client.get(Uri.parse(url));
final responseData = json.decode(response.body);
if (response.statusCode == 200) {
if (responseData['result'] != null) {
notifyListeners();
var types = new OftenModel.fromMap(responseData);
return types;
} else {
return null;
}
} else {
return null;
}
} catch (error) {
throw (error);
}
}

Future<StrengthModel> getAllStrength(String applicationNumber) async {
final url = AppServices.getAllStrength;
try {
final response = await client.post(Uri.parse(url),
body: json.encode({"medicine_name": applicationNumber}));
final responseData = json.decode(response.body);
if (response.statusCode == 200) {
if (responseData['result'] != null) {
notifyListeners();
var types = new StrengthModel.fromJson(responseData);
return types;
} else {
return null;
}
} else {
return null;
}
} catch (error) {
throw (error);
}
}

Future<DosageModel> getAllDosages() async {
final url = AppServices.getAllDosages;
try {
final response = await client.get(Uri.parse(url));
final responseData = json.decode(response.body);
if (response.statusCode == 200) {
if (responseData['result'] != null) {
notifyListeners();
var types = new DosageModel.fromMap(responseData);
return types;
} else {
return null;
}
} else {
return null;
}
} catch (error) {
throw (error);
}
}

Future<DoctorsModel> getAllDoctors(
String primarySpecialty, String cityID, String query) async {
final url = AppServices.getAllDoctors +
"?PrimarySpeciality=$primarySpecialty&CityId=$cityID";
try {
final response = await client.get(Uri.parse(url));
final responseData = json.decode(response.body);
if (response.statusCode == 200) {
if (responseData['result'] != null) {
notifyListeners();
var types = new DoctorsModel.fromMap(responseData);
return types;
} else {
return null;
}
} else {
return null;
}
} catch (error) {
throw (error);
}
}

/* Future<bool> removeRelation(String requestId) async {
final url = AppServices.removeRejectRelation + "?requestId=$requestId";
try {
final response = await client.delete(Uri.parse(url));
final responseData = json.decode(response.body);
if (response.statusCode == 200) {
return true;
} else {
return false;
}
} catch (error) {
throw (error);
}
}*/

/* Future<bool> removeRelation(
String requestID, String type, String token) async {
final baseUrl = AppServices.removeRejectRelation;
final url = Uri.parse(baseUrl + "/$requestID");
try {
final request = http.Request("DELETE", url);
request.headers.addAll(<String, String>{
"Content-Type": "application/json",
"Authorization": "Bearer $token",
});
request.body = jsonEncode({"removeRelationType": "DELETE"});
final response = await request.send();
if (response.statusCode == 200) {
return true;
}
} catch (error) {
throw (error);
}
}*/
Future<bool> removeRelation(
String requestID, String type, String token) async {
final baseUrl = AppServices.removeRejectRelation;
final url = Uri.parse(baseUrl + "/$requestID");
var body = jsonEncode({"removeRelationType": "DELETE"});
try {
final response = await client.delete(url, body: body, headers: {
"Content-Type": "application/json",
"Authorization": "Bearer $token",
});
final responseData = json.decode(response.body);
if (response.statusCode == 200) {
return true;
}
} catch (error) {
throw (error);
}
}

Future<dynamic> checkMemberEmail(String email, Uri link) async {
final url = AppServices.findMemberWithEmail;
try {
final response = await client.post(Uri.parse(url),
body: jsonEncode({"email": email, "deepLink": link.toString()}));

return response;
} catch (error) {
throw (error);
}
}

Future<dynamic> addRelation(
String relationID, String relationType, String typeDescription) async {
final url = AppServices.addCareGiver;
var body;
if (typeDescription == "") {
body = json.encode({
"relationId": relationID,
"relationType": relationType,
});
} else {
body = json.encode({
"relationId": relationID,
"relationType": relationType,
"typeDescription": typeDescription
});
}
try {
final response = await client.post(Uri.parse(url), body: body);
return response;
} catch (error) {
throw (error);
}
}

Future<void> getAllPatientDoctors() async {
final url = AppServices.getPatientDoctors;
try {
final response = await client.get(Uri.parse(url));
final responseData = json.decode(response.body);
if (response.statusCode == 200) {
if (responseData['result'] != null) {
notifyListeners();
var types = new PatientDoctorsModel.fromMap(responseData);
_patientDocStreamController.add(types);
}
}
} catch (error) {
throw (error);
}
}

final _patientDocStreamController =
StreamController<PatientDoctorsModel>.broadcast();

Stream<PatientDoctorsModel> get patientDoctorStream {
return _patientDocStreamController.stream;
}

void refreshPatientDoctor() {
getAllPatientDoctors();
}

Future<PatientFamilyMembers> getAllFamilyMembers() async {
final url = AppServices.getPatientFamilyMembers;
try {
final response = await client.get(Uri.parse(url));
final responseData = json.decode(response.body);
if (response.statusCode == 200) {
if (responseData['result'] != null) {
var types = new PatientFamilyMembers.fromMap(responseData);
notifyListeners();
return types;
} else {
return null;
}
} else {
return null;
}
} catch (error) {
throw (error);
}
}

Future<dynamic> addPatientMedicine(
String medicineID,
String from,
String strength,
String route,
double howMany,
String howOften,
String activeIngredient,
String dosage,
bool asNeeded) async {
final url = AppServices.addPatientMedicine;
var body;
body = json.encode({
"medicineName": medicineID,
"from": from,
"strength": strength,
"route": route,
"howMany": howMany,
"howOften": howOften,
"dosage": dosage,
"as_Needed": asNeeded,
"activeIngredient": activeIngredient
});

try {
final response = await client.post(Uri.parse(url), body: body);
print(response.body);
return response;
} catch (error) {
throw (error);
}
}

Future<PatientMedicineModel> getAllPatientMedicines() async {
final url = AppServices.getAllPatientMedicines;
try {
final response = await client.get(Uri.parse(url));
final responseData = json.decode(response.body);
if (response.statusCode == 200) {
if (responseData['result'] != null) {
var types = new PatientMedicineModel.fromMap(responseData);
notifyListeners();
return types;
} else {
return null;
}
} else {
return null;
}
} catch (error) {
throw (error);
}
}

Future<dynamic> updatePatientMedicine(
String medicineID,
String from,
String strength,
String route,
double howMany,
String howOften,
String dosage,
bool asNeeded) async {
final url = AppServices.editPatientMedicine + "/$medicineID";
var body;
body = json.encode({
"from": from,
"strength": strength,
"route": route,
"howMany": howMany,
"howOften": howOften,
"dosage": dosage,
"as_Needed": asNeeded
});

try {
final response = await client.put(Uri.parse(url), body: body);
return response;
} catch (error) {
throw (error);
}
}

Future<dynamic> deleteMyMedicine(String medID) async {
final url = AppServices.deleteMedicine + "/$medID";
try {
final response = await client.delete(Uri.parse(url));
final responseData = json.decode(response.body);
if (response.statusCode == 200) {
return responseData;
} else {
return null;
}
} catch (error) {
throw (error);
}
}

Future<PatientConditionModel> getAllConditions() async {
final url = AppServices.getAllConditions;
try {
final response = await client.get(Uri.parse(url));
final responseData = json.decode(response.body);
if (response.statusCode == 200) {
if (responseData['result'] != null) {
var types = new PatientConditionModel.fromMap(responseData);
notifyListeners();
return types;
} else {
return null;
}
} else {
return null;
}
} catch (error) {
throw (error);
}
}

Future<bool> addCondition(String id) async {
final url = AppServices.addConditions;
try {
final response = await client.post(Uri.parse(url),
body: jsonEncode({"condition_Id": id}));
final responseData = json.decode(response.body);
if (response.statusCode == 200) {
if (responseData['result'] != null) {
return true;
} else {
return null;
}
} else {
return null;
}
} catch (error) {
throw (error);
}
}

Future<CurrentConditionModel> getCurrentConditions() async {
final url = AppServices.getPatientConditions;
try {
final response = await client.get(Uri.parse(url));
final responseData = json.decode(response.body);
if (response.statusCode == 200) {
if (responseData['result'] != null) {
var types = new CurrentConditionModel.fromMap(responseData);
notifyListeners();
return types;
} else {
return null;
}
} else {
return null;
}
} catch (error) {
throw (error);
}
}

Future<bool> updateCondition(String id, int status) async {
String changeTo;
if (status == 0) {
changeTo = "DELETE";
} else if (status == 1) {
changeTo = "ACTIVE";
} else {
changeTo = "INACTIVE";
}
final url = AppServices.updateConditions + "/$id?Status=$changeTo";
try {
final response = await client.patch(Uri.parse(url));
final responseData = json.decode(response.body);
if (response.statusCode == 200) {
return true;
} else {
return null;
}
} catch (error) {
throw (error);
}
}
}
     
 
what is notes.io
 

Notes is a web-based application for online taking notes. You can take your notes and share with others people. If you like taking long notes, notes.io is designed for you. To date, over 8,000,000,000+ notes created and continuing...

With notes.io;

  • * You can take a note from anywhere and any device with internet connection.
  • * You can share the notes in social platforms (YouTube, Facebook, Twitter, instagram etc.).
  • * You can quickly share your contents without website, blog and e-mail.
  • * You don't need to create any Account to share a note. As you wish you can use quick, easy and best shortened notes with sms, websites, e-mail, or messaging services (WhatsApp, iMessage, Telegram, Signal).
  • * Notes.io has fabulous infrastructure design for a short link and allows you to share the note as an easy and understandable link.

Fast: Notes.io is built for speed and performance. You can take a notes quickly and browse your archive.

Easy: Notes.io doesn’t require installation. Just write and share note!

Short: Notes.io’s url just 8 character. You’ll get shorten link of your note when you want to share. (Ex: notes.io/q )

Free: Notes.io works for 14 years and has been free since the day it was started.


You immediately create your first note and start sharing with the ones you wish. If you want to contact us, you can use the following communication channels;


Email: [email protected]

Twitter: http://twitter.com/notesio

Instagram: http://instagram.com/notes.io

Facebook: http://facebook.com/notesio



Regards;
Notes.io Team

     
 
Shortened Note Link
 
 
Looding Image
 
     
 
Long File
 
 

For written notes was greater than 18KB Unable to shorten.

To be smaller than 18KB, please organize your notes, or sign in.