public void Birthdate_Is_A_Valid_Date()
        {
            var birthday = PhysicalCharacteristics.GetBirthdate();

            Assert.IsInstanceOf <System.DateTime>(birthday);
            Assert.True((DateTime.Now.Year - birthday.Year) > 17);
        }
 public void Mil_Height_Is_Not_Null()
 {
     Assert.IsNotNull(PhysicalCharacteristics.GetMilHeight());
     Assert.IsNotNull(PhysicalCharacteristics.GetMilHeight(MilitaryBranch.USMC));
     Assert.IsNotNull(PhysicalCharacteristics.GetMilHeight(BiologicalSex.Male));
     Assert.IsNotNull(PhysicalCharacteristics.GetMilHeight(BiologicalSex.Female));
 }
Example #3
0
        public static HealthProfile GetHealthProfile()
        {
            var o = new HealthProfile();

            o.Height    = PhysicalCharacteristics.GetMilHeight(Npc.NpcProfile.BiologicalSex, Npc.NpcProfile.Rank.Branch);
            o.Weight    = PhysicalCharacteristics.GetMilWeight(o.Height, Npc.NpcProfile.Birthdate, Npc.NpcProfile.BiologicalSex, Npc.NpcProfile.Rank.Branch);
            o.BloodType = PhysicalCharacteristics.GetBloodType();

            var mealPreference = string.Empty;

            if (PercentOfRandom.Does(95)) //x% have a meal preference
            {
                mealPreference = ($"config/meal_preferences.txt").GetRandomFromFile();
            }
            o.PreferredMeal = mealPreference;

            if (PercentOfRandom.Does(98)) //x% have a medical condition
            {
                var raw = File.ReadAllText("config/medical_conditions_and_medications.json");
                var r   = JsonConvert.DeserializeObject <IEnumerable <HealthProfileRecord> >(raw).RandomElement();

                var c = new MedicalCondition {
                    Name = r.Condition
                };
                foreach (var med in r.Medications)
                {
                    c.Prescriptions.Add(new Prescription {
                        Name = med
                    });
                }
                o.MedicalConditions.Add(c);
            }

            return(o);
        }
        private void ControlsToData()
        {
            if (_physicalCharacteristics == null)
            {
                _physicalCharacteristics = new PhysicalCharacteristics();
            }

            _physicalCharacteristics.Mass   = DatumMass.DoubleValue.value > 0 ? DatumMass.DoubleValue : null;
            _physicalCharacteristics.Volume = DatumVolume.DoubleValue.value > 0 ? DatumVolume.DoubleValue : null;

            if (_physicalCharacteristics.LinearMeasurements == null)
            {
                _physicalCharacteristics.LinearMeasurements = new PhysicalCharacteristicsLinearMeasurements();
            }

            _physicalCharacteristics.LinearMeasurements = physicalCharLinearControl.PhysicalCharacteristicsLinearMeasurements;
            _physicalCharacteristics.Other = otherListControl.NamedValues;
            if (_physicalCharacteristics.Mass == null &&
                _physicalCharacteristics.Volume == null &&
                _physicalCharacteristics.LinearMeasurements == null &&
                _physicalCharacteristics.Other == null)
            {
                _physicalCharacteristics = null;
            }
        }
 public void Mil_Height_Is_Below_Bound()
 {
     for (int i = 0; i < 500; i++)
     {
         Assert.LessOrEqual(60, PhysicalCharacteristics.GetMilHeight(BiologicalSex.Male));
         Assert.LessOrEqual(58, PhysicalCharacteristics.GetMilHeight(BiologicalSex.Female));
         Assert.LessOrEqual(58, PhysicalCharacteristics.GetMilHeight(MilitaryBranch.USMC));
     }
 }
 public void Mil_Height_Is_Above_Bound()
 {
     for (int i = 0; i < 500; i++)
     {
         Assert.GreaterOrEqual(80, PhysicalCharacteristics.GetMilHeight());
         Assert.GreaterOrEqual(78, PhysicalCharacteristics.GetMilHeight(BiologicalSex.Male, MilitaryBranch.USMC));
         Assert.GreaterOrEqual(72, PhysicalCharacteristics.GetMilHeight(BiologicalSex.Female, MilitaryBranch.USMC));
     }
 }
        public override IDeepCopyable CopyTo(IDeepCopyable other)
        {
            var dest = other as MedicinalProductManufactured;

            if (dest == null)
            {
                throw new ArgumentException("Can only copy to an object of the same type", "other");
            }

            base.CopyTo(dest);
            if (ManufacturedDoseForm != null)
            {
                dest.ManufacturedDoseForm = (Hl7.Fhir.Model.CodeableConcept)ManufacturedDoseForm.DeepCopy();
            }
            if (UnitOfPresentation != null)
            {
                dest.UnitOfPresentation = (Hl7.Fhir.Model.CodeableConcept)UnitOfPresentation.DeepCopy();
            }
            if (Quantity != null)
            {
                dest.Quantity = (Hl7.Fhir.Model.Quantity)Quantity.DeepCopy();
            }
            if (Manufacturer != null)
            {
                dest.Manufacturer = new List <Hl7.Fhir.Model.ResourceReference>(Manufacturer.DeepCopy());
            }
            if (Ingredient != null)
            {
                dest.Ingredient = new List <Hl7.Fhir.Model.ResourceReference>(Ingredient.DeepCopy());
            }
            if (PhysicalCharacteristics != null)
            {
                dest.PhysicalCharacteristics = (Hl7.Fhir.Model.ProdCharacteristic)PhysicalCharacteristics.DeepCopy();
            }
            if (OtherCharacteristics != null)
            {
                dest.OtherCharacteristics = new List <Hl7.Fhir.Model.CodeableConcept>(OtherCharacteristics.DeepCopy());
            }
            return(dest);
        }
Example #8
0
            public override IDeepCopyable CopyTo(IDeepCopyable other)
            {
                var dest = other as PackageItemComponent;

                if (dest == null)
                {
                    throw new ArgumentException("Can only copy to an object of the same type", "other");
                }

                base.CopyTo(dest);
                if (Identifier != null)
                {
                    dest.Identifier = new List <Hl7.Fhir.Model.Identifier>(Identifier.DeepCopy());
                }
                if (Type != null)
                {
                    dest.Type = (Hl7.Fhir.Model.CodeableConcept)Type.DeepCopy();
                }
                if (Quantity != null)
                {
                    dest.Quantity = (Hl7.Fhir.Model.Quantity)Quantity.DeepCopy();
                }
                if (Material != null)
                {
                    dest.Material = new List <Hl7.Fhir.Model.CodeableConcept>(Material.DeepCopy());
                }
                if (AlternateMaterial != null)
                {
                    dest.AlternateMaterial = new List <Hl7.Fhir.Model.CodeableConcept>(AlternateMaterial.DeepCopy());
                }
                if (Device != null)
                {
                    dest.Device = new List <Hl7.Fhir.Model.ResourceReference>(Device.DeepCopy());
                }
                if (ManufacturedItem != null)
                {
                    dest.ManufacturedItem = new List <Hl7.Fhir.Model.ResourceReference>(ManufacturedItem.DeepCopy());
                }
                if (PackageItem != null)
                {
                    dest.PackageItem = new List <Hl7.Fhir.Model.MedicinalProductPackaged.PackageItemComponent>(PackageItem.DeepCopy());
                }
                if (PhysicalCharacteristics != null)
                {
                    dest.PhysicalCharacteristics = (Hl7.Fhir.Model.ProdCharacteristic)PhysicalCharacteristics.DeepCopy();
                }
                if (OtherCharacteristics != null)
                {
                    dest.OtherCharacteristics = new List <Hl7.Fhir.Model.CodeableConcept>(OtherCharacteristics.DeepCopy());
                }
                if (ShelfLifeStorage != null)
                {
                    dest.ShelfLifeStorage = new List <Hl7.Fhir.Model.ProductShelfLife>(ShelfLifeStorage.DeepCopy());
                }
                if (Manufacturer != null)
                {
                    dest.Manufacturer = new List <Hl7.Fhir.Model.ResourceReference>(Manufacturer.DeepCopy());
                }
                return(dest);
            }
 public void Blood_Type_Is_A_Non_Empty_String()
 {
     Assert.IsNotEmpty(PhysicalCharacteristics.GetBloodType());
 }
 public void Mil_Weight_Is_Not_Null()
 {
     Assert.IsNotNull(PhysicalCharacteristics.GetMilWeight(70, new DateTime(2000, 4, 1)));
 }
 public void Weight_Is_Not_Null()
 {
     Assert.IsNotNull(PhysicalCharacteristics.GetWeight(66));
     Assert.IsNotNull(PhysicalCharacteristics.GetWeight(66, BiologicalSex.Male));
     Assert.IsNotNull(PhysicalCharacteristics.GetWeight(66, BiologicalSex.Female));
 }
 public void Mil_Sex_Is_Not_Null()
 {
     Assert.IsNotNull(PhysicalCharacteristics.GetMilBiologicalSex());
 }
 public void Weight_To_String_Works()
 {
     Assert.AreEqual("100 lbs", PhysicalCharacteristics.WeightToString(100));
 }
 public void Height_To_String_Works()
 {
     Assert.AreEqual("5' 10\"", PhysicalCharacteristics.HeightToString(70));
 }
        /// <summary>
        /// Serialize to a JSON object
        /// </summary>
        public new void SerializeJson(Utf8JsonWriter writer, JsonSerializerOptions options, bool includeStartObject = true)
        {
            if (includeStartObject)
            {
                writer.WriteStartObject();
            }
            ((fhirCsR4.Models.BackboneElement) this).SerializeJson(writer, options, false);

            if ((Identifier != null) && (Identifier.Count != 0))
            {
                writer.WritePropertyName("identifier");
                writer.WriteStartArray();

                foreach (Identifier valIdentifier in Identifier)
                {
                    valIdentifier.SerializeJson(writer, options, true);
                }

                writer.WriteEndArray();
            }

            if (Type != null)
            {
                writer.WritePropertyName("type");
                Type.SerializeJson(writer, options);
            }

            if (Quantity != null)
            {
                writer.WritePropertyName("quantity");
                Quantity.SerializeJson(writer, options);
            }

            if ((Material != null) && (Material.Count != 0))
            {
                writer.WritePropertyName("material");
                writer.WriteStartArray();

                foreach (CodeableConcept valMaterial in Material)
                {
                    valMaterial.SerializeJson(writer, options, true);
                }

                writer.WriteEndArray();
            }

            if ((AlternateMaterial != null) && (AlternateMaterial.Count != 0))
            {
                writer.WritePropertyName("alternateMaterial");
                writer.WriteStartArray();

                foreach (CodeableConcept valAlternateMaterial in AlternateMaterial)
                {
                    valAlternateMaterial.SerializeJson(writer, options, true);
                }

                writer.WriteEndArray();
            }

            if ((Device != null) && (Device.Count != 0))
            {
                writer.WritePropertyName("device");
                writer.WriteStartArray();

                foreach (Reference valDevice in Device)
                {
                    valDevice.SerializeJson(writer, options, true);
                }

                writer.WriteEndArray();
            }

            if ((ManufacturedItem != null) && (ManufacturedItem.Count != 0))
            {
                writer.WritePropertyName("manufacturedItem");
                writer.WriteStartArray();

                foreach (Reference valManufacturedItem in ManufacturedItem)
                {
                    valManufacturedItem.SerializeJson(writer, options, true);
                }

                writer.WriteEndArray();
            }

            if ((PackageItem != null) && (PackageItem.Count != 0))
            {
                writer.WritePropertyName("packageItem");
                writer.WriteStartArray();

                foreach (MedicinalProductPackagedPackageItem valPackageItem in PackageItem)
                {
                    valPackageItem.SerializeJson(writer, options, true);
                }

                writer.WriteEndArray();
            }

            if (PhysicalCharacteristics != null)
            {
                writer.WritePropertyName("physicalCharacteristics");
                PhysicalCharacteristics.SerializeJson(writer, options);
            }

            if ((OtherCharacteristics != null) && (OtherCharacteristics.Count != 0))
            {
                writer.WritePropertyName("otherCharacteristics");
                writer.WriteStartArray();

                foreach (CodeableConcept valOtherCharacteristics in OtherCharacteristics)
                {
                    valOtherCharacteristics.SerializeJson(writer, options, true);
                }

                writer.WriteEndArray();
            }

            if ((ShelfLifeStorage != null) && (ShelfLifeStorage.Count != 0))
            {
                writer.WritePropertyName("shelfLifeStorage");
                writer.WriteStartArray();

                foreach (ProductShelfLife valShelfLifeStorage in ShelfLifeStorage)
                {
                    valShelfLifeStorage.SerializeJson(writer, options, true);
                }

                writer.WriteEndArray();
            }

            if ((Manufacturer != null) && (Manufacturer.Count != 0))
            {
                writer.WritePropertyName("manufacturer");
                writer.WriteStartArray();

                foreach (Reference valManufacturer in Manufacturer)
                {
                    valManufacturer.SerializeJson(writer, options, true);
                }

                writer.WriteEndArray();
            }

            if (includeStartObject)
            {
                writer.WriteEndObject();
            }
        }
Example #16
0
        /// <summary>
        /// Serialize to a JSON object
        /// </summary>
        public new void SerializeJson(Utf8JsonWriter writer, JsonSerializerOptions options, bool includeStartObject = true)
        {
            if (includeStartObject)
            {
                writer.WriteStartObject();
            }

            if (!string.IsNullOrEmpty(ResourceType))
            {
                writer.WriteString("resourceType", (string)ResourceType !);
            }


            ((Fhir.R4.Models.DomainResource) this).SerializeJson(writer, options, false);

            if (ManufacturedDoseForm != null)
            {
                writer.WritePropertyName("manufacturedDoseForm");
                ManufacturedDoseForm.SerializeJson(writer, options);
            }

            if (UnitOfPresentation != null)
            {
                writer.WritePropertyName("unitOfPresentation");
                UnitOfPresentation.SerializeJson(writer, options);
            }

            if (Quantity != null)
            {
                writer.WritePropertyName("quantity");
                Quantity.SerializeJson(writer, options);
            }

            if ((Manufacturer != null) && (Manufacturer.Count != 0))
            {
                writer.WritePropertyName("manufacturer");
                writer.WriteStartArray();

                foreach (Reference valManufacturer in Manufacturer)
                {
                    valManufacturer.SerializeJson(writer, options, true);
                }

                writer.WriteEndArray();
            }

            if ((Ingredient != null) && (Ingredient.Count != 0))
            {
                writer.WritePropertyName("ingredient");
                writer.WriteStartArray();

                foreach (Reference valIngredient in Ingredient)
                {
                    valIngredient.SerializeJson(writer, options, true);
                }

                writer.WriteEndArray();
            }

            if (PhysicalCharacteristics != null)
            {
                writer.WritePropertyName("physicalCharacteristics");
                PhysicalCharacteristics.SerializeJson(writer, options);
            }

            if ((OtherCharacteristics != null) && (OtherCharacteristics.Count != 0))
            {
                writer.WritePropertyName("otherCharacteristics");
                writer.WriteStartArray();

                foreach (CodeableConcept valOtherCharacteristics in OtherCharacteristics)
                {
                    valOtherCharacteristics.SerializeJson(writer, options, true);
                }

                writer.WriteEndArray();
            }

            if (includeStartObject)
            {
                writer.WriteEndObject();
            }
        }