예제 #1
0
 private static void PopulateStandardValuesV01(ControlActEventBean controlActEvent)
 {
     controlActEvent.EventId       = new Identifier("2.16.840.1.113883.1.6", "8141234");
     controlActEvent.StatusCode    = CodeResolverRegistry.Lookup <ActStatus>("new");
     controlActEvent.EffectiveTime = EFFECTIVE_TIME;
     controlActEvent.Author        = CreateAuthorV01();
 }
예제 #2
0
        private EntityNamePartQualifier GetQualifier(ParseContext context, XmlElement element, XmlToModelResult xmlToModelResult)
        {
            EntityNamePartQualifier result = null;

            if (element.HasAttribute(AbstractNameR2ElementParser <V> .QUALIFIER_ATTRIBUTE))
            {
                string qualifierString = GetAttributeValue(element, AbstractNameR2ElementParser <V> .QUALIFIER_ATTRIBUTE);
                if (StringUtils.IsNotBlank(qualifierString))
                {
                    EntityNamePartQualifier qualifier = CodeResolverRegistry.Lookup <EntityNamePartQualifier>(qualifierString);
                    if (qualifier == null)
                    {
                        RecordError("Invalid qualifier detected in name part: " + qualifierString, element, xmlToModelResult);
                    }
                    result = qualifier;
                    if (StringUtils.Equals("PN", context.Type) && StringUtils.Equals(Ca.Infoway.Messagebuilder.Domainvalue.Basic.EntityNamePartQualifier
                                                                                     .LEGALSTATUS.CodeValue, qualifierString))
                    {
                        RecordError("Invalid qualifier for PN name part: " + qualifierString, element, xmlToModelResult);
                    }
                }
                else
                {
                    RecordError("Qualifier may not be blank.", element, xmlToModelResult);
                }
            }
            return(result);
        }
예제 #3
0
 /// <exception cref="Ca.Infoway.Messagebuilder.Marshalling.HL7.XmlToModelTransformationException"></exception>
 private void HandlePersonName(XmlToModelResult xmlToModelResult, PersonName result, XmlNodeList childNodes)
 {
     foreach (XmlNode childNode in new XmlNodeListIterable(childNodes))
     {
         if (childNode is XmlElement)
         {
             XmlElement element                = (XmlElement)childNode;
             string     name                   = NodeUtil.GetLocalOrTagName(element);
             string     value                  = GetTextValue(element, xmlToModelResult);
             string     qualifierString        = GetAttributeValue(element, NAME_PART_TYPE_QUALIFIER);
             EntityNamePartQualifier qualifier = CodeResolverRegistry.Lookup <EntityNamePartQualifier>(qualifierString);
             if (StringUtils.IsNotBlank(value))
             {
                 result.AddNamePart(new EntityNamePart(value, GetPersonalNamePartType(name), qualifier));
             }
         }
         else
         {
             //GN: Added in fix similar to what was done for AD.BASIC.  Issue with XML containing mixture of elements and untyped text nodes.
             if (IsNonBlankTextNode(childNode))
             {
                 // validation will catch if this type does not allow for a free-form name
                 result.AddNamePart(new EntityNamePart(childNode.Value.Trim(), null));
             }
         }
     }
 }
예제 #4
0
        public virtual NullFlavor ParseNullNode()
        {
            string     attributeValue = GetAttributeValue(node, NULL_FLAVOR_ATTRIBUTE_NAME);
            NullFlavor nullFlavor     = CodeResolverRegistry.Lookup <NullFlavor>(attributeValue);

            if (ConformanceLevelUtil.IsMandatory(this.conformanceLevel, null))
            {
                xmlToModelResult.AddHl7Error(Hl7Error.CreateMandatoryAttributeIsNullError(NodeUtil.GetLocalOrTagName((XmlElement)node), GetAttributeValue
                                                                                              (node, NULL_FLAVOR_ATTRIBUTE_NAME), (XmlElement)node));
            }
            else
            {
                //      RM #15431 - strictly speaking, nullFlavors are not allowed for REQUIRED fields. However, jurisdictions often ignore this restriction.
                //      FIXME:  TM (see RM18424) - once MB has error levels implemented, this can be reinstated as a warning
                //		} else if (this.conformanceLevel != null && this.conformanceLevel == ConformanceLevel.REQUIRED) {
                //			xmlToModelResult.addHl7Error(Hl7Error.createRequiredAttributeIsNullError(
                //					NodeUtil.getLocalOrTagName((Element) node),
                //					getAttributeValue(node, NULL_FLAVOR_ATTRIBUTE_NAME),
                //					(Element) node));
                if (this.isAssociation && !StringUtils.Equals(GetAttributeValue(node, NULL_FLAVOR_XSI_NIL_ATTRIBUTE_NAME), "true"))
                {
                    if (!Ca.Infoway.Messagebuilder.BooleanUtils.ValueOf(Runtime.GetProperty(Ca.Infoway.Messagebuilder.Marshalling.HL7.Parser.NullFlavorHelper
                                                                                            .MB_SUPPRESS_XSI_NIL_ON_NULLFLAVOR)))
                    {
                        xmlToModelResult.AddHl7Error(Hl7Error.CreateNullFlavorMissingXsiNilError(NodeUtil.GetLocalOrTagName((XmlElement)node), (XmlElement
                                                                                                                                                )node));
                    }
                }
            }
            return(nullFlavor);
        }
예제 #5
0
        private ICollection <Ca.Infoway.Messagebuilder.Domainvalue.PostalAddressUse> GetNameUses(string nameUseAttribute, XmlNode
                                                                                                 node, XmlToModelResult xmlToModelResult)
        {
            ICollection <Ca.Infoway.Messagebuilder.Domainvalue.PostalAddressUse> uses = CollUtils.SynchronizedSet(new LinkedSet <Ca.Infoway.Messagebuilder.Domainvalue.PostalAddressUse
                                                                                                                                 >());

            if (nameUseAttribute != null)
            {
                StringTokenizer tokenizer = new StringTokenizer(nameUseAttribute);
                while (tokenizer.HasMoreElements())
                {
                    string token = tokenizer.NextToken();
                    x_BasicPostalAddressUse postalAddressUse = CodeResolverRegistry.Lookup <x_BasicPostalAddressUse>(token);
                    if (postalAddressUse == null)
                    {
                        // error if a use is not found
                        RecordError("PostalAddressUse '" + token + "' is not valid", (XmlElement)node, xmlToModelResult);
                    }
                    else
                    {
                        uses.Add(postalAddressUse);
                    }
                }
            }
            return(uses);
        }
예제 #6
0
        private static SeverityObservationBean CreateSeverityObservation()
        {
            SeverityObservationBean severityObservation = new SeverityObservationBean();

            severityObservation.SetCode(CodeResolverRegistry.Lookup <Ca.Infoway.Messagebuilder.Domainvalue.ActCode>("DX"));
            severityObservation.SetStatusCode(CodeResolverRegistry.Lookup <ActStatus>("NORMAL"));
            return(severityObservation);
        }
예제 #7
0
 public static void PopulateDetectedIssue(DetectedIssueBean detectedIssue)
 {
     detectedIssue.SetCode(CodeResolverRegistry.Lookup <ActDetectedIssueCode>("VALIDAT"));
     detectedIssue.SetPriorityCode(CodeResolverRegistry.Lookup <ActIssuePriority>("I"));
     detectedIssue.SetStatusCode(CodeResolverRegistry.Lookup <ActStatus>("NORMAL"));
     detectedIssue.SetText("patient not found");
     detectedIssue.SetSeverityObservation(CreateSeverityObservation());
 }
예제 #8
0
        public virtual void ShouldCopyOriginalTextFromCVImplObjectToBean()
        {
            BeanD       beanD   = new BeanD();
            BeanWrapper wrapper = new BeanWrapper(beanD);
            CVImpl      cvImpl  = new CVImpl(CodeResolverRegistry.Lookup <IntoleranceValue>("CODE"));

            cvImpl.OriginalText = ORIGINAL_TEXT;
            wrapper.Write(new Relationship("value", "CV", Cardinality.Create("0-1")), cvImpl);
            Assert.AreEqual(ORIGINAL_TEXT, ((CV)beanD.GetField("someCode")).OriginalText, "originalText");
        }
예제 #9
0
        internal static object GetFixedValue(Relationship relationship, VersionNumber version, bool isR2, Hl7Errors errors, string
                                             propertyPath)
        {
            string fixedValue = relationship.FixedValue;

            if (StringUtils.Equals("BL", relationship.Type))
            {
                return(true.ToString().EqualsIgnoreCase(fixedValue));
            }
            else
            {
                if (StringUtils.Equals("INT.POS", relationship.Type))
                {
                    return(System.Convert.ToInt32(fixedValue));
                }
                else
                {
                    if (StringUtils.Equals("ST", relationship.Type))
                    {
                        return(fixedValue);
                    }
                    else
                    {
                        if (relationship.CodedType)
                        {
                            Type codeType = DomainTypeHelper.GetReturnType(relationship, version, CodeTypeRegistry.GetInstance());
                            if (codeType == null)
                            {
                                codeType = typeof(Code);
                            }
                            Code code = CodeResolverRegistry.Lookup(codeType, fixedValue);
                            if (code == null)
                            {
                                string message = System.String.Format("Fixed code lookup could not find match for {0}.{1}", relationship.DomainType, fixedValue
                                                                      );
                                errors.AddHl7Error(new Hl7Error(Hl7ErrorCode.VALUE_NOT_IN_CODE_SYSTEM, ErrorLevel.WARNING, message, propertyPath));
                            }
                            //Fixup for .NET
                            if (isR2)
                            {
                                return(code == null ? null : new CodedTypeR2 <Code>(code));
                            }
                            else
                            {
                                return(code);
                            }
                        }
                        else
                        {
                            throw new MarshallingException("Cannot handle a fixed relationship of type: " + relationship.Type);
                        }
                    }
                }
            }
        }
예제 #10
0
        public static void PopulateStandardValues(ControlActEventBean controlActEvent)
        {
            controlActEvent.EventId       = new Identifier("2.16.840.1.113883.1.6", "8141234");
            controlActEvent.StatusCode    = CodeResolverRegistry.Lookup <ActStatus>("new");
            controlActEvent.EffectiveTime = EFFECTIVE_TIME;
            controlActEvent.Author        = CreateAuthorV01();
            ServiceDeliveryLocationBean location = new ServiceDeliveryLocationBean();

            PopulateLocation(location);
            controlActEvent.Location = location;
        }
예제 #11
0
        private object ResolveCodeValue(Relationship relationship, string attributeValue, VersionNumber version, bool isR2)
        {
            Type   returnType = (Type)DomainTypeHelper.GetReturnType(relationship, version, CodeTypeRegistry.GetInstance());
            Code   codeLookup = CodeResolverRegistry.Lookup(returnType, attributeValue);
            object result     = codeLookup;

            if (isR2)
            {
                result = CodedTypeR2Helper.ConvertCodedTypeR2(new CodedTypeR2 <Code>(codeLookup), returnType);
            }
            return(result);
        }
        private CodedTypeR2 <ConsultDocumentType> GetLoincCode()
        {
            ConsultDocumentType code = CodeResolverRegistry.Lookup <ConsultDocumentType>(typeof(ConsultDocumentType), "11488-4", "2.16.840.1.113883.6.1");

            CodedTypeR2 <ConsultDocumentType> loincCode = new CodedTypeR2 <ConsultDocumentType>();

            loincCode.Code           = code;
            loincCode.CodeSystemName = "LOINC";
            loincCode.DisplayName    = "ConsultationNote";

            return(loincCode);
        }
예제 #13
0
        private void ParseAddressUses(XmlNode node, TelecommunicationAddress result)
        {
            string addressUses = GetAttributeValue(node, "use");

            if (addressUses != null)
            {
                StringTokenizer tokenizer = new StringTokenizer(addressUses);
                while (tokenizer.HasMoreElements())
                {
                    result.AddAddressUse(CodeResolverRegistry.Lookup <Ca.Infoway.Messagebuilder.Domainvalue.TelecommunicationAddressUse>(tokenizer
                                                                                                                                         .NextToken()));
                }
            }
        }
예제 #14
0
        private TelecommunicationAddress ParseTelecommunicationAddress(XmlNode node, XmlToModelResult xmlToModelResult)
        {
            string value = GetAttributeValue(node, "value");

            if (StringUtils.IsBlank(value) && this.allowReference)
            {
                value = GetAttributeValue(node, "reference");
            }
            // remove the // that appear after the colon if necessary
            // e.g. file://monkey
            value = value == null ? null : System.Text.RegularExpressions.Regex.Replace(value, "://", ":");
            // anything before the FIRST colon is the URL scheme. Anything after it is the address.
            int    colonIndex = value == null ? -1 : value.IndexOf(':');
            string address    = null;

            Ca.Infoway.Messagebuilder.Domainvalue.URLScheme urlScheme = null;
            if (colonIndex == -1)
            {
                address = value;
            }
            else
            {
                address = Ca.Infoway.Messagebuilder.StringUtils.Substring(value, colonIndex + 1);
                string urlSchemeString = Ca.Infoway.Messagebuilder.StringUtils.Substring(value, 0, colonIndex);
                urlScheme = CodeResolverRegistry.Lookup <Ca.Infoway.Messagebuilder.Domainvalue.URLScheme>(urlSchemeString);
                if (urlScheme == null)
                {
                    string message = "Unrecognized URL scheme '" + urlSchemeString + "' in element " + XmlDescriber.DescribePath(node);
                    xmlToModelResult.AddHl7Error(new Hl7Error(Hl7ErrorCode.DATA_TYPE_ERROR, message, (XmlElement)node));
                }
            }
            TelecommunicationAddress result = new TelecommunicationAddress();

            result.Address   = address;
            result.UrlScheme = urlScheme;
            // handle address uses
            string addressUses = GetAttributeValue(node, "use");

            if (addressUses != null)
            {
                StringTokenizer tokenizer = new StringTokenizer(addressUses);
                while (tokenizer.HasMoreElements())
                {
                    result.AddAddressUse(CodeResolverRegistry.Lookup <Ca.Infoway.Messagebuilder.Domainvalue.TelecommunicationAddressUse>(tokenizer
                                                                                                                                         .NextToken()));
                }
            }
            return(result);
        }
예제 #15
0
 private Ca.Infoway.Messagebuilder.Domainvalue.Basic.Currency ValidateCurrency(string currencyCode, XmlNode node, XmlToModelResult
                                                                               xmlToModelResult)
 {
     if (StringUtils.IsBlank(currencyCode))
     {
         return(null);
     }
     // TM - the MB enum for currency is very limited
     Ca.Infoway.Messagebuilder.Domainvalue.Basic.Currency currency = CodeResolverRegistry.Lookup <Ca.Infoway.Messagebuilder.Domainvalue.Basic.Currency
                                                                                                  >(currencyCode);
     if (currency == null)
     {
         RecordUnknownCurrencyError(currencyCode, node, xmlToModelResult);
     }
     return(currency);
 }
예제 #16
0
        public virtual bool HasValidNullFlavorAttribute()
        {
            string attributeValue = GetAttributeValue(node, NULL_FLAVOR_ATTRIBUTE_NAME);

            if (attributeValue == null)
            {
                return(false);
            }
            else
            {
                if (StringUtils.IsEmpty(attributeValue) || CodeResolverRegistry.Lookup <NullFlavor>(attributeValue) == null)
                {
                    xmlToModelResult.AddHl7Error(new Hl7Error(Hl7ErrorCode.VALUE_NOT_IN_CODE_SYSTEM, System.String.Format("The nullFavor attribute value \"{0}\" is not valid ({1})"
                                                                                                                          , attributeValue, XmlDescriber.DescribeSingleElement((XmlElement)node)), (XmlElement)node));
                    return(false);
                }
            }
            return(true);
        }
예제 #17
0
        private TelecommunicationAddress ParseValue(XmlNode node, XmlToModelResult xmlToModelResult)
        {
            string value = GetAttributeValue(node, "value");

            if (StringUtils.IsBlank(value))
            {
                xmlToModelResult.AddHl7Error(new Hl7Error(Hl7ErrorCode.DATA_TYPE_ERROR, "TEL elements must have a value or a nullFlavor."
                                                          , (XmlElement)node));
            }
            // remove the // that appear after the colon if necessary
            // e.g. file://monkey
            value = value == null ? null : System.Text.RegularExpressions.Regex.Replace(value, "://", ":");
            // anything before the FIRST colon is the URL scheme. Anything after it is the address.
            int    colonIndex = value == null ? -1 : value.IndexOf(':');
            string address    = null;

            Ca.Infoway.Messagebuilder.Domainvalue.URLScheme urlScheme = null;
            if (colonIndex == -1)
            {
                address = value;
            }
            else
            {
                address = Ca.Infoway.Messagebuilder.StringUtils.Substring(value, colonIndex + 1);
                string urlSchemeString = Ca.Infoway.Messagebuilder.StringUtils.Substring(value, 0, colonIndex);
                urlScheme = CodeResolverRegistry.Lookup <Ca.Infoway.Messagebuilder.Domainvalue.URLScheme>(urlSchemeString);
                if (urlScheme == null)
                {
                    urlScheme = CodeResolverRegistry.Lookup <Ca.Infoway.Messagebuilder.Domainvalue.URLScheme>(urlSchemeString.ToLower());
                    if (urlScheme == null)
                    {
                        string message = "Unrecognized URL scheme '" + urlSchemeString + "' in element " + XmlDescriber.DescribePath(node);
                        xmlToModelResult.AddHl7Error(new Hl7Error(Hl7ErrorCode.DATA_TYPE_ERROR, message, (XmlElement)node));
                    }
                }
            }
            TelecommunicationAddress result = new TelecommunicationAddress();

            result.Address   = address;
            result.UrlScheme = urlScheme;
            return(result);
        }
예제 #18
0
 public static void PopulateStandardValuesV01(NewBaseMessageBean bean)
 {
     bean.MessageIdentifier         = new Identifier("2.16.124.113620.1.1.1.1.2", "293844");
     bean.MessageTimestamp          = DateUtil.GetDate(2008, 5, 25, 14, 16, 10, 0);
     bean.ProcessingCode            = Ca.Infoway.Messagebuilder.Domainvalue.Transport.ProcessingID.PRODUCTION;
     bean.ProcessingMode            = Ca.Infoway.Messagebuilder.Domainvalue.Transport.ProcessingMode.CURRENT_PROCESSING;
     bean.ResponseType              = Ca.Infoway.Messagebuilder.Domainvalue.Transport.ResponseMode.IMMEDIATE;
     bean.DesiredAcknowledgmentType = Ca.Infoway.Messagebuilder.Domainvalue.Transport.AcknowledgementCondition.ALWAYS;
     bean.Receiver          = new Receiver();
     bean.Receiver.DeviceId = new Identifier("1.2.3", "123");
     bean.Receiver.SetTelecommunicationAddress(new TelecommunicationAddress(CodeResolverRegistry.Lookup <Ca.Infoway.Messagebuilder.Domainvalue.URLScheme
                                                                                                         >("http"), "123.456.789.10"));
     bean.Sender          = new Sender();
     bean.Sender.DeviceId = new Identifier("1.2.3", "123");
     bean.Sender.ManufacturerModelNumber            = "1.0";
     bean.Sender.SoftwareName                       = "Panacea Pharmacy";
     bean.Sender.TelecommunicationAddress           = new TelecommunicationAddress();
     bean.Sender.TelecommunicationAddress.Address   = "987.654.321.0";
     bean.Sender.TelecommunicationAddress.UrlScheme = CodeResolverRegistry.Lookup <Ca.Infoway.Messagebuilder.Domainvalue.URLScheme
                                                                                   >("http");
 }
예제 #19
0
 private Ca.Infoway.Messagebuilder.Domainvalue.Basic.Currency ValidateCurrency(string currencyCode, XmlNode node, XmlToModelResult
                                                                               xmlToModelResult)
 {
     if (StringUtils.IsBlank(currencyCode))
     {
         return(null);
     }
     Ca.Infoway.Messagebuilder.Domainvalue.Basic.Currency currency = CodeResolverRegistry.Lookup <Ca.Infoway.Messagebuilder.Domainvalue.Basic.Currency
                                                                                                  >(currencyCode);
     if (currency == null)
     {
         RecordUnknownCurrencyError(currencyCode, node, xmlToModelResult);
     }
     else
     {
         if (!Ca.Infoway.Messagebuilder.Domainvalue.Basic.Currency.CANADIAN_DOLLAR.CodeValue.Equals(currencyCode))
         {
             RecordCurrencyMustBeCanadianError(currencyCode, node, xmlToModelResult);
         }
     }
     return(currency);
 }
예제 #20
0
        private NullFlavor GetNullFlavor(XmlElement element, XmlToModelResult xmlToModelResult)
        {
            NullFlavor result = null;

            if (element.HasAttribute(AbstractNameR2ElementParser <V> .NULLFLAVOR_ATTRIBUTE))
            {
                string nullFlavorString = GetAttributeValue(element, AbstractNameR2ElementParser <V> .NULLFLAVOR_ATTRIBUTE);
                if (StringUtils.IsNotBlank(nullFlavorString))
                {
                    NullFlavor nullFlavor = CodeResolverRegistry.Lookup <NullFlavor>(nullFlavorString);
                    if (nullFlavor == null)
                    {
                        RecordError("Invalid nullFlavor detected in name part: " + nullFlavorString, element, xmlToModelResult);
                    }
                    result = nullFlavor;
                }
                else
                {
                    RecordError("NullFlavor may not be blank.", element, xmlToModelResult);
                }
            }
            return(result);
        }
예제 #21
0
 public virtual Ca.Infoway.Messagebuilder.Domainvalue.UnitsOfMeasureCaseSensitive ValidateUnits(string type, string unitsAsString
                                                                                                , XmlElement element, string propertyPath, Hl7Errors errors, bool isR2)
 {
     Ca.Infoway.Messagebuilder.Domainvalue.UnitsOfMeasureCaseSensitive units = null;
     if (StringUtils.IsNotBlank(unitsAsString))
     {
         units = (Ca.Infoway.Messagebuilder.Domainvalue.UnitsOfMeasureCaseSensitive)CodeResolverRegistry.Lookup(this.GetUnitTypeByHl7Type
                                                                                                                    (type, element, propertyPath, errors, isR2), unitsAsString);
         if (units == null)
         {
             CreateWarning(System.String.Format("Unit \"{0}\" is not valid for type {1}", unitsAsString, type), element, propertyPath,
                           errors);
         }
     }
     return(units);
 }
예제 #22
0
        public static Realm LookupRealm(string codeValue)
        {
            Realm realm = CodeResolverRegistry.Lookup <Realm>(codeValue);

            return(realm);
        }
        private CodedTypeR2 <BasicConfidentialityKind> GetConfidentialityCode()
        {
            BasicConfidentialityKind code = CodeResolverRegistry.Lookup <BasicConfidentialityKind>(typeof(BasicConfidentialityKind), "11488-4", "2.16.840.1.113883.6.1");

            return(new CodedTypeR2 <BasicConfidentialityKind>(code));
        }
        private CodedTypeR2 <Language> GetLanguageCode()
        {
            Language code = CodeResolverRegistry.Lookup <Language>(typeof(Language), "en-US");

            return(new CodedTypeR2 <Language>(code));
        }
예제 #25
0
        private ICollection <Ca.Infoway.Messagebuilder.Domainvalue.Basic.EntityNameUse> ParseNameUses(string usesString, XmlElement
                                                                                                      element, XmlToModelResult xmlToModelResult)
        {
            ICollection <Ca.Infoway.Messagebuilder.Domainvalue.Basic.EntityNameUse> uses = CollUtils.SynchronizedSet(new LinkedSet <Ca.Infoway.Messagebuilder.Domainvalue.Basic.EntityNameUse
                                                                                                                                    >());

            if (StringUtils.IsNotBlank(usesString))
            {
                StringTokenizer tokenizer = new StringTokenizer(usesString);
                while (tokenizer.HasMoreElements())
                {
                    string token = tokenizer.NextToken();
                    Ca.Infoway.Messagebuilder.Domainvalue.Basic.EntityNameUse nameUse = CodeResolverRegistry.Lookup <Ca.Infoway.Messagebuilder.Domainvalue.Basic.EntityNameUse
                                                                                                                     >(token);
                    if (nameUse != null)
                    {
                        uses.Add(nameUse);
                    }
                    else
                    {
                        RecordError("Name use '" + token + "' not recognized.", element, xmlToModelResult);
                    }
                }
            }
            return(uses);
        }
예제 #26
0
        private Diff <PlatformDate> ParseNullWidthNode(XmlElement width)
        {
            string nullFlavor = width.GetAttribute(NullFlavorHelper.NULL_FLAVOR_ATTRIBUTE_NAME);

            return(new DateDiff(CodeResolverRegistry.Lookup <NullFlavor>(nullFlavor)));
        }