Upload to server
uploading
This commit is contained in:
350
patientman/PatientMan/Forms/frmPatientLists.cs
Normal file
350
patientman/PatientMan/Forms/frmPatientLists.cs
Normal file
@@ -0,0 +1,350 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data.SqlTypes;
|
||||
using Datalib.EntityClasses;
|
||||
using Datalib.HelperClasses;
|
||||
using System.Linq;
|
||||
using DevExpress.XtraEditors;
|
||||
using System.Windows.Forms;
|
||||
using Datalib.Linq;
|
||||
using PatientMan;
|
||||
|
||||
namespace PatientMan.Forms
|
||||
{
|
||||
public partial class frmPatientLists : PatientMan.BasicForms.frmCommon
|
||||
{
|
||||
public EntityCollection <TblPatientEntity> PatientsCollection = new EntityCollection<TblPatientEntity>();
|
||||
private int SelectedIndex { get; set; }
|
||||
public frmPatientLists()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
public override void LoadData()
|
||||
{
|
||||
this.SelectedIndex = 0;
|
||||
this.barFilter.EditValue = cbFilter.Items[0];
|
||||
LoadAll();
|
||||
this.BeginDate.EditValue = DateTime.Now.AddYears(-1);
|
||||
this.EndDate.EditValue = DateTime.Now;
|
||||
|
||||
}
|
||||
|
||||
public void LoadAll()
|
||||
{
|
||||
colStatus.Visible = false; colReceiveServiceDate.Visible = false;
|
||||
this.SelectedIndex = 0;
|
||||
barAutoUpdate.Enabled = false;
|
||||
var Patients = new EntityCollection<TblPatientEntity>();
|
||||
adapter.FetchEntityCollection(Patients, null);
|
||||
|
||||
int No = 1;
|
||||
grdClients.DataSource = (from q in Patients select new { No = No++,ARV = q.DateofArv != null ? true : false, q.PatientId,PatientName=strUtil.Decrypt(q.PatientName), q.Sex, q.BirthYear, q.TelephoneNo }).ToList();
|
||||
grdClients.Patients = Patients.Select(q => q.PatientId).ToList();
|
||||
|
||||
|
||||
}
|
||||
|
||||
private void LoadUnderManagement()
|
||||
{
|
||||
colStatus.Visible = false; colReceiveServiceDate.Visible = false;
|
||||
this.SelectedIndex = 1;
|
||||
int No = 0;
|
||||
var exams = new EntityCollection<TblExaminationInfoEntity>();
|
||||
var patients = new EntityCollection<TblPatientEntity>();
|
||||
adapter.FetchEntityCollection(exams, null);
|
||||
adapter.FetchEntityCollection(patients, null);
|
||||
barAutoUpdate.Enabled = false;
|
||||
|
||||
List<string> noEnds = exams.GroupBy(q => q.PatientId).Select(g => g.OrderBy(m => m.ExamDate).Last()).ToList().Where(s => s.EndExamDate == null).Select(t => t.PatientId).ToList();
|
||||
|
||||
var ds = (from q in patients where (noEnds.Contains(q.PatientId))
|
||||
select new { No = No++, ARV = q.DateofArv != null ? true : false, q.PatientId, PatientName = strUtil.Decrypt(q.PatientName), q.Sex, q.BirthYear, q.TelephoneNo }).ToList();
|
||||
grdClients.DataSource = ds;
|
||||
grdClients.Patients = ds.Select(q => q.PatientId).ToList();
|
||||
}
|
||||
private void LoadMovedFrom()
|
||||
{
|
||||
barAutoUpdate.Enabled = false;
|
||||
int No = 0;
|
||||
colStatus.Visible = false; colReceiveServiceDate.Visible = false;
|
||||
this.SelectedIndex = 2;
|
||||
var Patients = new EntityCollection<TblPatientEntity>();
|
||||
adapter.FetchEntityCollection(Patients, null);
|
||||
var ds = (from q in Patients
|
||||
where (q.Dateofreferral != null && q.Dateofreferral >= (DateTime)BeginDate.EditValue && q.Dateofreferral <= (DateTime) EndDate.EditValue)
|
||||
select new { No = No++, ARV = q.DateofArv != null ? true : false, q.PatientId, PatientName = strUtil.Decrypt(q.PatientName), q.Sex, q.BirthYear, q.TelephoneNo }).ToList();
|
||||
grdClients.DataSource = ds;
|
||||
grdClients.Patients = ds.Select(q => q.PatientId).ToList();
|
||||
}
|
||||
|
||||
private void LoadMovedTo()
|
||||
{
|
||||
barAutoUpdate.Enabled = true;
|
||||
int No = 1;
|
||||
colStatus.Visible = false; colReceiveServiceDate.Visible = false;
|
||||
this.SelectedIndex = 3;
|
||||
var referrals = new EntityCollection<TblReferralsToEntity>();
|
||||
var patients = new EntityCollection<TblPatientEntity>();
|
||||
adapter.FetchEntityCollection(referrals, null);
|
||||
adapter.FetchEntityCollection(patients, null);
|
||||
var lastreferral = (from q in referrals
|
||||
where q.TypeId == "09" && q.EndDate >= (DateTime)BeginDate.EditValue && q.EndDate <= (DateTime)EndDate.EditValue
|
||||
group q by q.PatientId
|
||||
into groups
|
||||
select groups.OrderBy(p => p.EndDate).Last<TblReferralsToEntity>()).ToList<TblReferralsToEntity>();
|
||||
var ds = (from q in lastreferral join p in patients on q.PatientId equals p.PatientId
|
||||
select new { No = No++, ARV = p.DateofArv != null ? true : false, p.PatientId, PatientName = strUtil.Decrypt(p.PatientName), p.Sex, p.BirthYear, p.TelephoneNo, Status = q.Status == 1 ? true : false, q.ReceiveServiceDate }).ToList();
|
||||
colStatus.Visible = true; colReceiveServiceDate.Visible = true;
|
||||
grdClients.DataSource = ds;
|
||||
grdClients.Patients = ds.Select(q => q.PatientId).ToList();
|
||||
}
|
||||
private void LoadDeaths()
|
||||
{
|
||||
int No = 1;
|
||||
colStatus.Visible = false; colReceiveServiceDate.Visible = false;
|
||||
this.SelectedIndex = 4;
|
||||
var Patients = new EntityCollection<TblPatientEntity>();
|
||||
adapter.FetchEntityCollection(Patients, null);
|
||||
var ds = (from p in Patients
|
||||
where (p.DeathDate != null && p.DeathDate >= (DateTime)BeginDate.EditValue && p.DeathDate <= (DateTime)EndDate.EditValue)
|
||||
select new { No = No++, ARV = p.DateofArv != null ? true : false, p.PatientId, PatientName = strUtil.Decrypt(p.PatientName), p.Sex, p.BirthYear, p.TelephoneNo }).ToList();
|
||||
grdClients.DataSource = ds;
|
||||
grdClients.Patients = ds.Select(q => q.PatientId).ToList();
|
||||
barAutoUpdate.Enabled = true;
|
||||
}
|
||||
|
||||
private void LostFollowup()
|
||||
{
|
||||
|
||||
var exams = new EntityCollection<TblExaminationInfoEntity>();
|
||||
var patients = new EntityCollection<TblPatientEntity>();
|
||||
var lostfollowups = new EntityCollection<TblReferralsToEntity>();
|
||||
DateTime thisToday = DateTime.Today;
|
||||
adapter.FetchEntityCollection(exams, null);
|
||||
adapter.FetchEntityCollection(patients, null);
|
||||
adapter.FetchEntityCollection(lostfollowups, null);
|
||||
var allLostFolowup = (from element in lostfollowups
|
||||
where element.TypeId == "10"
|
||||
group element by element.PatientId
|
||||
into groups
|
||||
select groups.Last()).ToList();
|
||||
|
||||
List<string> exclusive = (from element in exams
|
||||
group element by element.PatientId
|
||||
into groups
|
||||
select groups.OrderBy(p => p.ExamDate).Last()).ToList()
|
||||
.Where(q => q.EndExamDate != null)
|
||||
.ToList()
|
||||
.Select(m => m.PatientId)
|
||||
.ToList();
|
||||
int No=1;
|
||||
var result = (from q in allLostFolowup
|
||||
join p in patients on q.PatientId equals p.PatientId where (!exclusive.Contains(q.PatientId))
|
||||
select new { No = No++, ARV = p.DateofArv != null ? true : false, p.PatientId, PatientName = strUtil.Decrypt(p.PatientName), p.Sex, p.BirthYear, p.TelephoneNo }).ToList();
|
||||
grdClients.DataSource = null;
|
||||
grdClients.DataSource = result;
|
||||
grdClients.Patients = result.Select(q => q.PatientId).ToList();
|
||||
barAutoUpdate.Enabled = false;
|
||||
|
||||
}
|
||||
|
||||
private void Addnew_Click(object sender, EventArgs e)
|
||||
{
|
||||
var frm = new frmPatientInfo();
|
||||
frm.PatientsCollection = new EntityCollection<TblPatientEntity>();
|
||||
frm.usrPatientInfo.Enabled = true;
|
||||
frm.NewRecord();
|
||||
frm.ShowDialog();
|
||||
}
|
||||
|
||||
private void gridView_DoubleClick(object sender, EventArgs e)
|
||||
{
|
||||
var frm = new frmPatientInfo();
|
||||
frm.PatientsCollection = new EntityCollection<TblPatientEntity>();
|
||||
var Patientid = gridView.GetFocusedRowCellValue(colPatientId).ToString();
|
||||
var PatientInfo = new TblPatientEntity(Patientid);
|
||||
adapter.FetchEntity(PatientInfo);
|
||||
frm.PatientsCollection.Add(PatientInfo);
|
||||
frm.PatientInfo = PatientInfo;
|
||||
frm.LoadData();
|
||||
frm.ShowDialog();
|
||||
}
|
||||
|
||||
private void View_Click(object sender, EventArgs e)
|
||||
{
|
||||
var frm = new frmPatientInfo();
|
||||
frm.PatientsCollection = new EntityCollection<TblPatientEntity>();
|
||||
var Patientid = gridView.GetFocusedRowCellValue(colPatientId).ToString();
|
||||
var PatientInfo = new TblPatientEntity(Patientid);
|
||||
adapter.FetchEntity(PatientInfo);
|
||||
frm.PatientsCollection.Add(PatientInfo);
|
||||
frm.PatientInfo = PatientInfo;
|
||||
frm.LoadData();
|
||||
frm.ShowDialog();
|
||||
}
|
||||
|
||||
|
||||
|
||||
private void cbFilter_EditValueChanged(object sender, EventArgs e)
|
||||
{
|
||||
this.SelectedIndex =((ComboBoxEdit)sender).SelectedIndex;
|
||||
if (this.SelectedIndex <=1 || this.SelectedIndex == 5 )
|
||||
{
|
||||
this.BeginDate.Visibility = DevExpress.XtraBars.BarItemVisibility.Never;
|
||||
this.EndDate.Visibility = DevExpress.XtraBars.BarItemVisibility.Never;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
this.BeginDate.Visibility = DevExpress.XtraBars.BarItemVisibility.Always;
|
||||
this.EndDate.Visibility = DevExpress.XtraBars.BarItemVisibility.Always;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void barFilterButton_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
|
||||
{
|
||||
switch (SelectedIndex)
|
||||
{
|
||||
case 0:
|
||||
LoadAll();
|
||||
break;
|
||||
case 1:
|
||||
LoadUnderManagement();
|
||||
break;
|
||||
case 2:
|
||||
LoadMovedFrom();
|
||||
break;
|
||||
case 3:
|
||||
LoadMovedTo();
|
||||
break;
|
||||
case 4:
|
||||
LoadDeaths();
|
||||
break;
|
||||
case 5: LostFollowup();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private void barAutoUpdate_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
|
||||
{
|
||||
switch (SelectedIndex)
|
||||
{
|
||||
case 0:
|
||||
|
||||
break;
|
||||
case 1:
|
||||
|
||||
break;
|
||||
case 2:
|
||||
|
||||
break;
|
||||
case 3:
|
||||
MoveToEnd();
|
||||
break;
|
||||
case 4:
|
||||
DeathsEnd();
|
||||
break;
|
||||
case 5:
|
||||
break;
|
||||
}
|
||||
MessageBox.Show("Task is completed");
|
||||
}
|
||||
|
||||
|
||||
private void DeathsEnd()
|
||||
{
|
||||
|
||||
for (int i = 0; i < gridView.DataRowCount; i++)
|
||||
{
|
||||
string Patientid = gridView.GetRowCellValue(i, colPatientId).ToString();
|
||||
LinqMetaData metadata = new LinqMetaData();
|
||||
metadata.AdapterToUse = adapter;
|
||||
if (metadata.TblTreatmentInfo.Where(m => m.PatientId == Patientid).Where(m => m.TreatmentId == "01").Count() > 0)
|
||||
{
|
||||
string Unique = metadata.TblTreatmentInfo.Where(m => m.PatientId == Patientid).Where(m => m.TreatmentId == "01").OrderByDescending(m => m.TreatmentSdate).First().UniqueKey;
|
||||
TblTreatmentInfoEntity TreatmentInfo = new TblTreatmentInfoEntity(Unique);
|
||||
DateTime EndDate = metadata.TblPatient.Where(m => m.PatientId == Patientid).First().DeathDate.Value;
|
||||
adapter.FetchEntity(TreatmentInfo);
|
||||
TreatmentInfo.TreatmentEdate = EndDate;
|
||||
TreatmentInfo.ReasonId = "11";
|
||||
adapter.SaveEntity(TreatmentInfo);
|
||||
}
|
||||
|
||||
if (metadata.TblExaminationInfo.Where(m => m.PatientId == Patientid).Count() > 0)
|
||||
{
|
||||
string Unique = metadata.TblExaminationInfo.Where(m => m.PatientId == Patientid).OrderByDescending(m => m.EndExamDate).First().UniqueKey;
|
||||
TblExaminationInfoEntity Exam = new TblExaminationInfoEntity(Unique);
|
||||
DateTime EndDate = metadata.TblPatient.Where(m => m.PatientId == Patientid).First().DeathDate.Value;
|
||||
adapter.FetchEntity(Exam);
|
||||
Exam.EndExamDate = EndDate;
|
||||
Exam.ReasonEnd = "11";
|
||||
adapter.SaveEntity(Exam);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
private void MoveToEnd()
|
||||
{
|
||||
for ( int i = 0; i < gridView.DataRowCount; i++)
|
||||
{
|
||||
string Patientid = gridView.GetRowCellValue(i,colPatientId).ToString();
|
||||
LinqMetaData metadata = new LinqMetaData();
|
||||
metadata.AdapterToUse = adapter;
|
||||
if (metadata.TblTreatmentInfo.Where(m => m.PatientId == Patientid).Where(m => m.TreatmentId == "01").Count() > 0)
|
||||
{
|
||||
string Unique = metadata.TblTreatmentInfo.Where(m => m.PatientId == Patientid).Where(m => m.TreatmentId == "01").OrderByDescending(m => m.TreatmentSdate).First().UniqueKey;
|
||||
TblTreatmentInfoEntity TreatnentInfo = new TblTreatmentInfoEntity(Unique);
|
||||
DateTime EndDate = metadata.TblReferralsTo.Where(m => m.PatientId == Patientid).OrderByDescending(m => m.EndDate).First().EndDate.Value;
|
||||
adapter.FetchEntity(TreatnentInfo);
|
||||
TreatnentInfo.TreatmentEdate = EndDate;
|
||||
TreatnentInfo.ReasonId = "09";
|
||||
adapter.SaveEntity(TreatnentInfo);
|
||||
}
|
||||
|
||||
if (metadata.TblExaminationInfo.Where(m => m.PatientId == Patientid).Count() > 0)
|
||||
{
|
||||
string Unique = metadata.TblExaminationInfo.Where(m => m.PatientId == Patientid).OrderByDescending(m => m.EndExamDate).First().UniqueKey;
|
||||
TblExaminationInfoEntity Exam = new TblExaminationInfoEntity(Unique);
|
||||
DateTime EndDate = metadata.TblReferralsTo.Where(m => m.PatientId == Patientid).OrderByDescending(m => m.EndDate).First().EndDate.Value;
|
||||
adapter.FetchEntity(Exam);
|
||||
Exam.EndExamDate = EndDate;
|
||||
Exam.ReasonEnd = "09";
|
||||
adapter.SaveEntity(Exam);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
private void Printing_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
|
||||
{
|
||||
this.grdClients.ShowPrintPreview();
|
||||
}
|
||||
|
||||
|
||||
|
||||
private void barEdit_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
|
||||
{
|
||||
if (gridView.RowCount == 0) return;
|
||||
var frm = new frmPatientInfo();
|
||||
frm.PatientsCollection = new EntityCollection<TblPatientEntity>();
|
||||
var Patientid = gridView.GetFocusedRowCellValue(colPatientId).ToString();
|
||||
var PatientInfo = new TblPatientEntity(Patientid);
|
||||
adapter.FetchEntity(PatientInfo);
|
||||
frm.PatientsCollection.Add(PatientInfo);
|
||||
frm.PatientInfo = PatientInfo;
|
||||
frm.LoadData();
|
||||
frm.ShowDialog();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user