Lots of updates

This commit is contained in:
Matthew Burke
2023-07-26 22:26:54 -04:00
parent 42794b6284
commit 1b65e9bb83
24 changed files with 1305 additions and 28 deletions
@@ -0,0 +1,37 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace PWAPPv2.Source.DataObjects
{
class APICredentials
{
public string UserID;
public string Password;
public string PracticeId;
public string APIid;
public APICredentials(Source.APIConfig config)
{
UserID = config.PWUserID;
Password = config.PWPassword;
PracticeId = config.PWPracticeID;
APIid = config.PWApiID;
}
public string BuildJsonBodyContents()
{
return "'UserID':'" + UserID + "'," +
"'Password':'" + Password + "'," +
"'PracticeId':'" + PracticeId + "'," +
"'APIid':'" + APIid + "'";
}
public string ToJsonString()
{
return "\"{" + BuildJsonBodyContents() + "}\"";
}
}
}
@@ -0,0 +1,38 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
namespace PWAPPv2.Source.DataObjects
{
abstract class ComboBoxData
{
protected ComboBox Box;
public ComboBoxData(ComboBox box)
{
Box = box;
}
public void Add(string content)
{
Box.Items.Add(content);
}
public string GetSelectedData()
{
return Box.SelectedItem.ToString();
}
public abstract void Update();
public abstract int GetSelectedIndex(string content);
public abstract int GetSelectedID();
}
}
+18
View File
@@ -0,0 +1,18 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace PWAPPv2.Source.DataObjects
{
class Exceptions
{
}
class DataInvalidException : Exception
{
}
}
+71
View File
@@ -0,0 +1,71 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace PWAPPv2.Source.DataObjects
{
class NumValList
{
private List<NumValPair> Pairs;
public NumValList()
{
}
public NumValList(string Content, char Delim)
{
string[] split = Content.Split(Delim);
if((split.Length % 2) != 0)
{
throw new UnevenValuesException();
}
for(int i = 0; i < split.Length; i++)
{
this.Add(int.Parse(split[i]), split[i + 1]);
i++;
}
}
public void Add(int Num, string Val)
{
Pairs.Add(new NumValPair(Num, Val));
}
public string GetValFromNum(int Num)
{
for (int i = 0; i < Pairs.Count; i++)
{
if (Pairs[i].Num == Num)
{
return Pairs[i].Value;
}
}
throw new NotFoundException();
}
public int GetNumFromVal(string Val)
{
for (int i = 0; i < Pairs.Count; i++)
{
if (Pairs[i].Value == Val)
{
return Pairs[i].Num;
}
}
throw new NotFoundException();
}
}
class NotFoundException : Exception
{
}
class UnevenValuesException : Exception
{
}
}
+20
View File
@@ -0,0 +1,20 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace PWAPPv2.Source.DataObjects
{
class NumValPair
{
public int Num;
public string Value;
public NumValPair(int N, string Val)
{
Num = N;
Value = Val;
}
}
}
@@ -0,0 +1,83 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
namespace PWAPPv2.Source.DataObjects
{
class ReferFromBox : ComboBoxData
{
List<string> DoctorName;
List<int> DoctorID;
public ReferFromBox(ComboBox box, string data) : base(box)
{
this.Add("Choose Refer From");
DoctorName = new List<string>();
DoctorID = new List<int>();
data = data.Replace("\\n", "");
data = data.Replace("\"", "");
string[] split = data.Split('|');
for (int i = 0; i < split.Length; i = i + 2)
{
try
{
int id = int.Parse(split[i]);
DoctorID.Add(id);
}
catch (Exception)
{
throw new DataInvalidException();
}
DoctorName.Add(split[i + 1]);
}
foreach (string name in DoctorName)
{
Add(name);
}
Box.SelectedItem = "Choose Refer From";
}
public override int GetSelectedID()
{
string Selected = GetSelectedData();
if (Selected == "Choose Refer From")
{
throw new ReferFromDefaultException();
}
for (int i = 0; i < DoctorName.Count; i++)
{
if (DoctorName[i] == Selected)
{
return DoctorID[i];
}
}
throw new InvalidReferralTypeException();
}
public override void Update()
{
throw new NotImplementedException();
}
public override int GetSelectedIndex(string content)
{
throw new NotImplementedException();
}
}
public class ReferFromDefaultException : Exception
{ }
public class InvalidDoctorException : Exception
{
}
}
+102
View File
@@ -0,0 +1,102 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
namespace PWAPPv2.Source.DataObjects
{
class ReferToBox : ComboBoxData
{
List<int> PractieID;
List<string> ToName;
List<int> DoctorID;
public ReferToBox(ComboBox box, string data) : base(box)
{
this.Add("Choose Refer To");
ToName = new List<string>();
DoctorID = new List<int>();
PractieID = new List<int>();
data = data.Replace("\\n", "");
data = data.Replace("\"", "");
string[] split = data.Split('|');
for (int i = 0; i < split.Length; i = i + 3)
{
try
{
PractieID.Add(int.Parse(split[i]));
ToName.Add(split[i + 1]);
DoctorID.Add(int.Parse(split[i + 2]));
}
catch (Exception)
{
throw new DataInvalidException();
}
}
foreach (string name in ToName)
{
this.Add(name);
}
Box.SelectedItem = "Choose Refer To";
}
public override void Update()
{
throw new NotImplementedException();
}
public override int GetSelectedID()
{
throw new NotImplementedException();
}
public int GetSelectedPracticeID()
{
string selected = GetSelectedData();
if (selected == "Choose Refer To")
{
throw new ReferToDefaultException();
}
for (int i = 0; i < ToName.Count; i++)
{
if (ToName[i] == selected)
{
return PractieID[i];
}
}
throw new InvalidReferToException();
}
public int GetSelectedDoctorID()
{
string selected = GetSelectedData();
if (selected == "Choose Refer To")
{
throw new ReferToDefaultException();
}
for (int i = 0; i < ToName.Count; i++)
{
if (ToName[i] == selected)
{
return DoctorID[i];
}
}
throw new InvalidReferToException();
}
public override int GetSelectedIndex(string content)
{
throw new NotImplementedException();
}
}
public class ReferToDefaultException : Exception
{ }
public class InvalidReferToException : Exception
{ }
}
+88
View File
@@ -0,0 +1,88 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows;
namespace PWAPPv2.Source.DataObjects
{
class Referral
{
APICredentials ApiCredentials;
Patient PatientData;
ReferToBox ReferTo;
ReferFromBox ReferFrom;
ReferralTypeBox ReferralType;
RichTextBox RemarksBox;
CheckBox ContactBox;
public Referral(APICredentials apiCredentials, Patient patient, ReferralTypeBox referralType, ReferToBox referTo, ReferFromBox referFrom, RichTextBox remarksBox, CheckBox contactBox)
{
ApiCredentials = apiCredentials;
PatientData = patient;
ReferralType = referralType;
ReferTo = referTo;
ReferFrom = referFrom;
RemarksBox = remarksBox;
ContactBox = contactBox;
}
public string ToJsonString()
{
string RemarksText = new TextRange(RemarksBox.Document.ContentStart, RemarksBox.Document.ContentEnd).Text;
int contact = 0;
if(ContactBox.IsChecked == true)
{
contact = 1;
}
try
{
return "\"{" + ApiCredentials.BuildJsonBodyContents() + "," +
"'LName':'" + PatientData.LName + "'," +
"'FName':'" + PatientData.FName + "'," +
"'Birthday':'" + PatientData.DoB + "'," +
"'Address':'" + PatientData.Address + "'," +
"'Address2':'" + PatientData.Address2 + "'," +
"'City':'" + PatientData.City + "'," +
"'State':'" + PatientData.State + "'," +
"'Zip':'" + PatientData.Zip + "'," +
"'HmPhone':'" + PatientData.HomePhone + "'," +
"'WkPhone':'" + PatientData.WorkPhone + "'," +
"'WirelessPhone':'" + PatientData.WirelessPhone + "'," +
"'Email':'" + PatientData.Email + "'," +
"'ReferralType':'" + ReferralType.GetSelectedID() + "'," +
"'SubmittedBy':'" + ReferFrom.GetSelectedID() + "'," +
"'ToPracticeId':'" + ReferTo.GetSelectedPracticeID() + "'," +
"'ToDoctorID':'" + ReferTo.GetSelectedDoctorID() + "'," +
"'Attachments':'False'," +
"'Remarks':'" + RemarksText + "'," +
"'Contact':'" + contact + "'}\"";
}
catch (Source.DataObjects.ReferralTypeDefaultException)
{
MessageBox.Show("Please select a referral type");
}
catch(Source.DataObjects.ReferToDefaultException)
{
MessageBox.Show("Please select a refer to");
}
catch(Source.DataObjects.ReferFromDefaultException)
{
MessageBox.Show("Please select a refer from");
}
throw new InvalidReferalDataException();
}
public class InvalidReferalDataException : Exception
{
}
}
}
@@ -0,0 +1,85 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
namespace PWAPPv2.Source.DataObjects
{
class ReferralTypeBox : ComboBoxData
{
List<string> TypeName;
List<int> TypeID;
public ReferralTypeBox(ComboBox box, string data) : base(box)
{
this.Add("Choose Referral Type");
TypeName = new List<string>();
TypeID = new List<int>();
data = data.Replace("\\n", "");
data = data.Replace("\"", "");
string[] split = data.Split('|');
for (int i = 0; i < split.Length; i = i + 2)
{
try
{
int id = int.Parse(split[i]);
TypeID.Add(id);
}
catch(Exception)
{
throw new DataInvalidException();
}
TypeName.Add(split[i + 1]);
}
foreach(string name in TypeName)
{
Add(name);
}
Box.SelectedItem = "Choose Referral Type";
}
public override int GetSelectedID()
{
string Selected = GetSelectedData();
if (Selected == "Choose Referral Type")
{
throw new ReferralTypeDefaultException();
}
for(int i = 0; i < TypeName.Count; i++)
{
if(TypeName[i] == Selected)
{
return TypeID[i];
}
}
throw new InvalidReferralTypeException();
}
public override void Update()
{
throw new NotImplementedException();
}
public override int GetSelectedIndex(string content)
{
throw new NotImplementedException();
}
}
public class InvalidReferralTypeException : Exception
{
}
public class ReferralTypeDefaultException : Exception
{ }
}