コード例 #1
0
 public CCodePhrase(TerminologyId terminologyId, List <string> codeList, string rmTypeName, string nodeId,
                    AssumedTypes.Interval <int> occurrences, CAttribute parent, object assumedValue)
     : base(rmTypeName, nodeId, occurrences, parent, assumedValue)
 {
     this.TerminologyId = terminologyId;
     this.CodeList      = codeList;
 }
コード例 #2
0
ファイル: CDvState.cs プロジェクト: panky2sharma/OpenEHR
 public CDvState(string rmTypeName, string nodeId, AssumedTypes.Interval <int> occurrences,
                 CAttribute parent, object assumedValue, StateMachine value)
     :
     base(rmTypeName, nodeId, occurrences, parent, assumedValue)
 {
     this.Value = value;
 }
コード例 #3
0
ファイル: Pathable.cs プロジェクト: panky2sharma/OpenEHR
 protected override void SetAttributeValue(string attributeName, object value)
 {
     // Set Constraint
     if (value != null && HasConstraint)
     {
         CAttribute attributeConstraint = Constraint.GetAttribute(attributeName);
         if (attributeConstraint != null)
         {
             CMultipleAttribute multipleAttributeConstraint = attributeConstraint as CMultipleAttribute;
             if (multipleAttributeConstraint != null)
             {
                 IAggregate aggregate = value as IAggregate;
                 Check.Assert(aggregate != null, "value must implement IAggregate when attribute constraint is CMultipleAttribute");
                 aggregate.Constraint = multipleAttributeConstraint;
             }
             else
             {
                 bool isValid = false;
                 foreach (CObject objectConstraint in attributeConstraint.Children)
                 {
                     if (objectConstraint.ValidValue(value))
                     {
                         isValid = true;
                         IRmType rmType = value as IRmType;
                         if (rmType != null)
                         {
                             rmType.Constraint = objectConstraint;
                         }
                         break;
                     }
                 }
             }
         }
     }
 }
コード例 #4
0
ファイル: Event.cs プロジェクト: panky2sharma/OpenEHR
        public virtual DataTypes.Quantity.DateTime.DvDuration Offset()
        {
            History <T> parent = this.Parent as History <T>;

            if (parent == null)
            {
                throw new ApplicationException("parent must not be null.");
            }

            DataTypes.Quantity.DateTime.DvDuration offset;
            if (parent.Origin != null)
            {
                offset = this.Time.Diff(parent.Origin);
            }
            else
            {
                if (this.HasConstraint)
                {
                    CAttribute attribute = this.Constraint.GetAttribute("offset");
                    Check.Assert(attribute != null, "attribute must not be null");

                    CComplexObject constraint = attribute.Children[0] as CComplexObject;
                    Check.Assert(constraint != null, "constraint must not be null");
                    offset = constraint.DefaultValue as DataTypes.Quantity.DateTime.DvDuration;
                }
                else
                {
                    throw new ApplicationException("origin is null with no offset constraint");
                }
            }
            Check.Ensure(offset != null, "offset must not be null");
            return(offset);
        }
コード例 #5
0
ファイル: CDvQuantity.cs プロジェクト: panky2sharma/OpenEHR
 public CDvQuantity(string rmTypeName, string nodeId, AssumedTypes.Interval <int> occurrences,
                    CAttribute parent, object assumedValue, List <CQuantityItem> list, CodePhrase property)
     : base(rmTypeName, nodeId, occurrences, parent, assumedValue)
 {
     this.List     = list;
     this.Property = property;
 }
コード例 #6
0
        public void ParseExample1_Selection()
        {
            CAttributes attributes = CHtmlParser.ParseAttributes(HtmlExamples.HtmlExample1);
            CAttribute  attribute  = attributes["Y00T00250.Y00A01088"];

            Assert.IsTrue(attribute.Description == "Status");
            Assert.IsTrue(string.Compare(@"For information", attribute.Value) == 0);
            Assert.IsTrue(attribute.Options.Where(x => x.Key == "").Count() == 1);
            Assert.IsTrue(attribute.Options.Where(x => x.Key == "N/A").Count() == 1);
            Assert.IsTrue(attribute.Options.Where(x => x.Key == "New").Count() == 1);
            Assert.IsTrue(attribute.Options.Where(x => x.Key == "For information").Count() == 1);
            Assert.IsTrue(attribute.Options.Where(x => x.Key == "Confirmed").Count() == 1);
            Assert.IsTrue(attribute.Options.Where(x => x.Key == "Suspended").Count() == 1);
            Assert.IsTrue(attribute.Options.Where(x => x.Key == "Completed").Count() == 1);
            Assert.IsTrue(attribute.Options.Where(x => x.Key == "Delegated").Count() == 1);


            Assert.IsTrue(attribute.Options.Where(x => x.Value == "").Count() == 1);
            Assert.IsTrue(attribute.Options.Where(x => x.Value == "N/A").Count() == 1);
            Assert.IsTrue(attribute.Options.Where(x => x.Value == "New").Count() == 1);
            Assert.IsTrue(attribute.Options.Where(x => x.Value == "For information").Count() == 1);
            Assert.IsTrue(attribute.Options.Where(x => x.Value == "Confirmed").Count() == 1);
            Assert.IsTrue(attribute.Options.Where(x => x.Value == "Suspended").Count() == 1);
            Assert.IsTrue(attribute.Options.Where(x => x.Value == "Completed").Count() == 1);
            Assert.IsTrue(attribute.Options.Where(x => x.Value == "Delegated").Count() == 1);
        }
コード例 #7
0
        //获取页面的值并组合成MODEL
        public CAttribute GetCAttributeValue()
        {
            CAttribute cAttribute = new CAttribute();

            cAttribute.Construction = construction.Text;
            cAttribute.HeavyCollar  = heavyCollar.SelectedValue;
            cAttribute.Pttern       = cmbPattern.SelectedValue;
            cAttribute.YarnLength   = yarnLength.Text;
            cAttribute.Layout       = Layout.Text;

            cAttribute.QC_Ref_PPO = txtQC_Ref_PPO.Text;
            cAttribute.QC_Ref_GP  = DropQC_Ref_GP.SelectedValue;
            cAttribute.HF_Ref_PPO = txtHF_Ref_PPO.Text;
            cAttribute.HF_Ref_GP  = DropHF_Ref_GP.SelectedValue;
            cAttribute.RF_Remart  = TxtRemart.Text;

            cAttribute.ListFinishing = new List <string>();
            string sFinishTemp = finishValue.Value;

            if (sFinishTemp.Contains(";"))
            {
                string[] arrS = sFinishTemp.Split(new string[] { ";" }, StringSplitOptions.None);
                for (int i = 0; i < arrS.Length; i++)
                {
                    if (arrS[i] != "" && arrS[i] != null)
                    {
                        cAttribute.ListFinishing.Add(arrS[i]);
                    }
                }
            }
            return(cAttribute);
        }
コード例 #8
0
        public void Parse_HtmlExample_TextArea()
        {
            CAttributes attributes = CHtmlParser.ParseAttributes(HtmlExamples.HtmlExample_TextArea);
            CAttribute  attribute  = attributes["Y00T00156.Y00A00171"];

            Assert.IsTrue(attribute.Description == "Binding norms and standards");
            Assert.IsTrue(attribute.Value == "");
        }
コード例 #9
0
        internal static string LocalTermDefText(string codeString, CAttribute cAttribute)
        {
            Check.Require(!string.IsNullOrEmpty(codeString), "codeString must not be null or empty.");
            Check.Require(cAttribute != null, "cAttribute must not be null");

            CComplexObject parent = cAttribute.parent;
            return LocalTermDefText(codeString, parent);
        }
コード例 #10
0
        //////////////////////////////////////////////////////
        // Function:
        //  LoadPrebuiltTree
        //
        // Purpose:
        //  Loads a decision tree that has already been
        //  built. Returns FALSE if the load fails.
        //////////////////////////////////////////////////////
        public bool LoadPrebuiltTree(
            string szInFilename)
        {
            using (var input = new StreamReader(szInFilename))
            {
                int i              = 0;
                int j              = 0;
                int iNumClasses    = 0;
                int iNumAttributes = 0;
                int numValues      = 0;

                string szInputString;
                string szAttributeName;
                string szAttributeValue;

                m_rwClasses.Clear();
                m_rwExamples.Clear();
                m_rwAttributes.Clear();

                //fscanf(input, "%d", &iNumClasses);
                iNumClasses = int.Parse(input.ReadLine());
                for (i = 0; i < iNumClasses; ++i)
                {
                    //fscanf(input, "%s", szInputString);
                    szInputString = input.ReadLine().Trim();
                    m_rwClasses.Add(szInputString);
                }

                //fscanf(input, "%d", &iNumAttributes);
                iNumAttributes = int.Parse(input.ReadLine());
                for (i = 0; i < iNumAttributes; ++i)
                {
                    //fscanf(input, "%s %d", szAttributeName, &numVals);
                    string[] tokens = input.ReadLine().Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
                    szAttributeName = tokens[0];
                    numValues       = int.Parse(tokens[1]);

                    var newAttribute = new CAttribute(szAttributeName);

                    for (j = 0; j < numValues; ++j)
                    {
                        //fscanf(input, "%s", szAttributeValue);
                        szAttributeValue = input.ReadLine().Trim();
                        newAttribute.AddValue(szAttributeValue);
                    }

                    m_rwAttributes.Add(newAttribute);
                }

                m_decisionTreeRootNode.SetDecisionTree(this);
                m_decisionTreeRootNode.LoadFromFile(input);

                input.Close();
            }

            return(true);
        }
コード例 #11
0
        private void WriteCMulitpleAttribute(XmlWriter writer, CAttribute attribute)
        {
            WriteCAttribute(writer, attribute);
            writer.WriteStartElement(
                UseOpenEhrPrefix(writer), "cardinality", RmXmlSerializer.OpenEhrNamespace);

            amSerializer.WriteCardinality(writer, ((CMultipleAttribute)attribute).Cardinality);

            writer.WriteEndElement();
        }
コード例 #12
0
        // TODO: this must be reinstated when ConfigurationSource is able to be specified

        #endregion



        void ReadCAttribute(XmlReader reader, CAttribute cAttribute)
        {
            Check.Require(cAttribute != null, string.Format(CommonStrings.XMustNotBeNull, "cAttribute"));

            if (reader.LocalName != "rm_attribute_name")
            {
                throw new InvalidXmlException("rm_attribute_name", reader.LocalName);
            }
            cAttribute.RmAttributeName = reader.ReadElementContentAsString("rm_attribute_name", OpenEhrNamespace);
            reader.MoveToContent();

            if (reader.LocalName != "existence")
            {
                throw new InvalidXmlException("existence", reader.LocalName);
            }
            cAttribute.Existence = new Interval <int>();
            amSerializer.ReadExistence(reader, cAttribute.Existence);

            if (reader.LocalName == "children")
            {
                cAttribute.Children = new OpenEhr.AssumedTypes.List <CObject>();
                do
                {
                    string cObjectType = reader.GetAttribute("type", RmXmlSerializer.XsiNamespace);
                    DesignByContract.Check.Assert(!string.IsNullOrEmpty(cObjectType), "cObjectType must not be null or empty.");

                    CObject cObj;
                    switch (cObjectType)
                    {
                    case "C_ARCHETYPE_ROOT":

                        CArchetypeRoot archetypeRoot = new CArchetypeRoot();
                        ReadCArchetypeRoot(reader, archetypeRoot);
                        cObj = archetypeRoot;
                        break;

                    case "C_COMPLEX_OBJECT":
                        CComplexObject complexObject = new CComplexObject();
                        ReadCComplexObject(reader, complexObject);
                        cObj = complexObject;
                        break;

                    default:
                        cObj = AmFactory.CObject(cObjectType);
                        amSerializer.ReadCObject(reader, cObj);
                        break;
                    }

                    cObj.Parent = cAttribute;
                    cAttribute.Children.Add(cObj);
                } while (reader.LocalName == "children" && reader.NodeType != XmlNodeType.EndElement);
            }
        }
コード例 #13
0
        public void Parse_HtmlExample_OptionsDuplicate()
        {
            CAttributes attributes = CHtmlParser.ParseAttributes(HtmlExamples.HtmlExampleOptionsDuplicate);
            CAttribute  attribute  = attributes["Y00T00001.Y00A03066"];

            Assert.IsTrue(attribute.Description == "Object class");
            Assert.IsTrue(attribute.Value == "Boundary stream");

            // Process stream is defined 2 times in this example of coos web.
            // Make sure it exists only once.
            Assert.IsTrue(attribute.Options.Where(x => x.Key == "Process stream").Count() == 1);
            Assert.IsTrue(attribute.Options["Process stream"] == "Process stream");
        }
コード例 #14
0
ファイル: JoinMapBase.cs プロジェクト: srmeteor/Essentials
        public string GetNameAttribute(MemberInfo memberInfo)
        {
            var name      = string.Empty;
            var attribute = (JoinNameAttribute)CAttribute.GetCustomAttribute(memberInfo, typeof(JoinNameAttribute));

            if (attribute == null)
            {
                return(name);
            }

            name = attribute.Name;
            Debug.Console(2, "JoinName Attribute value: {0}", name);
            return(name);
        }
コード例 #15
0
        protected virtual string FullPath()
        {
            string result = "";
            ArchetypeConstraint parent = constraint;

            do
            {
                CArchetypeRoot cArchetypeRoot = parent as CArchetypeRoot;

                if (cArchetypeRoot != null)
                {
                    string rootPath = cArchetypeRoot.Parent != null ? cArchetypeRoot.Path : "";

                    if (result.StartsWith(rootPath))
                    {
                        result = result.Substring(rootPath.Length);
                    }

                    result = rootPath + CArchetypeRootPredicate(cArchetypeRoot) + result;
                    parent = cArchetypeRoot.Parent;
                }
                else
                {
                    if (string.IsNullOrEmpty(result))
                    {
                        result = parent.Path;
                    }

                    CObject cObject = parent as CObject;

                    if (cObject != null)
                    {
                        parent = cObject.Parent;
                    }
                    else
                    {
                        CAttribute cAttribute = parent as CAttribute;

                        if (cAttribute != null)
                        {
                            parent = cAttribute.parent;
                        }
                    }
                }
            } while (parent != null);

            Check.Ensure(result != null);
            return(result);
        }
コード例 #16
0
        private void WriteCAttribute(XmlWriter writer, CAttribute cAttribute)
        {
            Check.Require(cAttribute != null, string.Format(CommonStrings.XMustNotBeNull, "cAttribute"));
            Check.Require(!string.IsNullOrEmpty(cAttribute.RmAttributeName), string.Format(CommonStrings.XMustNotBeNullOrEmpty, "cAttribute.RmAttributeName"));
            Check.Require(cAttribute.Existence != null, string.Format(CommonStrings.XMustNotBeNull, "cAttribute.Existence"));

            string openEhrPrefix = UseOpenEhrPrefix(writer);

            writer.WriteElementString(openEhrPrefix, "rm_attribute_name",
                                      OpenEhrNamespace, cAttribute.RmAttributeName);

            writer.WriteStartElement(openEhrPrefix, "existence", OpenEhrNamespace);
            amSerializer.WriteExistence(writer, cAttribute.Existence);

            writer.WriteEndElement();

            if (cAttribute.Children != null)
            {
                foreach (CObject child in cAttribute.Children)
                {
                    string cChildTypeName = AmType.GetName(child);
                    if (!string.IsNullOrEmpty(openEhrPrefix))
                    {
                        cChildTypeName = string.Format("{0}:{1}", openEhrPrefix, cChildTypeName);
                    }

                    writer.WriteStartElement(openEhrPrefix, "children", OpenEhrNamespace);
                    writer.WriteAttributeString(
                        UseXsiPrefix(writer), "type", RmXmlSerializer.XsiNamespace, cChildTypeName);

                    switch (cChildTypeName)
                    {
                    case "C_ARCHETYPE_ROOT":
                        WriteCArchetypeRoot(writer, (CArchetypeRoot)child);
                        break;

                    case "C_COMPLEX_OBJECT":
                        WriteCComplexObject(writer, (CComplexObject)child);
                        break;

                    default:
                        amSerializer.WriteCObject(writer, child);
                        break;
                    }
                    writer.WriteEndElement();
                }
            }
        }
コード例 #17
0
        public void testPath()
        {
            string adl = System.IO.File.ReadAllText(@"..\..\..\..\java-libs\adl-parser\src\test\resources\adl-test-car.paths.test.adl");

            se.acode.openehr.parser.ADLParser  parser    = new se.acode.openehr.parser.ADLParser(adl);
            org.openehr.am.archetype.Archetype archetype = parser.parse();
            Assert.IsNotNull(archetype);
            CComplexObject definition = archetype.getDefinition();

            // root path CAR
            Assert.AreEqual("/", definition.path());

            // wheels attribute
            CAttribute wheels = (CAttribute)definition.getAttributes().get(0);

            Assert.AreEqual("/wheels", wheels.path());

            // first WHEEL node
            CObject firstWheel = (CObject)wheels.getChildren().get(0);

            Assert.AreEqual("/wheels[at0001]", firstWheel.path());

            // description and parts of first WHEEL
            CComplexObject firstWheelObj = (CComplexObject)firstWheel;
            CAttribute     description   = (CAttribute)firstWheelObj.getAttributes().get(0);

            Assert.AreEqual("/wheels[at0001]/description", description.path());
            CAttribute parts = (CAttribute)firstWheelObj.getAttributes().get(1);

            Assert.AreEqual("/wheels[at0001]/parts", parts.path());

            // WHEEL_PART node
            CObject wheelParts = (CObject)parts.getChildren().get(0);

            Assert.AreEqual("/wheels[at0001]/parts[at0002]",
                            wheelParts.path());

            // something and something_else of WHEEL_PART node
            //CComplexObject wheelPartsObj = (CComplexObject)wheelParts;
            //Assert.AreEqual("something of WHEEL_PART",
            //        "/wheels[at0001]/parts[at0002]/something",
            //        wheelPartsObj.getAttributes().get(0).path());

            //Assert.AreEqual("something_else of WHEEL_PART",
            //        "/wheels[at0001]/parts[at0002]/something_else",
            //        wheelPartsObj.getAttributes().get(1).path());
        }
コード例 #18
0
        private static CObject Map(this C_OBJECT model, CAttribute parent)
        {
            CObject constraintObject;

            if (model is C_COMPLEX_OBJECT)
            {
                constraintObject = ((C_COMPLEX_OBJECT)model).Map();
            }
            else if (model is C_PRIMITIVE_OBJECT)
            {
                constraintObject = ((C_PRIMITIVE_OBJECT)model).Map();
            }
            else if (model is ARCHETYPE_SLOT)
            {
                constraintObject = ((ARCHETYPE_SLOT)model).Map();
            }
            else if (model is ARCHETYPE_INTERNAL_REF)
            {
                constraintObject = ((ARCHETYPE_INTERNAL_REF)model).Map();
            }
            else if (model is CONSTRAINT_REF)
            {
                constraintObject = ((CONSTRAINT_REF)model).Map();
            }
            else if (model is C_CODE_PHRASE)
            {
                constraintObject = ((C_CODE_PHRASE)model).Map();
            }
            else if (model is C_DV_QUANTITY)
            {
                constraintObject = ((C_DV_QUANTITY)model).Map();
            }
            else if (model is C_DV_ORDINAL)
            {
                constraintObject = ((C_DV_ORDINAL)model).Map();
            }
            else
            {
                throw new ParseException(string.Format("'{0}' is not a valid object type.", model.GetType()));
            }
            if (constraintObject != null)
            {
                constraintObject.Parent = parent;
            }
            return(constraintObject);
        }
コード例 #19
0
ファイル: ProfileLoader.cs プロジェクト: EMS-Master/EMS
        /// <summary>
        /// Adds information about attribure <c>att</c> to <c>entity</c>
        /// </summary>
        /// <param name="entity">ProfileElement to which attribute is being added</param>
        /// <param name="att">CAttribute contains information about attribute</param>
        private void addAttributeToElement(ProfileElement entity, CAttribute att, CClass modelClass)
        {
            ProfileElement newProperty = new ProfileElement();

            newProperty.URI      = att.name;
            newProperty.DataType = att.type;

            if (ProfileElementStereotype.StereotypeEnumeration.Equals(modelClass.stereotype))
            {
                newProperty.DataType        = "int";
                newProperty.TypeAsEnumValue = ProfileElementTypes.EnumerationElement;
                entity.AddToMyEnumerationMembers(newProperty);
            }
            else
            {
                newProperty.TypeAsEnumValue = ProfileElementTypes.Property;
                if (!newProperty.IsPropertyDataTypeSimple)
                {
                    List <ProfileElement> list = new List <ProfileElement>();
                    list.AddRange(profile.GetAllProfileElementsOfType(ProfileElementTypes.Class));
                    list.AddRange(predefined);
                    list.AddRange(newPredefined);
                    //if it is not simple, then it is a reference in profile, or another missing one?
                    foreach (ProfileElement type in list)
                    {
                        if (type.UniqueName.Equals(att.type))
                        {
                            //if its from profile, add needed references
                            newProperty.DataTypeAsComplexObject = type;
                            break;
                        }
                    }
                    if (newProperty.DataTypeAsComplexObject == null)
                    {
                        //not found so it has to be added in next iteration
                        //create flawed element so that it can be found
                        //flawed in a way that it only has URI
                        ProfileElement newElement = new ProfileElement();
                        newElement.URI = att.type;
                        newPredefined.Add(newElement);
                        newProperty.DataTypeAsComplexObject = newElement;
                    }
                }
                entity.AddToMyProperties(newProperty);
            }
        }
コード例 #20
0
ファイル: Archetype.cs プロジェクト: panky2sharma/OpenEHR
        /// <summary>
        /// an internal static method returning the targetPath corresponding CObject.
        /// Returns null if the targetPath doesn't have any associated CObject
        /// </summary>
        /// <param name="archetypeDefinition"></param>
        /// <param name="targetPath"></param>
        /// <returns></returns>
        internal static CObject GetCObjectAtTargetPath(CComplexObject archetypeDefinition, string targetPath)
        {
            CComplexObject cObj      = archetypeDefinition;
            CAttribute     attribute = null;

            Path pathProcessor = new Path(targetPath);

            do
            {
                foreach (CAttribute cAttri in cObj.Attributes)
                {
                    if (cAttri.RmAttributeName == pathProcessor.CurrentAttribute)
                    {
                        attribute = cAttri;
                        break;
                    }
                }

                Check.Assert(attribute != null, string.Format(CommonStrings.XMustNotBeNull, "attribute"));

                if (attribute.RmAttributeName != pathProcessor.CurrentAttribute)
                {
                    return(null);
                }

                foreach (CObject obj in attribute.Children)
                {
                    if (obj.NodeId == pathProcessor.CurrentNodeId)
                    {
                        cObj = obj as CComplexObject;
                        break;
                    }
                }

                Check.Assert(cObj != null, string.Format(CommonStrings.XMustNotBeNull, "cObj"));

                if (cObj.NodeId != pathProcessor.CurrentNodeId)
                {
                    return(null);
                }
            } while (pathProcessor.NextStep());

            Check.Ensure(cObj.Path == targetPath, "cObj.Path must be the same as this.TargetPath");

            return(cObj);
        }
コード例 #21
0
        internal static CArchetypeRoot GetCArchetypeRoot(CObject cObject)
        {
            Check.Require(cObject != null, "cObject must not be null");

            CObject parentObject = cObject;
            CArchetypeRoot cArchetypeRoot = null;
            while (parentObject != null && (cArchetypeRoot = parentObject as CArchetypeRoot) == null)
            {
                CAttribute cattribute = parentObject.Parent;
                Check.Assert(cattribute != null, "cattribute must not be null");
                parentObject = cattribute.parent;
            }

            if (cArchetypeRoot == null)
                throw new ApplicationException("Operational template must contain CArchetypeRoot");

            return cArchetypeRoot;
        }
コード例 #22
0
        public CAttribute GetCAttributeValue()
        {
            CAttribute cAttribute = new CAttribute();

            cAttribute.YarnLength  = yarnLength.Text;
            cAttribute.Size        = size.Text;
            cAttribute.TappingType = tappingType.SelectedValue;
            cAttribute.Layout      = Layout.Text;

            cAttribute.QC_Ref_PPO = txtQC_Ref_PPO.Text;
            cAttribute.QC_Ref_GP  = DropQC_Ref_GP.SelectedValue;
            cAttribute.HF_Ref_PPO = txtHF_Ref_PPO.Text;
            cAttribute.HF_Ref_GP  = DropHF_Ref_GP.SelectedValue;
            cAttribute.RF_Remart  = TxtRemart.Text;


            return(cAttribute);
        }
コード例 #23
0
        public void testExistenceCardinalityAndOccurrences()
        {
            // second attribute of root object
            CAttribute  attr = (CAttribute)definition.getAttributes().get(1);
            Cardinality card = new Cardinality(true, false, interval(0, 8));

            assertCAttribute(attr, "members", CAttribute.Existence.OPTIONAL, card, 2);

            // 1st PERSON
            CComplexObject obj = (CComplexObject)attr.getChildren().get(0);

            assertCComplexObject(obj, "PERSON", null, interval(1, 1), 1);

            // 2nd PERSON
            obj = (CComplexObject)attr.getChildren().get(1);
            assertCComplexObject(obj, "PERSON", null,
                                 new Interval(new java.lang.Integer(0), null, java.lang.Boolean.TRUE, java.lang.Boolean.FALSE), 1);
        }
コード例 #24
0
        public void ParseExample2_TextWithUnits()
        {
            CAttributes attributes = CHtmlParser.ParseAttributes(HtmlExamples.HtmlExample2);
            CAttribute  attribute  = attributes["Y00T00235.Y00A02875"];

            Assert.IsTrue(attribute.Description == "Units/time");
            Assert.IsTrue(attribute.Value == "");
            Assert.IsTrue(attribute.Options.Where(x => x.Key == "ppm").Count() == 1);
            Assert.IsTrue(attribute.Options.Where(x => x.Key == "1/1").Count() == 1);
            Assert.IsTrue(attribute.Options.Where(x => x.Key == "%").Count() == 1);
            Assert.IsTrue(attribute.Options.Where(x => x.Key == "‰").Count() == 1);

            Assert.IsTrue(attribute.Options["ppm"] == "F25.AA100");
            Assert.IsTrue(attribute.Options["1/1"] == "F25.AA110");
            Assert.IsTrue(attribute.Options["%"] == "F25.AA120");
            Assert.IsTrue(attribute.Options["‰"] == "F25.AA130");

            Assert.IsTrue(attribute.Unit == "%");
        }
コード例 #25
0
        internal static CComplexObject GetRootDefinition(ArchetypeInternalRef archeytpeInternalRef)
        {
            DesignByContract.Check.Require(archeytpeInternalRef != null, string.Format(CommonStrings.XMustNotBeNull, "archeytpeInternalRef"));
            DesignByContract.Check.Require(archeytpeInternalRef.Parent != null, string.Format(CommonStrings.XMustNotBeNull, "archeytpeInternalRef.Parent"));

            CComplexObject root = null;

            CAttribute parent = archeytpeInternalRef.Parent;

            while (parent != null)
            {
                root   = parent.parent;
                parent = root.Parent;
            }

            DesignByContract.Check.Ensure(root != null, "Root definition must not be null.");

            return(root);
        }
コード例 #26
0
ファイル: History.cs プロジェクト: panky2sharma/OpenEHR
        /// <summary>
        /// Get the origin value based on the history.Events time or IntervalStartTime
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="history"></param>
        /// <returns></returns>
        static public DvDateTime CalculateOrigin(History <T> history)
        {
            Check.Require(history != null, "history must not be null");

            DvDateTime originValue = null;

            if (history.Events != null && history.Events.Count > 0)
            {
                foreach (Event <T> anEvent in history.Events)
                {
                    DvDateTime        eventTime;
                    IntervalEvent <T> intervalEvent = anEvent as IntervalEvent <T>;
                    if (intervalEvent != null)
                    {
                        eventTime = intervalEvent.IntervalStartTime();
                    }
                    else
                    {
                        eventTime = anEvent.Time;
                    }

                    CComplexObject constraint = ((IRmType)anEvent).Constraint as CComplexObject;
                    if (constraint != null)
                    {
                        CAttribute offsetConstraint = constraint.GetAttribute("offset");
                        if (offsetConstraint != null && offsetConstraint.Children != null && offsetConstraint.Children.Count == 1)
                        {
                            CComplexObject offsetDuration = offsetConstraint.Children[0] as CComplexObject;
                            eventTime = eventTime.Subtract((DvDuration)offsetDuration.DefaultValue);
                        }
                    }

                    if (originValue == null || originValue > eventTime)
                    {
                        originValue = new DvDateTime(eventTime.Value);
                    }
                }
            }
            Check.Ensure(originValue != null, "originValue must not be null");
            return(originValue);
        }
コード例 #27
0
        internal static bool ValidValueTermDef(DvCodedText dvCodedText, CAttribute cAttribute, ITerminologyService terminologyService)
        {
            string value = string.Empty;
            if (dvCodedText.DefiningCode.TerminologyId.Value == OpenEhrTerminologyIdentifiers.TerminologyIdOpenehr)

                value = OpenEhrTermDefTerm(dvCodedText.DefiningCode.CodeString, terminologyService);

            else if (dvCodedText.DefiningCode.TerminologyId.Value == "local")
                value = LocalTermDefText(dvCodedText.DefiningCode.CodeString, cAttribute);

            if (!string.IsNullOrEmpty(value)
                && !string.IsNullOrEmpty(dvCodedText.Value)
                && value != dvCodedText.Value)
            {
                return false;
            }
            if (!string.IsNullOrEmpty(value) && string.IsNullOrEmpty(dvCodedText.Value))
                dvCodedText.Value = value;

            return true;
        }
コード例 #28
0
        protected void ValidateBase(CAttribute cAttribute)
        {
            this.Validate((ArchetypeConstraint)cAttribute);

            Invariant(!string.IsNullOrEmpty(cAttribute.RmAttributeName), string.Format(
                          CommonStrings.XMustNotBeNullOrEmpty, "CAttribute.RmAttributeName"));
            Invariant(cAttribute.Existence != null, string.Format(
                          CommonStrings.XMustNotBeNullOrEmpty, "CAttribute.Existence"));
            this.Validate(cAttribute.Existence);
            Invariant(cAttribute.Existence.Lower >= 0 && cAttribute.Existence.Upper <= 1,
                      AmValidationStrings.ExistenceOutOfRange);

            // TODO: Children_validity: any_allowed xor children /= Void

            if (cAttribute.Children != null)
            {
                foreach (CObject cObj in cAttribute.Children)
                {
                    this.Validate(cObj);
                }
            }
        }
コード例 #29
0
        internal static bool ValidateCAttribute(CAttribute cAttribute, ITerminologyService terminologyService)
        {
            AmValidator amValidator = new AmValidator(terminologyService);

            try
            {
                amValidator.Validate(cAttribute);
            }
            catch (Exception ex)
            {
                if (ex.GetType() == typeof(RmInvariantException))
                {
                    return(false);
                }
                else
                {
                    throw ex;
                }
            }

            return(true);
        }
コード例 #30
0
        public void testStructure()
        {
            // root object
            CComplexObject obj = definition;

            java.lang.Integer temp1       = new java.lang.Integer(1);
            Interval          occurrences = new Interval(temp1, temp1);

            assertCComplexObject(obj, "ENTRY", "at0000", occurrences, 2);

            // first attribute of root object
            CAttribute attr = (CAttribute)obj.getAttributes().get(0);

            assertCAttribute(attr, "subject_relationship", 1);

            // 2nd level object
            obj = (CComplexObject)attr.getChildren().get(0);
            assertCComplexObject(obj, "RELATED_PARTY", null, occurrences, 1);

            // attribute of 2nd level object
            attr = (CAttribute)obj.getAttributes().get(0);
            assertCAttribute(attr, "relationship", 1);

            // leaf object
            obj = (CComplexObject)attr.getChildren().get(0);
            assertCComplexObject(obj, "TEXT", null, occurrences, 1);

            // attribute of leaf object
            attr = (CAttribute)obj.getAttributes().get(0);
            assertCAttribute(attr, "value", 1);

            // primitive constraint of leaf object
            CString str = (CString)((CPrimitiveObject)attr.getChildren().get(0)).getItem();

            Assert.AreEqual(null, str.getPattern(), "pattern");
            Assert.AreEqual(1, str.getList().size(), "set.size");
            Assert.IsTrue(str.getList().contains("self"), "set has");
        }