///<summary>Updates one RequiredField in the database. Uses an old object to compare to, and only alters changed fields. This prevents collisions and concurrency problems in heavily used tables. Returns true if an update occurred.</summary> public static bool Update(RequiredField requiredField, RequiredField oldRequiredField) { string command = ""; if (requiredField.FieldType != oldRequiredField.FieldType) { if (command != "") { command += ","; } command += "FieldType = " + POut.Int((int)requiredField.FieldType) + ""; } if (requiredField.FieldName != oldRequiredField.FieldName) { if (command != "") { command += ","; } command += "FieldName = '" + POut.String(requiredField.FieldName.ToString()) + "'"; } if (command == "") { return(false); } command = "UPDATE requiredfield SET " + command + " WHERE RequiredFieldNum = " + POut.Long(requiredField.RequiredFieldNum); Db.NonQ(command); return(true); }
///<summary>Inserts one RequiredField into the database. Provides option to use the existing priKey. Doesn't use the cache.</summary> public static long InsertNoCache(RequiredField requiredField, bool useExistingPK) { bool isRandomKeys = Prefs.GetBoolNoCache(PrefName.RandomPrimaryKeys); string command = "INSERT INTO requiredfield ("; if (!useExistingPK && isRandomKeys) { requiredField.RequiredFieldNum = ReplicationServers.GetKeyNoCache("requiredfield", "RequiredFieldNum"); } if (isRandomKeys || useExistingPK) { command += "RequiredFieldNum,"; } command += "FieldType,FieldName) VALUES("; if (isRandomKeys || useExistingPK) { command += POut.Long(requiredField.RequiredFieldNum) + ","; } command += POut.Int((int)requiredField.FieldType) + "," + "'" + POut.String(requiredField.FieldName.ToString()) + "')"; if (useExistingPK || isRandomKeys) { Db.NonQ(command); } else { requiredField.RequiredFieldNum = Db.NonQ(command, true, "RequiredFieldNum", "requiredField"); } return(requiredField.RequiredFieldNum); }
///<summary>Converts a DataTable to a list of objects.</summary> public static List <RequiredField> TableToList(DataTable table) { List <RequiredField> retVal = new List <RequiredField>(); RequiredField requiredField; foreach (DataRow row in table.Rows) { requiredField = new RequiredField(); requiredField.RequiredFieldNum = PIn.Long(row["RequiredFieldNum"].ToString()); requiredField.FieldType = (OpenDentBusiness.RequiredFieldType)PIn.Int(row["FieldType"].ToString()); string fieldName = row["FieldName"].ToString(); if (fieldName == "") { requiredField.FieldName = (OpenDentBusiness.RequiredFieldName) 0; } else { try{ requiredField.FieldName = (OpenDentBusiness.RequiredFieldName)Enum.Parse(typeof(OpenDentBusiness.RequiredFieldName), fieldName); } catch { requiredField.FieldName = (OpenDentBusiness.RequiredFieldName) 0; } } retVal.Add(requiredField); } return(retVal); }
protected void btnSend_Click(object sender, EventArgs e) { strError = string.Empty; if (string.IsNullOrEmpty(txtWorkOrder.Text.Trim())) { RequiredField.Enabled = true; RequiredField.IsValid = false; RequiredField.Validate(); txtWorkOrder.Focus(); return; } lblResult.Text = string.Empty; txtWorkOrder.Text = txtWorkOrder.Text.ToUpperInvariant(); if (string.IsNullOrEmpty(txtWorkOrder.Text.Trim())) { return; } obj.orno = txtWorkOrder.Text.ToUpperInvariant(); resultado = idal.spareDelivery_listaRegistrosOrdenParam(ref obj, ref strError); if (resultado.Rows.Count < 1 || !string.IsNullOrEmpty(strError)) { lblResult.Text = string.Format("Order Work {0} : {1}", obj.orno.Trim(), strError); return; } grdRecords.DataSource = resultado; grdRecords.DataBind(); }
public FormReqFieldCondEdit(RequiredField reqField) { InitializeComponent(); Lan.F(this); _reqField = reqField; _listReqFieldConds = new List <RequiredFieldCondition>(); }
protected void btnSend_Click(object sender, EventArgs e) { strError = string.Empty; if (string.IsNullOrEmpty(txtWorkOrder.Text.Trim())) { RequiredField.Enabled = true; RequiredField.IsValid = false; RequiredField.Validate(); txtWorkOrder.Focus(); return; } lblResult.Text = string.Empty; txtWorkOrder.Text = txtWorkOrder.Text.ToUpperInvariant(); if (string.IsNullOrEmpty(txtWorkOrder.Text.Trim())) { return; } obj.orno = txtWorkOrder.Text.ToUpperInvariant(); resultado = idal.spareDelivery_verificaOrdenes_Param(ref obj, ref strError); if (resultado.Rows.Count < 1 || !string.IsNullOrEmpty(strError)) { lblResult.Text = string.Format("Order Work {0} : {1}", obj.orno.Trim(), strError); return; } createObjectTable(); divOptButtons.Visible = true; }
///<summary>Inserts one RequiredField into the database. Returns the new priKey.</summary> public static long Insert(RequiredField requiredField) { if (DataConnection.DBtype == DatabaseType.Oracle) { requiredField.RequiredFieldNum = DbHelper.GetNextOracleKey("requiredfield", "RequiredFieldNum"); int loopcount = 0; while (loopcount < 100) { try { return(Insert(requiredField, true)); } catch (Oracle.ManagedDataAccess.Client.OracleException ex) { if (ex.Number == 1 && ex.Message.ToLower().Contains("unique constraint") && ex.Message.ToLower().Contains("violated")) { requiredField.RequiredFieldNum++; loopcount++; } else { throw ex; } } } throw new ApplicationException("Insert failed. Could not generate primary key."); } else { return(Insert(requiredField, false)); } }
///<summary>Inserts one RequiredField into the database. Provides option to use the existing priKey.</summary> public static long Insert(RequiredField requiredField, bool useExistingPK) { if (!useExistingPK && PrefC.RandomKeys) { requiredField.RequiredFieldNum = ReplicationServers.GetKey("requiredfield", "RequiredFieldNum"); } string command = "INSERT INTO requiredfield ("; if (useExistingPK || PrefC.RandomKeys) { command += "RequiredFieldNum,"; } command += "FieldType,FieldName) VALUES("; if (useExistingPK || PrefC.RandomKeys) { command += POut.Long(requiredField.RequiredFieldNum) + ","; } command += POut.Int((int)requiredField.FieldType) + "," + "'" + POut.String(requiredField.FieldName.ToString()) + "')"; if (useExistingPK || PrefC.RandomKeys) { Db.NonQ(command); } else { requiredField.RequiredFieldNum = Db.NonQ(command, true, "RequiredFieldNum", "requiredField"); } return(requiredField.RequiredFieldNum); }
public void Empty_Strings_Are_Considered_Invalid() { var obj = new DummyObject(); var requiredField = new RequiredField<DummyObject>(obj, o => o.RequiredString); Exception<BuilderException> .ShouldBeThrownBy(requiredField.Validate); }
public void Null_Values_Are_Considered_Invalid() { var obj = new DummyObject(); var requiredField = new RequiredField<DummyObject>(obj, o => o.ChildProperty); Exception<BuilderException> .ShouldBeThrownBy(requiredField.Validate); }
public FormReqFieldCondEdit(RequiredField reqField, RequiredFieldName condType) { InitializeComponent(); Lan.F(this); _reqField = reqField; _originalFieldName = condType; _listReqFieldConds = reqField.ListRequiredFieldConditions.FindAll(x => x.ConditionType == _originalFieldName); }
public IActionResult Index(RequiredField model) { if (ModelState.IsValid) { ViewBag.FirstName = model.FirstName; ViewBag.LastName = model.LastName; } return(View()); }
///<summary>Updates one RequiredField in the database.</summary> public static void Update(RequiredField requiredField) { string command = "UPDATE requiredfield SET " + "FieldType = " + POut.Int((int)requiredField.FieldType) + ", " + "FieldName = '" + POut.String(requiredField.FieldName.ToString()) + "' " + "WHERE RequiredFieldNum = " + POut.Long(requiredField.RequiredFieldNum); Db.NonQ(command); }
/// <summary> /// GetPV1 /// Get the HL7 IN3 segment and parse into the IN2 object. /// Also perform field validation of required fields and types /// Verify no errors have been detected during processing /// </summary> /// <param name="line">HL7 segment to parse</param> /// <returns>IN3 object</returns> public IN3 GetIN3(HL7Encoding _encode, string line) { const string fnName = "GetIN3"; List <SegmentError> segError = null; IN3 ins = new IN3(); int nIdx = 0; try { ins.SegmentMsg = line; ins.Segment = "IN3"; segError = Validate(ins, _encode); // var enumCnt = Enum.GetNames(typeof(mshElements)).Length; foreach (int i in Enum.GetValues(typeof(in3Elements))) { nIdx = i; object obj = GetElement(_encode, line, i); if (obj == null) { // check if this a required field string sTmp1 = ((Gt1Elements)i).ToString(); RequiredField rqFld = ins.RequiredFields.Find(x => x.FieldName.Equals(sTmp1)); if (rqFld != null && rqFld.IsRequired) { ins.Errors.Add(string.Format("{0}:{1} - WARNING Element ({2}) not found in segment, at field {3}", modName, fnName, ((in3Elements)i).ToString(), i)); } continue; } switch ((in3Elements)i) { case in3Elements.Segment: ins.Segment = (string)obj; break; case in3Elements.SeqId: if (!string.IsNullOrEmpty((string)obj)) { ins.SeqId = int.Parse((string)obj); } break; default: ins.Errors.Add(string.Format("{0}:{1} - Error element ({2}) not found", modName, fnName, ((in3Elements)i).ToString())); break; } } } catch (Exception ex) { string sErr = string.Format("Exception:{0}:{1} - ({2}) {3}", modName, fnName, ((in3Elements)nIdx).ToString(), ex); ins.Errors.Add(sErr); Console.WriteLine(sErr); } return(ins); }
/// <summary> /// Ts the generate required field list from reader. /// </summary> /// <param name="returnData">The return data.</param> /// <param name="requiredFieldList">The required field list.</param> private static void GenerateRequiredFieldListFromReader(SqlDataReader returnData, ref List <RequiredField> requiredFieldList) { while (returnData.Read()) { var newRequiredField = new RequiredField(returnData["FieldName"].ToString(), returnData["FieldValue"].ToString()); requiredFieldList.Add(newRequiredField); } }
/// <summary> /// Serves as a hash function for a particular type. /// </summary> /// <returns> /// A hash code for the current <see cref="T:System.Object"/>. /// </returns> public override int GetHashCode() { unchecked { var hashCode = Name?.GetHashCode() ?? 0; hashCode = (hashCode * 397) ^ RequiredField.GetHashCode(); hashCode = (hashCode * 397) ^ EmptyIsNull.GetHashCode(); return(hashCode); } }
public void Non_Empty_Strings_Are_Considered_Valid() { var obj = new DummyObject { RequiredString = "Requirement Met" }; var requiredField = new RequiredField<DummyObject>(obj, o => o.RequiredString); requiredField.Validate(); // no exception expected }
public void Non_Null_Values_Are_Considered_Valid() { var obj = new DummyObject { ChildProperty = new DummyObject() }; var requiredField = new RequiredField<DummyObject>(obj, o => o.ChildProperty); requiredField.Validate(); // no exception expected }
/// <summary> /// Indicates whether the current object is equal to another object of the same type. /// </summary> /// <returns> /// true if the current object is equal to the <paramref name="other"/> parameter; otherwise, false. /// </returns> /// <param name="other">An object to compare with this object.</param> public bool Equals(ServiceInput other) { if (ReferenceEquals(null, other)) { return(false); } if (ReferenceEquals(this, other)) { return(true); } return(string.Equals(Name, other.Name) && RequiredField.Equals(other.RequiredField) && EmptyIsNull.Equals(other.EmptyIsNull)); }
///<summary>Returns true if Update(RequiredField,RequiredField) would make changes to the database. ///Does not make any changes to the database and can be called before remoting role is checked.</summary> public static bool UpdateComparison(RequiredField requiredField, RequiredField oldRequiredField) { if (requiredField.FieldType != oldRequiredField.FieldType) { return(true); } if (requiredField.FieldName != oldRequiredField.FieldName) { return(true); } return(false); }
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) { RequiredField field = (RequiredField)attribute; if (property.objectReferenceValue == null) { GUI.color = field.color; EditorGUI.PropertyField(position, property, label); GUI.color = Color.white; } else { EditorGUI.PropertyField(position, property, label); } }
///<summary>Inserts one RequiredField into the database. Returns the new priKey. Doesn't use the cache.</summary> public static long InsertNoCache(RequiredField requiredField) { if (DataConnection.DBtype == DatabaseType.MySql) { return(InsertNoCache(requiredField, false)); } else { if (DataConnection.DBtype == DatabaseType.Oracle) { requiredField.RequiredFieldNum = DbHelper.GetNextOracleKey("requiredfield", "RequiredFieldNum"); //Cacheless method } return(InsertNoCache(requiredField, true)); } }
public IActionResult Index(RequiredField model, string btnAction) { if (btnAction == "Submit") { if (ModelState.IsValid) { ViewBag.FirstName = model.FirstName; ViewBag.LastName = model.LastName; } } if (btnAction == "Reset") { ModelState.Clear(); } return(View()); }
void System.Xml.Serialization.IXmlSerializable.ReadXml(System.Xml.XmlReader reader) { reader.ReadStartElement(); Expression = reader.ReadElementString("Expression", Namespaces.Query); var parameters = new List <QueryParameter>(); reader.ReadStartElement("Parameters", Namespaces.Query); while (reader.NodeType != System.Xml.XmlNodeType.EndElement) { if (reader.LocalName == "QueryParameter") { var parameter = new QueryParameter(); ((System.Xml.Serialization.IXmlSerializable)parameter).ReadXml(reader); parameters.Add(parameter); } else { reader.Skip(); } } reader.ReadEndElement(); var requiredFields = new List <RequiredField>(); reader.ReadStartElement("RequiredFields", Namespaces.Query); while (reader.NodeType != System.Xml.XmlNodeType.EndElement) { if (reader.LocalName == "Field") { var field = new RequiredField(); ((System.Xml.Serialization.IXmlSerializable)field).ReadXml(reader); requiredFields.Add(field); } else { reader.Skip(); } } reader.ReadEndElement(); this.Parameters = parameters.ToArray(); this.RequiredFields = requiredFields.ToArray(); reader.ReadEndElement(); }
void Colosoft.Serialization.ICompactSerializable.Deserialize(Colosoft.Serialization.IO.CompactReader reader) { this.Expression = reader.ReadString(); var count = reader.ReadInt32(); var parameters = new List <QueryParameter>(count); for (var i = 0; i < count; i++) { var parameter = new QueryParameter(); ((Colosoft.Serialization.ICompactSerializable)parameter).Deserialize(reader); parameters.Add(parameter); } _parameters = parameters.ToArray(); count = reader.ReadInt32(); var requiredFields = new List <RequiredField>(count); for (var i = 0; i < count; i++) { var field = new RequiredField(); ((Colosoft.Serialization.ICompactSerializable)field).Deserialize(reader); requiredFields.Add(field); } _requiredFields = requiredFields.ToArray(); }
private void butRight_Click(object sender, EventArgs e) { if (listAvailableFields.SelectedIndices.Count == 0) { return; } RequiredField reqField; for (int i = 0; i < listAvailableFields.SelectedItems.Count; i++) { reqField = new RequiredField(); reqField.FieldType = (RequiredFieldType)comboFieldTypes.SelectedIndex; reqField.FieldName = _listFieldNames[listAvailableFields.SelectedIndices[i]]; RequiredFields.Insert(reqField); } RequiredFields.RefreshCache(); FillAvailable(); FillMain(); gridConditions.BeginUpdate(); gridConditions.ListGridRows.Clear(); gridConditions.EndUpdate(); labelExplanation.Text = ""; checkMedicaidLength.Visible = false; }
/// <summary> /// GetPV1 /// Get the HL7 ORC segment and parse into the orc object. /// Also perform field validation of required fields and types /// Verify no errors have been detected during processing /// </summary> /// <param name="line">HL7 segment to parse</param> /// <returns>ORC object</returns> public ORC GetORC(HL7Encoding _encode, string line) { const string fnName = "GetORC"; List <SegmentError> segError = null; ORC orc = new ORC(); int nIdx = 0; try { orc.SegmentMsg = line; orc.Segment = "ORC"; segError = Validate(orc, _encode); // var enumCnt = Enum.GetNames(typeof(mshElements)).Length; foreach (int i in Enum.GetValues(typeof(orcElements))) { nIdx = i; object obj = GetElement(_encode, line, i); if (obj == null) { // check if this a required field string sTmp1 = ((Gt1Elements)i).ToString(); RequiredField rqFld = orc.RequiredFields.Find(x => x.FieldName.Equals(sTmp1)); if (rqFld != null && rqFld.IsRequired) { orc.Errors.Add(string.Format("{0}:{1} - WARNING Element ({2}) not found in segment, at field {3}", modName, fnName, ((orcElements)i).ToString(), i)); } continue; } switch ((orcElements)i) { case orcElements.Segment: orc.Segment = (string)obj; break; case orcElements.EnteredBy: if (!string.IsNullOrEmpty((string)obj)) { orc.EnteredBy = (string)obj; } break; case orcElements.FillerOrderNumber: if (!string.IsNullOrEmpty((string)obj)) { orc.FillerOrderNumber = (string)obj; } break; case orcElements.OrderControl: if (!string.IsNullOrEmpty((string)obj)) { orc.OrderControl = (string)obj; } break; case orcElements.OrderingPhysician: if (!string.IsNullOrEmpty((string)obj)) { orc.NPI = GetComponent(_encode, (string)obj, (int)orcProvider.NPI); orc.LastName = GetComponent(_encode, (string)obj, (int)orcProvider.LastName); orc.FirstName = GetComponent(_encode, (string)obj, (int)orcProvider.FirstName); } break; case orcElements.OrderStatus: if (!string.IsNullOrEmpty((string)obj)) { orc.OrderStatus = (string)obj; } break; case orcElements.Parent: if (!string.IsNullOrEmpty((string)obj)) { orc.Parent = (string)obj; } break; case orcElements.PlacerGroupNumber: if (!string.IsNullOrEmpty((string)obj)) { orc.PlacerGroupNumber = (string)obj; } break; case orcElements.PlacerOrderNumber: if (!string.IsNullOrEmpty((string)obj)) { orc.PlacerOrderNumber = (string)obj; } break; case orcElements.QuantityTiming: if (!string.IsNullOrEmpty((string)obj)) { orc.QuantityTiming = (string)obj; } break; case orcElements.ResponseFlag: if (!string.IsNullOrEmpty((string)obj)) { orc.ResponseFlag = (string)obj; } break; case orcElements.TransactionDateTime: if (!string.IsNullOrEmpty((string)obj)) { orc.TransactionDateTime = (string)obj; } break; case orcElements.VerifiedBy: if (!string.IsNullOrEmpty((string)obj)) { orc.VerifiedBy = (string)obj; } break; default: orc.Errors.Add(string.Format("{0}:{1} - Error element ({2}) not found", modName, fnName, (orcElements)i).ToString()); break; } } } catch (Exception ex) { string sErr = string.Format("Exception:{0}:{1} - ({2}) {3}", modName, fnName, ((orcElements)nIdx).ToString(), ex); orc.Errors.Add(sErr); Console.WriteLine(sErr); } return(orc); }
public FreightCalculatedField() { this.freightField = RequiredField.ForProperty("Freight"); }
public CommissionCalculatedField() { this.Name = "Commission"; this.extendPriceField = RequiredField.ForProperty("ExtendedPrice"); }
///<summary>Inserts one RequiredField into the database. Returns the new priKey. Doesn't use the cache.</summary> public static long InsertNoCache(RequiredField requiredField) { return(InsertNoCache(requiredField, false)); }
/// <summary> /// GetOBR /// Get the HL7 OBR segment and parse into the OBR object. /// Also perform field validation of required fields and types /// Verify no errors have been detected during processing /// </summary> /// <param name="line">HL7 segment to parse</param> /// <returns>OBX object</returns> public OBX GetOBX(HL7Encoding _encode, string line, string messageType) { const string fnName = "GetOBX"; List <SegmentError> segError = null; OBX obx = new OBX(messageType); int nIdx = 0; try { obx.SegmentMsg = line; obx.Segment = "OBR"; segError = Validate(obx, _encode, messageType); // var enumCnt = Enum.GetNames(typeof(mshElements)).Length; foreach (int i in Enum.GetValues(typeof(obxElements))) { nIdx = i; object obj = GetElement(_encode, line, i); if (obj == null) { // check if this a required field string sTmp1 = ((Gt1Elements)i).ToString(); RequiredField rqFld = obx.RequiredFields.Find(x => x.FieldName.Equals(sTmp1)); if (rqFld != null && rqFld.IsRequired) { obx.Errors.Add(string.Format("{0}:{1} - WARNING Element ({2}) not found in segment, at field {3}", modName, fnName, ((obxElements)i).ToString(), i)); } continue; } switch ((obxElements)i) { case obxElements.Segment: obx.Segment = (string)obj; break; case obxElements.SeqId: if (!string.IsNullOrEmpty((string)obj)) { obx.SeqId = int.Parse((string)obj); } break; case obxElements.ObservationIdentifier: if (!string.IsNullOrEmpty((string)obj)) { obx.TestCode = GetComponent(_encode, (string)obj, (int)observationIdentifier.testCode); obx.TestCodeDescription = GetComponent(_encode, (string)obj, (int)observationIdentifier.testCodeDescription); obx.LimTestCode = GetComponent(_encode, (string)obj, (int)observationIdentifier.limTestCode); obx.LimTestCodeDescription = GetComponent(_encode, (string)obj, (int)observationIdentifier.limTestCodeDescription); obx.CodingSystem = GetComponent(_encode, (string)obj, (int)observationIdentifier.codingSystem); } break; case obxElements.ObservationSubId: if (!string.IsNullOrEmpty((string)obj)) { obx.ObservationSubId = (string)obj; } break; case obxElements.ObservationValue: if (!string.IsNullOrEmpty((string)obj)) { obx.ObservationValue = (string)obj; } break; case obxElements.ValueType: if (!string.IsNullOrEmpty((string)obj)) { obx.ValueType = (string)obj; } break; case obxElements.Units: if (!string.IsNullOrEmpty((string)obj)) { obx.Units = (string)obj; } break; case obxElements.ReferenceRange: if (!string.IsNullOrEmpty((string)obj)) { obx.ReferenceRange = (string)obj; } break; case obxElements.AbnormalFlags: if (!string.IsNullOrEmpty((string)obj)) { obx.AbnormalFlags = (string)obj; } break; case obxElements.Probability: if (!string.IsNullOrEmpty((string)obj)) { obx.Probability = (string)obj; } break; case obxElements.AbnormalTest: if (!string.IsNullOrEmpty((string)obj)) { obx.AbnormalTest = (string)obj; } break; case obxElements.ResultStatus: if (!string.IsNullOrEmpty((string)obj)) { obx.ResultStatus = (string)obj; } break; case obxElements.ObservedLastDate: if (!string.IsNullOrEmpty((string)obj)) { obx.ObservedLastDate = (string)obj; } break; case obxElements.AccessChecks: if (!string.IsNullOrEmpty((string)obj)) { obx.AccessChecks = (string)obj; } break; case obxElements.ObservationDateTime: if (!string.IsNullOrEmpty((string)obj)) { obx.ObservationDateTime = (string)obj; } break; case obxElements.Producers_ID: if (!string.IsNullOrEmpty((string)obj)) { obx.Producers_ID = (string)obj; } break; default: obx.Errors.Add(string.Format("{0}:{1} - Error element ({2}) not found", modName, fnName, ((obxElements)i).ToString())); break; } } } catch (Exception ex) { string sErr = string.Format("Exception:{0}:{1} - ({2}) {3}", modName, fnName, ((obxElements)nIdx).ToString(), ex); obx.Errors.Add(sErr); Console.WriteLine(sErr); } return(obx); }
public FreightCalculatedField() { this.freightField = RequiredField.ForProperty("Freight"); }
public CommissionCalculatedField() { this.Name = "Commission"; this.extendPriceField = RequiredField.ForProperty("ExtendedPrice"); }
/// <summary> /// GetPV1 /// Get the HL7 GT1 segment and parse into the GT1 object. /// Also perform field validation of required fields and types /// Verify no errors have been detected during processing /// </summary> /// <param name="line">HL7 segment to parse</param> /// <returns>GT1 object</returns> public GT1 GetGT1(HL7Encoding _encode, string line) { const string fnName = "GetGT1"; List <SegmentError> segError = null; GT1 gt1 = new GT1(); int nIdx = 0; try { gt1.SegmentMsg = line; gt1.Segment = "GT1"; segError = Validate(gt1, _encode); // var enumCnt = Enum.GetNames(typeof(mshElements)).Length; foreach (int i in Enum.GetValues(typeof(Gt1Elements))) { nIdx = i; object obj = GetElement(_encode, line, i); if (obj == null) { // check if this a required field string sTmp1 = ((Gt1Elements)i).ToString(); RequiredField rqFld = gt1.RequiredFields.Find(x => x.FieldName.Equals(sTmp1)); if (rqFld != null && rqFld.IsRequired) { gt1.Errors.Add(string.Format("{0}:{1} - WARNING Element ({2}) not found in segment, at field {3}", modName, fnName, ((Gt1Elements)i).ToString(), i)); } continue; } switch ((Gt1Elements)i) { case Gt1Elements.Segment: gt1.Segment = (string)obj; break; case Gt1Elements.SeqId: if (!string.IsNullOrEmpty((string)obj)) { gt1.SeqId = int.Parse((string)obj); } break; case Gt1Elements.GuarantorNumber: if (!string.IsNullOrEmpty((string)obj)) { gt1.GuarantorNumber = (string)obj; } break; case Gt1Elements.GuarantorName: if (!string.IsNullOrEmpty((string)obj)) { gt1.FirstName = GetComponent(_encode, (string)obj, (int)ProviderName.FirstName); gt1.LastName = GetComponent(_encode, (string)obj, (int)ProviderName.LastName); gt1.MiddleName = GetComponent(_encode, (string)obj, (int)ProviderName.MiddleName); } break; case Gt1Elements.GuarantorSpouseName: if (!string.IsNullOrEmpty((string)obj)) { gt1.GuarantorSpouseName = (string)obj; } break; case Gt1Elements.Address: if (!string.IsNullOrEmpty((string)obj)) { gt1.Address1 = GetComponent(_encode, (string)obj, (int)GuarantorAddress.Address1); gt1.Address2 = GetComponent(_encode, (string)obj, (int)GuarantorAddress.Address2); gt1.City = GetComponent(_encode, (string)obj, (int)GuarantorAddress.City); gt1.State = GetComponent(_encode, (string)obj, (int)GuarantorAddress.State); gt1.Zip = GetComponent(_encode, (string)obj, (int)GuarantorAddress.Zip); } break; case Gt1Elements.PhoneNumber: if (!string.IsNullOrEmpty((string)obj)) { gt1.PhoneNumber = (string)obj; } break; case Gt1Elements.BusinessPhone: if (!string.IsNullOrEmpty((string)obj)) { gt1.BusinessPhone = (string)obj; } break; case Gt1Elements.DOB: if (!string.IsNullOrEmpty((string)obj)) { gt1.DOB = (string)obj; } break; case Gt1Elements.Gender: if (!string.IsNullOrEmpty((string)obj)) { gt1.Gender = (string)obj; } break; case Gt1Elements.GuarantorType: if (!string.IsNullOrEmpty((string)obj)) { gt1.GuarantorType = (string)obj; } break; case Gt1Elements.Relationship: if (!string.IsNullOrEmpty((string)obj)) { gt1.Relationship = (string)obj; } break; case Gt1Elements.SSN: if (!string.IsNullOrEmpty((string)obj)) { gt1.SSN = (string)obj; } break; default: gt1.Errors.Add(string.Format("{0}:{1} - Error element ({2}) not found", modName, fnName, ((Gt1Elements)i).ToString())); break; } } } catch (Exception ex) { string sErr = string.Format("Exception:{0}:{1} - ({2}) {3}", modName, fnName, ((Gt1Elements)nIdx).ToString(), ex); gt1.Errors.Add(sErr); Console.WriteLine(sErr); } return(gt1); }
/// <summary> /// GetPV1 /// Get the HL7 IN1 segment and parse into the IN1 object. /// Also perform field validation of required fields and types /// Verify no errors have been detected during processing /// </summary> /// <param name="line">HL7 segment to parse</param> /// <returns>IN1 object</returns> public IN1 GetIN1(HL7Encoding _encode, string line) { const string fnName = "GetIN1"; List <SegmentError> segError = null; IN1 in1 = new IN1(); int nIdx = 0; try { in1.SegmentMsg = line; in1.Segment = "IN1"; segError = Validate(in1, _encode); // var enumCnt = Enum.GetNames(typeof(mshElements)).Length; foreach (int i in Enum.GetValues(typeof(In1Elements))) { nIdx = i; object obj = GetElement(_encode, line, i); if (obj == null) { // check if this a required field string sTmp1 = ((Gt1Elements)i).ToString(); RequiredField rqFld = in1.RequiredFields.Find(x => x.FieldName.Equals(sTmp1)); if (rqFld != null && rqFld.IsRequired) { in1.Errors.Add(string.Format("{0}:{1} - WARNING Element ({2}) not found in segment, at field {3}", modName, fnName, ((In1Elements)i).ToString(), i)); } continue; } switch ((In1Elements)i) { case In1Elements.Segment: in1.Segment = (string)obj; break; case In1Elements.SeqId: if (!string.IsNullOrEmpty((string)obj)) { in1.SeqId = int.Parse((string)obj); } break; case In1Elements.AdmissionCode: in1.AddmissinCode = (string)obj; break; case In1Elements.AdmissionDate: in1.AdmissionDate = (string)obj; break; case In1Elements.AgreementCode: in1.AgreementCode = (string)obj; break; case In1Elements.AssignmentBenefits: in1.AssignmentBenefits = (string)obj; break; case In1Elements.Authorization: in1.Authorization = (string)obj; break; case In1Elements.BenefitsPriority: in1.BenefitsPriority = (string)obj; break; case In1Elements.BillingStatus: in1.BillingStatus = (string)obj; break; case In1Elements.CompanyAddress: in1.CompanyAddress = (string)obj; break; case In1Elements.CompanyCode: in1.CompanyCode = (string)obj; break; case In1Elements.CompanyContact: in1.CompanyContact = (string)obj; break; case In1Elements.CompanyName: in1.CompanyName = (string)obj; break; case In1Elements.CompanyPhone: in1.CompanyPhone = (string)obj; break; case In1Elements.CompanyPlanCode: in1.CompanyPlanCode = (string)obj; break; case In1Elements.CoordinationBenefits: in1.CoordinationBenefits = (string)obj; break; case In1Elements.CoverageType: in1.CoverageType = (string)obj; break; case In1Elements.DelayBefore: in1.DelayBefore = (string)obj; break; case In1Elements.EffectiveDate: in1.EffectiveDate = (string)obj; break; case In1Elements.EligibilityCode: in1.EligibilityCode = (string)obj; break; case In1Elements.EligibilityDate: in1.EligibilityDate = (string)obj; break; case In1Elements.EmployerAddress: in1.EmployerAddress = (string)obj; break; case In1Elements.EmployerId: in1.EmployerId = (string)obj; break; case In1Elements.EmployerName: in1.EmployerName = (string)obj; break; case In1Elements.EmploymentStatus: in1.EmploymentStatus = (string)obj; break; case In1Elements.ExpirationDate: in1.ExpirationDate = (string)obj; break; case In1Elements.GroupName: in1.GroupName = (string)obj; break; case In1Elements.GroupNumber: in1.GroupNumber = (string)obj; break; case In1Elements.Handicap: in1.Handicap = (string)obj; break; case In1Elements.InsuredAddress: in1.InsuredAddress = (string)obj; break; case In1Elements.InsuredDOB: in1.InsuredDOB = (string)obj; break; case In1Elements.InsuredIdNumber: in1.InsuredIdNumber = (string)obj; break; case In1Elements.InsuredName: in1.InsuredName = (string)obj; break; case In1Elements.InsuredSex: in1.InsuredSex = (string)obj; break; case In1Elements.PlayType: in1.PlanType = (string)obj; break; case In1Elements.PolicyAmount: in1.PolicyAmount = (string)obj; break; case In1Elements.PolicyDays: in1.PolicyDays = (string)obj; break; case In1Elements.PolicyDeductible: in1.PolicyDeductible = (string)obj; break; case In1Elements.PolicyNumber: in1.PolicyNumber = (string)obj; break; case In1Elements.PreAdmin: in1.PreAdmin = (string)obj; break; case In1Elements.PriorInsurancePlanId: in1.PriorInsurancePlanId = (string)obj; break; case In1Elements.RelationshipTo: in1.RelationshipTo = (string)obj; break; case In1Elements.ReleaseCode: in1.ReleaseCode = (string)obj; break; case In1Elements.ReserveDays: in1.ReserveDays = (string)obj; break; case In1Elements.RoomPrivate: in1.RoomPrivate = (string)obj; break; case In1Elements.RoomSemiPrivate: in1.RoomSemiPrivate = (string)obj; break; case In1Elements.ShortName: in1.ShortName = (string)obj; break; case In1Elements.VerificationBy: in1.VerificationBy = (string)obj; break; case In1Elements.VerificationDate: in1.VerificationDate = (string)obj; break; case In1Elements.VerificationStatus: in1.VerificationStatus = (string)obj; break; default: in1.Errors.Add(string.Format("{0}:{1} - Error element ({0}) not found", modName, fnName, ((In1Elements)i).ToString())); break; } } } catch (Exception ex) { string sErr = string.Format("Exception:{0}:{1} - ({2}) {3}", modName, fnName, ((In1Elements)nIdx).ToString(), ex); in1.Errors.Add(sErr); Console.WriteLine(sErr); } return(in1); }
protected void btnSend_Click(object sender, EventArgs e) { if (string.IsNullOrEmpty(txtWorkOrderFrom.Text.Trim())) { RequiredField.Enabled = true; RequiredField.IsValid = false; RequiredField.Validate(); txtWorkOrderFrom.Focus(); return; } if (string.IsNullOrEmpty(txtWorkOrderTo.Text.Trim())) { RequiredFieldValidator1.Enabled = true; RequiredFieldValidator1.IsValid = false; RequiredFieldValidator1.Validate(); txtWorkOrderTo.Focus(); return; } lblResult.Text = string.Empty; txtWorkOrderFrom.Text = txtWorkOrderFrom.Text.ToUpperInvariant(); txtWorkOrderTo.Text = txtWorkOrderTo.Text.ToUpperInvariant(); if (string.IsNullOrEmpty(txtWorkOrderFrom.Text.Trim())) { return; } if (string.IsNullOrEmpty(txtWorkOrderTo.Text.Trim())) { return; } if (txtWorkOrderFrom.Text.Trim().ToUpperInvariant() == txtWorkOrderTo.Text.Trim().ToUpperInvariant()) { lblResult.Text = mensajes("ordersequals"); lblResult.ForeColor = System.Drawing.Color.Red; return; } string ErrorOrden = "FROM "; obj.fpdn = txtWorkOrderFrom.Text.ToUpperInvariant(); resultado = idal.lineClearance_verificaOrdenes_Param(ref obj, ref strError); if (resultado.Rows.Count < 1) { lblResult.Text = string.Format(mensajes("ordernotexists"), ErrorOrden, obj.fpdn.Trim()); lblResult.ForeColor = System.Drawing.Color.Red; return; } ErrorOrden = "TO "; obj.fpdn = txtWorkOrderTo.Text.ToUpperInvariant(); resultado = idal.lineClearance_verificaOrdenes_Param(ref obj, ref strError); if (resultado.Rows.Count < 1) { lblResult.Text = string.Format(mensajes("ordernotexists"), ErrorOrden, obj.fpdn.Trim()); lblResult.ForeColor = System.Drawing.Color.Red; return; } obj.fpdn = txtWorkOrderFrom.Text.ToUpperInvariant(); resultado = idal.lineClearance_listaRegistrosOrden_Param(ref obj, ref strError); if (resultado.Rows.Count < 1) { lblResult.Text = string.Format(mensajes("ordernotexists"), ErrorOrden, obj.fpdn.Trim()); lblResult.ForeColor = System.Drawing.Color.Red; return; } hidden.Value = txtWorkOrderTo.Text.Trim(); grdRecords.DataSource = resultado; grdRecords.DataBind(); HeaderGrid.Visible = true; btnSave.Visible = true; }