159 lines
4.4 KiB
C#
159 lines
4.4 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using System.Windows;
|
|
using System.Windows.Controls;
|
|
using System.Windows.Data;
|
|
using System.Windows.Documents;
|
|
using System.Windows.Input;
|
|
using System.Windows.Media;
|
|
using System.Windows.Media.Imaging;
|
|
using System.Windows.Navigation;
|
|
using System.Windows.Shapes;
|
|
|
|
/**
|
|
* TODO:
|
|
* * ADD API SUPPORT
|
|
*/
|
|
|
|
namespace PWAPPv2
|
|
{
|
|
/// <summary>
|
|
/// Interaction logic for MainWindow.xaml
|
|
/// </summary>
|
|
public partial class MainWindow : Window
|
|
{
|
|
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();
|
|
|
|
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)
|
|
{
|
|
|
|
}
|
|
|
|
private void DataGrid_SelectionChanged(object sender, SelectionChangedEventArgs e)
|
|
{
|
|
|
|
}
|
|
|
|
private void CheckBox_Checked(object sender, RoutedEventArgs e)
|
|
{
|
|
|
|
}
|
|
|
|
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)
|
|
{
|
|
|
|
}
|
|
}
|
|
}
|
|
}
|