Exemplo n.º 1
0
 private void HandleConstraints(string type, ICollection <BareANY> parsedItems, ConstrainedDatatype constraints, IList <XmlNode
                                                                                                                        > nodes, XmlToModelResult xmlToModelResult)
 {
     IiCollectionConstraintHandler.ConstraintResult constraintResult = this.constraintHandler.CheckConstraints(type, constraints
                                                                                                               , parsedItems);
     if (constraintResult != null)
     {
         bool isTemplateId = constraintResult.IsTemplateId();
         if (constraintResult.IsFoundMatch())
         {
             if (isTemplateId)
             {
                 string msg = System.String.Format("Found match for templateId fixed constraint: {0}", constraintResult.GetIdentifer());
                 xmlToModelResult.AddHl7Error(new Hl7Error(Hl7ErrorCode.CDA_TEMPLATEID_FIXED_CONSTRAINT_MATCH, ErrorLevel.INFO, msg, nodes
                                                           .Count > 0 ? nodes[0] : null));
             }
         }
         else
         {
             Hl7ErrorCode errorCode = (isTemplateId ? Hl7ErrorCode.CDA_TEMPLATEID_FIXED_CONSTRAINT_MISSING : Hl7ErrorCode.CDA_FIXED_CONSTRAINT_MISSING
                                       );
             string msg = "Expected to find an identifier with: " + constraintResult.GetIdentifer();
             xmlToModelResult.AddHl7Error(new Hl7Error(errorCode, ErrorLevel.WARNING, msg, nodes.Count > 0 ? nodes[0] : null));
         }
     }
 }
Exemplo n.º 2
0
 private void HandleConstraints(string type, ConstrainedDatatype constraints, BareANY hl7Value, ICollection <BareANY> bareAnyCollection
                                , FormatContext context)
 {
     IiCollectionConstraintHandler.ConstraintResult constraintResult = this.constraintHandler.CheckConstraints(type, constraints
                                                                                                               , bareAnyCollection);
     if (constraintResult != null && !constraintResult.IsFoundMatch())
     {
         // there should be a match, but if not we need to create an II with the appropriate values and add to collection
         Identifier identifier = constraintResult.GetIdentifer();
         //In Java these are really the same collection due to type erasure. In .NET we need two different collections.
         ICollection <II> iiCollection = (ICollection <II>)hl7Value.BareValue;
         iiCollection.Add(new IIImpl(identifier));
         context.GetModelToXmlResult().AddHl7Error(new Hl7Error(Hl7ErrorCode.CDA_FIXED_CONSTRAINT_PROVIDED, ErrorLevel.INFO, "A fixed constraint was added for compliance: "
                                                                + identifier, context.GetPropertyPath()));
     }
 }