private company_contact_info FindContactInfo(string addressField, int companyId, string phoneNum)
        {
            try
            {
                company_contact_info toReturn = new company_contact_info();
                string trimmedAddress         = CommonFunctions.TrimSpaces(addressField);

                toReturn.address = trimmedAddress;
                toReturn.phone   = phoneNum;

                DataTable results = toReturn.Search("SELECT * FROM company_contact_info WHERE company_id = " + companyId +
                                                    " AND address = '" + trimmedAddress + "' AND phone = '" + phoneNum + "'");
                if (results.Rows.Count > 0)
                {
                    toReturn.Load(results.Rows[0]);
                }

                toReturn.address = trimmedAddress;
                return(toReturn);
            }
            catch (Exception err)
            {
                // Somewhat dangerous, but it ensures that the import won't crash
                LoggingHelper.Log("Error in frmImportData.FindContactInfo", LogSeverity.Critical, err, true);
                return(null);
            }
        }
        internal List <company_contact_info> GetLinkedAddresses()
        {
            List <company_contact_info> toReturn = new List <company_contact_info>();
            company_contact_info        workingInfo;
            DataTable matches = Search("SELECT * FROM company_contact_info WHERE company_id = " + id);

            foreach (DataRow anInfo in matches.Rows)
            {
                workingInfo = new company_contact_info();
                workingInfo.Load(anInfo);
                toReturn.Add(workingInfo);
            }

            return(toReturn);
        }
        internal company_contact_info GetFirstContactInfo()
        {
            DataTable results = Search("SELECT * FROM company_contact_info WHERE company_id = " + id +
                                       " ORDER BY order_id");

            if (results.Rows.Count > 0)
            {
                company_contact_info toReturn = new company_contact_info();
                toReturn.Load(results.Rows[0]);

                return(toReturn);
            }
            else
            {
                return(null);
            }
        }
Esempio n. 4
0
        private bool Save()
        {
            if (ValidateForm())
            {
                try
                {
                    claim toSave;

                    if (_editMode == EditModes.Edit)
                    {
                        toSave = _claimsList[_currentIndex];
                    }
                    else
                    {
                        toSave = new claim();

                        toSave.created_on = DateTime.Now;
                        toSave.created_by = ActiveUser.UserObject.username;

                        _editMode = EditModes.Edit;

                        _claimsList.Add(toSave);
                        _currentIndex = _claimsList.Count - 1;
                    }

                    #region Field Assignments

                    // Services
                    SaveWithCheckForChange(ref toSave, "amount_of_claim", nmbClaimAmount.Value * 100);



                    // Insurance
                    if (cmbInsuranceCarrier.SelectedIndex >= 0)
                    {
                        int newID = ((company)cmbInsuranceCarrier.SelectedItem).id;
                        int oldID = toSave.company_id;
                        if (toSave.company_id != newID)
                        {
                            AddChange(toSave.id, "company", toSave.LinkedCompany.name, new company(newID).name);
                            toSave.company_id = newID;
                        }

                        if (toSave.company_address_id != _currentContactInfo.order_id)
                        {
                            company_contact_info oldInfo = new company_contact_info();
                            company_contact_info newInfo = new company_contact_info();
                            oldInfo.Load(new int[] { oldID, toSave.company_address_id });
                            newInfo.Load(new int[] { newID, _currentContactInfo.order_id });

                            AddChange(toSave.id, "company_address", oldInfo.address, newInfo.address);
                            toSave.company_address_id = _currentContactInfo.order_id;
                        }
                    }

                    // Patient


                    // name has to be handled in a special way
                    if (toSave.PatientName != txtPatientName.Text)
                    {
                        AddChange(toSave.id, "patient_name", toSave.PatientName, txtPatientName.Text);
                        toSave.PatientName = txtPatientName.Text;
                    }

                    SaveWithCheckForChangeSpecialDateTime(ref toSave, "patient_dob", ctlPatientDOB.CurrentDate);
                    SaveWithCheckForChange(ref toSave, "patient_ssn", txtPatientSSN.Text.Replace("-", ""));
                    SaveWithCheckForChange(ref toSave, "patient_address", txtPatientAddress.Text);
                    SaveWithCheckForChange(ref toSave, "patient_address2", txtPatientAddress2.Text);
                    SaveWithCheckForChange(ref toSave, "patient_city", txtPatientCity.Text);
                    SaveWithCheckForChange(ref toSave, "patient_state", txtPatientState.Text);
                    SaveWithCheckForChange(ref toSave, "patient_zip", txtPatientZIP.Text);

                    // Doctor
                    // name has to be handled in a special way
                    if (toSave.DoctorName != txtDoctorName.Text)
                    {
                        AddChange(toSave.id, "doctor_name", toSave.DoctorName, txtDoctorName.Text);
                        toSave.DoctorName = txtDoctorName.Text;
                    }

                    SaveWithCheckForChange(ref toSave, "doctor_tax_number", txtDoctorTaxID.Text);
                    SaveWithCheckForChange(ref toSave, "doctor_license_number", txtDoctorLicenseID.Text);
                    SaveWithCheckForChange(ref toSave, "doctor_bcbs_number", txtDoctorBC.Text);

                    // phone has to be handled in a special way
                    PhoneObject newDoctorPhone = new PhoneObject(txtDoctorPhone.Text);
                    if (toSave.doctor_phone_number_object.FormattedPhone != newDoctorPhone.FormattedPhone)
                    {
                        AddChange(toSave.id, "doctor_phone_number", toSave.doctor_phone_number_object.FormattedPhone,
                                  newDoctorPhone.FormattedPhone);
                        toSave.doctor_phone_number_object = newDoctorPhone;
                    }
                    // phone has to be handled in a special way
                    PhoneObject newDoctorFax = new PhoneObject(txtDoctorFax.Text);
                    if (toSave.doctor_fax_number_object.FormattedPhone != newDoctorFax.FormattedPhone)
                    {
                        AddChange(toSave.id, "doctor_fax_number", toSave.doctor_fax_number_object.FormattedPhone,
                                  newDoctorFax.FormattedPhone);
                        toSave.doctor_fax_number_object = newDoctorFax;
                    }

                    SaveWithCheckForChange(ref toSave, "doctor_address", txtDoctorAddress.Text);
                    SaveWithCheckForChange(ref toSave, "doctor_address2", txtDoctorAddress2.Text);
                    SaveWithCheckForChange(ref toSave, "doctor_city", txtDoctorCity.Text);
                    SaveWithCheckForChange(ref toSave, "doctor_state", txtDoctorState.Text);
                    SaveWithCheckForChange(ref toSave, "doctor_zip", txtDoctorZIP.Text);

                    // Subscriber

                    // Need special code for name
                    if (toSave.SubscriberName != txtSubscriberName.Text)
                    {
                        AddChange(toSave.id, "subscriber_name", toSave.SubscriberName, txtSubscriberName.Text);
                        toSave.SubscriberName = txtSubscriberName.Text;
                    }

                    SaveWithCheckForChangeSpecialDateTime(ref toSave, "subscriber_dob", ctlSubscriberDOB.CurrentDate);
                    SaveWithCheckForChange(ref toSave, "subscriber_number", txtSubscriberID.Text);
                    SaveWithCheckForChange(ref toSave, "subscriber_alternate_number", txtSubscriberAltID.Text);
                    SaveWithCheckForChange(ref toSave, "subscriber_ssn", txtSubscriberSSN.Text.Replace("-", ""));
                    SaveWithCheckForChange(ref toSave, "subscriber_group_name", txtSubscriberGroupName.Text);
                    SaveWithCheckForChange(ref toSave, "subscriber_group_number", txtSubscriberGroupNum.Text);
                    SaveWithCheckForChange(ref toSave, "subscriber_address", txtSubscriberAddress.Text);
                    SaveWithCheckForChange(ref toSave, "subscriber_address2", txtSubscriberAddress2.Text);
                    SaveWithCheckForChange(ref toSave, "subscriber_city", txtSubscriberCity.Text);
                    SaveWithCheckForChange(ref toSave, "subscriber_state", txtSubscriberState.Text);
                    SaveWithCheckForChange(ref toSave, "subscriber_zip", txtSubscriberZIP.Text);

                    // General
                    SaveWithCheckForChangeSpecialDateTime(ref toSave, "sent_date", ctlSentDate.CurrentDate);
                    SaveWithCheckForChangeSpecialDateTime(ref toSave, "resent_date", ctlResentDate.CurrentDate);
                    SaveWithCheckForChangeSpecialDateTime(ref toSave, "on_hold_date", ctlOnHoldDate.CurrentDate);
                    SaveWithCheckForChangeSpecialDateTime(ref toSave, "tracer_date", ctlTracerDate.CurrentDate);

                    // Notes / Open
                    SaveWithCheckForChange(ref toSave, "notes", txtNotes.Text);

                    // Special for boolean
                    if (toSave.open != System.Convert.ToInt32(!chkClosed.Checked))
                    {
                        AddChange(toSave.id, "open", !chkClosed.Checked, chkClosed.Checked);
                        toSave.open = System.Convert.ToInt32(!chkClosed.Checked);
                    }

                    toSave.handling = cmbHandling.Text;

                    #endregion



                    toSave.Save();

                    SaveRevisitDate();
                    _changed = false;
                    if (toSave.LinkedChanges.Count > 0)
                    {
                        lnkViewClaimChangeHistory.Visible = true;
                    }

                    choice choice = new choice();
                    call   call   = new call();

                    return(true);
                }
                catch (Exception err)
                {
                    MessageBox.Show(this, "An unexpected error occurred attempting to save this claim. Please report " +
                                    "this error to an administrator:\n\n" + err.Message, "Unexpected Error in Save Routine", MessageBoxButtons.OK,
                                    MessageBoxIcon.Error);
                    return(false);
                }
            }
            else
            {
                return(false);
            }
        }