public void WhenDosageCreatedFromHV_RouteIsCopied() { const string routeText = "By mouth"; var hvRoute = new CodableValue(routeText); var dosage = HealthVaultCodesToFhir.GetDosage(null, null, hvRoute); Assert.AreEqual(routeText, dosage.Route.Text); }
/// <summary> /// Creates a new instance of the <see cref="Service"/> 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="serviceType"> /// The type of the service. /// </param> /// <param name="serviceDates"> /// The dates for this service. /// </param> /// <param name="claimAmounts"> /// The financial information for this service. /// </param> /// <exception cref="ArgumentNullException"> /// If <paramref name="serviceType"/> is <b> null </b>. /// If <paramref name="serviceDates"/> is <b> null </b>. /// If <paramref name="claimAmounts"/> is <b> null </b>. /// </exception> /// public Service( CodableValue serviceType, DurationValue serviceDates, ClaimAmounts claimAmounts) { ServiceType = serviceType; ServiceDates = serviceDates; ClaimAmounts = claimAmounts; }
/// <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 a new instance of the <see cref="CarePlanGoalGroup"/> class /// specifying mandatory values. /// </summary> /// /// <param name="name"> /// Name of the goal group. /// </param> /// <param name="goals"> /// List of care plan goals associated with this goal group. /// </param> /// /// <exception cref="ArgumentNullException"> /// If <paramref name="name"/> is <b>null</b>. /// If <paramref name="goals"/> is <b>null</b>. /// </exception> /// public CarePlanGoalGroup( CodableValue name, Collection<CarePlanGoal> goals) { Name = name; Validator.ThrowArgumentExceptionIf(goals == null, "goals", "CarePlanGoalGroupGroupsNull"); Validator.ThrowArgumentExceptionIf(goals.Count == 0, "goals", "CarePlanGoalGroupGroupsNull"); _goals = goals; }
public File(string name, string contentType) : this() { if (string.IsNullOrEmpty(name)) { throw new ArgumentException("name"); } Name = name; ContentType = new CodableValue(contentType); }
public void SetTemperatureOnHealthVault(double tempValue) { try { if (!_isProvisioned) { MessageBox.Show("Please provision application first"); return; } HealthClientAuthorizedConnection connection = HealthClientApplication.CreateAuthorizedConnection(PersonId); HealthRecordAccessor accessor = new HealthRecordAccessor(connection, RecordId); TemperatureMeasurement temperature = new TemperatureMeasurement(tempValue); VitalSigns vitalSign = new VitalSigns(); //generate random date DateTime startDate = new DateTime(2018, 1, 1); DateTime endDate = new DateTime(2018, 12, 30); TimeSpan timeSpan = endDate - startDate; var randomTest = new Random(); TimeSpan newSpan = new TimeSpan(0, randomTest.Next(0, (int)timeSpan.TotalMinutes), 0); DateTime newDate = startDate + newSpan; //set time now //vitalSign.When = new HealthServiceDateTime(DateTime.UtcNow); vitalSign.When = new HealthServiceDateTime(newDate); CodableValue codableValue = new CodableValue(); codableValue.Text = "celsius"; VitalSignsResultType vitalSignsResultType = new VitalSignsResultType(); vitalSignsResultType.Unit = codableValue; vitalSignsResultType.TextValue = "Temperature"; vitalSignsResultType.Title.Text = "Temperature"; vitalSignsResultType.Value = tempValue; vitalSign.VitalSignsResults.Add(vitalSignsResultType); accessor.NewItem(vitalSign); } catch (Exception ex) { throw; } }
public static CodeableConcept ToFhir(this CodableValue codableValue) { var codeableConcept = new CodeableConcept { Text = codableValue.Text, }; foreach (var code in codableValue) { codeableConcept.Coding.Add(code.ToFhir()); } return(codeableConcept); }
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 static CodableValue ToCodableValue(this CodeableConcept codeableConcept) { if (codeableConcept == null) { return(null); } var codableValue = new CodableValue { Text = codeableConcept.Text, }; foreach (var coding in codeableConcept.Coding) { codableValue.Add(coding.ToCodedValue()); } return(codableValue); }
private static bool?IsAllowed(CodableValue substitution) { Func <CodedValue, bool> medicationSubstitutionPredicate = coded => coded.VocabularyName == HealthVaultVocabularies.MedicationSubstitution; var codedValue = substitution.FirstOrDefault(medicationSubstitutionPredicate); switch (codedValue?.Value) { case HealthVaultMedicationSubstitutionCodes.DispenseAsWrittenCode: return(false); case HealthVaultMedicationSubstitutionCodes.SubstitutionPermittedCode: return(true); case null: default: return(null); } }
private static Timing.UnitsOfTime?GetPeriodUnitFromFromRecurrenceIntervals(CodableValue units) { Func <CodedValue, bool> recurrenceIntervalsPredicate = coded => coded.VocabularyName == HealthVaultVocabularies.RecurrenceIntervals; if (units.Any(recurrenceIntervalsPredicate)) { var coded = units.First(recurrenceIntervalsPredicate); switch (coded.Value) { case HealthVaultRecurrenceIntervalCodes.SecondCode: return(Timing.UnitsOfTime.S); case HealthVaultRecurrenceIntervalCodes.MinuteCode: return(Timing.UnitsOfTime.Min); case HealthVaultRecurrenceIntervalCodes.HourCode: return(Timing.UnitsOfTime.H); case HealthVaultRecurrenceIntervalCodes.DayCode: return(Timing.UnitsOfTime.D); case HealthVaultRecurrenceIntervalCodes.WeekCode: return(Timing.UnitsOfTime.Wk); case HealthVaultRecurrenceIntervalCodes.MonthCode: return(Timing.UnitsOfTime.Mo); case HealthVaultRecurrenceIntervalCodes.YearCode: return(Timing.UnitsOfTime.A); default: throw new NotImplementedException(); } } else { throw new NotImplementedException(); } }
public IAsyncAction UploadAsync(IRecord record, string contentType, int size, IInputStream stream) { if (record == null) { throw new ArgumentNullException("record"); } return(AsyncInfo.Run( async cancelToken => { Size = size; if (string.IsNullOrEmpty(contentType)) { contentType = HttpStreamer.OctetStreamMimeType; } ContentType = new CodableValue(contentType); var blobInfo = new BlobInfo(contentType); await record.PutBlobInItem(Item, blobInfo, stream).AsTask(cancelToken); } )); }
/// <summary> /// Populates this <see cref="DailyMedicationUsage"/> instance from the /// data in the XML. /// </summary> /// /// <param name="typeSpecificXml"> /// The XML to get the medication usage data from. /// </param> /// /// <exception cref="InvalidOperationException"> /// The first node in <paramref name="typeSpecificXml"/> is not /// a <see cref="DailyMedicationUsage"/> node. /// </exception> /// protected override void ParseXml(IXPathNavigable typeSpecificXml) { XPathNavigator itemNav = typeSpecificXml.CreateNavigator().SelectSingleNode( "daily-medication-usage"); Validator.ThrowInvalidIfNull(itemNav, "DailyMedicationUsageUnexpectedNode"); _when = new HealthServiceDate(); _when.ParseXml(itemNav.SelectSingleNode("when")); _drugName = new CodableValue(); _drugName.ParseXml(itemNav.SelectSingleNode("drug-name")); _dosesConsumed = itemNav.SelectSingleNode("number-doses-consumed-in-day").ValueAsInt; _purposeOfUse = XPathHelper.GetOptNavValue<CodableValue>(itemNav, "purpose-of-use"); _intendedDoses = XPathHelper.GetOptNavValueAsInt(itemNav, "number-doses-intended-in-day"); _usageSchedule = XPathHelper.GetOptNavValue<CodableValue>(itemNav, "medication-usage-schedule"); _drugForm = XPathHelper.GetOptNavValue<CodableValue>(itemNav, "drug-form"); _prescriptionType = XPathHelper.GetOptNavValue<CodableValue>(itemNav, "prescription-type"); _singleDoseDescription = XPathHelper.GetOptNavValue<CodableValue>(itemNav, "single-dose-description"); }
/// <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> /// Constructs the new blood glucose health record item instance /// specifying the mandatory values. /// </summary> /// /// <param name="when"> /// The date/time when the blood glucose reading was take. /// </param> /// /// <param name="value"> /// The blood glucose value of the reading. /// </param> /// /// <param name="glucoseMeasurementType"> /// How the glucose was measured; whole blood, plasma, etc. /// </param> /// /// <exception cref="ArgumentNullException"> /// The <paramref name="when"/> parameter is <b>null</b>. /// </exception> /// public BloodGlucose( HealthServiceDateTime when, BloodGlucoseMeasurement value, CodableValue glucoseMeasurementType) : base(TypeId) { this.When = when; this.Value = value; this.GlucoseMeasurementType = glucoseMeasurementType; }
/// <summary> /// Populates this health assessment instance from the data in the XML. /// </summary> /// /// <param name="typeSpecificXml"> /// The XML to get the health assessment data from. /// </param> /// /// <exception cref="InvalidOperationException"> /// If the first node in <paramref name="typeSpecificXml"/> is not /// a health-assessment node. /// </exception> /// protected override void ParseXml(IXPathNavigable typeSpecificXml) { XPathNavigator itemNav = typeSpecificXml.CreateNavigator().SelectSingleNode("health-assessment"); Validator.ThrowInvalidIfNull(itemNav, "HealthAssessmentUnexpectedNode"); // <when> _when = new HealthServiceDateTime(); _when.ParseXml(itemNav.SelectSingleNode("when")); // <name> _name = itemNav.SelectSingleNode("name").Value; // <category> _category = new CodableValue(); _category.ParseXml(itemNav.SelectSingleNode("category")); // <result> _result.Clear(); XPathNodeIterator resultIterator = itemNav.Select("result"); foreach (XPathNavigator resultNav in resultIterator) { Assessment result = new Assessment(); result.ParseXml(resultNav); _result.Add(result); } }
/// <summary> /// Initialize a new instance of the <see cref="TestResultRange"/> /// class with mandatory parameters. /// </summary> /// /// <param name="type"> /// Type is the type of a test result. /// </param> /// /// <param name="text"> /// Text is the range expressed as text. /// </param> /// /// <exception cref="ArgumentNullException"> /// If <paramref name="text"/> or <paramref name="type"/> is <b> null </b>. /// </exception> /// public TestResultRange(CodableValue type, CodableValue text) { RangeType = type; Text = text; }
private static List <Dosage> AddDosage(GeneralMeasurement dose, GeneralMeasurement frequency, CodableValue route) { return(new List <Dosage> { HealthVaultCodesToFhir.GetDosage(dose, frequency, route) }); }
/// <summary> /// Creates a new instance of the <see cref="InsulinInjectionUse"/> class /// with the specified date/time, insulin type, and amount. /// </summary> /// /// <param name="when"> /// The date/time when the injection was administrated. /// </param> /// /// <param name="insulinType"> /// The type of insulin being used. /// </param> /// /// <param name="amount"> /// The amount of insulin. /// </param> /// /// <exception cref="ArgumentNullException"> /// The <paramref name="when"/>, /// <paramref name="amount"/>, or <paramref name="insulinType"/> parameter /// is <b>null</b>. /// </exception> /// public InsulinInjectionUse( HealthServiceDateTime when, CodableValue insulinType, InsulinInjectionMeasurement amount) : base(TypeId) { this.When = when; this.InsulinType = insulinType; this.Amount = amount; }
public Medication(string name) : this() { Name = new CodableValue(name); }
public void WhenHeathVaultExerciseTransformedToFhir_ThenCodeAndValuesEqual() { var swimmingCodableValue = new CodableValue("Swimming", "swimming", "exercise-activities", "wc", "1"); var secondsCodableValue = new CodableValue("seconds", "s", "duration-units", "wc", "1"); var exerciseSegment = new ExerciseSegment(swimmingCodableValue) { Duration = 180, Distance = new Length(31.5), Offset = 43.3, Title = "Segment 1" }; exerciseSegment.Details.Add("segment 1 - lap 1", new ExerciseDetail(swimmingCodableValue[0], new StructuredMeasurement(46.2, secondsCodableValue))); exerciseSegment.Details.Add("segment 1 - lap 2", new ExerciseDetail(swimmingCodableValue[0], new StructuredMeasurement(21, secondsCodableValue))); var exercise = new Exercise(new ApproximateDateTime(SystemClock.Instance.InUtc().GetCurrentLocalDateTime()), swimmingCodableValue) { Distance = new Length(30), Duration = 10, Title = "New Swim" }; exercise.Segments.Add(exerciseSegment); exercise.Details.Add("lap 1", new ExerciseDetail(swimmingCodableValue[0], new StructuredMeasurement(30, secondsCodableValue))); exercise.Details.Add("lap 2", new ExerciseDetail(swimmingCodableValue[0], new StructuredMeasurement(28, secondsCodableValue))); var observation = exercise.ToFhir(); Assert.IsNotNull(observation); Assert.AreEqual(5, observation.Extension.Count); Assert.AreEqual(HealthVaultThingTypeNameCodes.Exercise, observation.Code.Coding[0]); var detailExtensions = observation.Extension.Where(x => x.Url == HealthVaultExtensions.ExerciseDetail).ToList(); Assert.AreEqual(2, detailExtensions.Count); Assert.AreEqual("lap 1", ((FhirString)detailExtensions[0].Extension[0].Value).Value); Assert.AreEqual("swimming", ((Coding)detailExtensions[0].Extension[1].Value).Code); Assert.AreEqual(30, ((Quantity)detailExtensions[0].Extension[2].Value).Value); Assert.AreEqual("seconds", ((Quantity)detailExtensions[0].Extension[2].Value).Unit); var segmentExtensions = observation.Extension.Where(x => x.Url == HealthVaultExtensions.ExerciseSegment).ToList(); Assert.AreEqual(1, segmentExtensions.Count); Assert.AreEqual("swimming", ((CodeableConcept)segmentExtensions[0].Extension[0].Value).Coding[0].Code); Assert.AreEqual("Segment 1", ((FhirString)segmentExtensions[0].Extension[1].Value).Value); Assert.AreEqual(180, ((FhirDecimal)segmentExtensions[0].Extension[2].Value).Value); Assert.AreEqual(31.5m, ((Quantity)segmentExtensions[0].Extension[3].Value).Value); Assert.AreEqual(43.3m, ((FhirDecimal)segmentExtensions[0].Extension[4].Value).Value); Assert.AreEqual(3, segmentExtensions[0].Extension[5].Extension.Count); Assert.AreEqual("segment 1 - lap 1", ((FhirString)segmentExtensions[0].Extension[5].Extension[0].Value).Value); Assert.AreEqual(HealthVaultVocabularies.ExerciseDistance, observation.Component[0].Code.Text); Assert.AreEqual(30, ((Quantity)observation.Component[0].Value).Value); Assert.AreEqual("m", ((Quantity)observation.Component[0].Value).Unit); Assert.AreEqual(HealthVaultVocabularies.ExerciseDuration, observation.Component[1].Code.Text); Assert.AreEqual(10, ((Quantity)observation.Component[1].Value).Value); Assert.AreEqual("min", ((Quantity)observation.Component[1].Value).Unit); Assert.AreEqual(HealthVaultVocabularies.ExerciseActivity, observation.Component[2].Code.Text); Assert.AreEqual("swimming", ((CodeableConcept)observation.Component[2].Value).Coding[0].Code); }
/// <summary> /// Constructs a new instance of the <see cref="Assessment"/> class /// with name and value. /// </summary> /// /// <param name="name"> /// The name of the assessed area. See <see cref="Name"/> for more information. /// </param> /// /// <param name="value"> /// The calculated value of the assessed area. See <see cref="Value"/> for more information. /// </param> /// /// <exception cref="ArgumentNullException"> /// If <paramref name="name"/> or <paramref name="value"/> is <b> null </b>. /// </exception> /// public Assessment(CodableValue name, CodableValue value) { Name = name; Value = value; }
public Immunization(string name) : this() { Name = new CodableValue(name); }
private static void SetAllergyIntoleranceCategory(this AllergyIntolerance allergyIntolerance, CodableValue allergenType, Extension allergyExtension) { List <AllergyIntoleranceCategory?> lstAllergyIntoleranceCategory = new List <AllergyIntoleranceCategory?>(); string aValue = allergenType.FirstOrDefault().Value; AllergyIntoleranceCategory allergyIntoleranceCategory; if (aValue != null) { if (Enum.TryParse(aValue, true, out allergyIntoleranceCategory)) { lstAllergyIntoleranceCategory.Add(allergyIntoleranceCategory); } else { allergyExtension.AddExtension(HealthVaultExtensions.AllergenType, new FhirString(aValue)); } } if (lstAllergyIntoleranceCategory.Count > 0) { allergyIntolerance.Category = lstAllergyIntoleranceCategory; } }
public Procedure(string name) : this() { Name = new CodableValue(name); }
/// <summary> /// Creates a new instance of the <see cref="DailyMedicationUsage"/> class /// specifying the mandatory values. /// </summary> /// /// <param name="when"> /// The date when the medication/supplement was consumed. /// </param> /// /// <param name="drugName"> /// The name of the drug. /// </param> /// /// <param name="dosesConsumed"> /// The number of doses consumed by the person. /// </param> /// /// <exception cref="ArgumentNullException"> /// The <paramref name="when"/> or <paramref name="drugName"/> parameter is <b>null</b>. /// </exception> /// public DailyMedicationUsage( HealthServiceDate when, CodableValue drugName, int dosesConsumed) : base(TypeId) { this.When = when; this.DrugName = drugName; this.DosesConsumed = dosesConsumed; }
/// <summary> /// Sets the content of the file instance using the specified stream. /// </summary> /// /// <param name="stream"> /// The stream containing the data to associate with this <see cref="File"/> instance. /// </param> /// /// <param name="record"> /// The record to stream the data to. /// </param> /// /// <param name="name"> /// The name of the file instance. /// </param> /// /// <param name="contentType"> /// The content type of the file. /// </param> /// /// <exception cref="ArgumentException"> /// If <paramref name="name"/> is <b>null</b> or empty. /// </exception> /// /// <exception cref="ArgumentNullException"> /// If <paramref name="record"/>, <paramref name="stream"/> or <paramref name="contentType"/> is <b>null</b>. /// </exception> /// /// <exception cref="HealthServiceException"> /// If a failure occurs streaming the data to HealthVault. /// </exception> /// public void SetContent( HealthRecordAccessor record, Stream stream, String name, CodableValue contentType) { Validator.ThrowIfArgumentNull(record, "record", "FileRecordMustBeSpecified"); Validator.ThrowIfArgumentNull(stream, "stream", "FileStreamMustBeSpecified"); Validator.ThrowIfStringNullOrEmpty(name, "name"); Validator.ThrowIfArgumentNull(contentType, "contentType", "FileContentTypeMustBeSpecified"); if (stream.CanSeek) { Size = stream.Length; } Name = name; ContentType = contentType; BlobStore store = GetBlobStore(record); Blob blob = store.NewBlob(String.Empty, ContentType.Text); blob.Write(stream); }
/// <summary> /// Populates this <see cref="TestResultRange"/> instance from the data in the XML. /// </summary> /// /// <param name="navigator"> /// The XML to get the test result range data from. /// </param> /// /// <exception cref="ArgumentNullException"> /// The first node in <paramref name="navigator"/> is <b>null</b>. /// </exception> /// public override void ParseXml(XPathNavigator navigator) { Validator.ThrowIfNavigatorNull(navigator); // type _rangeType = new CodableValue(); _rangeType.ParseXml(navigator.SelectSingleNode("type")); // text _text = new CodableValue(); _text.ParseXml(navigator.SelectSingleNode("text")); // value _value = XPathHelper.GetOptNavValue<TestResultRangeValue>(navigator, "value"); }
/// <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"); }
/// <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"); }
internal static Dosage GetDosage(GeneralMeasurement dose, GeneralMeasurement frequency, CodableValue route) { var dosage = new Dosage(); if (route != null) { dosage.Route = route.ToFhir(); } if (frequency != null) { dosage.Text = frequency.Display; dosage.Timing = GetTiming(frequency); } if (dose != null) { dosage.Text = string.Join(Environment.NewLine, dose.Display, dosage.Text); dosage.Dose = GetSimpleQuantity(dose); } return(dosage); }
/// <summary> /// Populates this <see cref="Assessment"/> instance from the data in the XML. /// </summary> /// /// <param name="navigator"> /// The XML to get the assessment data from. /// </param> /// /// <exception cref="ArgumentNullException"> /// If <paramref name="navigator"/> is <b> null </b>. /// </exception> /// public override void ParseXml(XPathNavigator navigator) { Validator.ThrowIfNavigatorNull(navigator); // <name> _name = new CodableValue(); _name.ParseXml(navigator.SelectSingleNode("name")); // <value> _value = new CodableValue(); _value.ParseXml(navigator.SelectSingleNode("value")); // <group> _group = XPathHelper.GetOptNavValue<CodableValue>(navigator, "group"); }
public Condition(string name) : this() { Name = new CodableValue(name); }
/// <summary> /// Populates this <see cref="InsulinInjectionUse"/> instance from the /// data in the XML. /// </summary> /// /// <param name="typeSpecificXml"> /// The XML to get the insulin injection use data from. /// </param> /// /// <exception cref="InvalidOperationException"> /// The first node in <paramref name="typeSpecificXml"/> is not /// an insulin-injection-use node. /// </exception> /// protected override void ParseXml(IXPathNavigable typeSpecificXml) { XPathNavigator itemNav = typeSpecificXml.CreateNavigator().SelectSingleNode( "diabetes-insulin-injection-use"); Validator.ThrowInvalidIfNull(itemNav, "InsulinInjectionUseUnexpectedNode"); _when = new HealthServiceDateTime(); _when.ParseXml(itemNav.SelectSingleNode("when")); _insulinType = new CodableValue(); _insulinType.ParseXml(itemNav.SelectSingleNode("type")); _amount = new InsulinInjectionMeasurement(); _amount.ParseXml(itemNav.SelectSingleNode("amount")); XPathNavigator deviceIdNav = itemNav.SelectSingleNode("device-id"); if (deviceIdNav != null) { _deviceId = deviceIdNav.Value; } }
/// <summary> /// Creates a new instance of the <see cref="Allergy"/> class /// specifying the mandatory values. /// </summary> /// /// <param name="name"> /// The name of the allergy. /// </param> /// /// <exception cref="ArgumentNullException"> /// The <paramref name="name"/> parameter is <b>null</b>. /// </exception> /// public Allergy(CodableValue name) : base(TypeId) { this.Name = name; }
/// <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> /// Creates a <see cref="File"/> item instance using the specified stream and content /// type. /// </summary> /// /// <param name="record"> /// The record to stream the data to. /// </param> /// /// <param name="stream"> /// The stream containing the data to associate with this <see cref="File"/> instance. /// </param> /// /// <param name="name"> /// The name of the file instance. /// </param> /// /// <param name="contentType"> /// The content type of the file. This is usually something like "image/jpg", "application/csv", /// or other mime type. /// </param> /// /// <returns> /// A new instance of the <see cref="File"/> health record item with data populated from the /// specified stream. /// </returns> /// /// <exception cref="ArgumentException"> /// If <paramref name="name"/> is <b>null</b> or empty. /// </exception> /// /// <exception cref="ArgumentNullException"> /// If <paramref name="record"/>, <paramref name="stream"/>, or /// <paramref name="contentType"/> is <b>null</b>. /// </exception> /// /// <exception cref="HealthServiceException"> /// If a failure occurs streaming the data to HealthVault. /// </exception> /// public static File CreateFromStream( HealthRecordAccessor record, Stream stream, String name, CodableValue contentType) { File file = new File(); file.SetContent(record, stream, name, contentType); return file; }
/// <summary> /// Creates a <see cref="File"/> item instance using the specified file path and content /// type. /// </summary> /// /// <param name="path"> /// The path of the file to associate with this <see cref="File"/> instance. /// </param> /// /// <param name="contentType"> /// The content type of the file. This is usually something like "image/jpg", "application/csv", /// or other mime type. /// </param> /// /// <returns> /// A new instance of the <see cref="File"/> health record item with data populated from the /// specified file path. /// </returns> /// /// <exception cref="ArgumentException"> /// If <paramref name="path"/> is <b>null</b> or empty. /// </exception> /// /// <exception cref="ArgumentNullException"> /// If <paramref name="contentType"/> is <b>null</b>. /// </exception> /// /// <exception cref="PathTooLongException"> /// The specified path, file name, or both exceed the system-defined maximum length. /// For example, on Windows-based platforms, paths must be less than 248 characters, /// and file names must be less than 260 characters. /// </exception> /// /// <exception cref="DirectoryNotFoundException"> /// The specified path is invalid (for example, it is on an unmapped drive). /// </exception> /// /// <exception cref="IOException"> /// An I/O error occurred while opening the file. /// </exception> /// /// <exception cref="UnauthorizedAccessException"> /// <paramref name="path"/> specified a file that is read-only. /// -or- /// This operation is not supported on the current platform. /// -or- /// path specified a directory. /// -or- /// The caller does not have the required permission. /// </exception> /// /// <exception cref="FileNotFoundException"> /// The file specified in <paramref name="path"/> was not found. /// </exception> /// /// <exception cref="NotSupportedException"> /// <paramref name="path"/> is in an invalid format. /// </exception> /// /// <exception cref="System.Security.SecurityException"> /// The caller does not have the required permission. /// </exception> /// public static File CreateFromFilePath(string path, CodableValue contentType) { File file = new File(); file.SetContent(path, contentType); return file; }
public Allergy(string name) : this() { Name = new CodableValue(name); }
/// <summary> /// Sets the content of the file instance using the specified file. /// </summary> /// /// <param name="path"> /// The path of the file to associate with this <see cref="File"/> instance. /// </param> /// /// <param name="contentType"> /// The content type of the file. /// </param> /// /// <exception cref="ArgumentException"> /// If <paramref name="path"/> is <b>null</b> or empty. /// </exception> /// /// <exception cref="ArgumentNullException"> /// If <paramref name="contentType"/> is <b>null</b>. /// </exception> /// /// <exception cref="PathTooLongException"> /// The specified path, file name, or both exceed the system-defined maximum length. /// For example, on Windows-based platforms, paths must be less than 248 characters, /// and file names must be less than 260 characters. /// </exception> /// /// <exception cref="DirectoryNotFoundException"> /// The specified path is invalid (for example, it is on an unmapped drive). /// </exception> /// /// <exception cref="IOException"> /// An I/O error occurred while opening the file. /// </exception> /// /// <exception cref="UnauthorizedAccessException"> /// <paramref name="path"/> specified a file that is read-only. /// -or- /// This operation is not supported on the current platform. /// -or- /// path specified a directory. /// -or- /// The caller does not have the required permission. /// </exception> /// /// <exception cref="FileNotFoundException"> /// The file specified in <paramref name="path"/> was not found. /// </exception> /// /// <exception cref="NotSupportedException"> /// <paramref name="path"/> is in an invalid format. /// </exception> /// /// <exception cref="System.Security.SecurityException"> /// The caller does not have the required permission. /// </exception> /// public void SetContent(string path, CodableValue contentType) { Validator.ThrowIfStringNullOrEmpty(path, "path"); Validator.ThrowIfArgumentNull(contentType, "contentType", "FileContentTypeMustBeSpecified"); FileInfo fileInfo = new FileInfo(path); Size = fileInfo.Length; Name = fileInfo.Name; ContentType = contentType; BlobStore store = GetBlobStore(default(HealthRecordAccessor)); Blob blob = store.NewBlob(String.Empty, ContentType.Text); byte[] content = System.IO.File.ReadAllBytes(path); blob.WriteInline(content); }
/// <summary> /// Populates the data from the specified XML. /// </summary> /// /// <param name="navigator"> /// The XML containing the baby information. /// </param> /// /// <exception cref="ArgumentNullException"> /// The <paramref name="navigator"/> parameter is <b>null</b>. /// </exception> /// public override void ParseXml(XPathNavigator navigator) { Validator.ThrowIfNavigatorNull(navigator); _name = XPathHelper.GetOptNavValue<Name>(navigator, "name"); _gender = XPathHelper.GetOptNavValue<CodableValue>(navigator, "gender"); _weight = XPathHelper.GetOptNavValue<WeightValue>(navigator, "weight"); _length = XPathHelper.GetOptNavValue<Length>(navigator, "length"); _head = XPathHelper.GetOptNavValue<Length>(navigator, "head-circumference"); _note = XPathHelper.GetOptNavValue(navigator, "note"); }
/// <summary> /// Populates this <see cref="File"/> instance from the data in the XML. /// </summary> /// /// <param name="typeSpecificXml"> /// The XML to get the file data from. /// </param> /// /// <exception cref="InvalidOperationException"> /// The first node in <paramref name="typeSpecificXml"/> is not /// a file node. /// </exception> /// protected override void ParseXml(IXPathNavigable typeSpecificXml) { XPathNavigator fileNav = typeSpecificXml.CreateNavigator().SelectSingleNode("file"); Validator.ThrowInvalidIfNull(fileNav, "FileUnexpectedNode"); _name = fileNav.SelectSingleNode("name").Value; _size = fileNav.SelectSingleNode("size").ValueAsLong; XPathNavigator contentTypeNav = fileNav.SelectSingleNode("content-type"); if (contentTypeNav != null) { _contentType = new CodableValue(); _contentType.ParseXml(contentTypeNav); } }
/// <summary> /// Populates this <see cref="Status"/> instance from the data in the XML. /// </summary> /// /// <param name="typeSpecificXml"> /// The XML to get the status data from. /// </param> /// /// <exception cref="InvalidOperationException"> /// If the first node in <paramref name="typeSpecificXml"/> is not /// a status node. /// </exception> /// protected override void ParseXml(IXPathNavigable typeSpecificXml) { XPathNavigator itemNav = typeSpecificXml.CreateNavigator().SelectSingleNode("status"); Validator.ThrowInvalidIfNull(itemNav, "StatusUnexpectedNode"); _statusType = new CodableValue(); _statusType.ParseXml(itemNav.SelectSingleNode("status-type")); _text = XPathHelper.GetOptNavValue(itemNav, "text"); }
/// <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> /// Initializes an instance of the <see cref="Status"/> class, /// with a specified status type. /// </summary> /// /// <param name="statusType"> /// The specific type of status. /// </param> /// /// <exception cref="ArgumentNullException"> /// If <paramref name="statusType"/> is <b>null</b>. /// </exception> /// public Status(CodableValue statusType) : base(TypeId) { StatusType = statusType; }
/// <summary> /// Creates a new instance of the <see cref="HealthAssessment"/> class with the specified /// mandatory parameters. /// </summary> /// /// <param name="when"> /// The date and time the assessment was completed. /// </param> /// /// <param name="name"> /// The application's name for the assessment. See <see cref="Name"/> for more information. /// </param> /// /// <param name="category"> /// The type of the assessment. /// </param> /// /// <param name="result"> /// The results of the assessment. /// </param> /// /// <exception cref="ArgumentNullException"> /// If <paramref name="when"/> or <paramref name="category"/>, or <paramref name="result"/> /// is <b>null</b>. /// </exception> /// /// <exception cref="ArgumentException"> /// If <paramref name="name"/> is <b>null</b> or empty or <paramref name="result"/> is empty. /// </exception> /// public HealthAssessment( HealthServiceDateTime when, String name, CodableValue category, IList<Assessment> result) : base(TypeId) { this.When = when; this.Name = name; this.Category = category; Validator.ThrowIfArgumentNull(result, "result", "HealthAssessmentResultMandatory"); if (result.Count == 0) { throw Validator.ArgumentException("result", "HealthAssessmentResultMandatory"); } _result.Clear(); foreach (Assessment assessment in result) { _result.Add(assessment); } }
/// <summary> /// Populates this BloodGlucose instance from the data in the XML. /// </summary> /// /// <param name="typeSpecificXml"> /// The XML to get the blood glucose data from. /// </param> /// /// <exception cref="InvalidOperationException"> /// The first node in <paramref name="typeSpecificXml"/> is not /// a blood-glucose node. /// </exception> /// protected override void ParseXml(IXPathNavigable typeSpecificXml) { XPathNavigator bgNav = typeSpecificXml.CreateNavigator().SelectSingleNode( "blood-glucose"); Validator.ThrowInvalidIfNull(bgNav, "BGUnexpectedNode"); _when = new HealthServiceDateTime(); _when.ParseXml(bgNav.SelectSingleNode("when")); _value = new BloodGlucoseMeasurement(); _value.ParseXml(bgNav.SelectSingleNode("value")); _glucoseMeasurementType = new CodableValue(); _glucoseMeasurementType.ParseXml( bgNav.SelectSingleNode("glucose-measurement-type")); _outsideOperatingTemp = XPathHelper.GetOptNavValueAsBool( bgNav, "outside-operating-temp"); _isControlTest = XPathHelper.GetOptNavValueAsBool( bgNav, "is-control-test"); XPathNavigator normalcyNav = bgNav.SelectSingleNode("normalcy"); if (normalcyNav != null) { _normalcyValue = normalcyNav.ValueAsInt; if (_normalcyValue < (int)Normalcy.WellBelowNormal || _normalcyValue > (int)Normalcy.WellAboveNormal) { _normalcy = Normalcy.Unknown; } else { _normalcy = (Normalcy)_normalcyValue; } } _measurementContext = XPathHelper.GetOptNavValue<CodableValue>( bgNav, "measurement-context"); }