public void WhenDifferentDateTimePassedToEquals_ThenFalseReturned() { ApproximateDateTime approximateDateTime = new ApproximateDateTime(new LocalDateTime(2017, 5, 18, 5, 28, 20)); LocalDateTime dateTime = new LocalDateTime(2017, 5, 18, 5, 28, 24); Assert.IsFalse(approximateDateTime.Equals(dateTime), "Equals should return false"); }
/// <summary> /// Creates a new instance of the <see cref="DurationValue"/> class with /// the specified starting and ending date. /// </summary> /// /// <param name="startDate"> /// The start date/time of the duration value. /// </param> /// /// <param name="endDate"> /// The end date/time of the duration value. /// </param> /// /// <exception cref="ArgumentNullException"> /// The <paramref name="startDate"/> or <paramref name="endDate"/> /// parameter is <b>null</b>. /// </exception> /// public DurationValue( ApproximateDateTime startDate, ApproximateDateTime endDate) { this.StartDate = startDate; this.EndDate = endDate; }
public void WhenSameDateTimePassedToEquals_ThenTrueReturned() { ApproximateDateTime approximateDateTime = new ApproximateDateTime(new LocalDateTime(2017, 5, 18, 5, 28, 20)); LocalDateTime dateTime = new LocalDateTime(2017, 5, 18, 5, 28, 20); Assert.IsTrue(approximateDateTime.Equals(dateTime), "Equals should return true"); }
public void WhenDifferentDatePassedToEquals_ThenFalseReturned() { ApproximateDateTime dateTime1 = new ApproximateDateTime(new LocalDateTime(2017, 5, 18, 5, 28, 20)); ApproximateDateTime dateTime2 = new ApproximateDateTime(new LocalDateTime(2017, 5, 18, 5, 27, 20)); Assert.IsFalse(dateTime1.Equals(dateTime2), "Equals should return false."); }
public void Test_Range_of_Days() { var baseDate = new ApproximateDateTime(); int expectedYear = -1; byte expectedMonth = 10; byte expectedDay = 1; for (int i = -3 * 30; i <= 3 * 30; i++) { var date = baseDate.Copy; date.AddDays(i); Assert.Equal(expectedDay, date.Day); Assert.Equal(expectedMonth, date.Month); Assert.Equal(expectedYear, date.Year); expectedDay += 1; if (expectedDay > 30) { expectedDay = 1; expectedMonth += 1; if (expectedMonth > 12) { expectedMonth = 1; expectedYear += 1; } } } }
internal static FhirDateTime ToFhirInternal(ApproximateDateTime approximateDateTime) { if (!approximateDateTime.ApproximateDate.Day.HasValue) { if (!approximateDateTime.ApproximateDate.Month.HasValue) { return(new FhirDateTime(approximateDateTime.ApproximateDate.Year)); } else { return(new FhirDateTime(approximateDateTime.ApproximateDate.Year, approximateDateTime.ApproximateDate.Month.Value)); } } else if (approximateDateTime.ApproximateTime == null || !approximateDateTime.ApproximateTime.HasValue) { return(new FhirDateTime(approximateDateTime.ApproximateDate.Year, approximateDateTime.ApproximateDate.Month.Value, approximateDateTime.ApproximateDate.Day.Value)); } else { var dateTime = new DateTime( approximateDateTime.ApproximateDate.Year, approximateDateTime.ApproximateDate.Month.Value, approximateDateTime.ApproximateDate.Day.Value, approximateDateTime.ApproximateTime.Hour, approximateDateTime.ApproximateTime.Minute, approximateDateTime.ApproximateTime?.Second ?? 0, approximateDateTime.ApproximateTime?.Millisecond ?? 0); return(new FhirDateTime(dateTime)); } }
public void Add_Month() { var startDate = new ApproximateDateTime(); startDate.AddMonths(2); Assert.Equal(startDate.Month, 3); }
public void Subtract_Year() { var startDate = new ApproximateDateTime(); startDate.AddYears(-3); Assert.Equal(startDate.Year, -3); }
public void Add_Year() { var startDate = new ApproximateDateTime(); startDate.AddYears(3); Assert.Equal(startDate.Year, 3); }
public void Add_Day() { var startDate = new ApproximateDateTime(); startDate.AddDays(2); Assert.Equal(startDate.Day, 3); }
public void WhenSameDatePassedToEquals_ThenTrueReturned() { ApproximateDate date = new ApproximateDate(2017); ApproximateDateTime dateTime1 = new ApproximateDateTime(date); ApproximateDateTime dateTime2 = new ApproximateDateTime(date); Assert.IsTrue(dateTime1.Equals(dateTime2), "Equals should return true."); }
public void Add_Months_Beyond_Year() { var startDate = new ApproximateDateTime(); startDate.AddMonths(14); Assert.Equal(startDate.Month, 3); Assert.Equal(startDate.Year, 1); }
public void Subtract_Day() { var startDate = new ApproximateDateTime(); startDate.AddDays(-3); Assert.Equal(28, startDate.Day); Assert.Equal(12, startDate.Month); Assert.Equal(-1, startDate.Year); }
public void Absolute_Event_Test() { // Expectations var firstDate = new ApproximateDateTime(); // Create First Event Event firstEvent = EventFactory.AbsoluteEvent("First Event", firstDate); Assert.True(firstEvent.EventDate.Equals(firstDate), $"Expected ApproximateDateTime of {firstDate}, recieved: {firstEvent.EventDate}"); }
public void WhenHeathVaultApproximateDateTimeTransformedToFhir_ThenValuesEqual() { var testDateTime = new LocalDateTime(2017, 8, 3, 10, 17, 16, 115); var approximateDateTime = new ApproximateDateTime(testDateTime); var fhirDateTime = approximateDateTime.ToFhir(); Assert.IsNotNull(fhirDateTime); Assert.AreEqual(testDateTime.ToDateTimeUnspecified(), fhirDateTime.ToDateTime().Value); }
/// <summary> /// Stores a body dimension. /// </summary> /// /// <remarks> /// Examples: Waist size, head circumference, length (pediatric). /// </remarks> /// /// <param name="when"> /// The date and time of the body dimension measurement. /// </param> /// /// <param name="measurementName"> /// The name of the body dimension measurement. /// </param> /// /// <param name="value"> /// The value of the body dimension measurement. /// </param> /// /// <exception cref="ArgumentNullException"> /// If <paramref name="when"/>, <paramref name="measurementName"/> or /// <paramref name="value"/> is <b>null</b>. /// </exception> /// public BodyDimension( ApproximateDateTime when, CodableValue measurementName, Length value) : base(TypeId) { When = when; MeasurementName = measurementName; Value = value; }
/// <summary> /// Constructs an instance of suggested calorie intake guideline with specified values. /// </summary> /// /// <remarks> /// Examples: Daily calories suggested for weight loss, calories needed for weight /// maintenance, BMR. /// </remarks> /// /// <param name="when"> /// The date and time the guidelines were created. /// </param> /// /// <param name="name"> /// The name definies the guideline. /// </param> /// /// <param name="calories"> /// The number of calories to support the guideline. /// </param> /// /// <exception cref="ArgumentNullException"> /// If <paramref name="when"/>, <paramref name="name"/> or <paramref name="calories"/> /// is <b>null</b>. /// </exception> /// public CalorieGuideline( ApproximateDateTime when, CodableValue name, GeneralMeasurement calories) : base(TypeId) { When = when; Name = name; Calories = calories; }
/// <summary> /// Creates an instance of information about the body composition of the record owner /// with specified time, measurement name, and value. /// </summary> /// /// <remarks> /// Examples: % body fat, lean muscle mass. /// </remarks> /// /// <param name="when"> /// The date and time of the measurement. /// </param> /// /// <param name="measurementName"> /// The name of the measurement. /// </param> /// /// <param name="compositionValue"> /// The value of the measurement. /// </param> /// /// <exception cref="ArgumentNullException"> /// If <paramref name="when"/>, <paramref name="measurementName"/> or /// <paramref name="compositionValue"/> is <b>null</b>. /// </exception> /// public BodyComposition( ApproximateDateTime when, CodableValue measurementName, BodyCompositionValue compositionValue) : base(TypeId) { When = when; MeasurementName = measurementName; Value = compositionValue; }
public void Subtract_Hour() { var startDate = new ApproximateDateTime(); startDate.AddHours(-3); Assert.Equal(21, startDate.Hour); Assert.Equal(30, startDate.Day); Assert.Equal(12, startDate.Month); Assert.Equal(-1, startDate.Year); }
internal static FhirDateTime ToFhirInternal(ApproximateDateTime approximateDateTime) { var dateTime = new DateTime( approximateDateTime.ApproximateDate.Year, approximateDateTime.ApproximateDate.Month ?? 1, approximateDateTime.ApproximateDate.Day ?? 1, approximateDateTime.ApproximateTime?.Hour ?? 0, approximateDateTime.ApproximateTime?.Minute ?? 0, approximateDateTime.ApproximateTime?.Second ?? 0, approximateDateTime.ApproximateTime?.Millisecond ?? 0); return(new FhirDateTime(dateTime)); }
public void Subtract_Month() { var startDate = new ApproximateDateTime(); startDate.AddMonths(-3); Assert.Equal(10, startDate.Month); Assert.Equal(-1, startDate.Year); startDate.AddMonths(-26); Assert.Equal(8, startDate.Month); Assert.Equal(-3, startDate.Year); }
public void WhenHeathVaultApproximateDateTimePartialTransformedToFhir_ThenDefaultValuesEqual() { // Year only var approximateDateTime1 = new ApproximateDateTime(new ApproximateDate(2017)); var expectedDateTime1 = new DateTime(2017, 1, 1); var fhirDateTime1 = approximateDateTime1.ToFhir(); Assert.IsNotNull(fhirDateTime1); Assert.AreEqual(expectedDateTime1, fhirDateTime1.ToDateTime().Value); // Year, month only var approximateDateTime2 = new ApproximateDateTime(new ApproximateDate(2017, 8)); var expectedDateTime2 = new DateTime(2017, 8, 1); var fhirDateTime2 = approximateDateTime2.ToFhir(); Assert.IsNotNull(fhirDateTime2); Assert.AreEqual(expectedDateTime2, fhirDateTime2.ToDateTime().Value); // Year, month, day only var approximateDateTime3 = new ApproximateDateTime(new ApproximateDate(2017, 8, 3)); var expectedDateTime3 = new DateTime(2017, 8, 3); var fhirDateTime3 = approximateDateTime3.ToFhir(); Assert.IsNotNull(fhirDateTime3); Assert.AreEqual(expectedDateTime3, fhirDateTime3.ToDateTime().Value); // Year, month, day, hour, minute only var approximateDateTime4 = new ApproximateDateTime(new ApproximateDate(2017, 8, 3), new ApproximateTime(10, 15)); var expectedDateTime4 = new DateTime(2017, 8, 3, 10, 15, 0); var fhirDateTime4 = approximateDateTime4.ToFhir(); Assert.IsNotNull(fhirDateTime4); Assert.AreEqual(expectedDateTime4, fhirDateTime4.ToDateTime().Value); // Year, month, day, hour, minute, second only var approximateDateTime5 = new ApproximateDateTime(new ApproximateDate(2017, 8, 3), new ApproximateTime(10, 15, 30)); var expectedDateTime5 = new DateTime(2017, 8, 3, 10, 15, 30); var fhirDateTime5 = approximateDateTime5.ToFhir(); Assert.IsNotNull(fhirDateTime5); Assert.AreEqual(expectedDateTime5, fhirDateTime5.ToDateTime().Value); // Year, month, day, hour, minute, second, millisecond only var approximateDateTime6 = new ApproximateDateTime(new ApproximateDate(2017, 8, 3), new ApproximateTime(10, 15, 30, 115)); var expectedDateTime6 = new DateTime(2017, 8, 3, 10, 15, 30, 115); var fhirDateTime6 = approximateDateTime6.ToFhir(); Assert.IsNotNull(fhirDateTime6); Assert.AreEqual(expectedDateTime6, fhirDateTime6.ToDateTime().Value); }
public void Before_Event_Test() { // Expectations var firstDate = new ApproximateDateTime(1); var beforeDate = new ApproximateDateTime(0, 12); // Create First Event Event firstEvent = EventFactory.AbsoluteEvent("First Event", firstDate); // Create event 1 month before firstEvent Event beforeEvent = EventFactory.BeforeEvent("Before Event - Before First Event", firstEvent, new ApproximateDateTimeOffset(months: 1)); Assert.True(firstEvent.EventDate.Equals(firstDate), $"Expected ApproximateDateTime of {firstDate}, recieved: {firstEvent.EventDate}"); Assert.True(beforeEvent.EventDate.Equals(beforeDate), $"Expected ApproximateDateTime of {beforeDate}, recieved: {beforeEvent.EventDate}"); }
public void After_Event_Test() { // Expectations var firstDate = new ApproximateDateTime(); var afterDate = new ApproximateDateTime(1); // Create First Event Event firstEvent = EventFactory.AbsoluteEvent("First Event", firstDate); // Create event 1 year after first event Event afterEvent = EventFactory.AfterEvent("Second Event - After First Event", firstEvent, new ApproximateDateTimeOffset(years: 1)); Assert.True(firstEvent.EventDate.Equals(firstDate), $"Expected ApproximateDateTime of {firstDate}, recieved: {firstEvent.EventDate}"); Assert.True(afterEvent.EventDate.Equals(afterDate), $"Expected ApproximateDateTime of {afterDate}, recieved: {afterEvent.EventDate}"); }
protected void addSymptoms(object sender, EventArgs e) { String[] symptomValues = new String[] { c_pain.Text, c_nausea.Text, c_sleep.Text, c_fatigue.Text, c_constipation.Text }; for (int i = 0; i < 5; i++) { Condition condition = new Condition(); CodableValue symptomName = new CodableValue(Symptom.symptomNames[i]); condition.Name = symptomName; ApproximateDateTime now = new ApproximateDateTime(DateTime.Now); condition.OnsetDate = now; CodableValue symptomValue = new CodableValue(symptomValues[i]); condition.Status = symptomValue; PersonInfo.SelectedRecord.NewItem(condition); } }
public void Exact_Date_Between_Events_Test() { // Expectations var firstDate = new ApproximateDateTime(); var lastDate = new ApproximateDateTime(3); var betweenDate = new ApproximateDateTime(1); // Create First / Last Events Event firstEvent = EventFactory.AbsoluteEvent("First Event", firstDate); Event lastEvent = EventFactory.AbsoluteEvent("Last Event", lastDate); // Create Between Event Event betweenEvent = EventFactory.BetweenEvents("Between Event", firstEvent, new ApproximateDateTimeOffset(years: 1), lastEvent, new ApproximateDateTimeOffset(years: 2)); Assert.True(firstEvent.EventDate.Equals(firstDate), $"Expected ApproximateDateTime of {firstDate}, recieved: {firstEvent.EventDate}"); Assert.True(lastEvent.EventDate.Equals(lastDate), $"Expected ApproximateDateTime of {lastDate}, recieved: {lastEvent.EventDate}"); Assert.True(betweenEvent.EventDate.Equals(betweenDate), $"Expected ApproximateDateTime of {betweenDate}, recieved: {betweenEvent.EventDate}"); }
public static DateTime ApproximateDateTimeToDateTime(ApproximateDateTime medicationDateStarted) { ApproximateDate date = medicationDateStarted?.ApproximateDate; DateTime current; if (date == null) { current = EmptyDate; } else { var year = date.Year; var month = (date.Month != null) ? date.Month.Value : 1; var day = (date.Day != null) ? date.Day.Value : 1; current = new DateTime(year, month, day); } return(current); }
public void Concurrent_Event_Test() { // Expectations var firstDate = new ApproximateDateTime(); var concurrentDate = new ApproximateDateTime(0, 3 + 1); var negativeConcurrentDate = new ApproximateDateTime(-1, 9, 30 - 12 + 1); // Create First Event Event firstEvent = EventFactory.AbsoluteEvent("First Event", firstDate); // Create Concurrent Events Event ConcurrentEvent = EventFactory.ConcurrentEvent("Concurrent Event", firstEvent, new ApproximateDateTimeOffset(months: 3)); // negative Concurrent Event - subtract 3 months and 12 days Event NegativeConcurrentEvent = EventFactory.ConcurrentEvent("Negative Concurrent Event", firstEvent, new ApproximateDateTimeOffset(days: -3 * 30 - 12)); Assert.True(firstEvent.EventDate.Equals(firstDate), $"Expected ApproximateDateTime of {firstDate}, recieved: {firstEvent.EventDate}"); Assert.True(ConcurrentEvent.EventDate.Equals(concurrentDate), $"Expected ApproximateDateTime of {concurrentDate}, recieved: {ConcurrentEvent.EventDate}"); Assert.True(NegativeConcurrentEvent.EventDate.Equals(negativeConcurrentDate), $"Expected ApproximateDateTime of {negativeConcurrentDate}, recieved: {NegativeConcurrentEvent.EventDate}"); }
public void Test_Range_of_Months() { var baseDate = new ApproximateDateTime(); int expectedYear = -3; byte expectedMonth = 0; for (int i = -3 * 12; i <= 3 * 12; i++) { var date = baseDate.Copy; date.AddMonths(i); expectedMonth += 1; if (expectedMonth > 12) { expectedMonth = 1; expectedYear += 1; } Assert.Equal(expectedMonth, date.Month); Assert.Equal(expectedYear, date.Year); } }
public void Test_Range_of_Hours() { var baseDate = new ApproximateDateTime(); int expectedYear = -1; byte expectedMonth = 12; byte expectedDay = 28; byte expectedHour = 0; for (int i = -3 * 24; i <= 3 * 24; i++) { var date = baseDate.Copy; date.AddHours(i); Assert.Equal(expectedHour, date.Hour); Assert.Equal(expectedDay, date.Day); Assert.Equal(expectedMonth, date.Month); Assert.Equal(expectedYear, date.Year); expectedHour += 1; if (expectedHour >= 24) { expectedHour = 0; expectedDay += 1; if (expectedDay > 30) { expectedDay = 1; expectedMonth += 1; if (expectedMonth > 12) { expectedMonth = 1; expectedYear += 1; } } } } }
/// <summary> /// Populates the data from the specified XML. /// </summary> /// /// <param name="navigator"> /// The XML containing the delivery. /// </param> /// /// <exception cref="ArgumentNullException"> /// The <paramref name="navigator"/> parameter is <b>null</b>. /// </exception> /// public override void ParseXml(XPathNavigator navigator) { Validator.ThrowIfNavigatorNull(navigator); _location = XPathHelper.GetOptNavValue<Organization>(navigator, "location"); _timeOfDelivery = XPathHelper.GetOptNavValue<ApproximateDateTime>(navigator, "time-of-delivery"); _laborDuration = XPathHelper.GetOptNavValueAsDouble(navigator, "labor-duration"); _complications.Clear(); foreach (XPathNavigator complicationNav in navigator.Select("complications")) { CodableValue complication = new CodableValue(); complication.ParseXml(complicationNav); _complications.Add(complication); } _anesthesia.Clear(); foreach (XPathNavigator anesthesiaNav in navigator.Select("anesthesia")) { CodableValue anesthesia = new CodableValue(); anesthesia.ParseXml(anesthesiaNav); _anesthesia.Add(anesthesia); } _deliveryMethod = XPathHelper.GetOptNavValue<CodableValue>(navigator, "delivery-method"); _outcome = XPathHelper.GetOptNavValue<CodableValue>(navigator, "outcome"); _baby = XPathHelper.GetOptNavValue<Baby>(navigator, "baby"); _note = XPathHelper.GetOptNavValue(navigator, "note"); }
/// <summary> /// Creates a new instance of the <see cref="HealthEvent"/> class /// specifying mandatory values. /// </summary> /// /// <remarks> /// This item is not added to the health record until the /// <see cref="Microsoft.Health.HealthRecordAccessor.NewItem(HealthRecordItem)"/> method /// is called. /// </remarks> /// /// <param name="when"> /// The date and time the event occurred. /// </param> /// <param name="eventValue"> /// The name of the health event. /// </param> /// /// <exception cref="ArgumentNullException"> /// If <paramref name="when"/> is <b>null</b>. /// If <paramref name="eventValue"/> is <b>null</b>. /// </exception> /// public HealthEvent( ApproximateDateTime when, CodableValue eventValue) : base(TypeId) { When = when; Event = eventValue; }
public void WhenNullPassedToEquals_ThenFalseReturned() { ApproximateDateTime dateTime = new ApproximateDateTime(); Assert.IsFalse(dateTime.Equals(null), "Equals should return false."); }
public void WhenWrongTypePassedToEquals_ThenFalseReturned() { ApproximateDateTime dateTime = new ApproximateDateTime(); Assert.IsFalse(dateTime.Equals(this), "Equals should return false."); }
/// <summary> /// Create a new miles to HealthVault /// </summary> public static bool SaveMilesToHV(PersonInfo info, DateTime dateRecorded, double distance, ProfileModel profile) { ApproximateDateTime hvDate = new ApproximateDateTime( new ApproximateDate(dateRecorded.Year, dateRecorded.Month, dateRecorded.Day), new ApproximateTime( dateRecorded.Hour, dateRecorded.Minute, dateRecorded.Second)); Exercise newData = new Exercise((ApproximateDateTime)hvDate, new CodableValue("walk", new CodedValue("walk", "aerobic-activities"))); DisplayValue hvDisplay = new DisplayValue(distance, "Miles"); //convert miles into meters if (distance > 0) { newData.Distance = new Length(DataConversion.ConvertMilesToMeters(distance), hvDisplay); } if (profile.UserCtx.user_stride > 0) newData.Details.Add(ExerciseDetail.Steps_count, new ExerciseDetail(new CodedValue(ExerciseDetail.Steps_count, "exercise-detail-names"), new StructuredMeasurement( DataConversion.GetStepsFromDistanceAndStride(distance, profile.UserCtx.user_stride), new CodableValue("Count", new CodedValue("Count", "exercise-units"))))); if (profile.UserCtx.user_weight > 0) newData.Details.Add(ExerciseDetail.CaloriesBurned_calories, new ExerciseDetail(new CodedValue(ExerciseDetail.CaloriesBurned_calories, "exercise-detail-names"), new StructuredMeasurement( DataConversion.GetEnergyFromDistanceAndWeightNotNullable(distance, profile.UserCtx.user_weight), new CodableValue("Calories", new CodedValue("Calories", "exercise-units"))) )); info.SelectedRecord.NewItem(newData); return true; //Success }
/// <summary> /// Populates the data from the specified XML. /// </summary> /// /// <param name="navigator"> /// The XML containing the goal information. /// </param> /// /// <exception cref="ArgumentNullException"> /// The <paramref name="navigator"/> parameter is <b>null</b>. /// </exception> /// public override void ParseXml(XPathNavigator navigator) { Validator.ThrowIfNavigatorNull(navigator); XPathNavigator targetNav = navigator.SelectSingleNode("target-date"); if (targetNav != null) { _targetDate = new ApproximateDateTime(); _targetDate.ParseXml(targetNav); } XPathNavigator completionNav = navigator.SelectSingleNode("completion-date"); if (completionNav != null) { _completionDate = new ApproximateDateTime(); _completionDate.ParseXml(completionNav); } XPathNavigator statusNav = navigator.SelectSingleNode("status"); if (statusNav != null) { try { _status = (GoalStatus) Enum.Parse(typeof(GoalStatus), statusNav.Value, true); } catch (ArgumentException) { _status = GoalStatus.Unknown; _statusString = statusNav.Value; } } }
/// <summary> /// Populates this <see cref="HealthJournalEntry"/> instance from the data in the specified XML. /// </summary> /// /// <param name="typeSpecificXml"> /// The XML to get the HealthJournalEntry data from. /// </param> /// /// <exception cref="ArgumentNullException"> /// If <paramref name="typeSpecificXml"/> parameter is <b>null</b>. /// </exception> /// /// <exception cref="InvalidOperationException"> /// If the first node in <paramref name="typeSpecificXml"/> is not /// a HealthJournalEntry node. /// </exception> /// protected override void ParseXml(IXPathNavigable typeSpecificXml) { Validator.ThrowIfArgumentNull(typeSpecificXml, "typeSpecificXml", "ParseXmlNavNull"); XPathNavigator itemNav = typeSpecificXml.CreateNavigator().SelectSingleNode("health-journal-entry"); Validator.ThrowInvalidIfNull(itemNav, "HealthJournalEntryUnexpectedNode"); _when = new ApproximateDateTime(); _when.ParseXml(itemNav.SelectSingleNode("when")); _content = itemNav.SelectSingleNode("content").Value; _category = XPathHelper.GetOptNavValue<CodableValue>(itemNav, "category"); }
/// <summary> /// Populates this <see cref="Directive"/> instance from the data in the XML. /// </summary> /// /// <param name="typeSpecificXml"> /// The XML to get the directive data from. /// </param> /// /// <exception cref="InvalidOperationException"> /// The first node of the <paramref name="typeSpecificXml"/> /// parameter is not a directive node. /// </exception> /// protected override void ParseXml(IXPathNavigable typeSpecificXml) { XPathNavigator itemNav = typeSpecificXml.CreateNavigator().SelectSingleNode("directive"); Validator.ThrowInvalidIfNull(itemNav, "DirectiveUnexpectedNode"); // <start-date> _startDate = new ApproximateDateTime(); _startDate.ParseXml(itemNav.SelectSingleNode("start-date")); // <stop-date> _stopDate = new ApproximateDateTime(); _stopDate.ParseXml(itemNav.SelectSingleNode("stop-date")); // <description> _description = XPathHelper.GetOptNavValue(itemNav, "description"); // <full-resuscitation> _fullResuscitation = XPathHelper.GetOptNavValueAsBool(itemNav, "full-resuscitation"); // <prohibited-interventions> _prohibitedInterventions = XPathHelper.GetOptNavValue<CodableValue>( itemNav, "prohibited-interventions"); // <additional-instructions> _additionalInstructions = XPathHelper.GetOptNavValue(itemNav, "additional-instructions"); // <attending-physician> _attendingPhysician = XPathHelper.GetOptNavValue<PersonItem>( itemNav, "attending-physician"); // <attending-physician-endorsement> _attendingPhysicianEndorsement = XPathHelper.GetOptNavValue<HealthServiceDateTime>( itemNav, "attending-physician-endorsement"); // <attending-nurse> _attendingNurse = XPathHelper.GetOptNavValue<PersonItem>( itemNav, "attending-nurse"); // <attending-nurse-endorsement" type="d:date-time"> _attendingNurseEndorsement = XPathHelper.GetOptNavValue<HealthServiceDateTime>( itemNav, "attending-nurse-endorsement"); // <expiration-date> _expirationDate = XPathHelper.GetOptNavValue<HealthServiceDateTime>( itemNav, "expiration-date"); // <discontinuation-date> _discontinuationDate = XPathHelper.GetOptNavValue<ApproximateDateTime>( itemNav, "discontinuation-date"); // <discontinuation-physician> _discontinuationPhysician = XPathHelper.GetOptNavValue<PersonItem>( itemNav, "discontinuation-physician"); // <discontinuation-physician-endorsement> _discontinuationPhysicianEndorsement = XPathHelper.GetOptNavValue<HealthServiceDateTime>( itemNav, "discontinuation-physician-endorsement"); // <discontinuation-nurse> _discontinuationNurse = XPathHelper.GetOptNavValue<PersonItem>( itemNav, "discontinuation-nurse"); // <discontinuation-nurse-endorsement> _discontinuationNurseEndorsement = XPathHelper.GetOptNavValue<HealthServiceDateTime>( itemNav, "discontinuation-nurse-endorsement"); }
/// <summary> /// Populates this <see cref="Allergy"/> instance from the data in the XML. /// </summary> /// /// <param name="typeSpecificXml"> /// The XML to get the allergy data from. /// </param> /// /// <exception cref="InvalidOperationException"> /// The first node in <paramref name="typeSpecificXml"/> is not /// an allergy node. /// </exception> /// protected override void ParseXml(IXPathNavigable typeSpecificXml) { _name.Clear(); XPathNavigator itemNav = typeSpecificXml.CreateNavigator().SelectSingleNode("allergy"); Validator.ThrowInvalidIfNull(itemNav, "AllergyUnexpectedNode"); // <name> _name.ParseXml(itemNav.SelectSingleNode("name")); // <reaction> _reaction = XPathHelper.GetOptNavValue<CodableValue>( itemNav, "reaction"); // <first-observed> _firstObserved = XPathHelper.GetOptNavValue<ApproximateDateTime>( itemNav, "first-observed"); // <allergen-type> _allergen = XPathHelper.GetOptNavValue<CodableValue>( itemNav, "allergen-type"); // <allergen-code> _allergenCode = XPathHelper.GetOptNavValue<CodableValue>( itemNav, "allergen-code"); // <treatment-provider> _treatmentProvider = XPathHelper.GetOptNavValue<PersonItem>( itemNav, "treatment-provider"); // <treatment> _treatment = XPathHelper.GetOptNavValue<CodableValue>( itemNav, "treatment"); // <is-negated> _isNegated = XPathHelper.GetOptNavValueAsBool(itemNav, "is-negated"); }
/// <summary> /// Populates this <see cref="CarePlan"/> instance from the data in the specified XML. /// </summary> /// /// <param name="typeSpecificXml"> /// The XML to get the CarePlan data from. /// </param> /// /// <exception cref="ArgumentNullException"> /// If <paramref name="typeSpecificXml"/> parameter is <b>null</b>. /// </exception> /// /// <exception cref="InvalidOperationException"> /// If the first node in <paramref name="typeSpecificXml"/> is not /// a CarePlan node. /// </exception> /// protected override void ParseXml(IXPathNavigable typeSpecificXml) { Validator.ThrowIfArgumentNull(typeSpecificXml, "typeSpecificXml", "ParseXmlNavNull"); XPathNavigator itemNav = typeSpecificXml.CreateNavigator().SelectSingleNode("care-plan"); Validator.ThrowInvalidIfNull(itemNav, "CarePlanUnexpectedNode"); _name = itemNav.SelectSingleNode("name").Value; _startDate = XPathHelper.GetOptNavValue<ApproximateDateTime>(itemNav, "start-date"); _status = XPathHelper.GetOptNavValue<CodableValue>(itemNav, "status"); _carePlanManager = XPathHelper.GetOptNavValue<PersonItem>(itemNav, "care-plan-manager"); // collections _careTeam = XPathHelper.ParseXmlCollection<PersonItem>(itemNav, "care-team/person"); _tasks = XPathHelper.ParseXmlCollection<CarePlanTask>(itemNav, "tasks/task"); _goalGroups = XPathHelper.ParseXmlCollection<CarePlanGoalGroup>(itemNav, "goal-groups/goal-group"); }
private static void ValidateDates( ApproximateDateTime startDate, ApproximateDateTime endDate) { if (startDate != null && endDate != null) { if (startDate.ApproximateDate != null && endDate.ApproximateDate != null) { Validator.ThrowArgumentExceptionIf( startDate.CompareTo(endDate) > 0, "StartDate and EndDate", "CarePlanTaskDateInvalid"); } } }
/// <summary> /// Creates a new instance of the <see cref="DurationValue"/> class with /// the specified starting date. /// </summary> /// /// <param name="startDate"> /// The starting date/time of the duration value. /// </param> /// /// <exception cref="ArgumentNullException"> /// The <paramref name="startDate"/> parameter is <b>null</b>. /// </exception> /// public DurationValue(ApproximateDateTime startDate) { this.StartDate = startDate; }
// Register the type on the generic ItemBaseToFhir partial class public static FhirDateTime ToFhir(this ApproximateDateTime approximateDateTime) { return(ApproximateDateTimeToFhir.ToFhirInternal(approximateDateTime)); }
/// <summary> /// Populates this medication instance from the data in the XML. /// </summary> /// /// <param name="typeSpecificXml"> /// The XML to get the medication data from. /// </param> /// /// <exception cref="InvalidOperationException"> /// If the first node in <paramref name="typeSpecificXml"/> is not /// a medication node. /// </exception> /// protected override void ParseXml(IXPathNavigable typeSpecificXml) { XPathNavigator itemNav = typeSpecificXml.CreateNavigator().SelectSingleNode("medication"); Validator.ThrowInvalidIfNull(itemNav, "MedicationUnexpectedNode"); _name = new CodableValue(); _name.ParseXml(itemNav.SelectSingleNode("name")); _genericName = XPathHelper.GetOptNavValue<CodableValue>(itemNav, "generic-name"); _dose = XPathHelper.GetOptNavValue<GeneralMeasurement>(itemNav, "dose"); _strength = XPathHelper.GetOptNavValue<GeneralMeasurement>(itemNav, "strength"); _frequency = XPathHelper.GetOptNavValue<GeneralMeasurement>(itemNav, "frequency"); _route = XPathHelper.GetOptNavValue<CodableValue>(itemNav, "route"); _indication = XPathHelper.GetOptNavValue<CodableValue>(itemNav, "indication"); _dateStarted = XPathHelper.GetOptNavValue<ApproximateDateTime>(itemNav, "date-started"); _dateDiscontinued = XPathHelper.GetOptNavValue<ApproximateDateTime>(itemNav, "date-discontinued"); _prescribed = XPathHelper.GetOptNavValue<CodableValue>(itemNav, "prescribed"); _prescription = XPathHelper.GetOptNavValue<Prescription>(itemNav, "prescription"); }
public static string ApproximateDateTimeToString(ApproximateDateTime medicationDateStarted) { var current = ApproximateDateTimeToDateTime(medicationDateStarted); return(current.ToString(System.Globalization.DateTimeFormatInfo.CurrentInfo.ShortDatePattern)); }
/// <summary> /// Creates a new instance of the <see cref="HealthJournalEntry"/> class /// specifying mandatory values. /// </summary> /// /// <remarks> /// This item is not added to the health record until the /// <see cref="Microsoft.Health.HealthRecordAccessor.NewItem(HealthRecordItem)"/> method /// is called. /// </remarks> /// /// <param name="when"> /// The date and time associated with the journal entry. /// </param> /// <param name="content"> /// The text content of this health journal entry. /// </param> /// /// <exception cref="ArgumentException"> /// If <paramref name="content"/> is <b>null</b>, empty or contains only whitespace. /// </exception> /// /// <exception cref="ArgumentNullException"> /// If <paramref name="when"/> is <b>null</b>. /// </exception> /// public HealthJournalEntry( ApproximateDateTime when, string content) : base(TypeId) { When = when; Content = content; }
/// <summary> /// Creates a new instance of the <see cref="Comment"/> class /// specifying mandatory values. /// </summary> /// /// <remarks> /// This item is not added to the health record until the /// <see cref="Microsoft.Health.HealthRecordAccessor.NewItem(HealthRecordItem)"/> method /// is called. /// </remarks> /// /// <param name="when"> /// The date and time associated with the comment. /// </param> /// <param name="content"> /// The text content of this health comment. /// </param> /// /// <exception cref="ArgumentException"> /// If <paramref name="content"/> is <b>null</b>, empty or contains only whitespace. /// </exception> /// /// <exception cref="ArgumentNullException"> /// If <paramref name="when"/> is <b>null</b>. /// </exception> /// public Comment( ApproximateDateTime when, string content) : base(TypeId) { When = when; Content = content; }
/// <summary> /// Creates a new instance of the <see cref="Goal"/> class with the specified /// target date. /// </summary> /// /// <param name="targetDate"> /// The approximate date which is the target completion date /// for the goal. /// </param> /// public Goal(ApproximateDateTime targetDate) { this.TargetDate = targetDate; }
/// <summary> /// Populates this <see cref="GeneticSnpResults"/> instance from the data /// in the XML. /// </summary> /// /// <param name="typeSpecificXml"> /// The XML to get the genetic snp result data from. /// </param> /// /// <exception cref="InvalidOperationException"> /// If the first node in <paramref name="typeSpecificXml"/> is not /// an "genetic-snp-results" node. /// </exception> /// protected override void ParseXml(IXPathNavigable typeSpecificXml) { XPathNavigator itemNav = typeSpecificXml.CreateNavigator().SelectSingleNode("genetic-snp-results"); Validator.ThrowInvalidIfNull(itemNav, "GeneticSnpResultsUnexpectedNode"); // <when> mandatory _when = new ApproximateDateTime(); _when.ParseXml(itemNav.SelectSingleNode("when")); // <genome-build> mandatory _genomeBuild = itemNav.SelectSingleNode("genome-build").Value; // <chromosome> mandatory _chromosome = itemNav.SelectSingleNode("chromosome").Value; // <numbering-scheme> mandatory int numberingScheme = itemNav.SelectSingleNode("numbering-scheme").ValueAsInt; if ((numberingScheme == 0) || (numberingScheme == 1)) { _numberingScheme = (GenomeNumberingScheme)numberingScheme; } else { _numberingScheme = GenomeNumberingScheme.Unknown; } // ordered-by _orderedBy = XPathHelper.GetOptNavValue<Organization>(itemNav, "ordered-by"); // test-provider _testProvider = XPathHelper.GetOptNavValue<Organization>(itemNav, "test-provider"); // laboratory-name _laboratoryName = XPathHelper.GetOptNavValue<Organization>(itemNav, "laboratory-name"); // annotation-version _annotationVersion = XPathHelper.GetOptNavValue(itemNav, "annotation-version"); // dbSNP-build _dbSnpBuild = XPathHelper.GetOptNavValue(itemNav, "dbSNP-build"); // platform _platform = XPathHelper.GetOptNavValue(itemNav, "platform"); }
/// <summary> /// Populates this <see cref="CarePlanTask"/> instance from the data in the specified XML. /// </summary> /// /// <param name="navigator"> /// The XML to get the CarePlanTask data from. /// </param> /// /// <exception cref="ArgumentNullException"> /// If <paramref name="navigator"/> parameter is <b>null</b>. /// </exception> /// public override void ParseXml(XPathNavigator navigator) { Validator.ThrowIfNavigatorNull(navigator); _name = new CodableValue(); _name.ParseXml(navigator.SelectSingleNode("name")); _description = XPathHelper.GetOptNavValue(navigator, "description"); _startDate = XPathHelper.GetOptNavValue<ApproximateDateTime>(navigator, "start-date"); _endDate = XPathHelper.GetOptNavValue<ApproximateDateTime>(navigator, "end-date"); _sequenceNumber = XPathHelper.GetOptNavValueAsInt(navigator, "sequence-number"); _contact = XPathHelper.GetOptNavValue<PersonItem>(navigator, "contact"); _recurrence = XPathHelper.GetOptNavValue<CarePlanTaskRecurrence>(navigator, "recurrence"); _thingTypeVersionId = XPathHelper.GetOptNavValueAsGuid(navigator, "thing-type-version-id"); _thingTypeXPath = XPathHelper.GetOptNavValue(navigator, "thing-type-xpath"); _referenceId = XPathHelper.GetOptNavValue(navigator, "reference-id"); }
/// <summary> /// Create a new step to HealthVault /// </summary> public static bool SaveStepsToHV(PersonInfo info, DateTime dateRecorded, long steps, ProfileModel profile) { ApproximateDateTime hvDate = new ApproximateDateTime( new ApproximateDate(dateRecorded.Year, dateRecorded.Month, dateRecorded.Day), new ApproximateTime( dateRecorded.Hour, dateRecorded.Minute, dateRecorded.Second)); Exercise newData = new Exercise(hvDate, new CodableValue("walk", new CodedValue("walk", "aerobic-activities"))); newData.Details.Add(ExerciseDetail.Steps_count, new ExerciseDetail(new CodedValue(ExerciseDetail.Steps_count, "exercise-detail-names"), new StructuredMeasurement( (double)steps, new CodableValue("Count", new CodedValue("Count", "exercise-units"))))); if (profile.UserCtx.user_stride > 0) { double? distance = DataConversion.GetDistanceFromSteps(profile.UserCtx.user_stride, steps); if (distance.HasValue && distance.Value > 0) { newData.Distance = new Length(DataConversion.ConvertMilesToMeters(distance.Value)); } if (profile.UserCtx.user_weight > 0) { newData.Details.Add(ExerciseDetail.CaloriesBurned_calories, new ExerciseDetail(new CodedValue(ExerciseDetail.CaloriesBurned_calories, "exercise-detail-names"), new StructuredMeasurement( DataConversion.GetEnergyFromSteps(profile.UserCtx.user_stride, profile.UserCtx.user_weight, (int)steps).Value, new CodableValue("Calories", new CodedValue("Calories", "exercise-units"))) )); } } info.SelectedRecord.NewItem(newData); return true; //Success }
/// <summary> /// Creates a new instance of the <see cref="Directive"/> class /// specifying the mandatory values. /// </summary> /// /// <param name="startDate"> /// The date the directive takes effect. /// </param> /// /// <param name="stopDate"> /// The date the directive stops being effective. /// </param> /// /// <exception cref="ArgumentNullException"> /// The <paramref name="startDate"/> parameter or <paramref name="stopDate"/> /// is <b>null</b> or empty. /// </exception> /// public Directive( ApproximateDateTime startDate, ApproximateDateTime stopDate) : base(TypeId) { this.StartDate = startDate; this.StopDate = stopDate; }
/// <summary> /// Populates this <see cref="ImmunizationV1"/> instance from the data in the XML. /// </summary> /// /// <param name="typeSpecificXml"> /// The XML to get the immunization data from. /// </param> /// /// <exception cref="InvalidOperationException"> /// The first node in <paramref name="typeSpecificXml"/> is not /// an immunization node. /// </exception> /// protected override void ParseXml(IXPathNavigable typeSpecificXml) { XPathNavigator itemNav = typeSpecificXml.CreateNavigator().SelectSingleNode( "immunization"); Validator.ThrowInvalidIfNull(itemNav, "ImmunizationUnexpectedNode"); // <name> _name.ParseXml(itemNav.SelectSingleNode("name")); // <administration-date> _dateAdministrated = XPathHelper.GetOptNavValue<ApproximateDateTime>( itemNav, "administration-date"); // <administrator> _administrator = XPathHelper.GetOptNavValue<PersonItem>( itemNav, "administrator"); // <manufacturer> _manufacturer = XPathHelper.GetOptNavValue(itemNav, "manufacturer"); // <lot> _lot = XPathHelper.GetOptNavValue(itemNav, "lot"); // <route> _route = XPathHelper.GetOptNavValue<CodableValue>( itemNav, "route"); // <expiration-date> approx-date-time _expirationDate = XPathHelper.GetOptNavValue<ApproximateDate>( itemNav, "expiration-date"); // <sequence> _sequence = XPathHelper.GetOptNavValue(itemNav, "sequence"); // <anatomic-surface> _anatomicSurface = XPathHelper.GetOptNavValue<CodableValue>( itemNav, "anatomic-surface"); // <adverse-event> string _adverseEvent = XPathHelper.GetOptNavValue(itemNav, "adverse-event"); // <consent> _consent = XPathHelper.GetOptNavValue(itemNav, "consent"); }
/// <summary> /// Populates this <see cref="LabTestResults"/> instance from the data in the XML. /// </summary> /// /// <param name="typeSpecificXml"> /// The XML to get the lab test results data from. /// </param> /// /// <exception cref="InvalidOperationException"> /// If the first node in <paramref name="typeSpecificXml"/> is not /// a lab test results node. /// </exception> /// protected override void ParseXml(IXPathNavigable typeSpecificXml) { XPathNavigator itemNav = typeSpecificXml.CreateNavigator().SelectSingleNode("lab-test-results"); Validator.ThrowInvalidIfNull(itemNav, "LabTestResultsUnexpectedNode"); // when _when = XPathHelper.GetOptNavValue<ApproximateDateTime>(itemNav, "when"); // lab-group XPathNodeIterator labGroupIterator = itemNav.Select("lab-group"); _labGroup = new Collection<LabTestResultGroup>(); foreach (XPathNavigator labGroupNav in labGroupIterator) { LabTestResultGroup labTestResultGroup = new LabTestResultGroup(); labTestResultGroup.ParseXml(labGroupNav); _labGroup.Add(labTestResultGroup); } // ordered-by _orderedBy = XPathHelper.GetOptNavValue<Organization>(itemNav, "ordered-by"); }
/// <summary> /// Creates a new instance of the <see cref="ImmunizationV1"/> class /// specifying the mandatory values. /// </summary> /// /// <param name="name"> /// The name of the immunization. /// </param> /// /// <param name="dateAdministrated"> /// The approximate date that the immunization was adminstrated. /// </param> /// /// <exception cref="ArgumentNullException"> /// The <paramref name="name"/> or <paramref name="dateAdministrated"/> parameter is null. /// </exception> /// public ImmunizationV1(CodableValue name, ApproximateDateTime dateAdministrated) : base(TypeId) { this.Name = name; this.DateAdministrated = dateAdministrated; }
/// <summary> /// Creates an instance of <see cref="GeneticSnpResults"/> with specified /// parameters. /// </summary> /// /// <param name="when">The date and time of the SNP test.</param> /// /// <param name="genomeBuild">The genome build that defines the SNPs.</param> /// /// <param name="chromosome">The chromosome on which the SNPs are located.</param> /// /// <param name="numberingScheme">The numbering scheme used for positions.</param> /// /// <exception cref="ArgumentNullException"> /// If <paramref name="when"/> is <b> null</b>. /// </exception> /// /// <exception cref="ArgumentException"> /// If <paramref name="genomeBuild"/> or <paramref name="chromosome" /> /// is <b>null</b> or empty, or <paramref name="numberingScheme"/> is not 0 or 1. /// </exception> /// /// <exception cref="ArgumentOutOfRangeException" > /// The <paramref name="numberingScheme" /> is neither zero based scheme nor one /// based scheme. /// </exception> /// public GeneticSnpResults( ApproximateDateTime when, string genomeBuild, string chromosome, GenomeNumberingScheme numberingScheme) : base(TypeId) { When = when; GenomeBuild = genomeBuild; Chromosome = chromosome; NumberingScheme = numberingScheme; Sections |= HealthRecordItemSections.BlobPayload; }
/// <summary> /// Populates this discharge summary instance from the data in the XML. /// </summary> /// /// <param name="typeSpecificXml"> /// The XML to get the discharge summary data from. /// </param> /// /// <exception cref="InvalidOperationException"> /// The first node of the <paramref name="typeSpecificXml"/> parameter is not /// a discharge summary node. /// </exception> /// protected override void ParseXml(IXPathNavigable typeSpecificXml) { XPathNavigator itemNav = typeSpecificXml.CreateNavigator().SelectSingleNode("discharge-summary"); Validator.ThrowInvalidIfNull(itemNav, "DischargeSummaryUnexpectedNode"); // <when> _when = new HealthServiceDateTime(); _when.ParseXml(itemNav.SelectSingleNode("when")); // <type> _type = XPathHelper.GetOptNavValue<CodableValue>(itemNav, "type"); // <category> _category = XPathHelper.GetOptNavValue<CodableValue>(itemNav, "category"); // <setting> _setting = XPathHelper.GetOptNavValue<CodableValue>(itemNav, "setting"); // <specialty> _specialty = XPathHelper.GetOptNavValue(itemNav, "specialty"); // <text> _text = XPathHelper.GetOptNavValue(itemNav, "text"); // <primary-provider> _primaryProvider = XPathHelper.GetOptNavValue<PersonItem>( itemNav, "primary-provider"); // <primary-provider-endorsement> _primaryProviderEndorsement = XPathHelper.GetOptNavValue<HealthServiceDateTime>( itemNav, "primary-provider-endorsement"); // <secondary-provider> _secondaryProvider = XPathHelper.GetOptNavValue<PersonItem>( itemNav, "secondary-provider"); // <secondary-provider-endorsement> _secondaryProviderEndorsement = XPathHelper.GetOptNavValue<HealthServiceDateTime>( itemNav, "secondary-provider-endorsement"); // <discharge-date-time> _dischargeDateTime = XPathHelper.GetOptNavValue<ApproximateDateTime>( itemNav, "discharge-date-time"); // <admitting-diagnosis> _admittingDiagnosis = XPathHelper.GetOptNavValue<CodableValue>( itemNav, "admitting-diagnosis"); // <principal-diagnosis> _principalDiagnosis = XPathHelper.GetOptNavValue<CodableValue>( itemNav, "principal-diagnosis"); // <additional-diagnosis> _additionalDiagnosis = XPathHelper.GetOptNavValue<CodableValue>( itemNav, "additional-diagnosis"); // <principal-procedure-physician> _principalProcedurePhysician = XPathHelper.GetOptNavValue<PersonItem>( itemNav, "principal-procedure-physician"); // <principal-procedure> _principalProcedure = XPathHelper.GetOptNavValue<CodableValue>( itemNav, "principal-procedure"); // <additional-procedure> _additionalProcedure = XPathHelper.GetOptNavValue<CodableValue>( itemNav, "additional-procedure"); }
/// <summary> /// Populates this <see cref="Personal"/> instance from the data in the XML. /// </summary> /// /// <param name="typeSpecificXml"> /// The XML to get the personal data from. /// </param> /// /// <exception cref="InvalidOperationException"> /// The first node in <paramref name="typeSpecificXml"/> is not /// a personal node. /// </exception> /// protected override void ParseXml(IXPathNavigable typeSpecificXml) { XPathNavigator itemNav = typeSpecificXml.CreateNavigator().SelectSingleNode("personal"); Validator.ThrowInvalidIfNull(itemNav, "PersonalUnexpectedNode"); _name = XPathHelper.GetOptNavValue<Name>(itemNav, "name"); _birthDate = XPathHelper.GetOptNavValue<HealthServiceDateTime>( itemNav, "birthdate"); _bloodtype = XPathHelper.GetOptNavValue<CodableValue>( itemNav, "blood-type"); _ethnicity = XPathHelper.GetOptNavValue<CodableValue>( itemNav, "ethnicity"); _ssn = XPathHelper.GetOptNavValue(itemNav, "ssn"); _maritalStatus = XPathHelper.GetOptNavValue<CodableValue>( itemNav, "marital-status"); _employmentStatus = XPathHelper.GetOptNavValue(itemNav, "employment-status"); // <is-deceased> _isDeceased = XPathHelper.GetOptNavValueAsBool( itemNav, "is-deceased"); // <date-of-death> _dateOfDeath = XPathHelper.GetOptNavValue<ApproximateDateTime>( itemNav, "date-of-death"); // <religion> _religion = XPathHelper.GetOptNavValue<CodableValue>( itemNav, "religion"); // <is-veteran> _isVeteran = XPathHelper.GetOptNavValueAsBool(itemNav, "is-veteran"); // <highest-education-level> _highestEducationLevel = XPathHelper.GetOptNavValue<CodableValue>( itemNav, "highest-education-level"); // <is-disabled> _isDisabled = XPathHelper.GetOptNavValueAsBool(itemNav, "is-disabled"); // <organ-donor> _organDonor = XPathHelper.GetOptNavValue(itemNav, "organ-donor"); }
/// <summary> /// Populates this Person instance from the data in the XML. /// </summary> /// /// <param name="navigator"> /// The XML containing the duration information. /// </param> /// /// <exception cref="InvalidOperationException"> /// The first node in <paramref name="navigator"/> is not /// a person node. /// </exception> /// public override void ParseXml(XPathNavigator navigator) { Validator.ThrowIfNavigatorNull(navigator); // <start-date> _startDate = new ApproximateDateTime(); _startDate.ParseXml(navigator.SelectSingleNode("start-date")); // <end-date> _endDate = XPathHelper.GetOptNavValue<ApproximateDateTime>( navigator, "end-date"); }