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

View File

@@ -25,27 +25,76 @@ namespace PWAPPv2
/// </summary>
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)
{
}
}
}
}