public PatientDefenition(PatientDefenition copyFrom) { // get all the fields in the class FieldInfo[] fields_of_class = this.GetType().GetFields( BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance); // copy each value over to 'this' foreach (FieldInfo fi in fields_of_class) { fi.SetValue(this, fi.GetValue(copyFrom)); } }
public PatientDefenition addCustomer(PatientDefenition p) { p.PatientNo = doInsert(); fillFields(ref p); try { doPost(); } catch { throw new Exception("Faield to add customer " + p.PatientNo); } return p; }
public static ListViewItem[] convertToPatient(PatientDefenition[] p) { ListViewItem[] lw = new ListViewItem[p.Length]; for (int i = 0; i < lw.Length; i++) { lw[i] = new ListViewItem(p[i].SSN); lw[i].SubItems.Add(p[i].LastName); lw[i].SubItems.Add(p[i].SureName); lw[i].SubItems.Add(p[i].PoCity); } return lw; }
/// <summary> /// Konvertera en ArrayList till Patient object. /// </summary> /// <param name="arr"></param> /// <returns></returns> public static PatientDefenition[] convertFromArray(ArrayList arr) { PatientDefenition[] p = new PatientDefenition[arr.Count]; for (int i = 0; i < arr.Count; i++) { p[i] = (PatientDefenition)arr[i]; } return p; }
private FormControler() { currentOH = new OrderHeadDefinition(); currentPatient = new PatientDefenition(); lastPatient = new PatientDefenition(); }
/// <summary> /// Function som fyller på den returnerande struct som används bl a /// vid find metoderna. /// </summary> /// <param name="p"></param> private PatientDefenition fillStruct() { PatientDefenition p = new PatientDefenition(); p.PatientNo = KNR; p.SSN = PNR; p.LastName = LastNAM; p.SureName = SureNAM; p.Address = AD2; p.PoCity = ORT; p.Remark = Remark; p.TelHome = TelHome; p.TelWork = TelWork; p.TelMobile = TelMobile; p.TelSMS = TelSMS; p.Deceased = Deceased; p.OpenBalance = OpenBalance; p.PaymentTerms = PaymentTerms; p.DeliverTerms = DeliverTerms; p.WayOfDeliver = WayOfDeliver; p.VATCode = VATCode; p.Category = KAT; p.Journal = Journal; p.CopDok = CopDok; p.DoesExist = true; p.ViewCode = ViewCode; p.IsValid = IsValid; p.InterestInvoice = InterestInvoice; p.PaymentReminder = PaymentReminder; return p; }
//private PatientDefenition fillStruct() //{ // PatientDefenition p = new PatientDefenition(); // fillStruct(ref p); // return p; //} private void fillFields(ref PatientDefenition p) { KNR = p.PatientNo; PNR = p.SSN; LastNAM = p.LastName; SureNAM = p.SureName; AD2 = p.Address; ORT = p.PoCity; TelHome = p.TelHome; TelWork = p.TelWork; TelMobile = p.TelMobile; TelSMS = p.TelSMS; PaymentTerms = p.PaymentTerms; DeliverTerms = p.DeliverTerms; WayOfDeliver = p.WayOfDeliver; VATCode = p.VATCode; PriceListCode = p.PriceList; Deceased = p.Deceased; KAT = p.Category; Journal = p.Journal; CopDok = p.CopDok; ViewCode = p.ViewCode; InterestInvoice = p.InterestInvoice; PaymentReminder = p.PaymentReminder; }
public void updateCustomer(PatientDefenition p) { findByCust(p.PatientNo); fillFields(ref p); doPost(); }
/// <summary> /// Creates a missing customer and sets it's values /// from Thord. /// </summary> /// <param name="personnr">person number</param> public void createCustomer(ArrayList personnr) { string[] pnummer = (string[])personnr.ToArray(typeof(string)); ThordFunctions tf = new ThordFunctions(); ThordService.personinformation pinfo = new ThordService.personinformation(); PatientDefenition newPatient = new PatientDefenition(); pinfo = tf.getPersonInfo(pnummer); for (int i = 0; i < pinfo.person.Length; i++) { string namn = pinfo.person[i].lastname + pinfo.person[i].firstname; namn = namn.Replace("/", " "); String prnummer = pinfo.person[i].personnumber.Insert(8, "-"); newPatient.PatientNo = ""; newPatient.SSN = prnummer; newPatient.LastName = pinfo.person[i].lastname; newPatient.SureName = pinfo.person[i].firstname; newPatient.Address = pinfo.person[i].street; newPatient.PoCity = pinfo.person[i].postalcode.PadRight(7) + pinfo.person[i].postaladdress; newPatient.TelHome = pinfo.person[i].phonehome; newPatient.TelWork = pinfo.person[i].phonework; newPatient.TelMobile = pinfo.person[i].phonemobile; newPatient.Category = Ortoped.HelpClasses.Config.getCustTemplate.Category; newPatient.DeliverTerms = Ortoped.HelpClasses.Config.getCustTemplate.DeliverTerms; newPatient.PaymentTerms = Ortoped.HelpClasses.Config.getCustTemplate.PaymentTerms; newPatient.PriceList = Ortoped.HelpClasses.Config.getCustTemplate.PriceList; newPatient.VATCode = Ortoped.HelpClasses.Config.getCustTemplate.VATCode; newPatient.WayOfDeliver = Ortoped.HelpClasses.Config.getCustTemplate.WayOfDeliver; newPatient.ViewCode = Ortoped.HelpClasses.Config.getCustTemplate.ViewCode; newPatient.InterestInvoice = Ortoped.HelpClasses.Config.getCustTemplate.InterestInvoice; newPatient.PaymentReminder = Ortoped.HelpClasses.Config.getCustTemplate.PaymentReminder; newPatient.DoesExist = true; try { oCust.addCustomer(newPatient); } catch (Exception ex) { Log4Net.Logger.loggError(ex, "Error while adding patient", Config.User, "GarpReferrals.createCustomer"); throw ex; } } }
/// <summary> /// Kontrollera vad resultatet blev genom att undersöka parametern "p". /// T ex kontroll och hantering av flera träffar eller inga träffar. /// </summary> /// <param name="p"></param> private bool checkPatient(PatientDefenition[] p) { if (p.Length == 0) // Ingen patient hittades { // Om det är en sökning skall inte upplägg av patient visas if (txtPNR.Text.StartsWith(".")) { MessageBox.Show("Ingen Patienten som matchade sökbegreppet hittades", "Patient hittades ej", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return false; } else { if (MessageBox.Show("Patienten finns inte, vill du lägga upp en ny?", "patient saknas", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1) == DialogResult.Yes) { return addPatient(); } else // Användaren valde att inte lägga upp ny patient { return false; } } } else if (p.Length > 1) // Fler än en patient hittades { Ortoped.Dialogs.frmDiagPatient oDiaPat = new Ortoped.Dialogs.frmDiagPatient(PatientDefenition.convertToPatient(p)); oDiaPat.ShowDialog(); int idx = oDiaPat.selidx; string snn = oDiaPat.SSN; PatientDefenition selectedPatient = null; oDiaPat.Dispose(); // Kontrollera om användaren valde Cancel (idx == -1) if (idx != -1) { foreach (PatientDefenition p1 in p) { if (p1.SSN.Equals(snn)) { selectedPatient = p1; break; } } // Check if it's a valid patient if (selectedPatient.IsValid) { if (updateForm(selectedPatient)) return true; else return false; } else return false; } else return false; } else // Endast en patient hittades { if (p[0].IsValid) { updateForm(p[0]); return true; } else return false; } }
private bool updateForm(PatientDefenition p) { return updateForm(p, oOH.getPatientsLastOH(p.PatientNo)); }
private bool updateForm(PatientDefenition p, OrderHeadDefinition o) { try { // Do not execute when already in progress if (bFormUpdateInProgress) return false; else bFormUpdateInProgress = true; // If current OH couldnt be saved then abort. if (!saveOrder(true)) { try { txtONR.Text = GCF.noNULL(frmControler.CurrentOH.OrderNo); txtPNR.Text = GCF.noNULL(frmControler.CurrentPatient.SSN); bFormUpdateInProgress = false; Log4Net.Logger.loggWarning("In updateForm the saveOrder(true) failed on order " + frmControler.CurrentOH.OrderNo + " when trying to update order " + o.OrderNo, Config.User, ""); return false; } catch (Exception e) { Log4Net.Logger.loggWarning("Problem with saveorder in updateForm", Config.User, ""); return false; } } // Deaktivera sparafunktionen ignoreSave = true; try { // Move current patient to last patient befor update of new patient // (if not currentpatient is emty or the same as the one to update form with) if (!frmControler.CurrentPatient.PatientNo.Trim().Equals("") && !frmControler.CurrentPatient.PatientNo.Trim().Equals(p.PatientNo.Trim())) frmControler.LastPatient = new PatientDefenition(frmControler.CurrentPatient); } catch (Exception e) { Log4Net.Logger.loggWarning("Problem moving current patient to last patient", Config.User, "updateForm()"); } // If current order is the same as the new order, update definition after save if (o.OrderNo.Trim().Equals(frmControler.CurrentOH.OrderNo)) o = oOH.getOrder(o.OrderNo); try { // Save current orderhead and patient frmControler.CurrentOH = new OrderHeadDefinition(o); frmControler.CurrentPatient = new PatientDefenition(p); } catch (Exception e) { Log4Net.Logger.loggWarning("Problem saving current orderhead and patient", Config.User, "updateForm()"); } try { // Patient txtKNR.Text = p.PatientNo; txtPNR.Text = p.SSN; txtLN.Text = p.LastName; txtSN.Text = p.SureName; txtADD.Text = p.Address; txtORT.Text = p.PoCity; txtTelBostad.Text = p.TelHome; txtTelArbete.Text = p.TelWork; txtTelMobil.Text = p.TelMobile; txtTelSMS.Text = p.TelSMS; chkCopDok.Enabled = true; chkJournal.Enabled = true; chkDeceased.Enabled = true; chkJournal.Checked = p.Journal; chkCopDok.Checked = p.CopDok; chkDeceased.Checked = p.Deceased; txtANM.Text = p.Remark; if (p.OpenBalance > 0) { txtPNR.BackColor = Color.Salmon; toolTip1.SetToolTip(txtPNR, "Öppet saldo: " + p.OpenBalance + ":-"); } else { txtPNR.BackColor = Color.White; toolTip1.SetToolTip(txtPNR, ""); } } catch (Exception e) { Log4Net.Logger.loggWarning("Problem setting values on patient", Config.User, "updateForm()"); } try { // OH if (o.isClosed) { pnlOrderStat.Text = "### Ordern är stängd ###"; btnCloseOrder.Text = "&Öppna order"; } else { pnlOrderStat.Text = ""; btnCloseOrder.Text = "&Stäng order"; } // If OH is delivererd, or partly delivered, we do not allow changes of these fields ## JB 2010-05-19 if (o.CanChangeInvoiceCustomer) { txtFKN.Enabled = true; txtKlinik.Enabled = true; } else { txtFKN.Enabled = false; txtKlinik.Enabled = false; } txtONR.Text = o.OrderNo; txtODT.Text = o.OrderDate; txtFKN.Text = o.InvoiceCustomer; txtFKN_NAM.Text = o.InvoiceCustomerName; txtKlinik.Text = o.Clinik; txtKlinikNamn.Text = o.ClinikName; cboOrdinator.Items.Clear(); cboOrdinator.Text = ""; cboSignature.Text = ""; // ReferralDate (arrived at OTA) try { dtOTADate.Value = o.ReferralDate; } catch (Exception ex) { Log4Net.Logger.loggError(ex, "Error while handling datetime ReferralDate", Config.User, "frmMain.updateForm"); } // Hide combobox if signature is not found (and signature is not "") //2009-05-06:JB if ((cboSignature.FindStringExact(o.Signature.Trim()) == -1) && !o.Signature.Trim().Equals("")) if (!o.Signature.Trim().Equals("")) { cboSignature.Visible = false; txtSignature.Visible = true; txtSignature.Text = o.Signature; } else { cboSignature.Visible = true; txtSignature.Visible = false; try { cboSignature.SelectedIndex = cboSignature.FindStringExact(o.Signature); } catch (Exception e) { Log4Net.Logger.loggWarning("Problem setting signature on OH", Config.User, "updateForm()"); } } try { if (o.Ordinator != null) { cboOrdinator.Items.Add(""); cboOrdinator.Items.AddRange(o.Ordinator); } int idx = cboOrdinator.FindString(o.SelOrdinator); if (idx != -1) cboOrdinator.SelectedIndex = idx; } catch (Exception e) { Log4Net.Logger.loggWarning("Problem setting ordinator on OH", Config.User, "updateForm()"); } txtERF.Text = o.YourReference; labRemissNr.Text = o.ReferralNo; txtDiagID.Text = o.DiagnoseCode; try { txtDiagTxt.Text = oDiagnos.getDiagnosById(txtDiagID.Text.Trim()); } catch { txtDiagTxt.Text = ""; Log4Net.Logger.loggWarning("Problem setting diag on OH", Config.User, "updateForm()"); } txtOrdination.Text = o.Ordination; txtTillagg.Text = o.Diagnose; txtNotering.Text = o.Notation; try { dtpGilltigFrom.Value = o.ValidFrom; txtGilltigFrom.Text = o.ValidFrom.ToString("yyMMdd"); txtYears.Text = o.ValidYearsCount.ToString(); } catch (Exception ex) { Log4Net.Logger.loggError(ex, "Error while handling datetime", Config.User, "frmMain.updateForm"); } try { txtEndDate.Text = dtpGilltigFrom.Value.AddYears(int.Parse(txtYears.Text)).ToString("yyMMdd"); } catch { } txtAidCount.Text = o.AidCount; cboPrislista.Text = oPrislista.getPriceListById(o.Pricelist); tabctrlRow.SelectedIndex = 0; try { lwOr.Items.Clear(); lwOr.Items.AddRange(Definitions.Aid.convertToListView(oOR.getAllAid(frmControler.CurrentOH.OrderNo), oOR)); } catch (Exception e) { Log4Net.Logger.loggError(e, "Error while handling aids", Config.User, "updateForm"); Log4Net.Logger.loggInfo("Ordernummer: " + frmControler.CurrentOH.OrderNo, "", ""); } try { if (lwOr.Items.Count > 0) lwOr.Items[0].Selected = true; clearOrderrowDetailPane(true); } catch { clearOrderrowDetailPane(true); } // Get unbound errand if orderno is given if (!frmControler.CurrentOH.OrderNo.Trim().Equals("")) { if (oErr.getUnboundErrands(txtKNR.Text, frmControler.CurrentOH.OrderNo).Length > 0) { frmDiagUnboundErrand oDue = new frmDiagUnboundErrand(txtKNR.Text, frmControler.CurrentOH.OrderNo); oDue.ShowDialog(); } } lwErrand.Items.Clear(); lwErrand.Items.AddRange(ErrandFunc.Errand.convertToErrand(oErr.getErrands(txtKNR.Text, frmControler.CurrentOH.OrderNo))); // Kontrollera om vi skall enabla groupboxarna för OH och OR eller ej if (o.OrderNo.Trim() == "") { grbOH.Enabled = false; grbOr.Enabled = false; tabctrlRow.Enabled = false; } else { grbOH.Enabled = true; grbOr.Enabled = true; tabctrlRow.Enabled = true; //cboOrdinator.Focus(); } if (!p.DoesExist) grbTid.Enabled = false; else grbTid.Enabled = true; // Aktivera sparafunktionen ignoreSave = false; bFormUpdateInProgress = false; grbOH.ForeColor = grbPatient.ForeColor; } catch (Exception e) { Log4Net.Logger.loggWarning("Problem setting values on OH", Config.User, "updateForm()"); return false; } Log4Net.Logger.loggInfo("Successfully updated order " + frmControler.CurrentOH.OrderNo + " on patient " + GCF.noNULL(frmControler.CurrentPatient.PatientNo), Config.User, ""); return true; } catch (Exception ex) { Log4Net.Logger.loggError(ex, "Error in updateForm", Config.User, ""); bFormUpdateInProgress = false; return false; } }
private void fillPatient() { PersonNummer pnr = new PersonNummer(); string s = myCust.checkPnr(txtPnr.Text); if (s.Trim().Equals("")) { // Kontrollera checksiffra if (!pnr.calculate(txtPnr.Text)) { if (!(MessageBox.Show(this, "Checksiffran stämmer inte på detta personnummer, vill du gå vidare ändå?", "Fel checksiffra", MessageBoxButtons.YesNo, MessageBoxIcon.Stop) == DialogResult.Yes)) return; } newPatient.SSN = txtPnr.Text; newPatient.LastName = txtLN.Text; newPatient.SureName = txtSN.Text; newPatient.Address = txtADD.Text; newPatient.PoCity = txtPostNr.Text + " " + txtOrt.Text; newPatient.TelHome = txtTelBostad.Text; newPatient.TelWork = txtTelArbete.Text; newPatient.TelMobile = txtTelMobil.Text; newPatient.TelSMS = txtTelSMS.Text; newPatient.Category = Config.getCustTemplate.Category; newPatient.DeliverTerms = Config.getCustTemplate.DeliverTerms; newPatient.PaymentTerms = Config.getCustTemplate.PaymentTerms; newPatient.PriceList = Config.getCustTemplate.PriceList; newPatient.VATCode = Config.getCustTemplate.VATCode; newPatient.WayOfDeliver = Config.getCustTemplate.WayOfDeliver; newPatient.ViewCode = Config.getCustTemplate.ViewCode; newPatient.InterestInvoice = Config.getCustTemplate.InterestInvoice; newPatient.PaymentReminder = Config.getCustTemplate.PaymentReminder; newPatient.DoesExist = true; if (!ECS.noNULL(newPatient.PatientNo).Equals("")) {// Make global customer // Delete old name, otherwise the name gets corrupted when // the two patients are united newPatient.SureName = ""; newPatient.LastName = ""; myCust.updateCustomer(newPatient); newPatient.SureName = txtSN.Text; newPatient.LastName = txtLN.Text; newPatient.ViewCode = ""; myCust.updateCustomer(newPatient); } else {// Create new customer try { if (myCust.checkNextCustomerNo()) { PatientDefenition[] pd = myCust.getPatientByPnr(txtPnr.Text.Trim(), true, false); if (pd.Length == 0) { newPatient = myCust.addCustomer(newPatient); myCust.updateCustomer(newPatient); } else { MessageBox.Show(this, "Personnummret " + txtPnr.Text + " fanns redan, inget upplägg gjordes", "Personnummret finns redan", MessageBoxButtons.OK, MessageBoxIcon.Stop); newPatient.SSN = pd[0].SSN; newPatient.LastName = pd[0].LastName; newPatient.SureName = pd[0].SureName; newPatient.Address = pd[0].Address; newPatient.PoCity = pd[0].PoCity; newPatient.TelHome = pd[0].TelHome; newPatient.TelWork = pd[0].TelWork; newPatient.TelMobile = pd[0].TelMobile; newPatient.TelSMS = pd[0].TelSMS; newPatient.Category = pd[0].Category; newPatient.DeliverTerms = pd[0].DeliverTerms; newPatient.PaymentTerms = pd[0].PaymentTerms; newPatient.PriceList = pd[0].PriceList; newPatient.VATCode = pd[0].VATCode; newPatient.WayOfDeliver = pd[0].WayOfDeliver; newPatient.ViewCode = pd[0].ViewCode; newPatient.InterestInvoice = pd[0].InterestInvoice; newPatient.PaymentReminder = pd[0].PaymentReminder; newPatient.DoesExist = pd[0].DoesExist; newPatient.PatientNo = pd[0].PatientNo; } } else { newPatient.SSN = ""; MessageBox.Show(this, "Kundnumret är upptaget. Detta beror på problem med nummerräknaren i Garp, kontrollera nummerräknaren och försök igen.", "Kundnumret finns redan", MessageBoxButtons.OK, MessageBoxIcon.Stop); } } catch (Exception ex) { MessageBox.Show(this, ex.Message, "Ett fel inträffade vid upplägg av patient", MessageBoxButtons.OK, MessageBoxIcon.Stop); Log4Net.Logger.loggError(ex, "Error while adding patient", Config.User, ""); } } this.Close(); } else { MessageBox.Show(this, s, "Upplägg av patient misslyckades", MessageBoxButtons.OK, MessageBoxIcon.Stop); } }