コード例 #1
0
        private Code WrapFixedCodeValue(string code, string codeSystem, Type returnType)
        {
            Type codeType    = (Type)returnType;
            Code trivialCode = new TrivialCodeResolver().Lookup <Code>(codeType, code);

            return(FullCodeWrapper.Wrap(codeType, trivialCode, codeSystem));
        }
コード例 #2
0
        public virtual void ShouldWrapCodeWithCodeSystem()
        {
            Code   code       = Ca.Infoway.Messagebuilder.Domainvalue.Payload.AdministrativeGender.MALE;
            string codeSystem = CodeSystem.CANADA.ToString();
            Code   fullCode   = FullCodeWrapper.Wrap <Code>(code, codeSystem);

            Assert.AreEqual(codeSystem, fullCode.CodeSystem);
            Assert.AreEqual(code.CodeValue, fullCode.CodeValue);
        }
コード例 #3
0
        public virtual Code GetCorrespondingCode(string code, string codeSystem, Type expectedReturnType, XmlElement element, string
                                                 type, XmlToModelResult xmlToModelResult, bool relaxCodeSystemCheck, bool relaxCodeCheck)
        {
            Type codeType = GetReturnTypeAsCodeType(expectedReturnType);

            if (StandardDataType.CS.Type.Equals(type))
            {
                if (codeSystem != null)
                {
                    xmlToModelResult.AddHl7Error(new Hl7Error(Hl7ErrorCode.DATA_TYPE_ERROR, "CS should not include the 'codeSystem' property. ("
                                                              + XmlDescriber.DescribeSingleElement(element) + ")", element));
                }
            }
            else
            {
                if (StringUtils.IsNotBlank(code) && StringUtils.IsBlank(codeSystem))
                {
                    if (!relaxCodeSystemCheck)
                    {
                        xmlToModelResult.AddHl7Error(CreateMissingCodeSystemError(element, codeType, code));
                    }
                }
            }
            Code result = GetCode(codeType, code, codeSystem);

            // if a code is specified and there is no matching enum value for it,
            // something is seriously wrong
            if (StringUtils.IsNotBlank(code) && result == null && !relaxCodeCheck)
            {
                xmlToModelResult.AddHl7Error(CreateInvalidCodeError(element, codeType, code));
            }
            if (result == null && IsInterface(codeType))
            {
                //MBR-335: In some cases we have fixed values that are not part of the generated API and that have
                //values that do not conform to the expected return type. In this case, just fake up a value as
                //it will be discarded later in HL7SourceMapper. See PolicyActivity.GuarantorPerformerAssignedEntity
                //in ccda r1_1 message set for an example. i.e. GUAR is not a valid RoleClass
                if (relaxCodeCheck)
                {
                    result = WrapFixedCodeValue(code, codeSystem, codeType);
                }
                else
                {
                    // the following code will preserve the codeSystem even if the actual code can not be found
                    if (!StringUtils.IsEmpty(codeSystem))
                    {
                        result = FullCodeWrapper.Wrap(codeType, null, codeSystem);
                    }
                }
            }
            return(result);
        }