示例#1
0
        public static CD <T> Parse(CV <String> cd)
        {
            CD <T> retVal = new CD <T>();

            // Parse from wire format into this format
            retVal.Code = CodeValue <T> .Parse(cd.Code);

            // Code System
            retVal.CodeSystem        = cd.CodeSystem;
            retVal.CodeSystemName    = cd.CodeSystemName;
            retVal.CodeSystemVersion = cd.CodeSystemVersion;
            retVal.ControlActExt     = cd.ControlActExt;
            retVal.ControlActRoot    = cd.ControlActRoot;
            retVal.UpdateMode        = cd.UpdateMode == null ? null : cd.UpdateMode.Clone() as CS <UpdateMode>;
            retVal.NullFlavor        = cd.NullFlavor as CS <NullFlavor>;
            retVal.ValidTimeHigh     = cd.ValidTimeHigh;
            retVal.ValidTimeLow      = cd.ValidTimeLow;
            retVal.OriginalText      = cd.OriginalText == null ? null : cd.OriginalText.Clone() as ED;
            retVal.DisplayName       = cd.DisplayName;
            retVal.CodingRationale   = cd.CodingRationale;
            //retVal.Group = cd.Group != null ? cd.Group.Clone() as LIST<CDGroup> : null;
            retVal.UpdateMode = cd.UpdateMode;
            retVal.Flavor     = cd.Flavor;

            return(retVal);
        }
示例#2
0
        public static CE <T> Parse(CE <String> ce)
        {
            CE <T> retVal = new CE <T>();

            // Parse from wire format into this format
            retVal.Code = CodeValue <T> .Parse(ce.Code);

            // Code System
            retVal.Flavor            = ce.Flavor;
            retVal.CodeSystem        = ce.CodeSystem;
            retVal.CodeSystemName    = ce.CodeSystemName;
            retVal.CodeSystemVersion = ce.CodeSystemVersion;
            retVal.ControlActExt     = ce.ControlActExt;
            retVal.ControlActRoot    = ce.ControlActRoot;
            retVal.UpdateMode        = ce.UpdateMode == null ? null : ce.UpdateMode.Clone() as CS <UpdateMode>;
            retVal.NullFlavor        = ce.NullFlavor as CS <NullFlavor>;
            retVal.ValidTimeHigh     = ce.ValidTimeHigh;
            retVal.ValidTimeLow      = ce.ValidTimeLow;
            retVal.OriginalText      = ce.OriginalText == null ? null : ce.OriginalText.Clone() as ED;
            retVal.DisplayName       = ce.DisplayName;
            retVal.Translation       = ce.Translation == null ? null : new SET <CD <T> >(ce.Translation, CD <T> .Comparator);
            retVal.CodingRationale   = ce.CodingRationale;
            //retVal.Group = ce.Group != null ? ce.Group.Clone() as LIST<CDGroup> : null;
            retVal.UpdateMode = ce.UpdateMode;

            return(retVal);
        }
        public void CSExample9Test()
        {
            CS <AcknowledgementCondition> condition =
                new CS <AcknowledgementCondition>(AcknowledgementCondition.Always);

            // Direct assignment of a code
            condition = AcknowledgementCondition.Never;
            // Assignment through the code property
            condition.Code = AcknowledgementCondition.ErrorRejectOnly;
            // Assignment of a non-bound code
            condition.Code = CodeValue <AcknowledgementCondition> .Parse("OTHER CODE");

            Assert.IsFalse(condition.Validate());
        }
        /// <summary>
        /// Create a CV from the specified domain
        /// </summary>
        public CV <T> CreateCV <T>(MARC.HI.EHRS.SVC.Core.DataTypes.CodeValue codeValue, List <IResultDetail> dtls)
        {
            if (codeValue == null)
            {
                return new CV <T>()
                       {
                           NullFlavor = MARC.Everest.DataTypes.NullFlavor.NoInformation
                       }
            }
            ;

            // Attempt to create the CV
            CV <T> retVal = new CV <T>();

            retVal.Code = CodeValue <T> .Parse(codeValue.Code);

            // Fill in details
            if (m_terminologyService != null && (retVal.Code.IsAlternateCodeSpecified ||
                                                 typeof(T) == typeof(String)))
            {
                codeValue = m_terminologyService.FillInDetails(codeValue);
            }

            retVal.CodeSystemVersion = codeValue.CodeSystemVersion;
            if (!String.IsNullOrEmpty(codeValue.CodeSystem))
            {
                retVal.CodeSystem = codeValue.CodeSystem;
            }
            if (codeValue.DisplayName != null)
            {
                retVal.DisplayName = codeValue.DisplayName;
            }
            else if (codeValue.CodeSystem != null)
            {
                retVal.CodeSystemName = codeValue.CodeSystemName;
            }

            if (codeValue.OriginalText != null)
            {
                retVal.OriginalText = codeValue.OriginalText;
            }

            return(retVal);
        }
示例#5
0
        /// <summary>
        /// Converts a <see cref="CS"/> to a <see cref="CS"/>
        /// </summary>
        /// <param name="cs">CS to convert</param>
        /// <returns>Converted CS`1</returns>
        /// <remarks>Is a parse function as the string must be parsed by util</remarks>
        internal static CS <T> Parse(CS <String> cs)
        {
            CS <T> retVal = new CS <T>();

            // Parse from wire format into this format
            retVal.Code = CodeValue <T> .Parse(cs.Code);

            // Copy other members
            //retVal.CodeSystem = cs.CodeSystem;
            //retVal.CodeSystemName = cs.CodeSystemName;
            //retVal.CodeSystemVersion = cs.CodeSystemVersion;
            retVal.Flavor         = cs.Flavor;
            retVal.NullFlavor     = cs.NullFlavor == null ? null : cs.NullFlavor.Clone() as CS <NullFlavor>;
            retVal.UpdateMode     = cs.UpdateMode == null ? null : cs.UpdateMode.Clone() as CS <UpdateMode>;
            retVal.ControlActRoot = cs.ControlActRoot;
            retVal.ControlActExt  = cs.ControlActExt;
            retVal.ValidTimeHigh  = cs.ValidTimeHigh;
            retVal.ValidTimeLow   = cs.ValidTimeLow;
            retVal.NullFlavor     = cs.NullFlavor;
            return(retVal);
        }
示例#6
0
        public void GoodScriptTest()
        {
            //Arrange
            Script script = new Script();

            //Act
            script.Analyse(File.ReadAllText("usa.txt"));
            //Test code value
            CodeValue value       = script.FindValue("tag");
            string    valueString = value.Parse();
            //Test Assignation
            Assignation assign       = script.FindAssignation("modifier");
            string      assignString = assign.Parse();
            //Test Extraction
            ICodeStruct extracted       = script.Extract("default");
            string      extractedString = extracted.Parse();
            //Test find all focuses
            List <ICodeStruct> assigns = script.FindAllValuesOfType <CodeBlock>("focus");
            //Test try parse
            string tag = script.TryParse(script, "tag");

            //Assert
            Assert.IsTrue(script.Code.Any());
            Assert.IsFalse(script.Logger.hasErrors());
            Assert.IsTrue(valueString == "USA");
            Assert.IsTrue(!string.IsNullOrEmpty(assignString));
            Assert.IsTrue(extractedString.Contains("yes"));
            //Should not find a tag after extraction
            Assert.IsNull(script.FindValue("default"));
            Assert.IsTrue(assigns.Any());
            Assert.IsTrue(tag == "USA");
            //Test broken parse
            Assert.IsNull(script.TryParse(script, "default", null, false));
            script.TryParse(script, "default");
            Assert.IsTrue(script.Logger.hasErrors());
        }
示例#7
0
        public override void Graph(System.Xml.XmlWriter s, object o, DatatypeFormatterGraphResult result)
        {
            EN instance = o as EN;

            // Do a base format
            base.Graph(s, o as ANY, result);

            // Null flavor
            if (instance.NullFlavor != null)
            {
                return;
            }

            // use
            if (instance.Use != null)
            {
                s.WriteAttributeString("use", Util.ToWireFormat(instance.Use));
            }

            // parts
            if (instance.Part != null)
            {
                foreach (ENXP part in instance.Part)
                {
                    EntityNamePartType?pt = part.Type;
                    SET <CS <EntityNamePartQualifier> > qualifiers = new SET <CS <EntityNamePartQualifier> >();
                    if (part.Qualifier != null)
                    {
                        foreach (var qlf in part.Qualifier)
                        {
                            qualifiers.Add(qlf.Clone() as CS <EntityNamePartQualifier>);
                        }
                    }

                    // Title part type?
                    if (pt == EntityNamePartType.Title)
                    {
                        part.Qualifier.Add(new CS <EntityNamePartQualifier>()
                        {
                            Code = CodeValue <EntityNamePartQualifier> .Parse("TITLE")
                        }
                                           );
                        pt = null;
                    }

                    // Possible to match qualifier to a part tpye if none specified!
                    if (!qualifiers.IsEmpty)
                    {
                        CS <EntityNamePartQualifier> pfx = qualifiers.Find(a => a.Code.Equals(EntityNamePartQualifier.Prefix)),
                                                     sfx = qualifiers.Find(a => a.Code.Equals(EntityNamePartQualifier.Suffix));
                        if (pfx != null)
                        {
                            pt = EntityNamePartType.Prefix;
                            qualifiers.Remove(pfx);
                        }
                        else if (sfx != null)
                        {
                            pt = EntityNamePartType.Suffix;
                            qualifiers.Remove(sfx);
                        }
                    }

                    // Part type is not set so do it inline
                    if (pt == null)
                    {
                        if (!qualifiers.IsEmpty)
                        {
                            result.AddResultDetail(new NotSupportedChoiceResultDetail(ResultDetailType.Warning, "Part has qualifier but is not being rendered as a type element, qualifier will be dropped", s.ToString(), null));
                        }
                        s.WriteString(part.Value);
                    }
                    else if (mapping.ContainsKey(pt))
                    {
                        var prt = part.Clone() as ENXP;
                        prt.Type      = pt;
                        prt.Qualifier = qualifiers;
                        s.WriteStartElement(mapping[pt], "urn:hl7-org:v3");
                        ENXPFormatter enFormatter = new ENXPFormatter();
                        enFormatter.Graph(s, prt, result);
                        s.WriteEndElement();
                    }
                    else
                    {
                        throw new MessageValidationException(string.Format("Can't represent entity name part '{0}' in datatypes R1 at '{1}'", pt, (s as XmlStateWriter).CurrentPath));
                    }
                }
            }

            // Bug: 2102 - Graph the validTime element. Since the HXIT
            // class in R2 already has validTimeLow and validTimeHigh
            // what we'll do is map these attributes to the validTime element
            if (instance.ValidTimeLow != null || instance.ValidTimeHigh != null)
            {
                IVL <TS> validTime = new IVL <TS>(instance.ValidTimeLow, instance.ValidTimeHigh);
                s.WriteStartElement("validTime", "urn:hl7-org:v3");
                var hostResult = this.Host.Graph(s, validTime);
                result.AddResultDetail(hostResult.Details);
                s.WriteEndElement(); // valid time
            }
        }