/// <summary> /// Request all xContacts value changes from a given point by a specific xStudent with paging. /// </summary> /// <param name="refId">RefId of xStudent.</param> /// <param name="navigationPage">Page to retrieve.</param> /// <param name="navigationPageSize">Number of resources to retrieve.</param> /// <param name="opaqueMarker">Uses an ISO8601 timestamp that indicates a point since the last changes have been requested.</param> /// <returns>List of xContacts type.</returns> internal ResponseMulti <XContactType> GetXContactsByXStudent(string refId, int?navigationPage, int?navigationPageSize, string opaqueMarker) { RestReturn rr = new RestReturn(); RestHeader rh = new RestHeader(navigationPage, navigationPageSize); RestQueryParameter rqp = new RestQueryParameter(opaqueMarker); RestProperties rp = new RestProperties(baseApiUrl, ServicePath.GetXContactsByXStudent, refId, rh, rqp); return(rr.MakeAllRequest <XContactType, XContactCollectionType>(rc, rp)); }
/// <summary> /// Request all xContacts. /// </summary> /// <returns>List of xContacts type.</returns> internal ResponseMulti <XContactType> GetXContacts() { RestReturn rr = new RestReturn(); RestHeader rh = new RestHeader(); RestQueryParameter rqp = new RestQueryParameter(); RestProperties rp = new RestProperties(baseApiUrl, ServicePath.GetXContacts, rh, rqp); return(rr.MakeAllRequest <XContactType, XContactCollectionType>(rc, rp)); }
/// <summary> /// Request xContacts associated to a specific xStudent by refId by school year. /// </summary> /// <param name="refId">RefId of xStudent.</param> /// <param name="schoolYear">The year of the requested data (i.e. 2018 for the 2017-2018 school year).</param> /// <returns>List of xContacts type.</returns> internal ResponseMulti <XContactType> GetXContactsByXStudent(string refId, int?schoolYear) { RestReturn rr = new RestReturn(); RestHeader rh = new RestHeader(schoolYear); RestQueryParameter rqp = new RestQueryParameter(); RestProperties rp = new RestProperties(baseApiUrl, ServicePath.GetXContactsByXStudent, refId, rh, rqp); return(rr.MakeAllRequest <XContactType, XContactCollectionType>(rc, rp)); }
/// <summary> /// Request all xCourse value changes from a given point. /// </summary> /// <param name="opaqueMarker">Uses an ISO8601 timestamp that indicates a point since the last changes have been requested.</param> /// <returns>List of xCourses type.</returns> internal ResponseMulti <XCourseType> GetXCourses(string opaqueMarker) { RestReturn rr = new RestReturn(); RestHeader rh = new RestHeader(); RestQueryParameter rqp = new RestQueryParameter(opaqueMarker); RestProperties rp = new RestProperties(baseApiUrl, ServicePath.GetXCourses, rh, rqp); return(rr.MakeAllRequest <XCourseType, XCourseCollectionType>(rc, rp)); }
/// <summary> /// Request single xContact by refId. /// </summary> /// <param name="refId">RefId of xContact.</param> /// <returns>Single xContacts type.</returns> internal ResponseSingle <XContactType> GetXContact(string refId) { RestReturn rr = new RestReturn(); RestHeader rh = new RestHeader(); RestQueryParameter rqp = new RestQueryParameter(); RestProperties rp = new RestProperties(baseApiUrl, ServicePath.GetXContactByRefId, refId, rh, rqp); return(rr.MakeSingleRequest <XContactType, XContactCollectionType>(rc, rp)); }
/// <summary> /// Request all xRosters value changes from a given point by a specific xStudent. /// </summary> /// <param name="refId">RefId of xStudent.</param> /// <param name="opaqueMarker">Uses an ISO8601 timestamp that indicates a point since the last changes have been requested.</param> /// <returns>List of xRosters type.</returns> internal ResponseMulti <XRosterType> GetXRostersByXStudent(string refId, string opaqueMarker) { RestReturn rr = new RestReturn(); RestHeader rh = new RestHeader(); RestQueryParameter rqp = new RestQueryParameter(opaqueMarker); RestProperties rp = new RestProperties(baseApiUrl, ServicePath.GetXRostersByXStudent, refId, rh, rqp); return(rr.MakeAllRequest <XRosterType, XRosterCollectionType>(rc, rp)); }
/// <summary> /// Request all xCourses with paging by school year. /// </summary> /// <param name="navigationPage">Page to retrieve.</param> /// <param name="navigationPageSize">Number of resources to retrieve.</param> /// <param name="schoolYear">The year of the requested data (i.e. 2018 for the 2017-2018 school year).</param>> /// <returns>List of xCourses type.</returns> internal ResponseMulti <XCourseType> GetXCourses(int?navigationPage, int?navigationPageSize, int?schoolYear) { RestReturn rr = new RestReturn(); RestHeader rh = new RestHeader(navigationPage, navigationPageSize, schoolYear); RestQueryParameter rqp = new RestQueryParameter(); RestProperties rp = new RestProperties(baseApiUrl, ServicePath.GetXCourses, rh, rqp); return(rr.MakeAllRequest <XCourseType, XCourseCollectionType>(rc, rp)); }
/// <summary> /// Request all xRosters by school year. /// </summary> /// <param name="schoolYear">The year of the requested data (i.e. 2018 for the 2017-2018 school year).</param> /// <returns>List of xRosters type.</returns> internal ResponseMulti <XRosterType> GetXRosters(int?schoolYear) { RestReturn rr = new RestReturn(); RestHeader rh = new RestHeader(schoolYear); RestQueryParameter rqp = new RestQueryParameter(); RestProperties rp = new RestProperties(baseApiUrl, ServicePath.GetXRosters, rh, rqp); return(rr.MakeAllRequest <XRosterType, XRosterCollectionType>(rc, rp)); }
/// <summary> /// Request xRosters associated to a specific xStudent by refId with paging by school year. /// </summary> /// <param name="refId">RefId of xStudent.</param> /// <param name="navigationPage">Page to retrieve.</param> /// <param name="navigationPageSize">Number of resources to retrieve.</param> /// <param name="schoolYear">The year of the requested data (i.e. 2018 for the 2017-2018 school year).</param> /// <returns>List of xRosters type.</returns> internal ResponseMulti <XRosterType> GetXRostersByXStudent(string refId, int?navigationPage, int?navigationPageSize, int?schoolYear) { RestReturn rr = new RestReturn(); RestHeader rh = new RestHeader(navigationPage, navigationPageSize, schoolYear); RestQueryParameter rqp = new RestQueryParameter(); RestProperties rp = new RestProperties(baseApiUrl, ServicePath.GetXRostersByXStudent, refId, rh, rqp); return(rr.MakeAllRequest <XRosterType, XRosterCollectionType>(rc, rp)); }
/// <summary> /// Request single xRoster by refId by school year. /// </summary> /// <param name="refId">RefId of xRoster.</param> /// <param name="schoolYear">The year of the requested data (i.e. 2018 for the 2017-2018 school year).</param> /// <returns>Single xRosters type</returns> internal ResponseSingle <XRosterType> GetXRoster(string refId, int?schoolYear) { RestReturn rr = new RestReturn(); RestHeader rh = new RestHeader(schoolYear); RestQueryParameter rqp = new RestQueryParameter(); RestProperties rp = new RestProperties(baseApiUrl, ServicePath.GetXRosterByRefId, refId, rh, rqp); return(rr.MakeSingleRequest <XRosterType, XRosterCollectionType>(rc, rp)); }
/// <summary> /// Request all xRosters value changes from a given point with paging. /// </summary> /// <param name="navigationPage">Page to retrieve.</param> /// <param name="navigationPageSize">Number of resources to retrieve.</param> /// <param name="opaqueMarker">Uses an ISO8601 timestamp that indicates a point since the last changes have been requested.</param> /// <returns>List of xRosters type.</returns> internal ResponseMulti <XRosterType> GetXRosters(int?navigationPage, int?navigationPageSize, string opaqueMarker) { RestReturn rr = new RestReturn(); RestHeader rh = new RestHeader(navigationPage, navigationPageSize); RestQueryParameter rqp = new RestQueryParameter(opaqueMarker); RestProperties rp = new RestProperties(baseApiUrl, ServicePath.GetXRosters, rh, rqp); return(rr.MakeAllRequest <XRosterType, XRosterCollectionType>(rc, rp)); }
/// <summary> /// Request xStaffs associated to a specific xRoster by refId with paging. /// </summary> /// <param name="refId">RefId of xRoster.</param> /// <param name="navigationPage">Page to retrieve.</param> /// <param name="navigationPageSize">Number of resources to retrieve.</param> /// <returns>List of xStaffs type.</returns> internal ResponseMulti <XStaffType> GetXStaffsByXRoster(string refId, int?navigationPage, int?navigationPageSize) { RestReturn rr = new RestReturn(); RestHeader rh = new RestHeader(navigationPage, navigationPageSize); RestQueryParameter rqp = new RestQueryParameter(); RestProperties rp = new RestProperties(baseApiUrl, ServicePath.GetXStaffsByXRoster, refId, rh, rqp); return(rr.MakeAllRequest <XStaffType, XStaffCollectionType>(rc, rp)); }
/// <summary> /// Request single xStaff by State or Local Id by school year. /// </summary> /// <param name="idType">Header value can be set to state or local.</param> /// <param name="id">State or Local Id.</param> /// <param name="schoolYear">The year of the requested data (i.e. 2018 for the 2017-2018 school year).</param> /// <returns>Single xStaffs type.</returns> internal ResponseSingle <XStaffType> GetXStaff(string idType, string id, int?schoolYear) { RestReturn rr = new RestReturn(); RestHeader rh = new RestHeader(idType, id, schoolYear); RestQueryParameter rqp = new RestQueryParameter(); RestProperties rp = new RestProperties(baseApiUrl, ServicePath.GetXStaffById, rh, rqp); return(rr.MakeSingleRequest <XStaffType, XStaffCollectionType>(rc, rp)); }
/// <summary> /// Upload the data to GIIS /// </summary> private void button1_Click(object sender, EventArgs e) { try { btnSubmit.Enabled = false; errBarcode.Clear(); // Validation stuff if (!this.ValidateForm()) { return; } Place selectedPlace = (cbxVillage.SelectedItem as PlaceListItem)?.Place; // Register the child var childData = this.m_restUtil.Get <List <FormTZ01.ChildEntity> >("ChildManagement.svc/SearchByBarcode", new KeyValuePair <string, object>("barcodeId", txtBarcode.Text)); RestReturn childResult = null; if (childData.Count == 0) // Create { childResult = this.m_restUtil.Get <RestReturn>("ChildManagement.svc/RegisterChildWithAppoitments", new KeyValuePair <string, object>("barcodeId", txtBarcode.Text), new KeyValuePair <string, object>("firstname1", txtGiven.Text), new KeyValuePair <string, object>("lastname1", txtFamily.Text), new KeyValuePair <string, object>("birthdate", dtpDob.Value.ToString("yyyy-MM-dd")), new KeyValuePair <string, object>("gender", cbxGender.SelectedIndex == 0 ? false : true), new KeyValuePair <string, object>("healthFacilityId", this.m_rowData.FacilityId), new KeyValuePair <string, object>("domicileId", selectedPlace.Id), new KeyValuePair <string, object>("statusId", 1), new KeyValuePair <string, object>("phone", txtTelephone.Text), new KeyValuePair <string, object>("motherFirstname", txtMotherFamily.Text), new KeyValuePair <string, object>("motherLastname", txtMotherGiven.Text), new KeyValuePair <string, object>("notes", "Updated by form scanning application"), new KeyValuePair <string, object>("userId", this.m_rowData.UserInfo.Id) ); } else { childResult = this.m_restUtil.Get <RestReturn>("ChildManagement.svc/UpdateChild", new KeyValuePair <string, object>("childId", childData[0].childEntity.Id), new KeyValuePair <string, object>("barcode", txtBarcode.Text), new KeyValuePair <string, object>("firstname1", txtGiven.Text), new KeyValuePair <string, object>("lastname1", txtFamily.Text), new KeyValuePair <string, object>("birthdate", dtpDob.Value.ToString("yyyy-MM-dd")), new KeyValuePair <string, object>("gender", cbxGender.SelectedIndex == 0 ? false : true), new KeyValuePair <string, object>("healthFacilityId", this.m_rowData.FacilityId), new KeyValuePair <string, object>("domicileId", selectedPlace.Id), new KeyValuePair <string, object>("statusId", 1), new KeyValuePair <string, object>("phone", txtTelephone.Text), new KeyValuePair <string, object>("motherFirstname", txtMotherFamily.Text), new KeyValuePair <string, object>("motherLastname", txtMotherGiven.Text), new KeyValuePair <string, object>("notes", "Updated by form scanning application"), new KeyValuePair <string, object>("userId", this.m_rowData.UserInfo.Id) ); if (childResult.Id >= 0) { childResult = new RestReturn() { Id = childData[0].childEntity.Id } } ; } if (childResult.Id < 0) { MessageBox.Show("TIIS Service reported Error code. This is usually caused by a duplicate barcode sticker"); return; } // Update doses var vaccinationEvent = this.m_restUtil.Get <VaccinationEvent[]>("VaccinationEvent.svc/GetVaccinationEventListByChildId", new KeyValuePair <string, object>("childId", childResult.Id)); foreach (var evt in vaccinationEvent) { var dose = ReferenceData.Current.Doses.FirstOrDefault(o => o.Id == evt.DoseId); String doseName = dose.Fullname.Replace(" ", "").Replace("-", ""); if (doseName == "BCG") { doseName = "BCG0"; } var ctl = this.grpHistoricalVacc.Controls.Find(String.Format("chk{0}", doseName), false).FirstOrDefault() as CheckBox; evt.VaccinationDate = evt.ScheduledDate; if (ctl != null && ctl.Checked) { evt.VaccinationStatus = true; this.UpdateVaccination(evt, dose); } } // Re-fetch doses so we get new data from the system vaccinationEvent = this.m_restUtil.Get <VaccinationEvent[]>("VaccinationEvent.svc/GetVaccinationEventListByChildId", new KeyValuePair <string, object>("childId", childResult.Id)); // Give doses foreach (var ctl in grpVaccine.Controls) { if (!(ctl is CheckBox)) { continue; // skip non check boxes } var checkbox = ctl as CheckBox; if (!checkbox.Checked) { continue; } string antigenName = checkbox.Name.Substring(3); 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; } else if (antigenName == "Outreach") { continue; } var vaccine = ReferenceData.Current.Vaccines.FirstOrDefault(o => o.Name.Equals(antigenName)); // Find the scheduled vaccine for this List <Dose> sv = ReferenceData.Current.Doses.FindAll(o => o.ScheduledVaccinationId == vaccine.Id); // Find the current dose we're on var lastVe = vaccinationEvent .Where(ve => sv.Exists(o => o.Id == ve.DoseId) && ve.VaccinationStatus == true) .OrderByDescending(o => sv.Find(d => d.Id == o.DoseId).DoseNumber).FirstOrDefault(); int doseNumber = 0; // hack: OPV is odd if (antigenName == ReferenceData.Current.Vaccines .Single(d => d.Name.ToLower().Contains("opv")).Name) { doseNumber--; } if (lastVe != null) { doseNumber = sv.Find(d => d.Id == lastVe.DoseId).DoseNumber; } // Next we want to get the next dose Dose myDose = sv.FirstOrDefault(o => o.DoseNumber == doseNumber + 1); if (myDose == null) { MessageBox.Show(String.Format("Patient #{0} is marked to have antigen {1}. Have detected dose number {2} should be given however no dose of this exists", txtBarcode.Text, antigenName, doseNumber + 1)); } else { // Find an event that suits us var evt = vaccinationEvent.FirstOrDefault(o => o.DoseId == myDose.Id); if (evt == null) { // Is it because it is MR? if (antigenName == "Measles Rubella") // Maybe "measles" { antigenName = "Measles"; vaccine = ReferenceData.Current.Vaccines.FirstOrDefault(o => o.Name == antigenName); // Find the scheduled vaccine for this sv = ReferenceData.Current.Doses.FindAll(o => o.ScheduledVaccinationId == vaccine.Id); lastVe = vaccinationEvent.Where(ve => sv.Exists(o => o.Id == ve.DoseId) && ve.VaccinationStatus == true).OrderByDescending(o => sv.Find(d => d.Id == o.DoseId).DoseNumber).FirstOrDefault(); doseNumber = 0; if (lastVe != null) { doseNumber = sv.Find(d => d.Id == lastVe.DoseId).DoseNumber; } myDose = sv.FirstOrDefault(o => o.DoseNumber == doseNumber + 1); evt = vaccinationEvent.FirstOrDefault(o => o.DoseId == myDose.Id); } } if (evt == null) { MessageBox.Show(String.Format("Patient was never scheduled to receive {0} so can't update that dose", myDose.Fullname)); return; } evt.VaccinationDate = evt.ScheduledDate = dtpVaccDate.Value; evt.VaccinationStatus = true; this.UpdateVaccination(evt, myDose); if (chkOutreach.Checked) { this.m_restUtil.Get <RestReturn>("VaccinationAppointmentManagement.svc/UpdateVaccinationApp", new KeyValuePair <String, Object>("outreach", true), new KeyValuePair <String, Object>("userId", this.m_rowData.UserInfo.Id), new KeyValuePair <String, Object>("barcode", txtBarcode.Text), new KeyValuePair <String, Object>("doseId", myDose.Id) ); } } } this.Close(); } finally { btnSubmit.Enabled = true; } }
/// <summary> /// Returns the max page value for specified service path object. /// </summary> /// <param name="servicePath">The requested service path.</param> /// <param name="refId">RefId of xObject.</param> /// <param name="navigationPageSize">Number of resources to retrieve.</param> /// <param name="schoolYear">The year of the requested data (i.e. 2018 for the 2017-2018 school year).</param> /// <returns>Integer value.</returns> internal int GetLastPage(ServicePath servicePath, string refId, int?navigationPageSize, int?schoolYear) { int navigationPage = 1; RestReturn rr = new RestReturn(); RestHeader rh = new RestHeader(navigationPage, navigationPageSize, schoolYear); RestQueryParameter rqp = new RestQueryParameter(); try { switch (servicePath.GetServicePathName()) { case "GetXLeasByXSchool": case "GetXLeasByXRoster": case "GetXLeasByXStaff": case "GetXLeasByXStudent": case "GetXLeasByXContact": { RestProperties rp = new RestProperties(baseApiUrl, servicePath, refId, rh, rqp); rr.MakeAllRequest <XLeaType, XLeaCollectionType>(rc, rp); break; } case "GetXSchoolsByXLea": case "GetXSchoolsByXCalendar": case "GetXSchoolsByXCourse": case "GetXSchoolsByXRoster": case "GetXSchoolsByXStaff": case "GetXSchoolsByXStudent": case "GetXSchoolsByXContact": { RestProperties rp = new RestProperties(baseApiUrl, servicePath, refId, rh, rqp); rr.MakeAllRequest <XSchoolType, XSchoolCollectionType>(rc, rp); break; } case "GetXCalendarsByXLea": case "GetXCalendarsByXSchool": { RestProperties rp = new RestProperties(baseApiUrl, servicePath, refId, rh, rqp); rr.MakeAllRequest <XCalendarType, XCalendarCollectionType>(rc, rp); break; } case "GetXCoursesByXLea": case "GetXCoursesByXSchool": case "GetXCoursesByXRoster": { RestProperties rp = new RestProperties(baseApiUrl, servicePath, refId, rh, rqp); rr.MakeAllRequest <XCourseType, XCourseCollectionType>(rc, rp); break; } case "GetXRostersByXLea": case "GetXRostersByXSchool": case "GetXRostersByXCourse": case "GetXRostersByXStaff": case "GetXRostersByXStudent": { RestProperties rp = new RestProperties(baseApiUrl, servicePath, refId, rh, rqp); rr.MakeAllRequest <XRosterType, XRosterCollectionType>(rc, rp); break; } case "GetXStaffsByXLea": case "GetXStaffsByXSchool": case "GetXStaffsByXCourse": case "GetXStaffsByXRoster": case "GetXStaffsByXStudent": { RestProperties rp = new RestProperties(baseApiUrl, servicePath, refId, rh, rqp); rr.MakeAllRequest <XStaffType, XStaffCollectionType>(rc, rp); break; } case "GetXStudentsByXLea": case "GetXStudentsByXSchool": case "GetXStudentsByXRoster": case "GetXStudentsByXStaff": case "GetXStudentsByXContact": { RestProperties rp = new RestProperties(baseApiUrl, servicePath, refId, rh, rqp); rr.MakeAllRequest <XStudentType, XStudentCollectionType>(rc, rp); break; } case "GetXContactsByXLea": case "GetXContactsByXSchool": case "GetXContactsByXStudent": { RestProperties rp = new RestProperties(baseApiUrl, servicePath, refId, rh, rqp); rr.MakeAllRequest <XContactType, XContactCollectionType>(rc, rp); break; } } return(rr.NavigationLastPage); } catch (Exception) { return(0); } }