private static StudentPersonal CreateBartSimpson() { string[] text = new string[] { @"<MedicalCondition> <ConditionID>Unique Medical Condition ID</ConditionID> <Condition>Condition</Condition> <Severity>Condition Severity</Severity> <Details>Condition Details</Details> </MedicalCondition>" }; SIF_ExtendedElementsTypeSIF_ExtendedElement extendedElement = new SIF_ExtendedElementsTypeSIF_ExtendedElement { Name = "MedicalConditions", Text = text }; SIF_ExtendedElementsTypeSIF_ExtendedElement[] extendedElements = new SIF_ExtendedElementsTypeSIF_ExtendedElement[] { extendedElement }; NameOfRecordType name = new NameOfRecordType { Type = NameOfRecordTypeType.LGL, FamilyName = "Simpson", GivenName = "Bart" }; PersonInfoType personInfo = new PersonInfoType { Name = name }; StudentPersonal studentPersonal = new StudentPersonal { RefId = Guid.NewGuid().ToString(), LocalId = "666", PersonInfo = personInfo, SIF_ExtendedElements = extendedElements }; return(studentPersonal); }
private static StudentPersonal CreateStudent() { NameOfRecordType name = new NameOfRecordType { Type = NameOfRecordTypeType.LGL, FamilyName = RandomNameGenerator.FamilyName, GivenName = RandomNameGenerator.GivenName }; EmailType[] emails = new EmailType[2] { new EmailType { Type = AUCodeSetsEmailTypeType.Item01, Value = $"{name.GivenName}[email protected]" }, new EmailType { Type = AUCodeSetsEmailTypeType.Item02, Value = $"{name.GivenName}[email protected]" } }; PersonInfoType personInfo = new PersonInfoType { Name = name, EmailList = emails }; StudentPersonal studentPersonal = new StudentPersonal { RefId = Guid.NewGuid().ToString(), LocalId = random.Next(10000, 99999).ToString(), PersonInfo = personInfo }; return(studentPersonal); }
/// <summary> /// /// </summary> /// <returns></returns> private static StudentPersonal CreateStudent() { NameOfRecordType name = new NameOfRecordType { Type = NameOfRecordTypeType.LGL, FamilyName = RandomNameGenerator.FamilyName, GivenName = RandomNameGenerator.GivenName }; PersonInfoType personInfo = new PersonInfoType { Name = name }; StudentPersonal studentPersonal = new StudentPersonal { Id = Guid.NewGuid(), LocalId = random.Next(10000, 99999).ToString(), PersonInfo = personInfo }; return(studentPersonal); }
/// <summary> /// /// </summary> /// <returns></returns> private static StudentPersonal CreateBartSimpson() { NameOfRecordType name = new NameOfRecordType { Type = NameOfRecordTypeType.LGL, FamilyName = "Simpson", GivenName = "Bart" }; PersonInfoType personInfo = new PersonInfoType { Name = name }; StudentPersonal studentPersonal = new StudentPersonal { Id = Guid.NewGuid(), LocalId = "666", PersonInfo = personInfo }; return(studentPersonal); }
/// <summary> /// Returns a transactions which holds the employee and depenedednt records /// </summary> /// <param name="emp">CensusRow of the Employee Info</param> /// <param name="deps">List of CensusRows that hold dependent data</param> /// <returns></returns> public static TransactionType BuildTransaction(CensusRow emp, List <CensusRow> deps) { TransactionType transactionType = new TransactionType(); transactionType.TransactionType1 = HEALTHEVENTTYPE2; Guid guid = Guid.NewGuid(); transactionIds.Add(new KeyValuePair <string, string>(emp.EID, guid.ToString())); transactionType.UniqueTransactionId = guid.ToString(); transactionType.RescindIndicator = false; transactionType.RescindIndicatorSpecified = true; IdentifierType identifierType = new IdentifierType(); if (!String.IsNullOrEmpty(emp.CalPERS_ID)) { identifierType.ItemElementName = ItemChoiceType.CalPERSId; identifierType.Item = emp.CalPERS_ID; } else { identifierType.ItemElementName = ItemChoiceType.SSN; if (emp.SSN != null) { identifierType.Item = emp.CalPERS_ID; } else { identifierType.Item = ""; } } PersonInfoType personInfoType = new PersonInfoType(); personInfoType.PersonId = identifierType; if (identifierType.ItemElementName == ItemChoiceType.SSN) { personInfoType.PersonIdType = IdentificationType.SocialSecurityNumber; } else { personInfoType.PersonIdType = IdentificationType.CalPERSIndetification; } personInfoType.FirstName = emp.FirstName; personInfoType.MiddleName = emp.MiddleName; personInfoType.LastName = emp.LastName; DateTime bDate; if (DateTime.TryParse(emp.BirthDate, out bDate)) { personInfoType.BirthDate = bDate; personInfoType.BirthDateSpecified = true; } else { personInfoType.BirthDateSpecified = false; } personInfoType.Gender = emp.Gender.Substring(0, 1); AddressInfoType addressInfoType = new AddressInfoType(); addressInfoType.AddressType = AddressType.PhysicalAddress; addressInfoType.AddressLine = new string[] { emp.Address1.Trim(), emp.Address2.Trim() }; addressInfoType.City = emp.City; if (emp.State == "California") { addressInfoType.State = StateCode.California; } addressInfoType.ZipCode5 = emp.Zip; addressInfoType.Country = CountryCodes.UnitedStates; TransactionTypeDemographics transactionTypeDemographics = new TransactionTypeDemographics(); transactionTypeDemographics.PersonInfo = personInfoType; transactionTypeDemographics.AddressInfo = addressInfoType; transactionType.Demographics = transactionTypeDemographics; TransactionTypeAppointment transactionTypeAppointment = new TransactionTypeAppointment(); EmployerInfoType employerInfoType = new EmployerInfoType(); employerInfoType.EmployerCalPERSId = school.CalPERSID; employerInfoType.County = CountyCodes.SantaClara;//hard coded for campbell transactionTypeAppointment.EmployerInfo = employerInfoType; //TODO: MISSING CBU (Collective Bargaining Unit) codes. //The collective bargaining unit (CBU) the employee is associated with. EmploymentInfoType employmentInfo = new EmploymentInfoType(); //employmentInfo.CBU = "R03"; CollectiveBargainingUnit cbu = CollectiveBargainingUnits.GetCollectiveBargainingUnit(emp); employmentInfo.CBU = cbu.GroupNumber; transactionTypeAppointment.EmploymentInfo = employmentInfo; transactionTypeAppointment.JobPositionInfo = new JobPositionInfoType(); //leave empty? transactionType.Appointment = transactionTypeAppointment; TransactionTypeHealthEnrollment transactionTypeHealthEnrollment = new TransactionTypeHealthEnrollment(); transactionTypeHealthEnrollment.HealthEventReason = HEALTHEVENTREASON.CodeValue.ToString(); transactionTypeHealthEnrollment.EventDateSpecified = true;//Docs say turn off for OE, //ignore that. Needed transactionTypeHealthEnrollment.ReceivedDateSpecified = true; if (emp.E_SignDate != null && emp.E_SignDate != "") { transactionTypeHealthEnrollment.ReceivedDate = DateTime.Parse(emp.E_SignDate); transactionTypeHealthEnrollment.EventDate = DateTime.Parse(emp.E_SignDate); } else { transactionTypeHealthEnrollment.ReceivedDate = DateTime.Parse("10/3/2019"); transactionTypeHealthEnrollment.EventDate = DateTime.Parse("10/3/2019"); } SubscriberInfoType subscriberInfoType = new SubscriberInfoType(); subscriberInfoType.ApplyChangeToMedicalPlan = true; subscriberInfoType.ApplyChangeToDentalPlan = false; subscriberInfoType.ApplyChangeToVisionPlan = false; //hard coded as Employer zip var heInfoTempList = HEinfoList.Where(e => e.CalPERS_ID == emp.CalPERS_ID).ToList(); if (heInfoTempList != null && heInfoTempList.Count != 0) //if they are in list with a pervious choosen type { HEInfo heiTemp = heInfoTempList.First(); if (heiTemp.HEType == "Employer Address") //if they choose employer { subscriberInfoType.HealthEligibilityZipCodeType = HealthEligibilityZipCodeTypes.EmployerAddress; subscriberInfoType.HealthEligibilityZipCode = heiTemp.HEZip; //already set, so use it instead of hardcoding subscriberInfoType.HealthEligibilityCounty = CountyCodes.SantaClara; //all schools in same county... right...? } else //this is either physical or mailing. Doesn't matter. { subscriberInfoType.HealthEligibilityZipCodeType = HealthEligibilityZipCodeTypes.PersonalAddress; subscriberInfoType.HealthEligibilityZipCode = emp.Zip; if (String.IsNullOrEmpty(emp.County)) { if (String.IsNullOrEmpty(emp.Zip)) { subscriberInfoType.HealthEligibilityCounty = CountyCodes.SantaClara; } else { subscriberInfoType.HealthEligibilityCounty = ZipAndCounties.GetCountyCode(emp.Zip); } } else { subscriberInfoType.HealthEligibilityCounty = ZipAndCounties.GetCountyCodeByName(emp.County); } } } else //the have not previously choosen an eligibility type, default to personal { subscriberInfoType.HealthEligibilityZipCodeType = HealthEligibilityZipCodeTypes.PersonalAddress; subscriberInfoType.HealthEligibilityZipCode = emp.Zip; if (String.IsNullOrEmpty(emp.County)) { if (String.IsNullOrEmpty(emp.Zip)) { subscriberInfoType.HealthEligibilityCounty = CountyCodes.SantaClara; } else { subscriberInfoType.HealthEligibilityCounty = ZipAndCounties.GetCountyCode(emp.Zip); } } else { subscriberInfoType.HealthEligibilityCounty = ZipAndCounties.GetCountyCodeByName(emp.County); } //subscriberInfoType.HealthEligibilityCounty = ZipAndCounties.GetCountyCodeByName(emp.County); } try { subscriberInfoType.MedicalPlanSelection = MedicalPlanCodes.Plans.Where( c => c.EaseID == emp.PlanImportID).First().PlanCode; } catch (InvalidOperationException ioe) { log.Error(ioe.Message); gui.UpdateStatus("Unmatched Medical Plan for " + emp.PlanImportID); transactionType = null; return(transactionType); } transactionTypeHealthEnrollment.SubscriberInfo = subscriberInfoType; transactionType.HealthEnrollment = transactionTypeHealthEnrollment; List <DependentInfoType> dependents = new List <DependentInfoType>(); foreach (CensusRow depRow in deps) { DependentInfoType dep = new DependentInfoType(); DependentPersonInfoType depInfo = new DependentPersonInfoType(); IdentifierType depInfoIdent = new IdentifierType(); depInfo.FirstName = depRow.FirstName; depInfo.LastName = depRow.LastName; depInfo.BirthDate = DateTime.Parse(depRow.BirthDate); string tempDepKey = depInfo.FirstName.Substring(0, 1) + depInfo.LastName.Substring(0, 1) + depInfo.BirthDate.ToString("MMddyyyy"); var tempCID = cidList.Where(d => d.GetDepKey() == tempDepKey). ToList(); if (tempCID.Count == 1) { String tempCIDStr = tempCID.First().CalPERSID; depInfoIdent.ItemElementName = ItemChoiceType.CalPERSId; depInfoIdent.Item = tempCIDStr; depInfo.PersonId = depInfoIdent; depInfo.PersonIdType = IdentificationType.CalPERSIndetification; } else { depInfoIdent.ItemElementName = ItemChoiceType.SSN; depInfoIdent.Item = depRow.SSN; depInfo.PersonId = depInfoIdent; depInfo.PersonIdType = IdentificationType.SocialSecurityNumber; } if (depRow.Gender == null || depRow.Gender == "") { depInfo.Gender = Gender.Unknown; } else { depInfo.Gender = depRow.Gender.Substring(0, 1); } dep.DependentPersonInfo = depInfo; dep.Relationship = GetCalPERSRelationship(depRow.Relationship); if (depRow.MaritalDate != null && depRow.MaritalDate != "") { dep.DateOfPartnership = DateTime.Parse(depRow.MaritalDate); } dep.AddressSameAsPrimarySubscriber = true; dep.DependentType = GetCalPERSDependentType(depRow.Relationship); dep.DisabilityIndicator = false; dep.ApplyToMedical = true; dep.ApplyToDental = false; dep.ApplyToVision = false; if (depRow.Disabled is null || depRow.Disabled == "") { dep.DisabilityConfirmIndicator = false; }
private void RunStudentPersonalConsumer() { StudentPersonalConsumer studentPersonalConsumer = new StudentPersonalConsumer( SettingsManager.ConsumerSettings.ApplicationKey, SettingsManager.ConsumerSettings.InstanceId, SettingsManager.ConsumerSettings.UserToken, SettingsManager.ConsumerSettings.SolutionId); studentPersonalConsumer.Register(); if (log.IsInfoEnabled) { log.Info("Registered the Consumer."); } try { IEnumerable <StudentPersonal> queriedStudents = studentPersonalConsumer.DynamicQuery("[@id=1234]"); foreach (StudentPersonal student in queriedStudents) { if (log.IsInfoEnabled) { log.Info("Queried student name is " + student.PersonInfo.Name.GivenName + " " + student.PersonInfo.Name.FamilyName); } } // Retrieve Bart Simpson using QBE. if (log.IsInfoEnabled) { log.Info("*** Retrieve Bart Simpson using QBE."); } NameOfRecordType name = new NameOfRecordType { FamilyName = "Simpson", GivenName = "Bart" }; PersonInfoType personInfo = new PersonInfoType { Name = name }; StudentPersonal studentPersonal = new StudentPersonal { PersonInfo = personInfo }; IEnumerable <StudentPersonal> filteredStudents = studentPersonalConsumer.QueryByExample(studentPersonal); foreach (StudentPersonal student in filteredStudents) { if (log.IsInfoEnabled) { log.Info("Filtered student name is " + student.PersonInfo.Name.GivenName + " " + student.PersonInfo.Name.FamilyName); } } // Create a new student. if (log.IsInfoEnabled) { log.Info("*** Create a new student."); } string[] text = new string[] { @" <MedicalCondition> <ConditionID>Unique Medical Condition ID</ConditionID> <Condition>Condition</Condition> <Severity>Condition Severity</Severity> <Details>Condition Details</Details> </MedicalCondition> " }; SIF_ExtendedElementsTypeSIF_ExtendedElement extendedElement = new SIF_ExtendedElementsTypeSIF_ExtendedElement { Name = "MedicalConditions", Text = text }; SIF_ExtendedElementsTypeSIF_ExtendedElement[] extendedElements = new SIF_ExtendedElementsTypeSIF_ExtendedElement[] { extendedElement }; NameOfRecordType newStudentName = new NameOfRecordType { FamilyName = "Wayne", GivenName = "Bruce", Type = NameOfRecordTypeType.LGL }; PersonInfoType newStudentInfo = new PersonInfoType { Name = newStudentName }; string studentID = Guid.NewGuid().ToString(); StudentPersonal newStudent = new StudentPersonal { RefId = studentID, LocalId = "555", PersonInfo = newStudentInfo, SIF_ExtendedElements = extendedElements }; try { StudentPersonal retrievedNewStudent = studentPersonalConsumer.Create(newStudent, true); if (log.IsInfoEnabled) { log.Info($"Created new student {newStudent.PersonInfo.Name.GivenName} {newStudent.PersonInfo.Name.FamilyName} with ID of {studentID}."); } } catch (UnauthorizedAccessException) { if (log.IsInfoEnabled) { log.Info($"Access to create a new student is rejected."); } } // Create multiple new students. if (log.IsInfoEnabled) { log.Info("*** Create multiple new students."); } List <StudentPersonal> newStudents = CreateStudents(5); try { MultipleCreateResponse multipleCreateResponse = studentPersonalConsumer.Create(newStudents); int count = 0; foreach (CreateStatus status in multipleCreateResponse.StatusRecords) { if (log.IsInfoEnabled) { log.Info("Create status code is " + status.StatusCode); } newStudents[count++].RefId = status.Id; } // Update multiple students. if (log.IsInfoEnabled) { log.Info("*** Update multiple students."); } foreach (StudentPersonal student in newStudents) { student.PersonInfo.Name.GivenName += "o"; } try { MultipleUpdateResponse multipleUpdateResponse = studentPersonalConsumer.Update(newStudents); foreach (UpdateStatus status in multipleUpdateResponse.StatusRecords) { if (log.IsInfoEnabled) { log.Info("Update status code is " + status.StatusCode); } } } catch (UnauthorizedAccessException) { if (log.IsInfoEnabled) { log.Info($"Access to update multiple students is rejected."); } } // Delete multiple students. if (log.IsInfoEnabled) { log.Info("*** Delete multiple students."); } ICollection <string> refIds = new List <string>(); foreach (CreateStatus status in multipleCreateResponse.StatusRecords) { refIds.Add(status.Id); } try { MultipleDeleteResponse multipleDeleteResponse = studentPersonalConsumer.Delete(refIds); foreach (DeleteStatus status in multipleDeleteResponse.StatusRecords) { if (log.IsInfoEnabled) { log.Info("Delete status code is " + status.StatusCode); } } } catch (UnauthorizedAccessException) { if (log.IsInfoEnabled) { log.Info($"Access to delete multiple students is rejected."); } } } catch (UnauthorizedAccessException) { if (log.IsInfoEnabled) { log.Info($"Access to create multiple new students is rejected."); } } // Retrieve all students from zone "Gov" and context "Curr". if (log.IsInfoEnabled) { log.Info("*** Retrieve all students from zone \"Gov\" and context \"Curr\"."); } IEnumerable <StudentPersonal> students = studentPersonalConsumer.Query(zoneId: "Gov", contextId: "Curr"); foreach (StudentPersonal student in students) { if (log.IsInfoEnabled) { log.Info("Student name is " + student.PersonInfo.Name.GivenName + " " + student.PersonInfo.Name.FamilyName); } } if (students.Count() > 1) { // Retrieve a single student. if (log.IsInfoEnabled) { log.Info("*** Retrieve a single student."); } string studentId = students.ElementAt(1).RefId; StudentPersonal secondStudent = studentPersonalConsumer.Query(studentId); if (log.IsInfoEnabled) { log.Info("Name of second student is " + secondStudent.PersonInfo.Name.GivenName + " " + secondStudent.PersonInfo.Name.FamilyName); } // Update that student and confirm. if (log.IsInfoEnabled) { log.Info("*** Update that student and confirm."); } secondStudent.PersonInfo.Name.GivenName = "Homer"; secondStudent.PersonInfo.Name.FamilyName = "Simpson"; try { studentPersonalConsumer.Update(secondStudent); secondStudent = studentPersonalConsumer.Query(studentId); if (log.IsInfoEnabled) { log.Info("Name of second student has been changed to " + secondStudent.PersonInfo.Name.GivenName + " " + secondStudent.PersonInfo.Name.FamilyName); } } catch (UnauthorizedAccessException) { if (log.IsInfoEnabled) { log.Info($"Access to update a student is rejected."); } } // Delete that student and confirm. if (log.IsInfoEnabled) { log.Info("*** Delete that student and confirm."); } try { studentPersonalConsumer.Delete(studentId); StudentPersonal deletedStudent = studentPersonalConsumer.Query(studentId); bool studentDeleted = (deletedStudent == null ? true : false); if (studentDeleted) { if (log.IsInfoEnabled) { log.Info("Student " + secondStudent.PersonInfo.Name.GivenName + " " + secondStudent.PersonInfo.Name.FamilyName + " was successfully deleted."); } } else { if (log.IsInfoEnabled) { log.Info("Student " + secondStudent.PersonInfo.Name.GivenName + " " + secondStudent.PersonInfo.Name.FamilyName + " was NOT deleted."); } } } catch (UnauthorizedAccessException) { if (log.IsInfoEnabled) { log.Info($"Access to delete a student is rejected."); } } } // Retrieve students based on Teaching Group using Service Paths. if (log.IsInfoEnabled) { log.Info("*** Retrieve students based on Teaching Group using Service Paths."); } EqualCondition condition = new EqualCondition() { Left = "TeachingGroups", Right = "597ad3fe-47e7-4b2c-b919-a93c564d19d0" }; IList <EqualCondition> conditions = new List <EqualCondition> { condition }; try { IEnumerable <StudentPersonal> teachingGroupStudents = studentPersonalConsumer.QueryByServicePath(conditions); foreach (StudentPersonal student in teachingGroupStudents) { if (log.IsInfoEnabled) { log.Info("Student name is " + student.PersonInfo.Name.GivenName + " " + student.PersonInfo.Name.FamilyName); } if (student.SIF_ExtendedElements != null && student.SIF_ExtendedElements.Length > 0) { foreach (SIF_ExtendedElementsTypeSIF_ExtendedElement element in student.SIF_ExtendedElements) { foreach (string content in element.Text) { if (log.IsInfoEnabled) { log.Info("Extended element text is ...\n" + content); } } } } } } catch (UnauthorizedAccessException) { if (log.IsInfoEnabled) { log.Info("Access to query students by Service Path TeachingGroups/{}/StudentPersonals is rejected."); } } // Retrieve student changes since a particular point as defined by the Changes Since marker. if (log.IsInfoEnabled) { log.Info("*** Retrieve student changes since a particular point as defined by the Changes Since marker."); } string changesSinceMarker = studentPersonalConsumer.GetChangesSinceMarker(); IEnumerable <StudentPersonal> changedStudents = studentPersonalConsumer.QueryChangesSince(changesSinceMarker, out string nextChangesSinceMarker); if (log.IsInfoEnabled) { log.Info("Iteration 1 - Student changes based on Changes Since marker - " + changesSinceMarker); } if (changedStudents == null || changedStudents.Count() == 0) { if (log.IsInfoEnabled) { log.Info("No student changes"); } } else { foreach (StudentPersonal student in changedStudents) { if (log.IsInfoEnabled) { log.Info("Student name is " + student.PersonInfo.Name.GivenName + " " + student.PersonInfo.Name.FamilyName); } } } changesSinceMarker = nextChangesSinceMarker; nextChangesSinceMarker = null; changedStudents = studentPersonalConsumer.QueryChangesSince(changesSinceMarker, out nextChangesSinceMarker); if (log.IsInfoEnabled) { log.Info("Iteration 2 - Student changes based on Changes Since marker - " + changesSinceMarker); } if (changedStudents == null || changedStudents.Count() == 0) { if (log.IsInfoEnabled) { log.Info("No student changes"); } } else { foreach (StudentPersonal student in changedStudents) { if (log.IsInfoEnabled) { log.Info("Student name is " + student.PersonInfo.Name.GivenName + " " + student.PersonInfo.Name.FamilyName); } } } changesSinceMarker = nextChangesSinceMarker; nextChangesSinceMarker = null; changedStudents = studentPersonalConsumer.QueryChangesSince(changesSinceMarker, out nextChangesSinceMarker); if (log.IsInfoEnabled) { log.Info("Iteration 3 - Student changes based on Changes Since marker - " + changesSinceMarker); } if (changedStudents == null || changedStudents.Count() == 0) { if (log.IsInfoEnabled) { log.Info("No student changes"); } } else { foreach (StudentPersonal student in changedStudents) { if (log.IsInfoEnabled) { log.Info("Student name is " + student.PersonInfo.Name.GivenName + " " + student.PersonInfo.Name.FamilyName); } } } } catch (UnauthorizedAccessException) { if (log.IsInfoEnabled) { log.Info($"Access to query students is rejected."); } } catch (Exception e) { if (log.IsErrorEnabled) { log.Error("Error running the StudentPersonal Consumer.\n" + ExceptionUtils.InferErrorResponseMessage(e), e); } } finally { studentPersonalConsumer.Unregister(); if (log.IsInfoEnabled) { log.Info("Unregistered the Consumer."); } } }
void RunStudentPersonalConsumer() { StudentPersonalConsumer studentPersonalConsumer = new StudentPersonalConsumer("Sif3DemoApp"); studentPersonalConsumer.Register(); if (log.IsInfoEnabled) { log.Info("Registered the Consumer."); } try { // Retrieve Bart Simpson using QBE. if (log.IsInfoEnabled) { log.Info("*** Retrieve Bart Simpson using QBE."); } NameOfRecordType name = new NameOfRecordType { FamilyName = "Simpson", GivenName = "Bart" }; PersonInfoType personInfo = new PersonInfoType { Name = name }; StudentPersonal studentPersonal = new StudentPersonal { PersonInfo = personInfo }; IEnumerable <StudentPersonal> filteredStudents = studentPersonalConsumer.QueryByExample(studentPersonal); foreach (StudentPersonal student in filteredStudents) { if (log.IsInfoEnabled) { log.Info("Filtered student name is " + student.PersonInfo.Name.GivenName + " " + student.PersonInfo.Name.FamilyName); } } // Create a new student. if (log.IsInfoEnabled) { log.Info("*** Create a new student."); } string[] text = new string[] { @" <MedicalCondition> <ConditionID>Unique Medical Condition ID</ConditionID> <Condition>Condition</Condition> <Severity>Condition Severity</Severity> <Details>Condition Details</Details> </MedicalCondition> " }; SIF_ExtendedElementsTypeSIF_ExtendedElement extendedElement = new SIF_ExtendedElementsTypeSIF_ExtendedElement { Name = "MedicalConditions", Text = text }; SIF_ExtendedElementsTypeSIF_ExtendedElement[] extendedElements = new SIF_ExtendedElementsTypeSIF_ExtendedElement[] { extendedElement }; NameOfRecordType newStudentName = new NameOfRecordType { FamilyName = "Wayne", GivenName = "Bruce", Type = NameOfRecordTypeType.LGL }; PersonInfoType newStudentInfo = new PersonInfoType { Name = newStudentName }; StudentPersonal newStudent = new StudentPersonal { LocalId = "555", PersonInfo = newStudentInfo, SIF_ExtendedElements = extendedElements }; StudentPersonal retrievedNewStudent = studentPersonalConsumer.Create(newStudent); if (log.IsInfoEnabled) { log.Info("Created new student " + newStudent.PersonInfo.Name.GivenName + " " + newStudent.PersonInfo.Name.FamilyName); } // Create multiple new students. if (log.IsInfoEnabled) { log.Info("*** Create multiple new students."); } List <StudentPersonal> newStudents = CreateStudents(5); MultipleCreateResponse multipleCreateResponse = studentPersonalConsumer.Create(newStudents); int count = 0; foreach (CreateStatus status in multipleCreateResponse.StatusRecords) { if (log.IsInfoEnabled) { log.Info("Create status code is " + status.StatusCode); } newStudents[count++].RefId = status.Id; } // Update multiple students. if (log.IsInfoEnabled) { log.Info("*** Update multiple students."); } foreach (StudentPersonal student in newStudents) { student.PersonInfo.Name.GivenName += "o"; } MultipleUpdateResponse multipleUpdateResponse = studentPersonalConsumer.Update(newStudents); foreach (UpdateStatus status in multipleUpdateResponse.StatusRecords) { if (log.IsInfoEnabled) { log.Info("Update status code is " + status.StatusCode); } } // Delete multiple students. if (log.IsInfoEnabled) { log.Info("*** Delete multiple students."); } ICollection <string> refIds = new List <string>(); foreach (CreateStatus status in multipleCreateResponse.StatusRecords) { refIds.Add(status.Id); } MultipleDeleteResponse multipleDeleteResponse = studentPersonalConsumer.Delete(refIds); foreach (DeleteStatus status in multipleDeleteResponse.StatusRecords) { if (log.IsInfoEnabled) { log.Info("Delete status code is " + status.StatusCode); } } // Retrieve all students from zone "Gov" and context "Curr". if (log.IsInfoEnabled) { log.Info("*** Retrieve all students from zone \"Gov\" and context \"Curr\"."); } IEnumerable <StudentPersonal> students = studentPersonalConsumer.Query(zone: "Gov", context: "Curr"); foreach (StudentPersonal student in students) { if (log.IsInfoEnabled) { log.Info("Student name is " + student.PersonInfo.Name.GivenName + " " + student.PersonInfo.Name.FamilyName); } } if (students.Count() > 1) { // Retrieve a single student. if (log.IsInfoEnabled) { log.Info("*** Retrieve a single student."); } string studentId = students.ElementAt(1).RefId; StudentPersonal secondStudent = studentPersonalConsumer.Query(studentId); if (log.IsInfoEnabled) { log.Info("Name of second student is " + secondStudent.PersonInfo.Name.GivenName + " " + secondStudent.PersonInfo.Name.FamilyName); } // Update that student and confirm. if (log.IsInfoEnabled) { log.Info("*** Update that student and confirm."); } secondStudent.PersonInfo.Name.GivenName = "Homer"; secondStudent.PersonInfo.Name.FamilyName = "Simpson"; studentPersonalConsumer.Update(secondStudent); secondStudent = studentPersonalConsumer.Query(studentId); if (log.IsInfoEnabled) { log.Info("Name of second student has been changed to " + secondStudent.PersonInfo.Name.GivenName + " " + secondStudent.PersonInfo.Name.FamilyName); } // Delete that student and confirm. if (log.IsInfoEnabled) { log.Info("*** Delete that student and confirm."); } studentPersonalConsumer.Delete(studentId); StudentPersonal deletedStudent = studentPersonalConsumer.Query(studentId); bool studentDeleted = (deletedStudent == null ? true : false); if (studentDeleted) { if (log.IsInfoEnabled) { log.Info("Student " + secondStudent.PersonInfo.Name.GivenName + " " + secondStudent.PersonInfo.Name.FamilyName + " was successfully deleted."); } } else { if (log.IsInfoEnabled) { log.Info("Student " + secondStudent.PersonInfo.Name.GivenName + " " + secondStudent.PersonInfo.Name.FamilyName + " was NOT deleted."); } } } // Retrieve students based on Teaching Group using Service Paths. if (log.IsInfoEnabled) { log.Info("*** Retrieve students based on Teaching Group using Service Paths."); } EqualCondition condition = new EqualCondition() { Left = "TeachingGroups", Right = "597ad3fe-47e7-4b2c-b919-a93c564d19d0" }; IList <EqualCondition> conditions = new List <EqualCondition>(); conditions.Add(condition); IEnumerable <StudentPersonal> teachingGroupStudents = studentPersonalConsumer.QueryByServicePath(conditions); foreach (StudentPersonal student in teachingGroupStudents) { if (log.IsInfoEnabled) { log.Info("Student name is " + student.PersonInfo.Name.GivenName + " " + student.PersonInfo.Name.FamilyName); } if (student.SIF_ExtendedElements != null && student.SIF_ExtendedElements.Length > 0) { foreach (SIF_ExtendedElementsTypeSIF_ExtendedElement element in student.SIF_ExtendedElements) { foreach (string content in element.Text) { if (log.IsInfoEnabled) { log.Info("Extended element text is ...\n" + content); } } } } } } catch (Exception) { throw; } finally { studentPersonalConsumer.Unregister(); if (log.IsInfoEnabled) { log.Info("Unregistered the Consumer."); } } }