Patient registration complete with authentication flow fixed Co-authored-by: Benoy Bose <benoybose@gmail.com> Co-authored-by: Jipson George <152465898+Jipson-cosq@users.noreply.github.com> Reviewed-on: cosqnet/telemednet#3 Reviewed-by: Benoy Bose <benoybose@cosq.net> Co-authored-by: DhanshCOSQ <dhanshas@cosq.net> Co-committed-by: DhanshCOSQ <dhanshas@cosq.net>
145 lines
3.6 KiB
Dart
145 lines
3.6 KiB
Dart
class PatientModel {
|
|
String? name;
|
|
String? phoneNumber;
|
|
String? gender;
|
|
DateTime? dateOfBirth;
|
|
String? profileImagePath;
|
|
PatientAddress address;
|
|
|
|
List<FamilyMember> familyMembers = [];
|
|
|
|
PatientModel() : address = PatientAddress();
|
|
|
|
Map<String, dynamic> toJson() {
|
|
return {
|
|
'name': name,
|
|
'phoneNumber': phoneNumber,
|
|
'gender': gender,
|
|
'dateOfBirth': dateOfBirth?.toIso8601String(),
|
|
'profileImagePath': profileImagePath,
|
|
'address': address.toJson(),
|
|
'familyMembers': familyMembers.map((member) => member.toJson()).toList(),
|
|
};
|
|
}
|
|
|
|
PatientModel.fromJson(Map<String, dynamic> json)
|
|
: address = PatientAddress() {
|
|
name = json['name'];
|
|
phoneNumber = json['phoneNumber'];
|
|
gender = json['gender'];
|
|
dateOfBirth = json['dateOfBirth'] != null
|
|
? DateTime.parse(json['dateOfBirth'])
|
|
: null;
|
|
profileImagePath = json['profileImagePath'];
|
|
address.houseNo = json['houseNo'];
|
|
address.line = json['line'];
|
|
address.town = json['town'];
|
|
address.pincode = json['pincode'];
|
|
address.country = json['country'];
|
|
address.state = json['state'];
|
|
address.city = json['city'];
|
|
address.addressType = json['addressType'];
|
|
address.otherLabel = json['otherLabel'];
|
|
if (json['familyMembers'] != null) {
|
|
familyMembers = (json['familyMembers'] as List)
|
|
.map((memberJson) => FamilyMember.fromJson(memberJson))
|
|
.toList();
|
|
}
|
|
}
|
|
|
|
void updateFrom(PatientModel other) {
|
|
name = other.name;
|
|
phoneNumber = other.phoneNumber;
|
|
gender = other.gender;
|
|
dateOfBirth = other.dateOfBirth;
|
|
profileImagePath = other.profileImagePath;
|
|
address.houseNo = other.address.houseNo;
|
|
address.line = other.address.line;
|
|
address.town = other.address.town;
|
|
address.pincode = other.address.pincode;
|
|
address.country = other.address.country;
|
|
address.state = other.address.state;
|
|
address.city = other.address.city;
|
|
address.addressType = other.address.addressType;
|
|
address.otherLabel = other.address.otherLabel;
|
|
familyMembers = other.familyMembers;
|
|
}
|
|
}
|
|
|
|
class FamilyMember {
|
|
String? name;
|
|
String? relation;
|
|
String? gender;
|
|
DateTime? dateOfBirth;
|
|
|
|
FamilyMember({this.name, this.relation, this.gender, this.dateOfBirth});
|
|
|
|
Map<String, dynamic> toJson() {
|
|
return {
|
|
'name': name,
|
|
'relation': relation,
|
|
'gender': gender,
|
|
'dateOfBirth': dateOfBirth?.toIso8601String(),
|
|
};
|
|
}
|
|
|
|
FamilyMember.fromJson(Map<String, dynamic> json) {
|
|
name = json['name'];
|
|
relation = json['relation'];
|
|
gender = json['gender'];
|
|
dateOfBirth = json['dateOfBirth'] != null
|
|
? DateTime.parse(json['dateOfBirth'])
|
|
: null;
|
|
}
|
|
}
|
|
|
|
class PatientAddress {
|
|
String? houseNo;
|
|
String? line;
|
|
String? town;
|
|
String? pincode;
|
|
String? country;
|
|
String? state;
|
|
String? city;
|
|
String? addressType;
|
|
String? otherLabel;
|
|
|
|
PatientAddress({
|
|
this.houseNo,
|
|
this.line,
|
|
this.town,
|
|
this.pincode,
|
|
this.country,
|
|
this.state,
|
|
this.city,
|
|
this.addressType,
|
|
this.otherLabel,
|
|
});
|
|
|
|
Map<String, dynamic> toJson() {
|
|
return {
|
|
'houseNo': houseNo,
|
|
'line': line,
|
|
'town': town,
|
|
'pincode': pincode,
|
|
'country': country,
|
|
'state': state,
|
|
'city': city,
|
|
'addressType': addressType,
|
|
'otherLabel': otherLabel,
|
|
};
|
|
}
|
|
|
|
PatientAddress.fromJson(Map<String, dynamic> json) {
|
|
houseNo = json['houseNo'];
|
|
line = json['line'];
|
|
town = json['town'];
|
|
pincode = json['pincode'];
|
|
country = json['country'];
|
|
state = json['state'];
|
|
city = json['city'];
|
|
addressType = json['addressType'];
|
|
otherLabel = json['otherLabel'];
|
|
}
|
|
}
|