diff --git a/PWAPPv2/App.config b/PWAPPv2/App.config
index 56efbc7..5967870 100644
--- a/PWAPPv2/App.config
+++ b/PWAPPv2/App.config
@@ -1,6 +1,46 @@
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/PWAPPv2/App.xaml b/PWAPPv2/App.xaml
index f1eab26..5b9f06e 100644
--- a/PWAPPv2/App.xaml
+++ b/PWAPPv2/App.xaml
@@ -2,7 +2,8 @@
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:PWAPPv2"
- StartupUri="MainWindow.xaml">
+ StartupUri="MainWindow.xaml"
+ Startup="app_Startup">
diff --git a/PWAPPv2/App.xaml.cs b/PWAPPv2/App.xaml.cs
index 1147aa4..1f66738 100644
--- a/PWAPPv2/App.xaml.cs
+++ b/PWAPPv2/App.xaml.cs
@@ -13,5 +13,13 @@ namespace PWAPPv2
///
public partial class App : Application
{
+ public static string[] Args;
+ void app_Startup(object sender, StartupEventArgs e)
+ {
+ if(e.Args.Length > 0)
+ {
+ Args = e.Args;
+ }
+ }
}
}
diff --git a/PWAPPv2/Config/Config.xml b/PWAPPv2/Config/Config.xml
index 8cae57d..2296f93 100644
--- a/PWAPPv2/Config/Config.xml
+++ b/PWAPPv2/Config/Config.xml
@@ -1,5 +1,8 @@
+ 10.0.1.107
+ root
+
testdoctor
testdoctor
210
diff --git a/PWAPPv2/MainWindow.xaml b/PWAPPv2/MainWindow.xaml
index b0d8128..2173944 100644
--- a/PWAPPv2/MainWindow.xaml
+++ b/PWAPPv2/MainWindow.xaml
@@ -5,14 +5,14 @@
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:PWAPPv2"
mc:Ignorable="d"
- Title="Quick Referral" Height="500" Width="800">
+ Title="Quick Referral" Height="537" Width="800">
-
-
+
+
@@ -26,6 +26,11 @@
+
+
+
+
+
@@ -35,6 +40,11 @@
+
+
+
+
+
@@ -43,10 +53,15 @@
+
+
+
+
+
-
+
@@ -54,9 +69,9 @@
-
-
-
+
+
+
@@ -64,13 +79,13 @@
-
-
-
-
+
+
+
+
-
-
+
+
diff --git a/PWAPPv2/MainWindow.xaml.cs b/PWAPPv2/MainWindow.xaml.cs
index c9abf16..7901146 100644
--- a/PWAPPv2/MainWindow.xaml.cs
+++ b/PWAPPv2/MainWindow.xaml.cs
@@ -25,27 +25,76 @@ namespace PWAPPv2
///
public partial class MainWindow : Window
{
- Source.APIConfig apiconfig = new Source.APIConfig();
+ static Source.APIConfig apiconfig = new Source.APIConfig();
+ static Source.Database.DatabaseConfig DataConfig;
+
+ static Source.API.APIConnection apiConnection;
+ Source.DataObjects.APICredentials apiCreds;
+
+ Source.DataObjects.ComboBoxData TypeBox;
+ Source.DataObjects.ComboBoxData ToBox;
+ Source.DataObjects.ComboBoxData FromBox;
+
+ string[] args;
+
+ Source.Patient patient;
+
public MainWindow()
{
+ try
+ {
+ args = App.Args;
+ }
+ catch(Exception)
+ { }
+
apiconfig.LoadConfig("./Config/Config.xml");
+ DataConfig = new Source.Database.DatabaseConfig("./Config/Config.xml");
+ Source.Database.DatabaseConnection dbcon = new Source.Database.DatabaseConnection(DataConfig);
+
+ apiCreds = new Source.DataObjects.APICredentials(apiconfig);
+
+ apiConnection = new Source.API.APIConnection("http://apipatientweb.azurewebsites.net/",
+ apiCreds);
InitializeComponent();
- Source.Patient patient = new Source.Patient();
- patient.FName = "Matthew";
- patient.MName = "Charles";
- patient.LName = "Burke";
- patient.DoB = "02/24/1999";
- patient.Address = "33B N Earl St";
- patient.City = "Shippensburg";
- patient.State = "Pennsylvania";
- patient.Zip = "17257";
+ PopulateComboBoxes();
+
+ patient = new Source.Patient();
+
+ patient.BuildFromDatabase(dbcon, args[0]);
this.DataContext = new Source.PatientGUIAdapter(patient);
}
+ private void PopulateComboBoxes()
+ {
+ PopulateReferTypesBox();
+ PopulateReferToBox();
+ PopulateReferFromBox();
+ }
+
+ private void PopulateReferTypesBox()
+ {
+ string ReferTypeString = apiConnection.SendPostRequestAsync("api/PWReferralTypes");
+ TypeBox = new Source.DataObjects.ReferralTypeBox(boxReferType, ReferTypeString);
+
+ }
+
+ private void PopulateReferToBox()
+ {
+ string ReferToString = apiConnection.SendPostRequestAsync("api/PWReferTo");
+ ToBox = new Source.DataObjects.ReferToBox(boxReferTo, ReferToString);
+ }
+
+ private void PopulateReferFromBox()
+ {
+ string ReferFromString = apiConnection.SendPostRequestAsync("api/PWReferFrom");
+ FromBox = new Source.DataObjects.ReferFromBox(boxReferFrom, ReferFromString);
+ }
+
private void RichTextBox_TextChanged(object sender, TextChangedEventArgs e)
{
@@ -60,5 +109,50 @@ namespace PWAPPv2
{
}
+
+ private void boxReferType_SelectionChanged(object sender, SelectionChangedEventArgs e)
+ {
+ try
+ {
+ TypeBox.GetSelectedID();
+ }
+ catch(Source.DataObjects.ReferralTypeDefaultException)
+ {
+
+ }
+ catch(Source.DataObjects.InvalidReferralTypeException)
+ {
+
+ }
+ catch(NullReferenceException)
+ {
+
+ }
+ }
+
+ private void Button_Click(object sender, RoutedEventArgs e)
+ {
+ this.Close();
+ }
+
+ private void Button_Click_1(object sender, RoutedEventArgs e)
+ {
+ Source.DataObjects.Referral referral = new Source.DataObjects.Referral(apiCreds, patient,
+ (Source.DataObjects.ReferralTypeBox)TypeBox,
+ (Source.DataObjects.ReferToBox)ToBox,
+ (Source.DataObjects.ReferFromBox)FromBox,
+ fieldRemakrs, contact);
+ try
+ {
+ string referralString = referral.ToJsonString();
+ string result = apiConnection.SendPostRequestAsync("api/PWMakeReferral", referralString);
+ MessageBox.Show(result);
+ this.Close();
+ }
+ catch(Source.DataObjects.Referral.InvalidReferalDataException)
+ {
+
+ }
+ }
}
}
diff --git a/PWAPPv2/PWAPPv2.csproj b/PWAPPv2/PWAPPv2.csproj
index 3858d30..3fa3d88 100644
--- a/PWAPPv2/PWAPPv2.csproj
+++ b/PWAPPv2/PWAPPv2.csproj
@@ -14,6 +14,8 @@
4
true
true
+
+
AnyCPU
@@ -35,14 +37,167 @@
4
+
+ ..\packages\Azure.Core.1.25.0\lib\net461\Azure.Core.dll
+
+
+ ..\packages\Azure.Identity.1.7.0\lib\netstandard2.0\Azure.Identity.dll
+
+
+ ..\packages\Microsoft.Bcl.AsyncInterfaces.7.0.0\lib\net462\Microsoft.Bcl.AsyncInterfaces.dll
+
+
+ ..\packages\Microsoft.Data.SqlClient.5.1.1\lib\net462\Microsoft.Data.SqlClient.dll
+
+
+ ..\packages\Microsoft.Identity.Client.4.47.2\lib\net461\Microsoft.Identity.Client.dll
+
+
+ ..\packages\Microsoft.Identity.Client.Extensions.Msal.2.19.3\lib\net45\Microsoft.Identity.Client.Extensions.Msal.dll
+
+
+ ..\packages\Microsoft.IdentityModel.Abstractions.6.24.0\lib\net472\Microsoft.IdentityModel.Abstractions.dll
+
+
+ ..\packages\Microsoft.IdentityModel.JsonWebTokens.6.24.0\lib\net472\Microsoft.IdentityModel.JsonWebTokens.dll
+
+
+ ..\packages\Microsoft.IdentityModel.Logging.6.24.0\lib\net472\Microsoft.IdentityModel.Logging.dll
+
+
+ ..\packages\Microsoft.IdentityModel.Protocols.6.24.0\lib\net472\Microsoft.IdentityModel.Protocols.dll
+
+
+ ..\packages\Microsoft.IdentityModel.Protocols.OpenIdConnect.6.24.0\lib\net472\Microsoft.IdentityModel.Protocols.OpenIdConnect.dll
+
+
+ ..\packages\Microsoft.IdentityModel.Tokens.6.24.0\lib\net472\Microsoft.IdentityModel.Tokens.dll
+
+
+ ..\packages\MySqlConnector.2.2.7\lib\net471\MySqlConnector.dll
+
+
+ ..\packages\Newtonsoft.Json.13.0.3\lib\net45\Newtonsoft.Json.dll
+
+
+ ..\packages\System.Buffers.4.5.1\lib\net461\System.Buffers.dll
+
+
+
+
+ ..\packages\System.Configuration.ConfigurationManager.6.0.1\lib\net461\System.Configuration.ConfigurationManager.dll
+
+
+
+ ..\packages\System.Diagnostics.DiagnosticSource.6.0.0\lib\net461\System.Diagnostics.DiagnosticSource.dll
+
+
+
+
+ ..\packages\System.IdentityModel.Tokens.Jwt.6.24.0\lib\net472\System.IdentityModel.Tokens.Jwt.dll
+
+
+ ..\packages\System.IO.4.3.0\lib\net462\System.IO.dll
+ True
+ True
+
+
+ ..\packages\System.Memory.4.5.5\lib\net461\System.Memory.dll
+
+
+ ..\packages\System.Memory.Data.1.0.2\lib\net461\System.Memory.Data.dll
+
+
+
+ ..\packages\System.Net.Http.4.3.4\lib\net46\System.Net.Http.dll
+ True
+ True
+
+
+ ..\packages\Microsoft.Net.Http.2.2.29\lib\net45\System.Net.Http.Extensions.dll
+
+
+ ..\packages\Microsoft.AspNet.WebApi.Client.5.2.9\lib\net45\System.Net.Http.Formatting.dll
+
+
+ ..\packages\System.Net.Http.Json.7.0.1\lib\net462\System.Net.Http.Json.dll
+
+
+ ..\packages\Microsoft.Net.Http.2.2.29\lib\net45\System.Net.Http.Primitives.dll
+
+
+
+
+ ..\packages\System.Numerics.Vectors.4.5.0\lib\net46\System.Numerics.Vectors.dll
+
+
+ ..\packages\System.Runtime.4.3.1\lib\net462\System.Runtime.dll
+ True
+ True
+
+
+ ..\packages\System.Runtime.CompilerServices.Unsafe.6.0.0\lib\net461\System.Runtime.CompilerServices.Unsafe.dll
+
+
+ ..\packages\System.Runtime.InteropServices.RuntimeInformation.4.3.0\lib\net45\System.Runtime.InteropServices.RuntimeInformation.dll
+ True
+ True
+
+
+
+ ..\packages\System.Security.AccessControl.6.0.0\lib\net461\System.Security.AccessControl.dll
+
+
+ ..\packages\System.Security.Cryptography.Algorithms.4.3.1\lib\net463\System.Security.Cryptography.Algorithms.dll
+ True
+ True
+
+
+ ..\packages\System.Security.Cryptography.Encoding.4.3.0\lib\net46\System.Security.Cryptography.Encoding.dll
+ True
+ True
+
+
+ ..\packages\System.Security.Cryptography.Primitives.4.3.0\lib\net46\System.Security.Cryptography.Primitives.dll
+ True
+ True
+
+
+ ..\packages\System.Security.Cryptography.ProtectedData.4.7.0\lib\net461\System.Security.Cryptography.ProtectedData.dll
+
+
+ ..\packages\System.Security.Cryptography.X509Certificates.4.3.2\lib\net461\System.Security.Cryptography.X509Certificates.dll
+ True
+ True
+
+
+ ..\packages\System.Security.Permissions.6.0.0\lib\net461\System.Security.Permissions.dll
+
+
+ ..\packages\System.Security.Principal.Windows.5.0.0\lib\net461\System.Security.Principal.Windows.dll
+
+
+
+ ..\packages\System.Text.Encodings.Web.7.0.0\lib\net462\System.Text.Encodings.Web.dll
+
+
+ ..\packages\System.Text.Json.7.0.3\lib\net462\System.Text.Json.dll
+
+
+ ..\packages\System.Threading.Tasks.Extensions.4.5.4\lib\net461\System.Threading.Tasks.Extensions.dll
+
+
+
+ ..\packages\System.ValueTuple.4.5.0\lib\net47\System.ValueTuple.dll
+
+
-
4.0
@@ -55,7 +210,20 @@
MSBuild:Compile
Designer
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -89,6 +257,7 @@
ResXFileCodeGenerator
Resources.Designer.cs
+
SettingsSingleFileGenerator
Settings.Designer.cs
@@ -101,7 +270,16 @@
-
+
+
+
+
+ This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.
+
+
+
+
+
\ No newline at end of file
diff --git a/PWAPPv2/Source/APIConfig.cs b/PWAPPv2/Source/API/APIConfig.cs
similarity index 100%
rename from PWAPPv2/Source/APIConfig.cs
rename to PWAPPv2/Source/API/APIConfig.cs
diff --git a/PWAPPv2/Source/API/APIConnection.cs b/PWAPPv2/Source/API/APIConnection.cs
new file mode 100644
index 0000000..2efb4e5
--- /dev/null
+++ b/PWAPPv2/Source/API/APIConnection.cs
@@ -0,0 +1,128 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Net;
+using System.Net.Http;
+using System.Net.Http.Headers;
+using System.IO;
+using Newtonsoft.Json;
+
+namespace PWAPPv2.Source.API
+{
+ class APIConnection
+ {
+ private static string BaseURL;
+
+ public DataObjects.APICredentials Credentials;
+
+ private static bool ResponseReady = false;
+ private static string Response = "";
+
+ public APIConnection(string baseUrl, DataObjects.APICredentials credentials)
+ {
+ Credentials = credentials;
+ BaseURL = baseUrl;
+ }
+
+ public string GetResponse()
+ {
+ while (!ResponseReady) ;
+ return Response;
+ }
+
+ public static async void APIGet(string Call)
+ {
+ //WebRequest request = WebRequest.Create(BaseURL + Call);
+ //request.Method = "GET";
+ //request.ContentType = "application/json; charset=utf-8";
+ //var response = (HttpWebResponse)request.GetResponse();
+ //string text;
+ //using (var sr = new StreamReader(response.GetResponseStream()))
+ //{
+ // text = sr.ReadToEnd();
+ //}
+ //return text;
+
+ using (var client = new HttpClient())
+ {
+ client.BaseAddress = new Uri(BaseURL);
+ client.DefaultRequestHeaders.Accept.Clear();
+ client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
+
+ HttpResponseMessage response = await client.GetAsync(Call);
+
+ }
+ }
+
+ public string APIPost()
+ {
+ string text;
+ try
+ {
+ HttpWebRequest request = (HttpWebRequest)WebRequest.Create("http://apipatientweb.azurewebsites.net/api/PWReferralTypes");
+ request.Method = "POST";
+ request.ContentType = "application/json; charset=\"utf-8\"";
+ request.Accept = "application/json";
+
+ string postData = Source.API.APIRequestBuilder.BuildJsonBodyRequest(Credentials);
+
+ ASCIIEncoding encoding = new ASCIIEncoding();
+ byte[] data = encoding.GetBytes(postData);
+ request.ContentLength = data.Length;
+ Stream newStream = request.GetRequestStream();
+ newStream.Write(data, 0, data.Length);
+ newStream.Close();
+
+ var response = (HttpWebResponse)request.GetResponse();
+
+ using (var sr = new StreamReader(response.GetResponseStream()))
+ {
+ text = sr.ReadToEnd();
+ }
+ }
+ catch(WebException wex)
+ {
+ text = new StreamReader(wex.Response.GetResponseStream()).ReadToEnd();
+ }
+ return text;
+ }
+
+ public string SendPostRequestAsync(string apiUri)
+ {
+ HttpClient client = new HttpClient();
+ client.BaseAddress = new Uri(BaseURL);
+ client.DefaultRequestHeaders.Accept.Add(
+ new MediaTypeWithQualityHeaderValue("application/json"));
+
+ StringContent contetnt = new StringContent(Credentials.ToJsonString(), Encoding.UTF8, "application/json");
+
+ var response = client.PostAsync(apiUri, contetnt).Result;
+
+ if(response.IsSuccessStatusCode)
+ {
+ return response.Content.ReadAsStringAsync().Result;
+ }
+ return "";
+ }
+ public string SendPostRequestAsync(string apiUri, string PostData)
+ {
+ HttpClient client = new HttpClient();
+ client.BaseAddress = new Uri(BaseURL);
+ client.DefaultRequestHeaders.Accept.Add(
+ new MediaTypeWithQualityHeaderValue("application/json"));
+
+ StringContent contetnt = new StringContent(PostData, Encoding.UTF8, "application/json");
+
+ var response = client.PostAsync(apiUri, contetnt).Result;
+
+ if (response.IsSuccessStatusCode)
+ {
+ return response.Content.ReadAsStringAsync().Result;
+ }
+ return "";
+ }
+
+ }
+}
diff --git a/PWAPPv2/Source/API/APIRequestBuilder.cs b/PWAPPv2/Source/API/APIRequestBuilder.cs
new file mode 100644
index 0000000..48da6aa
--- /dev/null
+++ b/PWAPPv2/Source/API/APIRequestBuilder.cs
@@ -0,0 +1,20 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Xml;
+using System.Xml.Serialization;
+using Newtonsoft.Json;
+
+namespace PWAPPv2.Source.API
+{
+ class APIRequestBuilder
+ {
+ public static string BuildJsonBodyRequest(Object src)
+ {
+ return JsonConvert.SerializeObject(src);
+ }
+
+ }
+}
diff --git a/PWAPPv2/Source/DataObjects/APICredentials.cs b/PWAPPv2/Source/DataObjects/APICredentials.cs
new file mode 100644
index 0000000..c90a014
--- /dev/null
+++ b/PWAPPv2/Source/DataObjects/APICredentials.cs
@@ -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() + "}\"";
+ }
+ }
+}
diff --git a/PWAPPv2/Source/DataObjects/ComboBoxData.cs b/PWAPPv2/Source/DataObjects/ComboBoxData.cs
new file mode 100644
index 0000000..70f7736
--- /dev/null
+++ b/PWAPPv2/Source/DataObjects/ComboBoxData.cs
@@ -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();
+
+
+ }
+}
diff --git a/PWAPPv2/Source/DataObjects/Exceptions.cs b/PWAPPv2/Source/DataObjects/Exceptions.cs
new file mode 100644
index 0000000..cf5bb7b
--- /dev/null
+++ b/PWAPPv2/Source/DataObjects/Exceptions.cs
@@ -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
+ {
+
+ }
+
+}
diff --git a/PWAPPv2/Source/DataObjects/NumValList.cs b/PWAPPv2/Source/DataObjects/NumValList.cs
new file mode 100644
index 0000000..d63cf08
--- /dev/null
+++ b/PWAPPv2/Source/DataObjects/NumValList.cs
@@ -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 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
+ {
+
+ }
+}
diff --git a/PWAPPv2/Source/DataObjects/NumValPair.cs b/PWAPPv2/Source/DataObjects/NumValPair.cs
new file mode 100644
index 0000000..f6bc7bd
--- /dev/null
+++ b/PWAPPv2/Source/DataObjects/NumValPair.cs
@@ -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;
+ }
+ }
+}
diff --git a/PWAPPv2/Source/DataObjects/ReferFromBox.cs b/PWAPPv2/Source/DataObjects/ReferFromBox.cs
new file mode 100644
index 0000000..b0128ff
--- /dev/null
+++ b/PWAPPv2/Source/DataObjects/ReferFromBox.cs
@@ -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 DoctorName;
+ List DoctorID;
+ public ReferFromBox(ComboBox box, string data) : base(box)
+ {
+ this.Add("Choose Refer From");
+ DoctorName = new List();
+ DoctorID = new List();
+ 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
+ {
+
+ }
+}
diff --git a/PWAPPv2/Source/DataObjects/ReferToBox.cs b/PWAPPv2/Source/DataObjects/ReferToBox.cs
new file mode 100644
index 0000000..73c8d37
--- /dev/null
+++ b/PWAPPv2/Source/DataObjects/ReferToBox.cs
@@ -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 PractieID;
+ List ToName;
+ List DoctorID;
+
+ public ReferToBox(ComboBox box, string data) : base(box)
+ {
+ this.Add("Choose Refer To");
+ ToName = new List();
+ DoctorID = new List();
+ PractieID = new List();
+ 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
+ { }
+}
diff --git a/PWAPPv2/Source/DataObjects/Referral.cs b/PWAPPv2/Source/DataObjects/Referral.cs
new file mode 100644
index 0000000..1398690
--- /dev/null
+++ b/PWAPPv2/Source/DataObjects/Referral.cs
@@ -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
+ {
+
+ }
+ }
+}
diff --git a/PWAPPv2/Source/DataObjects/ReferralTypeBox.cs b/PWAPPv2/Source/DataObjects/ReferralTypeBox.cs
new file mode 100644
index 0000000..4d5b410
--- /dev/null
+++ b/PWAPPv2/Source/DataObjects/ReferralTypeBox.cs
@@ -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 TypeName;
+ List TypeID;
+ public ReferralTypeBox(ComboBox box, string data) : base(box)
+ {
+ this.Add("Choose Referral Type");
+ TypeName = new List();
+ TypeID = new List();
+ 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
+ { }
+
+}
diff --git a/PWAPPv2/Source/Database/DatabaseConfig.cs b/PWAPPv2/Source/Database/DatabaseConfig.cs
new file mode 100644
index 0000000..971b1a7
--- /dev/null
+++ b/PWAPPv2/Source/Database/DatabaseConfig.cs
@@ -0,0 +1,46 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Xml;
+
+namespace PWAPPv2.Source.Database
+{
+ class DatabaseConfig
+ {
+ public string host;
+ public string user;
+ public string password;
+ public string database;
+
+
+ public DatabaseConfig(string path)
+ {
+ XmlDocument cfg = new XmlDocument();
+ try
+ {
+ cfg.Load(path);
+ }
+ catch(XmlException)
+ {
+ Console.WriteLine("An error has occured parsing the config file.");
+ return;
+ }
+ catch(System.IO.FileNotFoundException)
+ {
+ Console.WriteLine("Config file could not be found!");
+ }
+
+ XmlNodeList XHost = cfg.GetElementsByTagName("ODhost");
+ XmlNodeList XUser = cfg.GetElementsByTagName("ODuser");
+ XmlNodeList XPassword = cfg.GetElementsByTagName("ODpassword");
+ XmlNodeList XDatabase = cfg.GetElementsByTagName("ODdatabase");
+
+ host = XHost[0].InnerText;
+ user = XUser[0].InnerText;
+ password = XPassword[0].InnerText;
+ database = XDatabase[0].InnerText;
+ }
+ }
+}
diff --git a/PWAPPv2/Source/Database/DatabaseConnection.cs b/PWAPPv2/Source/Database/DatabaseConnection.cs
new file mode 100644
index 0000000..3d26098
--- /dev/null
+++ b/PWAPPv2/Source/Database/DatabaseConnection.cs
@@ -0,0 +1,115 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using Microsoft.Data.SqlClient;
+using MySqlConnector;
+
+namespace PWAPPv2.Source.Database
+{
+ class DatabaseConnection
+ {
+
+ private MySqlConnection Connection;
+ private string SqlString;
+ DatabaseConfig Config;
+
+ public DatabaseConnection(DatabaseConfig config)
+ {
+ Config = config;
+ SqlString = "server=" + config.host + ";Uid=" + config.user + ";database=" + config.database + ";Pwd=" + config.password;
+ Connection = new MySqlConnection(SqlString);
+ }
+
+ public void Connect()
+ {
+ try
+ {
+ Connection.Open();
+ }
+ catch(Exception)
+ {
+ throw new DatabaseConnectionException();
+ }
+ }
+
+ public List QueryDatabase(string query)
+ {
+ try
+ {
+ Connection.Open();
+ }
+ catch (Exception)
+ {
+ throw new CouldNotOpenConnectionException();
+ }
+
+ MySqlCommand Command = new MySqlCommand(query, Connection);
+ MySqlDataReader reader;
+ try
+ {
+ reader = Command.ExecuteReader();
+ }
+ catch (Exception)
+ {
+ Connection.Close();
+ throw new ReaderException();
+ }
+ List result = new List();
+
+
+ while (reader.Read())
+ {
+ int n = reader.VisibleFieldCount;
+ for (int i = 0; i < reader.VisibleFieldCount; i++)
+ {
+ var type = reader.GetFieldType(i);
+ if (type.Name == "Int64")
+ {
+ result.Add(reader.GetInt64(i).ToString());
+ }
+ if (type.Name == "Int32")
+ {
+ result.Add(reader.GetInt32(i).ToString());
+ }
+ if (type.Name == "String")
+ {
+ result.Add(reader.GetString(i));
+
+ }
+ if (type.Name == "Byte")
+ {
+ result.Add(reader.GetByte(i).ToString());
+ }
+ if (type.Name == "DateTime")
+ {
+ result.Add(reader.GetDateTime(i).ToString());
+ }
+ }
+ }
+ Connection.Close();
+
+ return result;
+ }
+
+ }
+
+ class DatabaseConfigurationException : Exception
+ {
+
+ }
+
+ class DatabaseConnectionException : Exception
+ { }
+
+ class CouldNotOpenConnectionException : Exception
+ {
+
+ }
+
+ class ReaderException : Exception
+ {
+
+ }
+}
diff --git a/PWAPPv2/Source/Patient.cs b/PWAPPv2/Source/Patient.cs
index 326858b..c46a0da 100644
--- a/PWAPPv2/Source/Patient.cs
+++ b/PWAPPv2/Source/Patient.cs
@@ -8,13 +8,48 @@ namespace PWAPPv2.Source
{
class Patient
{
+ public string PatNum;
+
public string FName;
public string MName;
public string LName;
+ public string Gender;
public string DoB;
+ public string SSN;
public string Address;
+ public string Address2;
public string City;
public string State;
public string Zip;
+
+ public string HomePhone;
+ public string WorkPhone;
+ public string WirelessPhone;
+ public string Email;
+
+
+ public void BuildFromDatabase(Database.DatabaseConnection databaseConnection, string patNum)
+ {
+ List result = databaseConnection.QueryDatabase("SELECT PatNum, LName, FName, MiddleI, Gender, Birthdate," +
+ "SSN, Address, Address2, City, State, Zip, HmPhone, WkPhone, WirelessPhone, Email FROM patient WHERE PatNum = " + patNum);
+ PatNum = result[0];
+ LName = result[1];
+ FName = result[2];
+ MName = result[3];
+ Gender = result[4];
+ DoB = result[5];
+ SSN = result[6];
+ Address = result[7];
+ Address2 = result[8];
+ City = result[9];
+ State = result[10];
+ Zip = result[11];
+ HomePhone = result[12];
+ WorkPhone = result[13];
+ WirelessPhone = result[14];
+ Email = result[15];
+ }
+
+
}
}
diff --git a/PWAPPv2/Source/PatientGUIAdapter.cs b/PWAPPv2/Source/PatientGUIAdapter.cs
index 0a3969e..aa6e5cc 100644
--- a/PWAPPv2/Source/PatientGUIAdapter.cs
+++ b/PWAPPv2/Source/PatientGUIAdapter.cs
@@ -17,6 +17,10 @@ namespace PWAPPv2.Source
public string txtCity { get { return p.City; } }
public string txtState { get { return p.State; } }
public string txtZip { get { return p.Zip; } }
+ public string txtHomePhone { get { return p.HomePhone; } }
+ public string txtWorkPhone { get { return p.WorkPhone; } }
+ public string txtWirelessPhone { get { return p.WirelessPhone; } }
+ public string txtEmail { get { return p.Email; } }
public PatientGUIAdapter(Patient patient)
{
diff --git a/PWAPPv2/packages.config b/PWAPPv2/packages.config
new file mode 100644
index 0000000..9b70386
--- /dev/null
+++ b/PWAPPv2/packages.config
@@ -0,0 +1,48 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file