public bool SavePatient()
 {
     if (formView.FormAction == 0)
     {
         if (BeforeSaveEvent != null)
         {
             BeforeSaveEventArgs e = new BeforeSaveEventArgs( );
             BeforeSaveEvent(this, e);
             if (e.Cancel)
             {
                 return(false);
             }
         }
         //新增病人
         OutPatient outpatient = new OutPatient( );
         outpatient.NewRegister( );
         int    patlistId = outpatient.PatListID;
         string visitno   = outpatient.VisitNo;
         outpatient           = PatientConvert.ConvertPatient((UIOutPatient)formView.Patient);
         outpatient.PatListID = patlistId;
         outpatient.VisitNo   = visitno;
         outpatient.UpdateRegister( );
         formView.Patient = PatientConvert.ConvertPatient(outpatient);
     }
     return(true);
 }
        /// <summary>
        /// 查找病人
        /// </summary>
        /// <param name="searchMode">查找模式</param>
        /// <param name="keyWord">检索关键字</param>
        public void SearchPatient(SearchPatientMode searchMode, string keyWord)
        {
            //在此调用业务逻辑层的方法查找到业务病人对象
            OutPatient patient = new OutPatient( );

            //TODO:
            switch (searchMode)
            {
            case SearchPatientMode.门诊就诊号:
                patient = new OutPatient(keyWord);
                break;

            //case SearchPatientMode.挂号收据号:
            //    patient = new OutPatient( keyWord , OPDBillKind.门诊挂号发票 );
            //    break;
            //case SearchPatientMode.收费发票号:
            //    patient = new OutPatient( keyWord , OPDBillKind.门诊收费发票 );
            //    break;
            default:
                patient = new OutPatient( );
                break;
            }
            formView.Patient = PatientConvert.ConvertPatient(patient);
            if (patient.CureEmpCode.Trim( ) != "")
            {
                formView.PrescDoctorId = Convert.ToInt32(patient.CureEmpCode);
            }
            if (patient.CureDeptCode.Trim( ) != "")
            {
                formView.DoctorDeptId = Convert.ToInt32(patient.CureDeptCode);
            }
        }
 public bool SelectedPateint()
 {
     if (formView.SelectedPatientId != 0)
     {
         OutPatient   patient1 = new OutPatient(formView.SelectedPatientId);
         UIOutPatient patient2 = PatientConvert.ConvertPatient(patient1);
         SetPatient(patient2);
         return(true);
     }
     else
     {
         return(false);
     }
 }
        /// <summary>
        /// 预算
        /// </summary>
        public void Budget()
        {
            OutPatient patient = PatientConvert.ConvertPatient((UIOutPatient)formView.Patient);

            Prescription[] prescriptions = GetPrescriptionsFromDataTable();

            List <Prescription> lstPrescription = new List <Prescription>( );

            for (int i = 0; i < prescriptions.Length; i++)
            {
                if (prescriptions[i].Selected)
                {
                    lstPrescription.Add(prescriptions[i]);
                }
            }
            prescriptions = lstPrescription.ToArray( );

            HIS.MZ_BLL.ChargeControl chargeController = new ChargeControl(patient, formView.CurrentEmployeeId);

            AfterBudgetEndArgs e = new AfterBudgetEndArgs( );

            e.ChargeController = chargeController;
            try
            {
                ChargeInfo[] chargeInfos = chargeController.Budget(prescriptions);
                e.BudgetInfos = chargeInfos;
                ChargeInfo chargeInfo = new ChargeInfo( );
                for (int i = 0; i < chargeInfos.Length; i++)
                {
                    chargeInfo.TotalFee   += chargeInfos[i].TotalFee;
                    chargeInfo.FavorFee   += chargeInfos[i].FavorFee;
                    chargeInfo.SelfFee    += chargeInfos[i].SelfFee;
                    chargeInfo.VillageFee += chargeInfos[i].VillageFee;
                }
                e.TotalBugetInfo = chargeInfo;
                e.Prescriptions  = prescriptions;
                e.Success        = true;
            }
            catch (Exception err)
            {
                e.Success = false;
                e.Message = err.Message;
            }

            if (AfterBudgetEndEvent != null)
            {
                AfterBudgetEndEvent(this, e);
            }
        }
        /// <summary>
        /// 保存处方
        /// </summary>
        public bool SavePrescription()
        {
            DataTable tbPresc = formView.Prescriptions;

            if (tbPresc.Rows.Count == 0)
            {
                return(false);
            }

            if (BeforeSavePrescriptionEvent != null)
            {
                BeforeSaveEventArgs be = new BeforeSaveEventArgs( );
                BeforeSavePrescriptionEvent(this, be);

                if (be.Cancel == true)
                {
                    return(false);
                }
            }

            OutPatient patient = PatientConvert.ConvertPatient((UIOutPatient)formView.Patient);
            DataTable  tbAmbit = GetPrescriptionAmbitList( );

            Prescription[]      prescriptions = GetPrescriptionsFromDataTable();
            AfterSavedEventArgs e             = new AfterSavedEventArgs( );

            try
            {
                bool success = prescController.SavePrescription(patient, prescriptions);
                if (success)
                {
                    FillPrescData(prescriptions, tbPresc);
                }
            }
            catch (Exception err)
            {
                e.Cancel  = true;
                e.Message = err.Message;
                return(false);
            }


            if (AfterSavedEvent != null)
            {
                AfterSavedEvent(this, e);
            }

            return(true);
        }
        /// <summary>
        /// 读取病人未收费的处方
        /// </summary>
        public void ReadPatientNotBalancePrescription(bool afterBalance)
        {
            OutPatient patient = PatientConvert.ConvertPatient((UIOutPatient)formView.Patient);

            Prescription[] prescriptions = patient.GetPrescriptions(PresStatus.未收费, true);
            for (int i = 0; i < prescriptions.Length; i++)
            {
                prescriptions[i].Selected = true;
            }

            DataTable tbPresc = formView.Prescriptions;

            tbPresc.Rows.Clear( );

            FillPrescData(prescriptions, tbPresc);

            CalculateAllPrescriptionFee( );

            AfterReadPatientPrescriptionArgs e = new AfterReadPatientPrescriptionArgs();

            e.PrescCount = GetPrescriptionAmbitList( ).Rows.Count;
            if (tbPresc.Select(COL_DOC_PRESDETAIL_ID + " <> 0").Length > 0)
            {
                e.HasDoctorPresc = true;
            }
            else
            {
                e.HasDoctorPresc = false;
            }

            e.AfterBalance = afterBalance;

            if (AfterReadPatientPrescription != null)
            {
                AfterReadPatientPrescription(this, e);
            }
        }