92 lines
3.3 KiB
C#
92 lines
3.3 KiB
C#
using System;
|
|
using System.Windows;
|
|
using System.Windows.Controls;
|
|
using System.Windows.Documents;
|
|
|
|
namespace PWAPPv2.Source.DataObjects
|
|
{
|
|
class Referral
|
|
{
|
|
APICredentials ApiCredentials;
|
|
Patient PatientData;
|
|
ReferToBox ReferTo;
|
|
ReferFromBox ReferFrom;
|
|
ReferralTypeBox ReferralType;
|
|
|
|
RichTextBox RemarksBox;
|
|
CheckBox ContactBox;
|
|
|
|
bool Attachments;
|
|
|
|
public Referral(APICredentials apiCredentials, Patient patient, ReferralTypeBox referralType, ReferToBox referTo, ReferFromBox referFrom, RichTextBox remarksBox, CheckBox contactBox, bool attachments)
|
|
{
|
|
ApiCredentials = apiCredentials;
|
|
PatientData = patient;
|
|
ReferralType = referralType;
|
|
ReferTo = referTo;
|
|
ReferFrom = referFrom;
|
|
RemarksBox = remarksBox;
|
|
ContactBox = contactBox;
|
|
Attachments = attachments;
|
|
}
|
|
|
|
public string ToJsonString()
|
|
{
|
|
|
|
string RemarksText = new TextRange(RemarksBox.Document.ContentStart, RemarksBox.Document.ContentEnd).Text;
|
|
|
|
int contact = 0;
|
|
if (ContactBox.IsChecked == true)
|
|
{
|
|
contact = 1;
|
|
}
|
|
|
|
string attachmentsText = "False";
|
|
if (Attachments)
|
|
attachmentsText = "True";
|
|
|
|
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':'" + attachmentsText + "'," +
|
|
"'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
|
|
{
|
|
|
|
}
|
|
}
|
|
}
|