///<summary>Converts a DataTable to a list of objects.</summary>
		public static List<EhrLabResult> TableToList(DataTable table){
			List<EhrLabResult> retVal=new List<EhrLabResult>();
			EhrLabResult ehrLabResult;
			for(int i=0;i<table.Rows.Count;i++) {
				ehrLabResult=new EhrLabResult();
				ehrLabResult.EhrLabResultNum                                            = PIn.Long  (table.Rows[i]["EhrLabResultNum"].ToString());
				ehrLabResult.EhrLabNum                                                  = PIn.Long  (table.Rows[i]["EhrLabNum"].ToString());
				ehrLabResult.SetIdOBX                                                   = PIn.Long  (table.Rows[i]["SetIdOBX"].ToString());
				string valueType=table.Rows[i]["ValueType"].ToString();
				if(valueType==""){
					ehrLabResult.ValueType                                                =(HL70125)0;
				}
				else try{
					ehrLabResult.ValueType                                                =(HL70125)Enum.Parse(typeof(HL70125),valueType);
				}
				catch{
					ehrLabResult.ValueType                                                =(HL70125)0;
				}
				ehrLabResult.ObservationIdentifierID                                    = PIn.String(table.Rows[i]["ObservationIdentifierID"].ToString());
				ehrLabResult.ObservationIdentifierText                                  = PIn.String(table.Rows[i]["ObservationIdentifierText"].ToString());
				ehrLabResult.ObservationIdentifierCodeSystemName                        = PIn.String(table.Rows[i]["ObservationIdentifierCodeSystemName"].ToString());
				ehrLabResult.ObservationIdentifierIDAlt                                 = PIn.String(table.Rows[i]["ObservationIdentifierIDAlt"].ToString());
				ehrLabResult.ObservationIdentifierTextAlt                               = PIn.String(table.Rows[i]["ObservationIdentifierTextAlt"].ToString());
				ehrLabResult.ObservationIdentifierCodeSystemNameAlt                     = PIn.String(table.Rows[i]["ObservationIdentifierCodeSystemNameAlt"].ToString());
				ehrLabResult.ObservationIdentifierTextOriginal                          = PIn.String(table.Rows[i]["ObservationIdentifierTextOriginal"].ToString());
				ehrLabResult.ObservationIdentifierSub                                   = PIn.String(table.Rows[i]["ObservationIdentifierSub"].ToString());
				ehrLabResult.ObservationValueCodedElementID                             = PIn.String(table.Rows[i]["ObservationValueCodedElementID"].ToString());
				ehrLabResult.ObservationValueCodedElementText                           = PIn.String(table.Rows[i]["ObservationValueCodedElementText"].ToString());
				ehrLabResult.ObservationValueCodedElementCodeSystemName                 = PIn.String(table.Rows[i]["ObservationValueCodedElementCodeSystemName"].ToString());
				ehrLabResult.ObservationValueCodedElementIDAlt                          = PIn.String(table.Rows[i]["ObservationValueCodedElementIDAlt"].ToString());
				ehrLabResult.ObservationValueCodedElementTextAlt                        = PIn.String(table.Rows[i]["ObservationValueCodedElementTextAlt"].ToString());
				ehrLabResult.ObservationValueCodedElementCodeSystemNameAlt              = PIn.String(table.Rows[i]["ObservationValueCodedElementCodeSystemNameAlt"].ToString());
				ehrLabResult.ObservationValueCodedElementTextOriginal                   = PIn.String(table.Rows[i]["ObservationValueCodedElementTextOriginal"].ToString());
				ehrLabResult.ObservationValueDateTime                                   = PIn.String(table.Rows[i]["ObservationValueDateTime"].ToString());
				ehrLabResult.ObservationValueTime                                       = PIn.Time(table.Rows[i]["ObservationValueTime"].ToString());
				ehrLabResult.ObservationValueComparator                                 = PIn.String(table.Rows[i]["ObservationValueComparator"].ToString());
				ehrLabResult.ObservationValueNumber1                                    = PIn.Double(table.Rows[i]["ObservationValueNumber1"].ToString());
				ehrLabResult.ObservationValueSeparatorOrSuffix                          = PIn.String(table.Rows[i]["ObservationValueSeparatorOrSuffix"].ToString());
				ehrLabResult.ObservationValueNumber2                                    = PIn.Double(table.Rows[i]["ObservationValueNumber2"].ToString());
				ehrLabResult.ObservationValueNumeric                                    = PIn.Double(table.Rows[i]["ObservationValueNumeric"].ToString());
				ehrLabResult.ObservationValueText                                       = PIn.String(table.Rows[i]["ObservationValueText"].ToString());
				ehrLabResult.UnitsID                                                    = PIn.String(table.Rows[i]["UnitsID"].ToString());
				ehrLabResult.UnitsText                                                  = PIn.String(table.Rows[i]["UnitsText"].ToString());
				ehrLabResult.UnitsCodeSystemName                                        = PIn.String(table.Rows[i]["UnitsCodeSystemName"].ToString());
				ehrLabResult.UnitsIDAlt                                                 = PIn.String(table.Rows[i]["UnitsIDAlt"].ToString());
				ehrLabResult.UnitsTextAlt                                               = PIn.String(table.Rows[i]["UnitsTextAlt"].ToString());
				ehrLabResult.UnitsCodeSystemNameAlt                                     = PIn.String(table.Rows[i]["UnitsCodeSystemNameAlt"].ToString());
				ehrLabResult.UnitsTextOriginal                                          = PIn.String(table.Rows[i]["UnitsTextOriginal"].ToString());
				ehrLabResult.referenceRange                                             = PIn.String(table.Rows[i]["referenceRange"].ToString());
				ehrLabResult.AbnormalFlags                                              = PIn.String(table.Rows[i]["AbnormalFlags"].ToString());
				string observationResultStatus=table.Rows[i]["ObservationResultStatus"].ToString();
				if(observationResultStatus==""){
					ehrLabResult.ObservationResultStatus                                  =(HL70085)0;
				}
				else try{
					ehrLabResult.ObservationResultStatus                                  =(HL70085)Enum.Parse(typeof(HL70085),observationResultStatus);
				}
				catch{
					ehrLabResult.ObservationResultStatus                                  =(HL70085)0;
				}
				ehrLabResult.ObservationDateTime                                        = PIn.String(table.Rows[i]["ObservationDateTime"].ToString());
				ehrLabResult.AnalysisDateTime                                           = PIn.String(table.Rows[i]["AnalysisDateTime"].ToString());
				ehrLabResult.PerformingOrganizationName                                 = PIn.String(table.Rows[i]["PerformingOrganizationName"].ToString());
				ehrLabResult.PerformingOrganizationNameAssigningAuthorityNamespaceId    = PIn.String(table.Rows[i]["PerformingOrganizationNameAssigningAuthorityNamespaceId"].ToString());
				ehrLabResult.PerformingOrganizationNameAssigningAuthorityUniversalId    = PIn.String(table.Rows[i]["PerformingOrganizationNameAssigningAuthorityUniversalId"].ToString());
				ehrLabResult.PerformingOrganizationNameAssigningAuthorityUniversalIdType= PIn.String(table.Rows[i]["PerformingOrganizationNameAssigningAuthorityUniversalIdType"].ToString());
				string performingOrganizationIdentifierTypeCode=table.Rows[i]["PerformingOrganizationIdentifierTypeCode"].ToString();
				if(performingOrganizationIdentifierTypeCode==""){
					ehrLabResult.PerformingOrganizationIdentifierTypeCode                 =(HL70203)0;
				}
				else try{
					ehrLabResult.PerformingOrganizationIdentifierTypeCode                 =(HL70203)Enum.Parse(typeof(HL70203),performingOrganizationIdentifierTypeCode);
				}
				catch{
					ehrLabResult.PerformingOrganizationIdentifierTypeCode                 =(HL70203)0;
				}
				ehrLabResult.PerformingOrganizationIdentifier                           = PIn.String(table.Rows[i]["PerformingOrganizationIdentifier"].ToString());
				ehrLabResult.PerformingOrganizationAddressStreet                        = PIn.String(table.Rows[i]["PerformingOrganizationAddressStreet"].ToString());
				ehrLabResult.PerformingOrganizationAddressOtherDesignation              = PIn.String(table.Rows[i]["PerformingOrganizationAddressOtherDesignation"].ToString());
				ehrLabResult.PerformingOrganizationAddressCity                          = PIn.String(table.Rows[i]["PerformingOrganizationAddressCity"].ToString());
				string performingOrganizationAddressStateOrProvince=table.Rows[i]["PerformingOrganizationAddressStateOrProvince"].ToString();
				if(performingOrganizationAddressStateOrProvince==""){
					ehrLabResult.PerformingOrganizationAddressStateOrProvince             =(USPSAlphaStateCode)0;
				}
				else try{
					ehrLabResult.PerformingOrganizationAddressStateOrProvince             =(USPSAlphaStateCode)Enum.Parse(typeof(USPSAlphaStateCode),performingOrganizationAddressStateOrProvince);
				}
				catch{
					ehrLabResult.PerformingOrganizationAddressStateOrProvince             =(USPSAlphaStateCode)0;
				}
				ehrLabResult.PerformingOrganizationAddressZipOrPostalCode               = PIn.String(table.Rows[i]["PerformingOrganizationAddressZipOrPostalCode"].ToString());
				ehrLabResult.PerformingOrganizationAddressCountryCode                   = PIn.String(table.Rows[i]["PerformingOrganizationAddressCountryCode"].ToString());
				string performingOrganizationAddressAddressType=table.Rows[i]["PerformingOrganizationAddressAddressType"].ToString();
				if(performingOrganizationAddressAddressType==""){
					ehrLabResult.PerformingOrganizationAddressAddressType                 =(HL70190)0;
				}
				else try{
					ehrLabResult.PerformingOrganizationAddressAddressType                 =(HL70190)Enum.Parse(typeof(HL70190),performingOrganizationAddressAddressType);
				}
				catch{
					ehrLabResult.PerformingOrganizationAddressAddressType                 =(HL70190)0;
				}
				ehrLabResult.PerformingOrganizationAddressCountyOrParishCode            = PIn.String(table.Rows[i]["PerformingOrganizationAddressCountyOrParishCode"].ToString());
				ehrLabResult.MedicalDirectorID                                          = PIn.String(table.Rows[i]["MedicalDirectorID"].ToString());
				ehrLabResult.MedicalDirectorLName                                       = PIn.String(table.Rows[i]["MedicalDirectorLName"].ToString());
				ehrLabResult.MedicalDirectorFName                                       = PIn.String(table.Rows[i]["MedicalDirectorFName"].ToString());
				ehrLabResult.MedicalDirectorMiddleNames                                 = PIn.String(table.Rows[i]["MedicalDirectorMiddleNames"].ToString());
				ehrLabResult.MedicalDirectorSuffix                                      = PIn.String(table.Rows[i]["MedicalDirectorSuffix"].ToString());
				ehrLabResult.MedicalDirectorPrefix                                      = PIn.String(table.Rows[i]["MedicalDirectorPrefix"].ToString());
				ehrLabResult.MedicalDirectorAssigningAuthorityNamespaceID               = PIn.String(table.Rows[i]["MedicalDirectorAssigningAuthorityNamespaceID"].ToString());
				ehrLabResult.MedicalDirectorAssigningAuthorityUniversalID               = PIn.String(table.Rows[i]["MedicalDirectorAssigningAuthorityUniversalID"].ToString());
				ehrLabResult.MedicalDirectorAssigningAuthorityIDType                    = PIn.String(table.Rows[i]["MedicalDirectorAssigningAuthorityIDType"].ToString());
				string medicalDirectorNameTypeCode=table.Rows[i]["MedicalDirectorNameTypeCode"].ToString();
				if(medicalDirectorNameTypeCode==""){
					ehrLabResult.MedicalDirectorNameTypeCode                              =(HL70200)0;
				}
				else try{
					ehrLabResult.MedicalDirectorNameTypeCode                              =(HL70200)Enum.Parse(typeof(HL70200),medicalDirectorNameTypeCode);
				}
				catch{
					ehrLabResult.MedicalDirectorNameTypeCode                              =(HL70200)0;
				}
				string medicalDirectorIdentifierTypeCode=table.Rows[i]["MedicalDirectorIdentifierTypeCode"].ToString();
				if(medicalDirectorIdentifierTypeCode==""){
					ehrLabResult.MedicalDirectorIdentifierTypeCode                        =(HL70203)0;
				}
				else try{
					ehrLabResult.MedicalDirectorIdentifierTypeCode                        =(HL70203)Enum.Parse(typeof(HL70203),medicalDirectorIdentifierTypeCode);
				}
				catch{
					ehrLabResult.MedicalDirectorIdentifierTypeCode                        =(HL70203)0;
				}
				retVal.Add(ehrLabResult);
			}
			return retVal;
		}
		///<summary>Inserts one EhrLabResult into the database.  Provides option to use the existing priKey.</summary>
		public static long Insert(EhrLabResult ehrLabResult,bool useExistingPK){
			if(!useExistingPK && PrefC.RandomKeys) {
				ehrLabResult.EhrLabResultNum=ReplicationServers.GetKey("ehrlabresult","EhrLabResultNum");
			}
			string command="INSERT INTO ehrlabresult (";
			if(useExistingPK || PrefC.RandomKeys) {
				command+="EhrLabResultNum,";
			}
			command+="EhrLabNum,SetIdOBX,ValueType,ObservationIdentifierID,ObservationIdentifierText,ObservationIdentifierCodeSystemName,ObservationIdentifierIDAlt,ObservationIdentifierTextAlt,ObservationIdentifierCodeSystemNameAlt,ObservationIdentifierTextOriginal,ObservationIdentifierSub,ObservationValueCodedElementID,ObservationValueCodedElementText,ObservationValueCodedElementCodeSystemName,ObservationValueCodedElementIDAlt,ObservationValueCodedElementTextAlt,ObservationValueCodedElementCodeSystemNameAlt,ObservationValueCodedElementTextOriginal,ObservationValueDateTime,ObservationValueTime,ObservationValueComparator,ObservationValueNumber1,ObservationValueSeparatorOrSuffix,ObservationValueNumber2,ObservationValueNumeric,ObservationValueText,UnitsID,UnitsText,UnitsCodeSystemName,UnitsIDAlt,UnitsTextAlt,UnitsCodeSystemNameAlt,UnitsTextOriginal,referenceRange,AbnormalFlags,ObservationResultStatus,ObservationDateTime,AnalysisDateTime,PerformingOrganizationName,PerformingOrganizationNameAssigningAuthorityNamespaceId,PerformingOrganizationNameAssigningAuthorityUniversalId,PerformingOrganizationNameAssigningAuthorityUniversalIdType,PerformingOrganizationIdentifierTypeCode,PerformingOrganizationIdentifier,PerformingOrganizationAddressStreet,PerformingOrganizationAddressOtherDesignation,PerformingOrganizationAddressCity,PerformingOrganizationAddressStateOrProvince,PerformingOrganizationAddressZipOrPostalCode,PerformingOrganizationAddressCountryCode,PerformingOrganizationAddressAddressType,PerformingOrganizationAddressCountyOrParishCode,MedicalDirectorID,MedicalDirectorLName,MedicalDirectorFName,MedicalDirectorMiddleNames,MedicalDirectorSuffix,MedicalDirectorPrefix,MedicalDirectorAssigningAuthorityNamespaceID,MedicalDirectorAssigningAuthorityUniversalID,MedicalDirectorAssigningAuthorityIDType,MedicalDirectorNameTypeCode,MedicalDirectorIdentifierTypeCode) VALUES(";
			if(useExistingPK || PrefC.RandomKeys) {
				command+=POut.Long(ehrLabResult.EhrLabResultNum)+",";
			}
			command+=
				     POut.Long  (ehrLabResult.EhrLabNum)+","
				+    POut.Long  (ehrLabResult.SetIdOBX)+","
				+"'"+POut.String(ehrLabResult.ValueType.ToString())+"',"
				+"'"+POut.String(ehrLabResult.ObservationIdentifierID)+"',"
				+"'"+POut.String(ehrLabResult.ObservationIdentifierText)+"',"
				+"'"+POut.String(ehrLabResult.ObservationIdentifierCodeSystemName)+"',"
				+"'"+POut.String(ehrLabResult.ObservationIdentifierIDAlt)+"',"
				+"'"+POut.String(ehrLabResult.ObservationIdentifierTextAlt)+"',"
				+"'"+POut.String(ehrLabResult.ObservationIdentifierCodeSystemNameAlt)+"',"
				+"'"+POut.String(ehrLabResult.ObservationIdentifierTextOriginal)+"',"
				+"'"+POut.String(ehrLabResult.ObservationIdentifierSub)+"',"
				+"'"+POut.String(ehrLabResult.ObservationValueCodedElementID)+"',"
				+"'"+POut.String(ehrLabResult.ObservationValueCodedElementText)+"',"
				+"'"+POut.String(ehrLabResult.ObservationValueCodedElementCodeSystemName)+"',"
				+"'"+POut.String(ehrLabResult.ObservationValueCodedElementIDAlt)+"',"
				+"'"+POut.String(ehrLabResult.ObservationValueCodedElementTextAlt)+"',"
				+"'"+POut.String(ehrLabResult.ObservationValueCodedElementCodeSystemNameAlt)+"',"
				+"'"+POut.String(ehrLabResult.ObservationValueCodedElementTextOriginal)+"',"
				+"'"+POut.String(ehrLabResult.ObservationValueDateTime)+"',"
				+    POut.Time  (ehrLabResult.ObservationValueTime)+","
				+"'"+POut.String(ehrLabResult.ObservationValueComparator)+"',"
				+"'"+POut.Double(ehrLabResult.ObservationValueNumber1)+"',"
				+"'"+POut.String(ehrLabResult.ObservationValueSeparatorOrSuffix)+"',"
				+"'"+POut.Double(ehrLabResult.ObservationValueNumber2)+"',"
				+"'"+POut.Double(ehrLabResult.ObservationValueNumeric)+"',"
				+"'"+POut.String(ehrLabResult.ObservationValueText)+"',"
				+"'"+POut.String(ehrLabResult.UnitsID)+"',"
				+"'"+POut.String(ehrLabResult.UnitsText)+"',"
				+"'"+POut.String(ehrLabResult.UnitsCodeSystemName)+"',"
				+"'"+POut.String(ehrLabResult.UnitsIDAlt)+"',"
				+"'"+POut.String(ehrLabResult.UnitsTextAlt)+"',"
				+"'"+POut.String(ehrLabResult.UnitsCodeSystemNameAlt)+"',"
				+"'"+POut.String(ehrLabResult.UnitsTextOriginal)+"',"
				+"'"+POut.String(ehrLabResult.referenceRange)+"',"
				+"'"+POut.String(ehrLabResult.AbnormalFlags)+"',"
				+"'"+POut.String(ehrLabResult.ObservationResultStatus.ToString())+"',"
				+"'"+POut.String(ehrLabResult.ObservationDateTime)+"',"
				+"'"+POut.String(ehrLabResult.AnalysisDateTime)+"',"
				+"'"+POut.String(ehrLabResult.PerformingOrganizationName)+"',"
				+"'"+POut.String(ehrLabResult.PerformingOrganizationNameAssigningAuthorityNamespaceId)+"',"
				+"'"+POut.String(ehrLabResult.PerformingOrganizationNameAssigningAuthorityUniversalId)+"',"
				+"'"+POut.String(ehrLabResult.PerformingOrganizationNameAssigningAuthorityUniversalIdType)+"',"
				+"'"+POut.String(ehrLabResult.PerformingOrganizationIdentifierTypeCode.ToString())+"',"
				+"'"+POut.String(ehrLabResult.PerformingOrganizationIdentifier)+"',"
				+"'"+POut.String(ehrLabResult.PerformingOrganizationAddressStreet)+"',"
				+"'"+POut.String(ehrLabResult.PerformingOrganizationAddressOtherDesignation)+"',"
				+"'"+POut.String(ehrLabResult.PerformingOrganizationAddressCity)+"',"
				+"'"+POut.String(ehrLabResult.PerformingOrganizationAddressStateOrProvince.ToString())+"',"
				+"'"+POut.String(ehrLabResult.PerformingOrganizationAddressZipOrPostalCode)+"',"
				+"'"+POut.String(ehrLabResult.PerformingOrganizationAddressCountryCode)+"',"
				+"'"+POut.String(ehrLabResult.PerformingOrganizationAddressAddressType.ToString())+"',"
				+"'"+POut.String(ehrLabResult.PerformingOrganizationAddressCountyOrParishCode)+"',"
				+"'"+POut.String(ehrLabResult.MedicalDirectorID)+"',"
				+"'"+POut.String(ehrLabResult.MedicalDirectorLName)+"',"
				+"'"+POut.String(ehrLabResult.MedicalDirectorFName)+"',"
				+"'"+POut.String(ehrLabResult.MedicalDirectorMiddleNames)+"',"
				+"'"+POut.String(ehrLabResult.MedicalDirectorSuffix)+"',"
				+"'"+POut.String(ehrLabResult.MedicalDirectorPrefix)+"',"
				+"'"+POut.String(ehrLabResult.MedicalDirectorAssigningAuthorityNamespaceID)+"',"
				+"'"+POut.String(ehrLabResult.MedicalDirectorAssigningAuthorityUniversalID)+"',"
				+"'"+POut.String(ehrLabResult.MedicalDirectorAssigningAuthorityIDType)+"',"
				+"'"+POut.String(ehrLabResult.MedicalDirectorNameTypeCode.ToString())+"',"
				+"'"+POut.String(ehrLabResult.MedicalDirectorIdentifierTypeCode.ToString())+"')";
			if(useExistingPK || PrefC.RandomKeys) {
				Db.NonQ(command);
			}
			else {
				ehrLabResult.EhrLabResultNum=Db.NonQ(command,true);
			}
			return ehrLabResult.EhrLabResultNum;
		}
		///<summary>Updates one EhrLabResult 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.</summary>
		public static void Update(EhrLabResult ehrLabResult,EhrLabResult oldEhrLabResult){
			string command="";
			if(ehrLabResult.EhrLabNum != oldEhrLabResult.EhrLabNum) {
				if(command!=""){ command+=",";}
				command+="EhrLabNum = "+POut.Long(ehrLabResult.EhrLabNum)+"";
			}
			if(ehrLabResult.SetIdOBX != oldEhrLabResult.SetIdOBX) {
				if(command!=""){ command+=",";}
				command+="SetIdOBX = "+POut.Long(ehrLabResult.SetIdOBX)+"";
			}
			if(ehrLabResult.ValueType != oldEhrLabResult.ValueType) {
				if(command!=""){ command+=",";}
				command+="ValueType = '"+POut.String(ehrLabResult.ValueType.ToString())+"'";
			}
			if(ehrLabResult.ObservationIdentifierID != oldEhrLabResult.ObservationIdentifierID) {
				if(command!=""){ command+=",";}
				command+="ObservationIdentifierID = '"+POut.String(ehrLabResult.ObservationIdentifierID)+"'";
			}
			if(ehrLabResult.ObservationIdentifierText != oldEhrLabResult.ObservationIdentifierText) {
				if(command!=""){ command+=",";}
				command+="ObservationIdentifierText = '"+POut.String(ehrLabResult.ObservationIdentifierText)+"'";
			}
			if(ehrLabResult.ObservationIdentifierCodeSystemName != oldEhrLabResult.ObservationIdentifierCodeSystemName) {
				if(command!=""){ command+=",";}
				command+="ObservationIdentifierCodeSystemName = '"+POut.String(ehrLabResult.ObservationIdentifierCodeSystemName)+"'";
			}
			if(ehrLabResult.ObservationIdentifierIDAlt != oldEhrLabResult.ObservationIdentifierIDAlt) {
				if(command!=""){ command+=",";}
				command+="ObservationIdentifierIDAlt = '"+POut.String(ehrLabResult.ObservationIdentifierIDAlt)+"'";
			}
			if(ehrLabResult.ObservationIdentifierTextAlt != oldEhrLabResult.ObservationIdentifierTextAlt) {
				if(command!=""){ command+=",";}
				command+="ObservationIdentifierTextAlt = '"+POut.String(ehrLabResult.ObservationIdentifierTextAlt)+"'";
			}
			if(ehrLabResult.ObservationIdentifierCodeSystemNameAlt != oldEhrLabResult.ObservationIdentifierCodeSystemNameAlt) {
				if(command!=""){ command+=",";}
				command+="ObservationIdentifierCodeSystemNameAlt = '"+POut.String(ehrLabResult.ObservationIdentifierCodeSystemNameAlt)+"'";
			}
			if(ehrLabResult.ObservationIdentifierTextOriginal != oldEhrLabResult.ObservationIdentifierTextOriginal) {
				if(command!=""){ command+=",";}
				command+="ObservationIdentifierTextOriginal = '"+POut.String(ehrLabResult.ObservationIdentifierTextOriginal)+"'";
			}
			if(ehrLabResult.ObservationIdentifierSub != oldEhrLabResult.ObservationIdentifierSub) {
				if(command!=""){ command+=",";}
				command+="ObservationIdentifierSub = '"+POut.String(ehrLabResult.ObservationIdentifierSub)+"'";
			}
			if(ehrLabResult.ObservationValueCodedElementID != oldEhrLabResult.ObservationValueCodedElementID) {
				if(command!=""){ command+=",";}
				command+="ObservationValueCodedElementID = '"+POut.String(ehrLabResult.ObservationValueCodedElementID)+"'";
			}
			if(ehrLabResult.ObservationValueCodedElementText != oldEhrLabResult.ObservationValueCodedElementText) {
				if(command!=""){ command+=",";}
				command+="ObservationValueCodedElementText = '"+POut.String(ehrLabResult.ObservationValueCodedElementText)+"'";
			}
			if(ehrLabResult.ObservationValueCodedElementCodeSystemName != oldEhrLabResult.ObservationValueCodedElementCodeSystemName) {
				if(command!=""){ command+=",";}
				command+="ObservationValueCodedElementCodeSystemName = '"+POut.String(ehrLabResult.ObservationValueCodedElementCodeSystemName)+"'";
			}
			if(ehrLabResult.ObservationValueCodedElementIDAlt != oldEhrLabResult.ObservationValueCodedElementIDAlt) {
				if(command!=""){ command+=",";}
				command+="ObservationValueCodedElementIDAlt = '"+POut.String(ehrLabResult.ObservationValueCodedElementIDAlt)+"'";
			}
			if(ehrLabResult.ObservationValueCodedElementTextAlt != oldEhrLabResult.ObservationValueCodedElementTextAlt) {
				if(command!=""){ command+=",";}
				command+="ObservationValueCodedElementTextAlt = '"+POut.String(ehrLabResult.ObservationValueCodedElementTextAlt)+"'";
			}
			if(ehrLabResult.ObservationValueCodedElementCodeSystemNameAlt != oldEhrLabResult.ObservationValueCodedElementCodeSystemNameAlt) {
				if(command!=""){ command+=",";}
				command+="ObservationValueCodedElementCodeSystemNameAlt = '"+POut.String(ehrLabResult.ObservationValueCodedElementCodeSystemNameAlt)+"'";
			}
			if(ehrLabResult.ObservationValueCodedElementTextOriginal != oldEhrLabResult.ObservationValueCodedElementTextOriginal) {
				if(command!=""){ command+=",";}
				command+="ObservationValueCodedElementTextOriginal = '"+POut.String(ehrLabResult.ObservationValueCodedElementTextOriginal)+"'";
			}
			if(ehrLabResult.ObservationValueDateTime != oldEhrLabResult.ObservationValueDateTime) {
				if(command!=""){ command+=",";}
				command+="ObservationValueDateTime = '"+POut.String(ehrLabResult.ObservationValueDateTime)+"'";
			}
			if(ehrLabResult.ObservationValueTime != oldEhrLabResult.ObservationValueTime) {
				if(command!=""){ command+=",";}
				command+="ObservationValueTime = "+POut.Time  (ehrLabResult.ObservationValueTime)+"";
			}
			if(ehrLabResult.ObservationValueComparator != oldEhrLabResult.ObservationValueComparator) {
				if(command!=""){ command+=",";}
				command+="ObservationValueComparator = '"+POut.String(ehrLabResult.ObservationValueComparator)+"'";
			}
			if(ehrLabResult.ObservationValueNumber1 != oldEhrLabResult.ObservationValueNumber1) {
				if(command!=""){ command+=",";}
				command+="ObservationValueNumber1 = '"+POut.Double(ehrLabResult.ObservationValueNumber1)+"'";
			}
			if(ehrLabResult.ObservationValueSeparatorOrSuffix != oldEhrLabResult.ObservationValueSeparatorOrSuffix) {
				if(command!=""){ command+=",";}
				command+="ObservationValueSeparatorOrSuffix = '"+POut.String(ehrLabResult.ObservationValueSeparatorOrSuffix)+"'";
			}
			if(ehrLabResult.ObservationValueNumber2 != oldEhrLabResult.ObservationValueNumber2) {
				if(command!=""){ command+=",";}
				command+="ObservationValueNumber2 = '"+POut.Double(ehrLabResult.ObservationValueNumber2)+"'";
			}
			if(ehrLabResult.ObservationValueNumeric != oldEhrLabResult.ObservationValueNumeric) {
				if(command!=""){ command+=",";}
				command+="ObservationValueNumeric = '"+POut.Double(ehrLabResult.ObservationValueNumeric)+"'";
			}
			if(ehrLabResult.ObservationValueText != oldEhrLabResult.ObservationValueText) {
				if(command!=""){ command+=",";}
				command+="ObservationValueText = '"+POut.String(ehrLabResult.ObservationValueText)+"'";
			}
			if(ehrLabResult.UnitsID != oldEhrLabResult.UnitsID) {
				if(command!=""){ command+=",";}
				command+="UnitsID = '"+POut.String(ehrLabResult.UnitsID)+"'";
			}
			if(ehrLabResult.UnitsText != oldEhrLabResult.UnitsText) {
				if(command!=""){ command+=",";}
				command+="UnitsText = '"+POut.String(ehrLabResult.UnitsText)+"'";
			}
			if(ehrLabResult.UnitsCodeSystemName != oldEhrLabResult.UnitsCodeSystemName) {
				if(command!=""){ command+=",";}
				command+="UnitsCodeSystemName = '"+POut.String(ehrLabResult.UnitsCodeSystemName)+"'";
			}
			if(ehrLabResult.UnitsIDAlt != oldEhrLabResult.UnitsIDAlt) {
				if(command!=""){ command+=",";}
				command+="UnitsIDAlt = '"+POut.String(ehrLabResult.UnitsIDAlt)+"'";
			}
			if(ehrLabResult.UnitsTextAlt != oldEhrLabResult.UnitsTextAlt) {
				if(command!=""){ command+=",";}
				command+="UnitsTextAlt = '"+POut.String(ehrLabResult.UnitsTextAlt)+"'";
			}
			if(ehrLabResult.UnitsCodeSystemNameAlt != oldEhrLabResult.UnitsCodeSystemNameAlt) {
				if(command!=""){ command+=",";}
				command+="UnitsCodeSystemNameAlt = '"+POut.String(ehrLabResult.UnitsCodeSystemNameAlt)+"'";
			}
			if(ehrLabResult.UnitsTextOriginal != oldEhrLabResult.UnitsTextOriginal) {
				if(command!=""){ command+=",";}
				command+="UnitsTextOriginal = '"+POut.String(ehrLabResult.UnitsTextOriginal)+"'";
			}
			if(ehrLabResult.referenceRange != oldEhrLabResult.referenceRange) {
				if(command!=""){ command+=",";}
				command+="referenceRange = '"+POut.String(ehrLabResult.referenceRange)+"'";
			}
			if(ehrLabResult.AbnormalFlags != oldEhrLabResult.AbnormalFlags) {
				if(command!=""){ command+=",";}
				command+="AbnormalFlags = '"+POut.String(ehrLabResult.AbnormalFlags)+"'";
			}
			if(ehrLabResult.ObservationResultStatus != oldEhrLabResult.ObservationResultStatus) {
				if(command!=""){ command+=",";}
				command+="ObservationResultStatus = '"+POut.String(ehrLabResult.ObservationResultStatus.ToString())+"'";
			}
			if(ehrLabResult.ObservationDateTime != oldEhrLabResult.ObservationDateTime) {
				if(command!=""){ command+=",";}
				command+="ObservationDateTime = '"+POut.String(ehrLabResult.ObservationDateTime)+"'";
			}
			if(ehrLabResult.AnalysisDateTime != oldEhrLabResult.AnalysisDateTime) {
				if(command!=""){ command+=",";}
				command+="AnalysisDateTime = '"+POut.String(ehrLabResult.AnalysisDateTime)+"'";
			}
			if(ehrLabResult.PerformingOrganizationName != oldEhrLabResult.PerformingOrganizationName) {
				if(command!=""){ command+=",";}
				command+="PerformingOrganizationName = '"+POut.String(ehrLabResult.PerformingOrganizationName)+"'";
			}
			if(ehrLabResult.PerformingOrganizationNameAssigningAuthorityNamespaceId != oldEhrLabResult.PerformingOrganizationNameAssigningAuthorityNamespaceId) {
				if(command!=""){ command+=",";}
				command+="PerformingOrganizationNameAssigningAuthorityNamespaceId = '"+POut.String(ehrLabResult.PerformingOrganizationNameAssigningAuthorityNamespaceId)+"'";
			}
			if(ehrLabResult.PerformingOrganizationNameAssigningAuthorityUniversalId != oldEhrLabResult.PerformingOrganizationNameAssigningAuthorityUniversalId) {
				if(command!=""){ command+=",";}
				command+="PerformingOrganizationNameAssigningAuthorityUniversalId = '"+POut.String(ehrLabResult.PerformingOrganizationNameAssigningAuthorityUniversalId)+"'";
			}
			if(ehrLabResult.PerformingOrganizationNameAssigningAuthorityUniversalIdType != oldEhrLabResult.PerformingOrganizationNameAssigningAuthorityUniversalIdType) {
				if(command!=""){ command+=",";}
				command+="PerformingOrganizationNameAssigningAuthorityUniversalIdType = '"+POut.String(ehrLabResult.PerformingOrganizationNameAssigningAuthorityUniversalIdType)+"'";
			}
			if(ehrLabResult.PerformingOrganizationIdentifierTypeCode != oldEhrLabResult.PerformingOrganizationIdentifierTypeCode) {
				if(command!=""){ command+=",";}
				command+="PerformingOrganizationIdentifierTypeCode = '"+POut.String(ehrLabResult.PerformingOrganizationIdentifierTypeCode.ToString())+"'";
			}
			if(ehrLabResult.PerformingOrganizationIdentifier != oldEhrLabResult.PerformingOrganizationIdentifier) {
				if(command!=""){ command+=",";}
				command+="PerformingOrganizationIdentifier = '"+POut.String(ehrLabResult.PerformingOrganizationIdentifier)+"'";
			}
			if(ehrLabResult.PerformingOrganizationAddressStreet != oldEhrLabResult.PerformingOrganizationAddressStreet) {
				if(command!=""){ command+=",";}
				command+="PerformingOrganizationAddressStreet = '"+POut.String(ehrLabResult.PerformingOrganizationAddressStreet)+"'";
			}
			if(ehrLabResult.PerformingOrganizationAddressOtherDesignation != oldEhrLabResult.PerformingOrganizationAddressOtherDesignation) {
				if(command!=""){ command+=",";}
				command+="PerformingOrganizationAddressOtherDesignation = '"+POut.String(ehrLabResult.PerformingOrganizationAddressOtherDesignation)+"'";
			}
			if(ehrLabResult.PerformingOrganizationAddressCity != oldEhrLabResult.PerformingOrganizationAddressCity) {
				if(command!=""){ command+=",";}
				command+="PerformingOrganizationAddressCity = '"+POut.String(ehrLabResult.PerformingOrganizationAddressCity)+"'";
			}
			if(ehrLabResult.PerformingOrganizationAddressStateOrProvince != oldEhrLabResult.PerformingOrganizationAddressStateOrProvince) {
				if(command!=""){ command+=",";}
				command+="PerformingOrganizationAddressStateOrProvince = '"+POut.String(ehrLabResult.PerformingOrganizationAddressStateOrProvince.ToString())+"'";
			}
			if(ehrLabResult.PerformingOrganizationAddressZipOrPostalCode != oldEhrLabResult.PerformingOrganizationAddressZipOrPostalCode) {
				if(command!=""){ command+=",";}
				command+="PerformingOrganizationAddressZipOrPostalCode = '"+POut.String(ehrLabResult.PerformingOrganizationAddressZipOrPostalCode)+"'";
			}
			if(ehrLabResult.PerformingOrganizationAddressCountryCode != oldEhrLabResult.PerformingOrganizationAddressCountryCode) {
				if(command!=""){ command+=",";}
				command+="PerformingOrganizationAddressCountryCode = '"+POut.String(ehrLabResult.PerformingOrganizationAddressCountryCode)+"'";
			}
			if(ehrLabResult.PerformingOrganizationAddressAddressType != oldEhrLabResult.PerformingOrganizationAddressAddressType) {
				if(command!=""){ command+=",";}
				command+="PerformingOrganizationAddressAddressType = '"+POut.String(ehrLabResult.PerformingOrganizationAddressAddressType.ToString())+"'";
			}
			if(ehrLabResult.PerformingOrganizationAddressCountyOrParishCode != oldEhrLabResult.PerformingOrganizationAddressCountyOrParishCode) {
				if(command!=""){ command+=",";}
				command+="PerformingOrganizationAddressCountyOrParishCode = '"+POut.String(ehrLabResult.PerformingOrganizationAddressCountyOrParishCode)+"'";
			}
			if(ehrLabResult.MedicalDirectorID != oldEhrLabResult.MedicalDirectorID) {
				if(command!=""){ command+=",";}
				command+="MedicalDirectorID = '"+POut.String(ehrLabResult.MedicalDirectorID)+"'";
			}
			if(ehrLabResult.MedicalDirectorLName != oldEhrLabResult.MedicalDirectorLName) {
				if(command!=""){ command+=",";}
				command+="MedicalDirectorLName = '"+POut.String(ehrLabResult.MedicalDirectorLName)+"'";
			}
			if(ehrLabResult.MedicalDirectorFName != oldEhrLabResult.MedicalDirectorFName) {
				if(command!=""){ command+=",";}
				command+="MedicalDirectorFName = '"+POut.String(ehrLabResult.MedicalDirectorFName)+"'";
			}
			if(ehrLabResult.MedicalDirectorMiddleNames != oldEhrLabResult.MedicalDirectorMiddleNames) {
				if(command!=""){ command+=",";}
				command+="MedicalDirectorMiddleNames = '"+POut.String(ehrLabResult.MedicalDirectorMiddleNames)+"'";
			}
			if(ehrLabResult.MedicalDirectorSuffix != oldEhrLabResult.MedicalDirectorSuffix) {
				if(command!=""){ command+=",";}
				command+="MedicalDirectorSuffix = '"+POut.String(ehrLabResult.MedicalDirectorSuffix)+"'";
			}
			if(ehrLabResult.MedicalDirectorPrefix != oldEhrLabResult.MedicalDirectorPrefix) {
				if(command!=""){ command+=",";}
				command+="MedicalDirectorPrefix = '"+POut.String(ehrLabResult.MedicalDirectorPrefix)+"'";
			}
			if(ehrLabResult.MedicalDirectorAssigningAuthorityNamespaceID != oldEhrLabResult.MedicalDirectorAssigningAuthorityNamespaceID) {
				if(command!=""){ command+=",";}
				command+="MedicalDirectorAssigningAuthorityNamespaceID = '"+POut.String(ehrLabResult.MedicalDirectorAssigningAuthorityNamespaceID)+"'";
			}
			if(ehrLabResult.MedicalDirectorAssigningAuthorityUniversalID != oldEhrLabResult.MedicalDirectorAssigningAuthorityUniversalID) {
				if(command!=""){ command+=",";}
				command+="MedicalDirectorAssigningAuthorityUniversalID = '"+POut.String(ehrLabResult.MedicalDirectorAssigningAuthorityUniversalID)+"'";
			}
			if(ehrLabResult.MedicalDirectorAssigningAuthorityIDType != oldEhrLabResult.MedicalDirectorAssigningAuthorityIDType) {
				if(command!=""){ command+=",";}
				command+="MedicalDirectorAssigningAuthorityIDType = '"+POut.String(ehrLabResult.MedicalDirectorAssigningAuthorityIDType)+"'";
			}
			if(ehrLabResult.MedicalDirectorNameTypeCode != oldEhrLabResult.MedicalDirectorNameTypeCode) {
				if(command!=""){ command+=",";}
				command+="MedicalDirectorNameTypeCode = '"+POut.String(ehrLabResult.MedicalDirectorNameTypeCode.ToString())+"'";
			}
			if(ehrLabResult.MedicalDirectorIdentifierTypeCode != oldEhrLabResult.MedicalDirectorIdentifierTypeCode) {
				if(command!=""){ command+=",";}
				command+="MedicalDirectorIdentifierTypeCode = '"+POut.String(ehrLabResult.MedicalDirectorIdentifierTypeCode.ToString())+"'";
			}
			if(command==""){
				return;
			}
			command="UPDATE ehrlabresult SET "+command
				+" WHERE EhrLabResultNum = "+POut.Long(ehrLabResult.EhrLabResultNum);
			Db.NonQ(command);
		}
		///<summary>Inserts one EhrLabResult into the database.  Returns the new priKey.</summary>
		public static long Insert(EhrLabResult ehrLabResult){
			if(DataConnection.DBtype==DatabaseType.Oracle) {
				ehrLabResult.EhrLabResultNum=DbHelper.GetNextOracleKey("ehrlabresult","EhrLabResultNum");
				int loopcount=0;
				while(loopcount<100){
					try {
						return Insert(ehrLabResult,true);
					}
					catch(Oracle.DataAccess.Client.OracleException ex){
						if(ex.Number==1 && ex.Message.ToLower().Contains("unique constraint") && ex.Message.ToLower().Contains("violated")){
							ehrLabResult.EhrLabResultNum++;
							loopcount++;
						}
						else{
							throw ex;
						}
					}
				}
				throw new ApplicationException("Insert failed.  Could not generate primary key.");
			}
			else {
				return Insert(ehrLabResult,false);
			}
		}