From 6ecea11075160d661f61ea8cdc9d5ab54163326f Mon Sep 17 00:00:00 2001
From: Trang Nguyen <thi_huyen_trang.nguyen@student.reutlingen-university.de>
Date: Tue, 17 Nov 2020 16:24:25 +0100
Subject: [PATCH] add model to patient.dart

---
 rescueapp/lib/model-patient/patient.dart | 40 ++++++++++++++++++++++++
 1 file changed, 40 insertions(+)
 create mode 100644 rescueapp/lib/model-patient/patient.dart

diff --git a/rescueapp/lib/model-patient/patient.dart b/rescueapp/lib/model-patient/patient.dart
new file mode 100644
index 0000000..f7ca36f
--- /dev/null
+++ b/rescueapp/lib/model-patient/patient.dart
@@ -0,0 +1,40 @@
+import 'package:rescueapp/database/database_provide.dart';
+
+class Patient {
+  int id;
+  String name;
+  String birthday;
+  bool isAmbilatory;
+  String imagePath;
+  String category;
+
+
+  Patient({this.id, this.name, this.birthday, this.isAmbilatory, this.imagePath, this.category});
+//converts to map
+  Map<String, dynamic> toMap() {
+    var map = <String, dynamic>{
+      DatabaseProvider.COLUMN_NAME: name,
+      DatabaseProvider.COLUMN_BIRTHDAY: birthday,
+      DatabaseProvider.COLUMN_ISAMBILATORY: isAmbilatory ? 1 : 0,
+      DatabaseProvider.COLUMN_IMAGEPATH: imagePath,
+      DatabaseProvider.COLUMN_CATEGORIE: category,
+
+    };
+
+    if (id != null) {
+      map[DatabaseProvider.COLUMN_ID] = id;
+    }
+
+    return map;
+  }
+
+  Patient.fromMap(Map<String, dynamic> map) {
+    id = map[DatabaseProvider.COLUMN_ID];
+    name = map[DatabaseProvider.COLUMN_NAME];
+    birthday = map[DatabaseProvider.COLUMN_BIRTHDAY];
+    isAmbilatory = map[DatabaseProvider.COLUMN_ISAMBILATORY] == 1;
+    imagePath = map[DatabaseProvider.COLUMN_IMAGEPATH];
+    category = map[DatabaseProvider.COLUMN_CATEGORIE];
+
+  }
+}
\ No newline at end of file
-- 
GitLab