public bool InsertStandardDataType(StandardDataTypeModel model) { AutomationStandardsContext db = new AutomationStandardsContext(); StandardDataType Result = new StandardDataType(); Result.DataTypeName = model.StandardDataTypeName; Result.SQLDataType = model.SQLDataType; db.StandardDataType.Add(Result); try { db.SaveChanges(); model.StandardDataTypeID = Result.DataTypeID; return(true); } catch (DbEntityValidationException ex) { string body = ""; foreach (var eve in ex.EntityValidationErrors) { body += string.Format("Entity of type \"{0}\" in state \"{1}\" has the following validation errors:", eve.Entry.Entity.GetType().Name, eve.Entry.State); body += "<br>"; foreach (var ve in eve.ValidationErrors) { body += string.Format("- Property: \"{0}\", Error: \"{1}\"", ve.PropertyName, ve.ErrorMessage); } } //GlobalFunctions gf = new //GlobalFunctions(); //gf.SendErrorModelEmail(this.GetType().Name, body); return(false); } }
private string DetermineActualDataType(StandardDataType modelType, StandardDataType newType, bool isCdaR1, ErrorLogger errorLogger ) { StandardDataType convertedModelType = modelType; if (cdaR1MappingsToOld.ContainsKey(modelType)) { convertedModelType = cdaR1MappingsToOld.SafeGet(modelType); } string unspecializedModelType = convertedModelType.TypeName.UnspecializedName; string unspecializedNewType = newType.TypeName.UnspecializedName; // allow ANY handlers and collection handlers deal with type changes on their own if (StandardDataType.ANY.Type.Equals(unspecializedModelType) || StandardDataType.IsSetOrList(unspecializedModelType)) { return(modelType.Type); } if (IsValidTypeChange(unspecializedModelType, unspecializedNewType)) { return(MapCdaR1Type(newType, isCdaR1)); } else { string message = System.String.Format("Not able to handle type change from {0} to {1}. Type has been left unchanged.", convertedModelType .Type, newType.Type); errorLogger.LogError(Hl7ErrorCode.UNSUPPORTED_TYPE_CHANGE, ErrorLevel.WARNING, message); return(modelType.Type); } }
// Note that the behaviour for this datatype has not been fully defined by CHI. It is likely that the code below will need to be adjusted at some point. /// <exception cref="Ca.Infoway.Messagebuilder.Marshalling.HL7.XmlToModelTransformationException"></exception> protected override string ParseNonNullNode(ParseContext context, XmlNode node, BareANY parseResult, Type expectedReturnType , XmlToModelResult xmlToModelResult) { StandardDataType type = StandardDataType.GetByTypeName(context); ValidateUnallowedAttributes(type, (XmlElement)node, xmlToModelResult, "compression"); ValidateUnallowedAttributes(type, (XmlElement)node, xmlToModelResult, "language"); ValidateUnallowedAttributes(type, (XmlElement)node, xmlToModelResult, "reference"); ValidateUnallowedAttributes(type, (XmlElement)node, xmlToModelResult, "integrityCheck"); ValidateUnallowedAttributes(type, (XmlElement)node, xmlToModelResult, "thumbnail"); ValidateMaxChildCount(context, node, 1); if (!Ca.Infoway.Messagebuilder.Domainvalue.Basic.MediaType.XML_TEXT.CodeValue.Equals(GetAttributeValue(node, "mediaType") )) { xmlToModelResult.AddHl7Error(CreateHl7Error("Attribute mediaType must be included with a value of \"text/xml\" for ED.SIGNATURE" , (XmlElement)node)); } string result = null; XmlNode signatureNode = GetNamedChildNode(node, "signature"); if (signatureNode == null || signatureNode.NodeType != System.Xml.XmlNodeType.Element) { xmlToModelResult.AddHl7Error(CreateHl7Error("Expected ED.SIGNATURE node to have a child element named signature", (XmlElement )node)); } else { result = (string)this.stElementParser.Parse(context, signatureNode, xmlToModelResult).BareValue; } return(result); }
private string DetermineActualType(Relationship relationship, BareANY hl7Value, Hl7Errors errors, string propertyPath) { StandardDataType newTypeEnum = (hl7Value == null ? null : hl7Value.DataType); return(this.polymorphismHandler.DetermineActualDataType(relationship.Type, newTypeEnum, this.isCda, !this.isR2, CreateErrorLogger (propertyPath, errors))); }
private void ValidateRootLength(string root, VersionNumber version, StandardDataType type, FormatContext context) { if (iiValidationUtils.IsRootLengthInvalid(root, type, version)) { RecordError(iiValidationUtils.GetInvalidRootLengthErrorMessage(root, type, version), context); } }
private PlatformDate ParseNonNullNode(ParseContext context, XmlElement element, XmlToModelResult xmlToModelResult) { // TM - for V02R01, "width" property is allowed (PQ.TIME) - not including this here, as MB does not officially support that release PlatformDate result = null; string unparsedDate = GetAttributeValue(element, "value"); if (StringUtils.IsBlank(unparsedDate)) { xmlToModelResult.AddHl7Error(new Hl7Error(Hl7ErrorCode.DATA_TYPE_ERROR, "Timestamp value must be non-blank.", element)); } else { try { result = ParseDate(unparsedDate, GetAllDateFormats(StandardDataType.GetByTypeName(GetType(context)), context.GetVersion() ), context); CheckForMissingTimezone(context, xmlToModelResult, result, unparsedDate, element); } catch (ArgumentException) { result = TryEveryFormat(context, unparsedDate, element, xmlToModelResult); if (result == null) { string message = "The timestamp " + unparsedDate + " in element " + XmlDescriber.DescribeSingleElement(element) + " cannot be parsed."; xmlToModelResult.AddHl7Error(new Hl7Error(Hl7ErrorCode.DATA_TYPE_ERROR, message, element)); } } } return(result); }
private void ValidateSpecializationType(StandardDataType specializationType, bool valueOmitted, FormatContext context) { if (specializationType == StandardDataType.TS || specializationType == null) { if (Ca.Infoway.Messagebuilder.BooleanUtils.ValueOf(Runtime.GetProperty(TsDateFormats.ABSTRACT_TS_IGNORE_SPECIALIZATION_TYPE_ERROR_PROPERTY_NAME ))) { } else { // user has specified that this validation error should be suppressed if (valueOmitted) { } else { // RM16399 - there are some cases where it is valid to omit a specialization type (such as when not providing a TS value) // do nothing; other potential errors will be caught by the default concrete TS formatter context.GetModelToXmlResult().AddHl7Error(new Hl7Error(Hl7ErrorCode.DATA_TYPE_ERROR, System.String.Format("No specializationType provided. Value should be one of TS.FULLDATE / TS.FULLDATETIME / TS.FULLDATEPARTTIME. TS.FULLDATETIME will be assumed." , specializationType.Type), context.GetPropertyPath())); } } } else { if (specializationType != StandardDataType.TS_FULLDATE && specializationType != StandardDataType.TS_FULLDATETIME && specializationType != StandardDataType.TS_FULLDATEPARTTIME) { context.GetModelToXmlResult().AddHl7Error(new Hl7Error(Hl7ErrorCode.DATA_TYPE_ERROR, System.String.Format("Invalid specializationType: {0}. Value should be one of TS.FULLDATE / TS.FULLDATETIME / TS.FULLDATEPARTTIME. TS.FULLDATETIME will be assumed." , specializationType.Type), context.GetPropertyPath())); } } }
private bool IsValidSpecializationType(string specializationType) { StandardDataType type = StandardDataType.GetByTypeName(specializationType); return(StandardDataType.TS_FULLDATE.Equals(type) || StandardDataType.TS_FULLDATETIME.Equals(type) || StandardDataType.TS_FULLDATEPARTTIME .Equals(type)); }
private void ValidateDatePattern(string datePattern, FormatContext context) { StandardDataType standardDataType = StandardDataType.GetByTypeName(context); VersionNumber version = (context == null ? null : context.GetVersion()); string[] allowedDateFormats = TsDateFormats.GetAllDateFormats(standardDataType, version); if (ArrayContains(allowedDateFormats, datePattern)) { // check if this pattern is missing a timezone if (!IsCerx(standardDataType, version) && TsDateFormats.datetimeFormatsRequiringWarning.Contains(datePattern)) { context.GetModelToXmlResult().AddHl7Error(new Hl7Error(Hl7ErrorCode.DATA_TYPE_ERROR, System.String.Format("Date format {0} supplied for value of type {1} should also have a timezone (ZZZZZ)" , datePattern, context == null ? "TS" : context.Type), context.GetPropertyPath())); } } else { // MBR-368: a temporary work-around for producing AB PIN compliant date time renderings // with out error messages -- required until the runtime's knowledge of datatypes has been // corrected to distinguish between CeRx v3 (ie., V01R03) and CeRx v4 (ie., V01R04) if (!SpecificationVersion.IsExactVersion(SpecificationVersion.V01R04_1_AB, version)) { context.GetModelToXmlResult().AddHl7Error(new Hl7Error(Hl7ErrorCode.DATA_TYPE_ERROR, System.String.Format("Invalid date format {0} supplied for value of type {1}" , datePattern, context == null ? "TS" : context.Type), context.GetPropertyPath())); } } }
public virtual string DetermineActualDataTypeFromXsiType(string modelType, string newTypeFromXsiType, bool isCda, bool isR1 , ErrorLogger errorLogger) { StandardDataType newTypeEnum = EnumPattern.ValueOf <StandardDataType>(newTypeFromXsiType); return(DetermineActualDataType(modelType, newTypeEnum, isCda, isR1, errorLogger)); }
private bool IsCenterProhibited(bool isCeRx, StandardDataType innerType) { // only allowed for *CeRx* types: IVL<TS.DATE> and IVL<TS.FULLDATE> // also allowed for types (of any version): URG<TS.DATE> return(!(isCeRx && !this.isUncertainRangeValidation && (innerType == StandardDataType.TS_DATE || innerType == StandardDataType .TS_FULLDATE)) && !(this.isUncertainRangeValidation && innerType == StandardDataType.TS_DATE)); }
private string CreateWrongNumberOfElementsProvidedErrorMessage(bool isCeRx, string type, StandardDataType ivlType, StandardDataType innerType, StandardDataType baseInnerType) { return(GetIntervalOrRange() + "s of type " + type + " must " + (ivlType == StandardDataType.IVL || ivlType == StandardDataType .URG ? "provide exactly 2 of" : "only provide") + ": " + (IsLowProhibited(ivlType) ? string.Empty : "low ") + (IsHighProhibited (ivlType) ? string.Empty : "high ") + (IsCenterProhibited(isCeRx, innerType) ? string.Empty : "center ") + (IsWidthProhibited (ivlType, innerType, baseInnerType) ? string.Empty : "width ")); }
internal virtual bool IsValidTypeChange(string currentType, string newType) { // assumes types come in as IVL<TS> and *not* IVL_TS (which is what xsi:type would have for a value) StandardDataType inType = StandardDataType.GetByTypeName(currentType); StandardDataType outType = StandardDataType.GetByTypeName(newType); return(IsValidTypeChange(inType, outType)); }
public virtual string MapCdaR1Type(StandardDataType newType, bool isCdaR1) { if (isCdaR1 && cdaR1MappingsToNew.ContainsKey(newType)) { return(cdaR1MappingsToNew.SafeGet(newType).Type); } return(newType.Type); }
private string GetDefaultDatePattern(StandardDataType standardDataType, VersionNumber version) { if (SpecificationVersion.IsVersion(standardDataType, version, Hl7BaseVersion.CERX)) { return(DATE_FORMAT_YYYYMMDDHHMMSS); } return(DATE_FORMAT_YYYYMMDDHHMMSS_SSSZZZZZ); }
private void ValidateRootLength(XmlElement element, string root, XmlToModelResult xmlToModelResult, VersionNumber version , StandardDataType type) { if (iiValidationUtils.IsRootLengthInvalid(root, type, version)) { RecordError(iiValidationUtils.GetInvalidRootLengthErrorMessage(root, type, version), element, xmlToModelResult); } }
public virtual bool CanAdapt(Type fromDataType, string toDataTypeName) { if (IsCOLLECTIONType(fromDataType) && !StandardDataType.IsSetOrList(toDataTypeName)) { return(true); } return(false); }
public virtual bool CanAdapt(Type fromDataType, string toDataTypeName) { if (IsCOLLECTIONType(fromDataType) && StandardDataType.SET.Equals(StandardDataType.GetByTypeName (toDataTypeName)) && ContainerOfTn(toDataTypeName)) { return(true); } return(false); }
public virtual bool IsSpecializationTypeRequired(VersionNumber version, string type, bool isCda) { StandardDataType standardDataType = StandardDataType.GetByTypeName(type); // AB does not treat II as abstract; for CeRx, II is concrete; Newfoundland is excepted to allow our legacy tests to pass return(IsIiBusAndVer(type) || (IsII(type) && !(isCda || SpecificationVersion.IsVersion(standardDataType, version, Hl7BaseVersion .CERX) || "NEWFOUNDLAND".Equals(version == null ? null : version.VersionLiteral) || SpecificationVersion.IsExactVersion( SpecificationVersion.V02R02_AB, version)))); }
protected virtual void ValidateUnallowedAttributes(StandardDataType type, XmlElement node, XmlToModelResult result, string attribute) { if (StringUtils.IsNotBlank(GetAttributeValue(node, attribute))) { result.AddHl7Error(new Hl7Error(Hl7ErrorCode.DATA_TYPE_ERROR, type.Type + " should not include the '" + attribute + "' property. (" + XmlDescriber.DescribeSingleElement(node) + ")", node)); } }
internal virtual bool IsValidTypeChange(StandardDataType currentType, StandardDataType newType) { // bug fix: if the new type ends up being the root type of the current (model) type, that is valid if (currentType != null && currentType.Equals(newType)) { return(true); } IList <StandardDataType> allowedTypes = allowedMappings.SafeGet(currentType); return(allowedTypes != null && allowedTypes.Contains(newType)); }
protected sealed override string GetValue(TelecommunicationAddress uri, FormatContext context, BareANY bareAny) { string type = context.Type; StandardDataType specializationType = bareAny.DataType; VersionNumber version = context.GetVersion(); Hl7Errors errors = context.GetModelToXmlResult(); TEL_VALIDATION_UTILS.ValidateTelecommunicationAddress(uri, type, specializationType.Type, version, null, context.GetPropertyPath (), errors); return(uri.ToString()); }
private void ValidateRootAsOid(string root, VersionNumber version, StandardDataType type, FormatContext context) { if (StringUtils.IsNotBlank(root)) { if (!iiValidationUtils.IsOid(root)) { RecordError(iiValidationUtils.GetRootMustBeAnOidErrorMessage(root), context); } ValidateRootLength(root, version, type, context); } }
private void ValidateRootAsOid(string root, XmlElement element, XmlToModelResult xmlToModelResult, VersionNumber version, StandardDataType type) { if (StringUtils.IsNotBlank(root)) { if (!iiValidationUtils.IsOid(root)) { RecordError(iiValidationUtils.GetRootMustBeAnOidErrorMessage(root), element, xmlToModelResult); } ValidateRootLength(element, root, xmlToModelResult, version, type); } }
private void ChangeDatatypeIfNecessary(string type, Relationship relationship, BareANY @object) { // if the type parsed was different from the relationship type, preserve that info in the parsed object if (@object != null && !relationship.Type.Equals(type)) { StandardDataType newDataType = StandardDataType.GetByTypeName(type); if (newDataType != null) { @object.DataType = newDataType; } } }
private Type GetUnitTypeByHl7Type(string typeAsString, XmlElement element, string propertyPath, Hl7Errors errors, bool isR2 ) { StandardDataType type = StandardDataType.GetByTypeName(typeAsString); if (StandardDataType.PQ_BASIC.Equals(type)) { return(typeof(x_BasicUnitsOfMeasure)); } else { if (StandardDataType.PQ_DRUG.Equals(type)) { return(typeof(x_DrugUnitsOfMeasure)); } else { if (StandardDataType.PQ_TIME.Equals(type)) { return(typeof(x_TimeUnitsOfMeasure)); } else { if (StandardDataType.PQ_LAB.Equals(type)) { return(typeof(x_LabUnitsOfMeasure)); } else { if (StandardDataType.PQ_HEIGHTWEIGHT.Equals(type)) { return(typeof(x_HeightOrWeightObservationUnitsOfMeasure)); } else { if (StandardDataType.PQ_DISTANCE.Equals(type)) { return(typeof(x_DistanceObservationUnitsOfMeasure)); } else { if (!isR2) { CreateWarning(System.String.Format("Type \"{0}\" is not a valid PQ type", typeAsString), element, propertyPath, errors); } return(typeof(Ca.Infoway.Messagebuilder.Domainvalue.UnitsOfMeasureCaseSensitive)); } } } } } } }
private void PerformStandardValidations(ParseContext context, XmlElement element, XmlToModelResult result) { StandardDataType type = StandardDataType.GetByTypeName(context); if (type == StandardDataType.CS) { ValidateUnallowedAttributes(type, element, result, AbstractCodeTypeElementParser.CODE_SYSTEM_ATTRIBUTE_NAME); } ValidateUnallowedAttributes(type, element, result, "codeSystemName"); ValidateUnallowedAttributes(type, element, result, "codeSystemVersion"); ValidateUnallowedChildNode(context.Type, element, result, "qualifier"); }
private bool IsCodedType(FormatContext context) { if (context != null && context.Type != null) { StandardDataType dataType = StandardDataType.GetByTypeName(context); if (dataType != null) { return(dataType.Coded); } } return(false); }
protected virtual void AddSpecializationType(IDictionary <string, string> attributes, string typeAsString) { StandardDataType type = StandardDataType.GetByTypeName(typeAsString); string xsiType = Xmlify(type.TypeName.UnspecializedName); string specializationType = Xmlify(type.Type); attributes[XSI_TYPE] = xsiType; if (!StringUtils.Equals(xsiType, specializationType)) { attributes[SPECIALIZATION_TYPE] = specializationType; } }
public virtual string DetermineActualDataType(string modelType, StandardDataType newTypeEnum, bool isCda, bool isR1, ErrorLogger errorLogger) { StandardDataType modelTypeEnum = StandardDataType.GetByTypeName(modelType); if (!isCda || modelTypeEnum == null || newTypeEnum == null || StandardDataType.IsSetOrList(modelType) || NewTypeIsRootOfCurrent (modelTypeEnum, newTypeEnum)) { return(modelType); } return(DetermineActualDataType(modelTypeEnum, newTypeEnum, isCda && isR1, errorLogger)); }