Пример #1
0
		private void ToolButIns_Click(){
			DialogResult result=MessageBox.Show(Lan.g(this,"Is this patient the subscriber?"),"",MessageBoxButtons.YesNoCancel);
			if(result==DialogResult.Cancel){
				return;
			}
			//Pick a subscriber------------------------------------------------------------------------------------------------
			Patient subscriber;
			if(result==DialogResult.Yes){//current patient is subscriber
				subscriber=PatCur.Copy();
			}
			else{//patient is not subscriber
				//show list of patients in this family
				FormSubscriberSelect FormS=new FormSubscriberSelect(FamCur);
				FormS.ShowDialog();
				if(FormS.DialogResult==DialogResult.Cancel){
					return;
				}
				subscriber=Patients.GetPat(FormS.SelectedPatNum);
			}
			//Subscriber has been chosen. Now, pick a plan-------------------------------------------------------------------
			InsPlan plan=null;
			InsSub sub=null;
			bool planIsNew=false;
			List<InsSub> subList=InsSubs.GetListForSubscriber(subscriber.PatNum);
			if(subList.Count==0){
				planIsNew=true;
			}
			else{
				FormInsSelectSubscr FormISS=new FormInsSelectSubscr(subscriber.PatNum);
				FormISS.ShowDialog();
				if(FormISS.DialogResult==DialogResult.Cancel) {
					return;
				}
				if(FormISS.SelectedInsSubNum==0){//'New' option selected.
					planIsNew=true;
				}
				else{
					sub=InsSubs.GetSub(FormISS.SelectedInsSubNum,subList);
					plan=InsPlans.GetPlan(sub.PlanNum,new List<InsPlan>());
				}
			}
			//New plan was selected instead of an existing plan.  Create the plan--------------------------------------------
			if(planIsNew){
				plan=new InsPlan();
				plan.EmployerNum=subscriber.EmployerNum;
				plan.PlanType="";
				InsPlans.Insert(plan);
				sub=new InsSub();
				sub.PlanNum=plan.PlanNum;
				sub.Subscriber=subscriber.PatNum;
				if(subscriber.MedicaidID==""){
					sub.SubscriberID=subscriber.SSN;
				}
				else{
					sub.SubscriberID=subscriber.MedicaidID;
				}
				sub.ReleaseInfo=true;
				sub.AssignBen=true;
				InsSubs.Insert(sub);
				Benefit ben;
				for(int i=0;i<CovCatC.ListShort.Count;i++){
					if(CovCatC.ListShort[i].DefaultPercent==-1){
						continue;
					}
					ben=new Benefit();
					ben.BenefitType=InsBenefitType.CoInsurance;
					ben.CovCatNum=CovCatC.ListShort[i].CovCatNum;
					ben.PlanNum=plan.PlanNum;
					ben.Percent=CovCatC.ListShort[i].DefaultPercent;
					ben.TimePeriod=BenefitTimePeriod.CalendarYear;
					ben.CodeNum=0;
					Benefits.Insert(ben);
				}
				//Zero deductible diagnostic
				if(CovCats.GetForEbenCat(EbenefitCategory.Diagnostic)!=null) {
					ben=new Benefit();
					ben.CodeNum=0;
					ben.BenefitType=InsBenefitType.Deductible;
					ben.CovCatNum=CovCats.GetForEbenCat(EbenefitCategory.Diagnostic).CovCatNum;
					ben.PlanNum=plan.PlanNum;
					ben.TimePeriod=BenefitTimePeriod.CalendarYear;
					ben.MonetaryAmt=0;
					ben.Percent=-1;
					ben.CoverageLevel=BenefitCoverageLevel.Individual;
					Benefits.Insert(ben);
				}
				//Zero deductible preventive
				if(CovCats.GetForEbenCat(EbenefitCategory.RoutinePreventive)!=null) {
					ben=new Benefit();
					ben.CodeNum=0;
					ben.BenefitType=InsBenefitType.Deductible;
					ben.CovCatNum=CovCats.GetForEbenCat(EbenefitCategory.RoutinePreventive).CovCatNum;
					ben.PlanNum=plan.PlanNum;
					ben.TimePeriod=BenefitTimePeriod.CalendarYear;
					ben.MonetaryAmt=0;
					ben.Percent=-1;
					ben.CoverageLevel=BenefitCoverageLevel.Individual;
					Benefits.Insert(ben);
				}
			}
			//Then attach plan------------------------------------------------------------------------------------------------
			PatPlan patplan=new PatPlan();
			patplan.Ordinal=(byte)(PatPlanList.Count+1);//so the ordinal of the first entry will be 1, NOT 0.
			patplan.PatNum=PatCur.PatNum;
			patplan.InsSubNum=sub.InsSubNum;
			patplan.Relationship=Relat.Self;
			PatPlans.Insert(patplan);
			//Then, display insPlanEdit to user-------------------------------------------------------------------------------
			FormInsPlan FormI=new FormInsPlan(plan,patplan,sub);
			FormI.IsNewPlan=planIsNew;
			FormI.IsNewPatPlan=true;
			FormI.ShowDialog();//this updates estimates also.
			//if cancel, then patplan is deleted from within that dialog.
			//if cancel, and planIsNew, then plan and benefits are also deleted.
			ModuleSelected(PatCur.PatNum);
		}
Пример #2
0
		private void gridMain_CellDoubleClick(object sender,ODGridClickEventArgs e) {
			if(e.Col!=3) {
				return;
			}
			if(Rows[e.Row].IsSeparator) {
				return;
			}
			if(!IsEditable(Rows[e.Row])){
				return;
			}
			if(Rows[e.Row].FieldName=="referredFrom") {
				FormReferralSelect formRS=new FormReferralSelect();
				formRS.IsSelectionMode=true;
				formRS.ShowDialog();
				if(formRS.DialogResult!=DialogResult.OK) {
					return;
				}
				Referral referralSelected=formRS.SelectedReferral;
				Rows[e.Row].DoImport=true;
				Rows[e.Row].IsFlaggedImp=false;
				Rows[e.Row].ImpValDisplay=referralSelected.GetNameFL();
				Rows[e.Row].ImpValObj=referralSelected;
			}
			#region string
			else if(Rows[e.Row].ObjType==typeof(string)) {
				InputBox inputbox=new InputBox(Rows[e.Row].FieldName);
				inputbox.textResult.Text=Rows[e.Row].ImpValDisplay;
				inputbox.ShowDialog();
				if(inputbox.DialogResult!=DialogResult.OK) {
					return;
				}
				if(Rows[e.Row].FieldName=="addressAndHmPhoneIsSameEntireFamily") {
					if(inputbox.textResult.Text=="") {
						AddressSameForFam=false;
					}
					else if(inputbox.textResult.Text!="X") {
						AddressSameForFam=true;
					}
					else {
						MsgBox.Show(this,"The only allowed values are X or blank.");
						return;
					}
				}
				if(Rows[e.Row].OldValDisplay==inputbox.textResult.Text) {//value is now same as original
					Rows[e.Row].DoImport=false;
				}
				else {
					Rows[e.Row].DoImport=true;
				}
				Rows[e.Row].ImpValDisplay=inputbox.textResult.Text;
				Rows[e.Row].ImpValObj=inputbox.textResult.Text;
			}
			#endregion
			#region Enum
			else if(Rows[e.Row].ObjType.IsEnum) {
				//Note.  This only works for zero-indexed enums.
				FormSheetImportEnumPicker formEnum=new FormSheetImportEnumPicker(Rows[e.Row].FieldName);
				for(int i=0;i<Enum.GetNames(Rows[e.Row].ObjType).Length;i++) {
					formEnum.listResult.Items.Add(Enum.GetNames(Rows[e.Row].ObjType)[i]);
					if(Rows[e.Row].ImpValObj!=null && i==(int)Rows[e.Row].ImpValObj) {
						formEnum.listResult.SelectedIndex=i;
					}
				}
				formEnum.ShowDialog();
				if(formEnum.DialogResult==DialogResult.OK) {
					int selectedI=formEnum.listResult.SelectedIndex;
					if(Rows[e.Row].ImpValObj==null) {//was initially null
						if(selectedI!=-1) {//an item was selected
							Rows[e.Row].ImpValObj=Enum.ToObject(Rows[e.Row].ObjType,selectedI);
							Rows[e.Row].ImpValDisplay=Rows[e.Row].ImpValObj.ToString();
						}
					}
					else {//was not initially null
						if((int)Rows[e.Row].ImpValObj!=selectedI) {//value was changed.
							//There's no way for the user to set it to null, so we do not need to test that
							Rows[e.Row].ImpValObj=Enum.ToObject(Rows[e.Row].ObjType,selectedI);
							Rows[e.Row].ImpValDisplay=Rows[e.Row].ImpValObj.ToString();
						}
					}
					if(selectedI==-1) {
						Rows[e.Row].DoImport=false;//impossible to import a null
					}
					else if(Rows[e.Row].OldValObj!=null && (int)Rows[e.Row].ImpValObj==(int)Rows[e.Row].OldValObj) {//it's the old setting for the patient, whether or not they actually changed it.
						Rows[e.Row].DoImport=false;//so no need to import
					}
					else {
						Rows[e.Row].DoImport=true;
					}
				}
			}
			#endregion
			#region DateTime
			else if(Rows[e.Row].ObjType==typeof(DateTime)) {//this is only for one field so far: Birthdate
				InputBox inputbox=new InputBox(Rows[e.Row].FieldName);
				inputbox.textResult.Text=Rows[e.Row].ImpValDisplay;
				inputbox.ShowDialog();
				if(inputbox.DialogResult!=DialogResult.OK) {
					return;
				}
				DateTime enteredDate;
				if(inputbox.textResult.Text=="") {
					enteredDate=DateTime.MinValue;
					Rows[e.Row].ImpValObj=enteredDate;
					Rows[e.Row].ImpValDisplay="";
				}
				else {
					try {
						enteredDate=DateTime.Parse(inputbox.textResult.Text);
					}
					catch {
						MsgBox.Show(this,"Invalid date");
						return;
					}
					if(enteredDate.Year<1880 || enteredDate.Year>2050) {
						MsgBox.Show(this,"Invalid date");
						return;
					}
					Rows[e.Row].ImpValObj=enteredDate;
					Rows[e.Row].ImpValDisplay=enteredDate.ToShortDateString();
				}
				if(Rows[e.Row].ImpValDisplay==Rows[e.Row].OldValDisplay) {//value is now same as original
					Rows[e.Row].DoImport=false;
				}
				else {
					Rows[e.Row].DoImport=true;
				}
			}
			#endregion
			#region Medication, Allergy or Disease
			else if(Rows[e.Row].ObjType==typeof(MedicationPat)
				|| Rows[e.Row].ObjType==typeof(Allergy)
				|| Rows[e.Row].ObjType==typeof(Disease)) 
			{
				//User entered medications will have a MedicationNum as the ImpValObj.
				if(Rows[e.Row].ImpValObj.GetType()==typeof(long)) {
					FormMedications FormM=new FormMedications();
					FormM.IsSelectionMode=true;
					FormM.textSearch.Text=Rows[e.Row].FieldName;
					FormM.ShowDialog();
					if(FormM.DialogResult!=DialogResult.OK) {
						return;
					}
					Rows[e.Row].ImpValDisplay="Y";
					Rows[e.Row].ImpValObj=FormM.SelectedMedicationNum;
					string descript=Medications.GetDescription(FormM.SelectedMedicationNum);
					Rows[e.Row].FieldDisplay=descript;
					((SheetField)Rows[e.Row].NewValObj).FieldValue=descript;
					Rows[e.Row].NewValDisplay="Y";
					Rows[e.Row].DoImport=true;
					Rows[e.Row].IsFlaggedImp=false;
				}
				else {
					FormSheetImportEnumPicker FormIEP=new FormSheetImportEnumPicker(Rows[e.Row].FieldName);
					for(int i=0;i<Enum.GetNames(typeof(YN)).Length;i++) {
						FormIEP.listResult.Items.Add(Enum.GetNames(typeof(YN))[i]);
					}
					FormIEP.listResult.SelectedIndex=0;//Unknown
					if(Rows[e.Row].ImpValDisplay=="Y") {
						FormIEP.listResult.SelectedIndex=1;
					}
					if(Rows[e.Row].ImpValDisplay=="N") {
						FormIEP.listResult.SelectedIndex=2;
					}
					FormIEP.ShowDialog();
					if(FormIEP.DialogResult!=DialogResult.OK) {
						return;
					}
					int selectedI=FormIEP.listResult.SelectedIndex;
					switch(selectedI) {
						case 0:
							Rows[e.Row].ImpValDisplay="";
							break;
						case 1:
							Rows[e.Row].ImpValDisplay="Y";
							break;
						case 2:
							Rows[e.Row].ImpValDisplay="N";
							break;
					}
					if(Rows[e.Row].OldValDisplay==Rows[e.Row].ImpValDisplay) {//value is now same as original
						Rows[e.Row].DoImport=false;
					}
					else {
						Rows[e.Row].DoImport=true;
					}
					if(selectedI==-1 || selectedI==0) {
						Rows[e.Row].DoImport=false;
					}
				}
			}
			#endregion
			#region Subscriber
			else if(Rows[e.Row].ObjType==typeof(Patient)) {
				Patient subscriber=new Patient();
				FormSubscriberSelect FormSS=new FormSubscriberSelect(Fam);
				FormSS.ShowDialog();
				if(FormSS.DialogResult!=DialogResult.OK) {
					return;
				}
				subscriber=Patients.GetPat(FormSS.SelectedPatNum);
				if(subscriber==null) {
					return;//Should never happen but is a possibility.
				}
				//Use GetNameFirst() because this is how OldValDisplay is displayed.
				string patName=Patients.GetNameFirst(subscriber.FName,subscriber.Preferred);
				if(Rows[e.Row].OldValDisplay==patName) {
					Rows[e.Row].DoImport=false;
				}
				else {
					Rows[e.Row].DoImport=true;
				}
				Rows[e.Row].ImpValDisplay=patName;
				Rows[e.Row].ImpValObj=subscriber;
			}
			#endregion
			#region Carrier
			else if(Rows[e.Row].ObjType==typeof(Carrier)) {
				//Change both carrier rows at the same time.
				string insStr="ins1";
				if(Rows[e.Row].FieldName.StartsWith("ins2")) {
					insStr="ins2";
				}
				SheetImportRow carrierNameRow=GetImportRowByFieldName(insStr+"CarrierName");
				SheetImportRow carrierPhoneRow=GetImportRowByFieldName(insStr+"CarrierPhone");
				Carrier carrier=new Carrier();
				FormCarriers FormC=new FormCarriers();
				FormC.IsSelectMode=true;
				if(carrierNameRow!=null) {
					FormC.textCarrier.Text=carrierNameRow.NewValDisplay;
				}
				if(carrierPhoneRow!=null) {
					FormC.textPhone.Text=carrierPhoneRow.NewValDisplay;
				}
				FormC.ShowDialog();
				if(FormC.DialogResult!=DialogResult.OK) {
					return;
				}
				carrier=FormC.SelectedCarrier;
				//Check for nulls because the name AND phone rows might not both be on the sheet.
				if(carrierNameRow!=null) {
					if(carrierNameRow.OldValDisplay==carrier.CarrierName) {
						carrierNameRow.DoImport=false;
					}
					else {
						carrierNameRow.DoImport=true;
					}
					carrierNameRow.ImpValDisplay=carrier.CarrierName;
					carrierNameRow.ImpValObj=carrier;
				}
				if(carrierPhoneRow!=null) {
					if(carrierPhoneRow.OldValDisplay==carrier.Phone) {
						carrierPhoneRow.DoImport=false;
					}
					else {
						carrierPhoneRow.DoImport=true;
					}
					carrierPhoneRow.ImpValDisplay=carrier.Phone;
					carrierPhoneRow.ImpValObj=carrier;
				}
			}
			#endregion
			FillGrid();
		}