Example #1
0
 public PatientUserDataContract GetPatientUser(string username)
 {
     echelperDBEntities context = new echelperDBEntities();
     context.Refresh(System.Data.Objects.RefreshMode.StoreWins, context.Patient);
     List<string> keylist = context.Patient.Select(c => c.LiveID).Distinct().ToList();
     echelperDBEntities context_ = new echelperDBEntities();
     Patient data = context_.GetObjectByKey(new System.Data.EntityKey("echelperDBEntities.Patient", "LiveID", username)) as Patient;
     return ConvertPatientUserToDataContract(data);
 }
Example #2
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
 }
Example #3
0
 public List<MyDoctorDataContract> GetDoctorUserList(string username) {
     echelperDBEntities context = new echelperDBEntities();
     context.Refresh(System.Data.Objects.RefreshMode.StoreWins, context.Patient);
     context.Refresh(System.Data.Objects.RefreshMode.StoreWins, context.Doctor);
     List<MyDoctorDataContract> temp = new List<MyDoctorDataContract>();
     List<Doctor> tempuser = context.Doctor.ToList();
    // List<string> keylist = context.Patient.Select(c => c.LiveID).Distinct().ToList();
     //echelperDBEntities context_ = new echelperDBEntities();
     //Patient data = context_.GetObjectByKey(new System.Data.EntityKey("echelperDBEntities.Patient", "LiveID", username)) as Patient;
     Patient data = context.Patient.First(p => p.LiveID == username);
     foreach(Doctor i in tempuser){
         bool ismy = false;
         if (i.Patient.Contains(data)) {
             ismy = true;
         }
         temp.Add(ConvertMyDoctorToDataContract(i,ismy));
     }          
     return temp;
 }
Example #4
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();
        }
Example #5
0
        public void EmergencyConfirm1(string username, string patientid)
        {
            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);
            Patient patient = context.Patient.First(p => p.LiveID == patientid);
            string toastMessage = null;

                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);
            }
        }
Example #6
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();
 }
Example #7
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();
 }
Example #8
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);
            }
        }
Example #9
0
 public List<MailDataContract> GetDoctorMailList(string username)
 {
     echelperDBEntities context = new echelperDBEntities();
     context.Refresh(System.Data.Objects.RefreshMode.StoreWins, context.Mail);
     context.Refresh(System.Data.Objects.RefreshMode.StoreWins, context.Doctor);
     context.Refresh(System.Data.Objects.RefreshMode.StoreWins, context.Patient);
     List<MailDataContract> temp = new List<MailDataContract>();
     List<Mail> mails = context.Mail.Where(a => a.DoctorID == username).ToList();
     foreach (Mail i in mails)
     {
         temp.Add(ConvertMailToDataContract(i));
     }
     return temp;
 }
Example #10
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();
 }
Example #11
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;
 }
Example #12
0
 public DoctorUserDataContract GetDoctorUser(string username)
 {
     echelperDBEntities context = new echelperDBEntities();
     context.Refresh(System.Data.Objects.RefreshMode.StoreWins, context.Doctor);
     //List<string> keylist = context.Doctor.Select(c => c.LiveID).Distinct().ToList();
    // echelperDBEntities context_ = new echelperDBEntities();
    // Doctor data = context_.GetObjectByKey(new System.Data.EntityKey("echelperDBEntities.Doctor", "LiveID", username)) as Doctor;
     Doctor data = context.Doctor.First(p => p.LiveID == username );
     return ConvertDoctorUserToDataContract(data);
 }
Example #13
0
 public List<FileListDataContract> GetPatientFileList(string username)
 {
     echelperDBEntities context = new echelperDBEntities();
     context.Refresh(System.Data.Objects.RefreshMode.StoreWins, context.Patient);
     List<FileListDataContract> list = new List<FileListDataContract>();
     CloudStorageAccount storageAccount = CloudStorageAccount.Parse(
     RoleEnvironment.GetConfigurationSettingValue("StorageAccountConnectionString"));
     CloudBlobClient blobClient = storageAccount.CreateCloudBlobClient();
     CloudBlobContainer container = blobClient.GetContainerReference(username);
     container.CreateIfNotExist();
     BlobContainerPermissions permissions = new BlobContainerPermissions();
     permissions.PublicAccess = BlobContainerPublicAccessType.Off;
     foreach (IListBlobItem i in container.ListBlobs()) {
        
         FileListDataContract m = new FileListDataContract();
         m.Filename = i.Uri.ToString();
         list.Add(m);
     }
     return list;
 }
Example #14
0
 public string GetPatientTempKey(string username)
 {
     echelperDBEntities context = new echelperDBEntities();
     context.Refresh(System.Data.Objects.RefreshMode.StoreWins, context.Patient);
     CloudStorageAccount storageAccount = CloudStorageAccount.Parse(
         RoleEnvironment.GetConfigurationSettingValue("StorageAccountConnectionString"));
     CloudBlobClient blobClient = storageAccount.CreateCloudBlobClient();
     CloudBlobContainer container = blobClient.GetContainerReference(username);
     container.CreateIfNotExist();
     BlobContainerPermissions permissions = new BlobContainerPermissions();
     permissions.PublicAccess = BlobContainerPublicAccessType.Off;
     container.SetPermissions(permissions);
     string sas = container.GetSharedAccessSignature(new SharedAccessPolicy()
     {
         SharedAccessExpiryTime = DateTime.UtcNow.AddSeconds(60),
         Permissions = SharedAccessPermissions.Read | SharedAccessPermissions.Write
     });
     return sas;
 }
Example #15
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();
        }
Example #16
0
        public void EmergencyCall1(string username, string doctorid)
        {
            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);
            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: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);
            }
        }
Example #17
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();
 }
Example #18
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);
        }