/// <summary> /// Bubble answer field /// </summary> private void btnAddBubble_Click(object sender, EventArgs e) { OmrBubbleField field = new OmrBubbleField() { Id = String.Format("OmrBubble{0}", this.m_currentTemplate.Fields.Count(o => o.Id.StartsWith("OmrBubble")) + 1) }; this.m_currentTemplate.Fields.Add(field); this.m_canvas.Add(new BubbleFormFieldStencil(field) { Position = new PointF(this.skHost1.HorizontalScroll.Value, this.skHost1.VerticalScroll.Value) }, field.Id); }
/// <summary> /// True/false form field stencil /// </summary> public BubbleFormFieldStencil(OmrBubbleField field) { this.Tag = this.m_field = field; this.Size = new SizeF(48, 48); this.m_answerShape.Text = field.Value; this.Add(m_bubbleShape); this.Add(m_answerShape); this.PositionChanged += BubbleFormFieldStencil_PositionChanged; this.SizeChanged += BubbleFormFieldStencil_SizeChanged; this.m_field.PropertyChanged += m_field_PropertyChanged; }
public void UploadData(OmrPageOutput page) { if (!Connectivity.CheckForInternetConnection()) { MessageBox.Show( "Username is empty, This is usually caused by lack of internet connectivity. Please try again later"); Exception e = new Exception("No internet connection"); Trace.TraceError("Error:{0}", e); throw e; } StatusDialog dlg = new StatusDialog(); dlg.Show(); try { int facilityId = FacilitySelectionContext.FacilityId; // Non-remembered facility if (facilityId == 0) { LocationSelectionBox location = new LocationSelectionBox(); if (location.ShowDialog() != System.Windows.Forms.DialogResult.OK) { throw new InvalidOperationException("Cannot upload data without selecting a facility"); } if (location.Remember) { FacilitySelectionContext.FacilityId = location.FacilityId; } facilityId = location.FacilityId; } var monthBubble = page.Details.OfType <OmrBubbleData>().FirstOrDefault(o => o.Key == "month"); if (monthBubble == null) { Err += "Must select month!; "; return; } RestUtil restUtil = new RestUtil(new Uri(ConfigurationManager.AppSettings["GIIS_URL"])); var userInfo = restUtil.Get <User>("UserManagement.svc/GetUserInfo", new KeyValuePair <string, object>("username", restUtil.GetCurrentUserName)); var placeInfo = restUtil.Get <Place[]>("PlaceManagement.svc/GetPlaceByHealthFacilityId", new KeyValuePair <string, object>("hf_id", facilityId)); foreach (var dtl in page.Details.OfType <OmrRowData>()) { string rowNum = dtl.Id.Substring(dtl.Id.Length - 1, 1); if (dtl.Details.Count == 0) { continue; } // (string barcodeId, string firstname1, string firstname2, string lastname1, DateTime birthdate, bool gender, // int healthFacilityId, int birthplaceId, int domicileId, string address, string phone, string motherFirstname, // string motherLastname, string notes, int userId, DateTime modifiedOn) OmrBarcodeData omrBarcode = dtl.Details.OfType <OmrBarcodeData>().FirstOrDefault(); OmrBubbleData omrDobDay = dtl.Details.OfType <OmrBubbleData>().FirstOrDefault(o => o.Key == "dobDay"), omrDobDay10 = dtl.Details.OfType <OmrBubbleData>().FirstOrDefault(o => o.Key == "dobDay10"), omrDobMonth = dtl.Details.OfType <OmrBubbleData>().FirstOrDefault(o => o.Key == "dobMonth"), omrDobYear = dtl.Details.OfType <OmrBubbleData>().FirstOrDefault(o => o.Key == "dobYear"), omrGender = dtl.Details.OfType <OmrBubbleData>().FirstOrDefault(o => o.Key == "gender"), omrOutreach = dtl.Details.OfType <OmrBubbleData>().FirstOrDefault(o => o.Key == "Outreach"), omrVaccDay10 = dtl.Details.OfType <OmrBubbleData>().FirstOrDefault(o => o.Key == "vaccDay10"), omrVaccDay = dtl.Details.OfType <OmrBubbleData>().FirstOrDefault(o => o.Key == "vaccDay"), omrNew = dtl.Details.OfType <OmrBubbleData>().FirstOrDefault(o => o.Key == "newInfo"), omrUpdate = dtl.Details.OfType <OmrBubbleData>().FirstOrDefault(o => o.Key == "correct"), omrIgnore = dtl.Details.OfType <OmrBubbleData>().FirstOrDefault(o => o.Key == "moved"); OmrBubbleData[] omrBcg = dtl.Details.OfType <OmrBubbleData>().Where(o => o.Key == "BCG").ToArray(), omrOpv = dtl.Details.OfType <OmrBubbleData>().Where(o => o.Key == "OPV").ToArray(), omrPenta = dtl.Details.OfType <OmrBubbleData>().Where(o => o.Key == "PENTA").ToArray(), omrPcv = dtl.Details.OfType <OmrBubbleData>().Where(o => o.Key == "PCV").ToArray(), omrRota = dtl.Details.OfType <OmrBubbleData>().Where(o => o.Key == "ROTA").ToArray(), omrMr = dtl.Details.OfType <OmrBubbleData>().Where(o => o.Key == "MR").ToArray(), omrVaccine = dtl.Details.OfType <OmrBubbleData>().Where(o => o.Key == "vaccine").ToArray(); // From WCF Call // Create row data for the verification form OmrBarcodeField barcodeField = page.Template.FlatFields.Find(o => o.Id == String.Format("{0}Barcode", dtl.Id)) as OmrBarcodeField; OmrBubbleField outreachField = page.Template.FlatFields.OfType <OmrBubbleField>() .SingleOrDefault(o => o.AnswerRowGroup == dtl.Id && o.Question == "Outreach"), monthField = page.Template.FlatFields.OfType <OmrBubbleField>() .SingleOrDefault(o => o.AnswerRowGroup == dtl.Id && o.Question == "dobMonth" && o.Value == "12"); // Barcode bounds Tz02RowData rowData = new Tz02RowData() { RowBounds = new RectangleF() { Location = new PointF(barcodeField.TopLeft.X, monthField.TopLeft.Y - 20), Width = outreachField.TopLeft.X - barcodeField.TopLeft.X, Height = barcodeField.BottomLeft.Y - monthField.TopLeft.Y - 20 }, UserInfo = userInfo, Page = page, FacilityId = facilityId }; if (omrBarcode != null) { rowData.Barcode = omrBarcode.BarcodeData; } if (omrDobDay != null && omrDobDay10 != null && omrDobMonth != null && omrDobYear != null) { try { rowData.DateOfBirth = new DateTime((int)omrDobYear.ValueAsFloat, (int)omrDobMonth.ValueAsFloat, (int)omrDobDay10.ValueAsFloat + (int)omrDobDay.ValueAsFloat); } catch { } } if (omrGender != null) { rowData.Gender = omrGender.Value == "M" ? true : false; } if (omrOutreach != null) { rowData.Outreach = omrOutreach.Value == "T"; } // Doses rowData.Doses = new List <Dose>(); if (omrBcg != null && omrBcg.Length > 0) { rowData.Doses.Add(this.FindDoseOrThrow("BCG")); } if (omrOpv != null) { foreach (var bub in omrOpv) { VaccinationEvent opvEvent = null; rowData.Doses.Add(ReferenceData.Current.Doses .Single(d => (d.DoseNumber == Helper.ConvertToInt(bub.Value) && d.ScheduledVaccinationId == (ReferenceData.Current.Vaccines .Single(v => v.Name.ToLower().Contains("opv")).Id)))); } } if (omrPenta != null) { foreach (var bub in omrPenta) { rowData.Doses.Add(ReferenceData.Current.Doses .Single(d => (d.DoseNumber == Helper.ConvertToInt(bub.Value) && d.ScheduledVaccinationId == (ReferenceData.Current.Vaccines .Single(v => (v.Name.ToLower().Contains("dtp") || v.Name.ToLower().Contains("penta"))).Id)))); } } if (omrPcv != null) { foreach (var bub in omrPcv) { rowData.Doses.Add(ReferenceData.Current.Doses .Single(d => (d.DoseNumber == Helper.ConvertToInt(bub.Value) && d.ScheduledVaccinationId == (ReferenceData.Current.Vaccines .Single(v => v.Name.ToLower().Contains("pcv")).Id)))); } } if (omrRota != null) { foreach (var bub in omrRota) { rowData.Doses.Add(ReferenceData.Current.Doses .Single(d => (d.DoseNumber == Helper.ConvertToInt(bub.Value) && d.ScheduledVaccinationId == (ReferenceData.Current.Vaccines .Single(v => v.Name.ToLower().Contains("rota")).Id)))); } } if (omrMr != null) { foreach (var bub in omrMr) { rowData.Doses.Add(ReferenceData.Current.Doses .Single(d => (d.DoseNumber == Helper.ConvertToInt(bub.Value) && d.ScheduledVaccinationId == (ReferenceData.Current.Vaccines .Single(v => v.Name.ToLower().Contains("mr")) .Id)))); } } // Given vaccines rowData.VaccineGiven = new List <ScheduledVaccination>(); foreach (var vacc in omrVaccine) { string antigenName = vacc.Value; if (antigenName == "ROTA") { antigenName = ReferenceData.Current.Vaccines .Single(d => d.Name.ToLower().Contains("rota")).Name; } else if (antigenName == "PENTA") { antigenName = ReferenceData.Current.Vaccines.Single(d => (d.Name.ToLower().Contains("dtp") || d.Name.ToLower().Contains("penta"))).Name; } else if (antigenName == "MR") { antigenName = ReferenceData.Current.Vaccines .Single(d => (d.Name.ToLower().Contains("mr"))) .Name; } else if (antigenName == "PCV") { antigenName = ReferenceData.Current.Vaccines .Single(d => d.Name.ToLower().Contains("pcv")).Name; } else if (antigenName == "OPV") { antigenName = ReferenceData.Current.Vaccines .Single(d => d.Name.ToLower().Contains("opv")).Name; } var refData = ReferenceData.Current.Vaccines.FirstOrDefault(v => v.Name == antigenName); if (refData != null) { rowData.VaccineGiven.Add(refData); } else { MessageBox.Show(String.Format("The form expected a vaccination named {0} but the server did not respond with such a vaccine. Server vaccinations: [{1}]", antigenName, String.Join(",", ReferenceData.Current.Vaccines.Select(o => o.Name).ToArray()))); } } // Date of vaccination rowData.VaccineDate = DateTime.Now; if (omrVaccDay10 != null && omrVaccDay != null) { rowData.VaccineDate = new DateTime(DateTime.Now.Month < monthBubble.ValueAsFloat ? DateTime.Now.Year - 1 : DateTime.Now.Year, (int)monthBubble.ValueAsFloat, (int)omrVaccDay10.ValueAsFloat + (int)omrVaccDay.ValueAsFloat); } // Determine what to do if (omrUpdate?.Value == "T") { ChildSearch bc = new ChildSearch(rowData); if (bc.ShowDialog() == DialogResult.OK) { rowData.Barcode = bc.Child.BarcodeId; rowData.ChildId = bc.Child.Id; } else { continue; } } else if (omrIgnore?.Value == "T") { continue; } if (BarcodeUtil.HasData(page, barcodeField) || dtl.Details.Count > 2) { Registration registration = new Registration(rowData); registration.ShowDialog(); } } } catch (Exception e) { Trace.TraceError("Error:{0}", e); throw; } finally { dlg.Close(); } }