Beispiel #1
0
 public void UpdatePatientUser(string username, PatientUserDataContract user)
 {
     echelperDBEntities context = new echelperDBEntities();
     context.Refresh(System.Data.Objects.RefreshMode.StoreWins, context.Patient);
     Patient patient = context.Patient.First(p => p.LiveID.Equals(user.UserName));
     patient.Name = user.NickName;
     patient.Gender = user.Gender;
     patient.Age = user.Age;
     patient.Description = user.Description;
     patient.Allergy = user.Allery;
     context.SaveChanges();
     
     //return user;
     //context.Refresh
 }
Beispiel #2
0
 public void AddDoctor(string username, string doctorid)
 {
     echelperDBEntities context = new echelperDBEntities();
     context.Refresh(System.Data.Objects.RefreshMode.StoreWins, context.Doctor);
     context.Refresh(System.Data.Objects.RefreshMode.StoreWins, context.Patient);
     Patient pa = context.Patient.First(p => p.LiveID == username);
     Doctor doc = context.Doctor.First(p => p.LiveID == doctorid);
     if (!pa.Doctor.Contains(doc) && !doc.Patient.Contains(pa))
     {
         pa.Doctor.Add(doc);
         doc.Patient.Add(pa);
     }
     context.SaveChanges();
 }
Beispiel #3
0
        public void UpdateDoctorOffline(string username, OnlineStatusDataContract user)
        {
            echelperDBEntities context = new echelperDBEntities();
            context.Refresh(System.Data.Objects.RefreshMode.StoreWins, context.Doctor);
            context.Refresh(System.Data.Objects.RefreshMode.StoreWins, context.Patient);
            Doctor doctor = context.Doctor.First(p => p.LiveID == username);

            doctor.Latitude = user.Latitude;
            doctor.Longitude = user.Longtitude;
            doctor.Status = 0;
            context.SaveChanges();
        }
Beispiel #4
0
        public void EmergencyConfirm(string username, string patientid, EmergencyConfirm mesge)
        {
            echelperDBEntities context = new echelperDBEntities();
            context.Refresh(System.Data.Objects.RefreshMode.StoreWins, context.Patient);
            context.Refresh(System.Data.Objects.RefreshMode.StoreWins, context.Doctor);
            Doctor doctor = context.Doctor.First(p => p.LiveID == username);
            doctor.Latitude = mesge.latitude;
            doctor.Longitude = mesge.longitude;
            context.SaveChanges();
            Patient patient = context.Patient.First(p => p.LiveID == patientid);
            string toastMessage="";
            if (mesge.confirm=="yes")
            {
                toastMessage = "<EmergencyConfirm>" +
                            "<Type>1</Type>"+
                              "<doctorName>" + doctor.Name + "</doctorName>" +
                               "<latitude>" + doctor.Longitude + "</latitude>" +
                               "<longitude>" + doctor.Latitude + "</longitude>" +
                               "<reply>true</reply>" +
                        "</EmergencyConfirm>";

            }
            else {
                toastMessage = "<EmergencyConfirm>" +
                                "<Type>1</Type>" +
                              "<doctorName>" + doctor.Name + "</doctorName>" +
                               "<latitude>" + doctor.Longitude + "</latitude>" +
                               "<longitude>" + doctor.Latitude + "</longitude>" +
                               "<reply>false</reply>" +
                        "</EmergencyConfirm>";
            }
            byte[] strBytes = new UTF8Encoding().GetBytes(toastMessage);
            if (patient.Channel != null)
            {
                sendWinNotificationType(strBytes, patient.Channel);
            }
        }
Beispiel #5
0
 public void BuildDoctorChannel(string username, NoticeUri uri)
 {
     echelperDBEntities context = new echelperDBEntities();
     context.Refresh(System.Data.Objects.RefreshMode.StoreWins, context.Doctor);
     Doctor doctor = context.Doctor.First(p => p.LiveID == username);
     doctor.Channel = uri.uri;
     context.SaveChanges();
 }
Beispiel #6
0
 public void IsReadMailp(string username, string mailid)
 {
     echelperDBEntities context = new echelperDBEntities();
     context.Refresh(System.Data.Objects.RefreshMode.StoreWins, context.Doctor);
     context.Refresh(System.Data.Objects.RefreshMode.StoreWins, context.Mail);
     int id = (int)Convert.ToInt32(mailid);
     Mail mail = context.Mail.First(p => p.ID == id);
     mail.IsRead = 1;
     context.SaveChanges();
 }
Beispiel #7
0
        public void addDiagnosis(string username, NewMailDataContract temp)
        {
            echelperDBEntities context = new echelperDBEntities();
            context.Refresh(System.Data.Objects.RefreshMode.StoreWins, context.Mail);
            context.Refresh(System.Data.Objects.RefreshMode.StoreWins, context.Patient);
            context.Refresh(System.Data.Objects.RefreshMode.StoreWins, context.Doctor);
            DateTime time = DateTime.Now;
            Mail newMail = new Mail();
            newMail.PatientID = temp.PatientId;
            newMail.DoctorID = temp.DoctorId;
            newMail.Title = temp.Title;
            newMail.TextContent = temp.TextContent;
            newMail.Time = time;
            newMail.ECG = temp.ECG;
            newMail.FromOrTo = temp.FromOrTo;
            newMail.IsRead = 0;
            context.AddToMail(newMail);
            context.SaveChanges();
           // return ConvertMailToDataContract(newMail);


            Patient patient = context.Patient.First(p => p.LiveID == temp.PatientId);

            int count = 0;
            foreach (Mail i in context.Mail)
            {
                if (i.PatientID == temp.PatientId && i.FromOrTo == 0 && i.IsRead == 0)
                {
                    count++;
                }
            }
            string toastMessage = null;

            toastMessage = "<EmergencyConfirm>" +
                        "<Type>0</Type>" +
                          "<doctorName>" + count + "</doctorName>" +
                           "<latitude>0</latitude>" +
                           "<longitude>0</longitude>" +
                           "<reply>0</reply>" +
                    "</EmergencyConfirm>";

            
            byte[] strBytes = new UTF8Encoding().GetBytes(toastMessage);
            if (patient.Channel != null)
            {
                sendWinNotificationType(strBytes, patient.Channel);
            }
        }
Beispiel #8
0
 public DoctorUserDataContract UpdateDoctorUser(string username, DoctorUserDataContract user)
 {
     echelperDBEntities context = new echelperDBEntities();
     context.Refresh(System.Data.Objects.RefreshMode.StoreWins, context.Doctor);
     Doctor doctor = context.Doctor.First(p => p.LiveID == username);
     doctor.Name = user.NickName;
     doctor.Description = user.Description;
     doctor.Phone = user.phone;
     doctor.Email = user.email;
    // doctor.
     context.SaveChanges();
     context.Refresh(System.Data.Objects.RefreshMode.StoreWins, doctor);
     return user;
 }
Beispiel #9
0
        public void UpdatePatientOnline(string username, OnlineStatusDataContract user)
        {
            echelperDBEntities context = new echelperDBEntities();
            context.Refresh(System.Data.Objects.RefreshMode.StoreWins, context.Patient);
            Patient patient = context.Patient.First(p => p.LiveID==username);

            patient.Latitude = user.Latitude;
            patient.Longitude = user.Longtitude;
            patient.Status = 1;
            context.SaveChanges();
        }
Beispiel #10
0
        public void EmergencyCall(string username,string doctorid,EmergencyMesg mesg) {
            echelperDBEntities context = new echelperDBEntities();
            context.Refresh(System.Data.Objects.RefreshMode.StoreWins, context.Patient);
            context.Refresh(System.Data.Objects.RefreshMode.StoreWins, context.Doctor);
            Patient patient = context.Patient.First(p => p.LiveID == username);
            patient.Latitude = mesg.latitude;
            patient.Longitude = mesg.longitude;
            context.SaveChanges();
            Doctor doctor = context.Doctor.First(p=> p.LiveID == doctorid);

            string toastMessage = "<?xml version=\"1.0\" encoding=\"utf-8\"?>" +
                        "<wp:Notification xmlns:wp=\"WPNotification\">" +
                           "<wp:Toast>" +
                              "<wp:Text0>1</wp:Text0>" +
                              "<wp:Text1>" + patient.Name + "</wp:Text1>" +
                              "<wp:Text2>" + patient.Latitude + "</wp:Text2>" +
                              "<wp:Text3>" + patient.Longitude + "</wp:Text3>" +
                           "</wp:Toast>" +
                        "</wp:Notification>";

            byte[] strBytes = new UTF8Encoding().GetBytes(toastMessage);
            if (doctor.Channel != null)
            {
                sendNotificationType(strBytes, doctor.Channel);
            }
        }
Beispiel #11
0
 public void BuildPatientChannel(string username,NoticeUri uri) {
     echelperDBEntities context = new echelperDBEntities();
     context.Refresh(System.Data.Objects.RefreshMode.StoreWins, context.Patient);
     Patient patient = context.Patient.First(p => p.LiveID == username);
     patient.Channel = uri.uri;
     context.SaveChanges();
 }
Beispiel #12
0
        public void addnewMail(string username, NewMailDataContract temp) {
            echelperDBEntities context = new echelperDBEntities();
            context.Refresh(System.Data.Objects.RefreshMode.StoreWins, context.Mail);
            context.Refresh(System.Data.Objects.RefreshMode.StoreWins, context.Patient);
            DateTime time = DateTime.Now;
            Mail newMail = new Mail();
            newMail.PatientID = temp.PatientId;
            newMail.DoctorID = temp.DoctorId;
            newMail.Title = temp.Title;
            newMail.TextContent = temp.TextContent;
            newMail.Time = time;
            newMail.ECG = temp.ECG;
            newMail.FromOrTo = temp.FromOrTo;
            newMail.IsRead = 0;
            context.AddToMail(newMail);
            context.SaveChanges();

            //Patient patient = context.Patient.First(p => p.LiveID == username);
            Doctor doctor = context.Doctor.First(p => p.LiveID == temp.DoctorId);
            int count = 0;
            foreach (Mail i in context.Mail) {
                if (i.DoctorID==temp.DoctorId&&i.FromOrTo == 1 && i.IsRead==0)
                {
                    count++;
                }
            }

            string toastMessage = "<?xml version=\"1.0\" encoding=\"utf-8\"?>" +
                        "<wp:Notification xmlns:wp=\"WPNotification\">" +
                           "<wp:Toast>" +
                              "<wp:Text0>0</wp:Text0>" +
                              "<wp:Text1>" + count + "</wp:Text1>" +
                              "<wp:Text2>0</wp:Text2>" +
                              "<wp:Text3>0</wp:Text3>" +
                           "</wp:Toast>" +
                        "</wp:Notification>";

            byte[] strBytes = new UTF8Encoding().GetBytes(toastMessage);
            if (doctor.Channel != null)
            {
                sendNotificationType(strBytes, doctor.Channel);
            }


            //return ConvertMailToDataContract(newMail);
        }