Преглед на файлове

doctorform user list added

RD125632 преди 10 години
родител
ревизия
d88ac81831

+ 2 - 1
Proftaak Remote Healthcare/FietsClientV2/DoctorModel.cs

@@ -21,6 +21,7 @@ namespace FietsClient
 
         public List<string> onlinePatients { get; set; } = new List<string>();
         public Dictionary<string, Forms.DoctorSessionUC> doctorSessions { get; set; } = new Dictionary<string, Forms.DoctorSessionUC>();
+        public List<User> activePatientObject; 
 
         private DoctorModel()
         {
@@ -51,7 +52,7 @@ namespace FietsClient
 
         public void CheckOnlineUsersUpdated()
         {
-            tcpConnection.SendGetActivePatients();
+            tcpConnection.SendGet(8);
             if (onlinePatients.Count != doctorSessions.Count || true)
             {
                 // ruim eerst alle doctorSessions op die niet van toepassing zijn

+ 1 - 0
Proftaak Remote Healthcare/FietsClientV2/FietsClient.csproj

@@ -100,6 +100,7 @@
     <Compile Include="Forms\PatientForm.Designer.cs">
       <DependentUpon>PatientForm.cs</DependentUpon>
     </Compile>
+    <Compile Include="JSONObjecten\User.cs" />
     <Compile Include="lib\JsonConverter.cs" />
     <Compile Include="DoctorModel.cs" />
     <Compile Include="PatientModel.cs" />

+ 59 - 0
Proftaak Remote Healthcare/FietsClientV2/JSONObjecten/User.cs

@@ -0,0 +1,59 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using FietsClient.JSONObjecten;
+using Newtonsoft.Json;
+
+namespace FietsClient
+{
+    [Serializable]
+    public class User
+    {
+        
+        public string id { get; private set; }
+        public string password { get; private set; }
+        public List<Session> tests { get; private set; }
+        public int age { get; private set; }
+        public bool gender { get; private set; }
+        public int weight { get; private set; }
+
+        public bool isDoctor { get; private set; }
+
+        //Create Patient
+        public User(string id, string password, int age, bool gender, int weight)
+        {
+            this.id = id;
+            this.password = password;
+            this.tests = new List<Session>();
+            this.age = age;
+            this.gender = gender;
+            this.weight = weight;
+            this.isDoctor = false;
+        }
+
+        //Create Patient or Doctor
+        public User(string id, string password, int age, bool gender, int weight, bool isDoctor)
+        {
+            this.id = id;
+            this.password = password;
+            this.tests = new List<Session>();
+            this.age = age;
+            this.gender = gender;
+            this.weight = weight;
+            this.isDoctor = isDoctor;
+        }
+
+        public void AddSession(Session session)
+        {
+            tests.Add(session);
+        }
+        
+        public List<Session> GetSessions()
+        {
+            return tests;
+        }
+
+    }
+}

+ 3 - 4
Proftaak Remote Healthcare/FietsClientV2/TCPConnection.cs

@@ -144,6 +144,9 @@ namespace FietsClient
                                 DoctorModel.doctorModel.onlinePatients = new List<String>();
                             }
                             
+                            break;
+                        case "9":
+                            DoctorModel.doctorModel.activePatientObject = JsonConvert.DeserializeObject<List<User>>(response_parts[1]);
                             break;
                     }
                 }
@@ -191,10 +194,6 @@ namespace FietsClient
                 }
             }
         }
-        public void SendGetActivePatients()
-        {
-            SendString("8|" + userID + "|");
-        }
 
         public void SendDistance(int distance)
         {

+ 6 - 1
Proftaak Remote Healthcare/Server/AppGlobal.cs

@@ -69,7 +69,12 @@ namespace Server
         {
             return users;
         }
-        
+
+        public List<User> GetActivePatientObjects()
+        {
+            return activePatient;
+        }
+
         public List<string> GetActivePatients()
         {
             List<string> patients = new List<string>();

+ 9 - 0
Proftaak Remote Healthcare/Server/Client.cs

@@ -131,6 +131,15 @@ namespace Server
                                 }
                             }
                             break;
+                        case "9": //alle Patients sturen naar Doctorclient
+                            if (response_parts[1] != null)
+                            {
+                                if (response_parts[1] == "doctor" || true) //TODO: doctor check
+                                {
+                                    sendString("9|" + JsonConverter.GetPatients(_global.GetActivePatientObjects()) + "|");
+                                }
+                            }
+                            break;
                     }
                 }
             }

+ 5 - 0
Proftaak Remote Healthcare/Server/FileIO/JsonConverter.cs

@@ -21,6 +21,11 @@ namespace Server.FileIO
            return JsonConvert.SerializeObject(u);
         }
 
+        public static string GetPatients(List<User> u)
+        {
+            return JsonConvert.SerializeObject(u);
+        }
+
         public static string GetUserSessions(User patient)
         {
             return JsonConvert.SerializeObject(patient.GetSessions());