//OHAPP EXECUTE PROCEDURE sp_CreateIndex90( 'OHAPP', 'OHAPP.adi', 'IDXREASONPROVIDER', 'Reason Code;Provider', '', 2, 512, '' ); EXECUTE PROCEDURE sp_CreateIndex90( 'OHAPP', 'OHAPP.adi', 'IDXPROVIDERREASON', 'Provider;Reason Code', '', 2, 512, '' ); EXECUTE PROCEDURE sp_CreateIndex90( 'OHAPP', 'OHAPP.adi', 'IDXCHART', 'Upper(Chart Number)', '', 2, 512, '' ); EXECUTE PROCEDURE sp_ModifyTableProperty( 'OHAPP', 'Table_Auto_Create', 'False', 'APPEND_FAIL', 'OHAPPfail'); EXECUTE PROCEDURE sp_ModifyTableProperty( 'OHAPP', 'Table_Permission_Level', '2', 'APPEND_FAIL', 'OHAPPfail'); EXECUTE PROCEDURE sp_ModifyTableProperty( 'OHAPP', 'Triggers_Disabled', 'False', 'APPEND_FAIL', 'OHAPPfail'); EXECUTE PROCEDURE sp_ModifyTableProperty( 'OHAPP', 'Table_Trans_Free', 'False', 'APPEND_FAIL', 'OHAPPfail'); EXECUTE PROCEDURE sp_ModifyFieldProperty ( 'OHAPP', 'RepeatID', 'Field_Default_Value', '0', 'APPEND_FAIL', 'OHAPPfail' ); CREATE TRIGGER OHAPP_DELETEHL7TRIGGER ON OHAPP AFTER DELETE BEGIN DECLARE sGUID CHAR(32); DECLARE iTableType INTEGER; DECLARE InputCursor CURSOR AS SELECT * FROM __old; OPEN InputCursor; FETCH InputCursor; sGUID = (SELECT UPPER(NEWIDSTRING("Numbers")) AS GUID FROM SYSTEM.IOTA); // eHL7MessageType = (SIU, ADT, DFT); //0, 1, 2 // eHL7EventType = (A04, //New Patient - 0 // A08, //Patient Update - 1 // S12, //New Appointment - 2 // S13, //Appointment Reschedule - 3 // S14, //Appointment Modification - 4 // S15, //Appointment Cancellation - 5 // S17, //Appointment Deletion - 6 // P03); //Transaction (inbound only) 7 // Patient: 0 // Appointment: 1 // RepeatingAppointment: 2 IF InputCursor.[RepeatId] IS NOT NULL AND InputCursor.[RepeatId] > 0 THEN iTableType = 2; //RepeatingAppointment ELSE iTableType = 1; //Appointment ENDIF; IF InputCursor.[Is Break] = False THEN EXECUTE PROCEDURE sp_InsertHL7Trigger(sGUID, //ID 0, //HL7MSGTYPE - SIU 6, //EVENTTYPE - S17 - Delete Appt CURRENT_TIMESTAMP(), //CREATEDT InputCursor.[Chart Number], //CHARID InputCursor.[ID], //INTID InputCursor.[Case Number], //CASEID InputCursor.[Provider], //PROVIDER InputCursor.[Date], //DATE CONVERT(InputCursor.[Start Time], SQL_TIME), //START TIME 1, //TABLETYPE (Always 1 for HL7Trigger) 0, //STATUS 14 ); //CREATEDBY ENDIF; CLOSE InputCursor; END PRIORITY 1; CREATE TRIGGER OHAPP_INSERTHL7TRIGGER ON OHAPP AFTER INSERT BEGIN DECLARE sGUID CHAR(32); DECLARE iTableType INTEGER; DECLARE InputCursor CURSOR AS SELECT * FROM __new; OPEN InputCursor; FETCH InputCursor; sGUID = (SELECT UPPER(NEWIDSTRING("Numbers")) AS GUID FROM SYSTEM.IOTA); // eHL7MessageType = (SIU, ADT, DFT); //0, 1, 2 // eHL7EventType = (A04, //New Patient - 0 // A08, //Patient Update - 1 // S12, //New Appointment - 2 // S13, //Appointment Reschedule - 3 // S14, //Appointment Modification - 4 // S15, //Appointment Cancellation - 5 // S17, //Appointment Deletion - 6 // P03); //Transaction (inbound only) 7 // Patient: 0 // Appointment: 1 // RepeatingAppointment: 2 IF InputCursor.[RepeatId] IS NOT NULL AND InputCursor.[RepeatId] > 0 THEN iTableType = 2; //RepeatingAppointment ELSE iTableType = 1; //Appointment ENDIF; IF InputCursor.[Is Break] = False THEN EXECUTE PROCEDURE sp_InsertHL7Trigger(sGUID, //ID 0, //HL7MSGTYPE - SIU 2, //EVENTTYPE - S12 - New Appt CURRENT_TIMESTAMP(), //CREATEDT InputCursor.[Chart Number], //CHARID InputCursor.[ID], //INTID InputCursor.[Case Number], //CASEID InputCursor.[Provider], //PROVIDER InputCursor.[Date], //DATE CONVERT(InputCursor.[Start Time], SQL_TIME), //START TIME 1, //TABLETYPE (Always 1 for HL7Trigger) 0, //STATUS 14 ); //CREATEDBY ENDIF; CLOSE InputCursor; END PRIORITY 1; CREATE TRIGGER OHAPPUPDATE_AUD ON OHAPP BEFORE UPDATE BEGIN Declare NC Cursor as Select * from __New; Declare OC Cursor as Select * from __Old; Declare nString String; Declare @UName String; Declare iIdx Integer; Open NC; Fetch NC; Open OC; Fetch OC; Set nString = (Select User() from System.iota); iIdx = POSITION('mwmw' IN nString); IF (iIdx > 1) THEN nString = SUBSTRING(nString, 1, iIdx-1); ENDIF; Set @UName = nString; --(Select User() from System.iota); Set nString = ''; if (OC.[Chart Number] <> '') then Set nString = nString + 'Chart Number: "' + Trim(OC.[Chart Number]) + '" '; else Set nString = nString + 'Name: "' + Trim(OC.[Name]) + '" '; endif; Set nString = nString + 'ID: "' + Trim(Convert(OC.[ID], SQL_Char)) + '" '; Set nString = nString + 'Date: "' + Trim(Convert(OC.[Date], SQL_Char)) + '" '; Set nString = nString + 'Start Time: "' + Trim(Convert(OC.[Start Time], SQL_Char)) + '" '; Set nString = nString + 'Provider: "' + Trim(OC.[Provider]) + '"'; if (OC.[Date] <> NC.[Date]) then Set nString = nString + char(9) + 'Date: "' + Trim(Convert(OC.[Date], SQL_Char)) + '" changed to "' + Trim(Convert(NC.[Date], SQL_Char)) + '"'; endif; if (OC.[Start Time] <> NC.[Start Time]) then Set nString = nString + char(9) + 'Start Time: "' + Trim(Convert(OC.[Start Time], SQL_Char)) + '" changed to "' + Trim(Convert(NC.[Start Time], SQL_Char)) + '"'; endif; if (OC.[Length] <> NC.[Length]) then Set nString = nString + char(9) + 'Length: "' + Trim(Convert(OC.[Length], SQL_Char)) + '" changed to "' + Trim(Convert(NC.[Length], SQL_Char)) + '"'; endif; if (OC.[Provider] <> NC.[Provider]) then Set nString = nString + char(9) + 'Provider: "' + Trim(OC.[Provider]) + '" changed to "' + Trim(NC.[Provider]) + '"'; endif; if (OC.[Chart Number] <> NC.[Chart Number]) then Set nString = nString + char(9) + 'Chart Number: "' + Trim(OC.[Chart Number]) + '" changed to "' + Trim(NC.[Chart Number]) + '"'; endif; if (OC.[Name] <> NC.[Name]) then Set nString = nString + char(9) + 'Name: "' + Trim(OC.[Name]) + '" changed to "' + Trim(NC.[Name]) + '"'; endif; if (OC.[Phone] <> NC.[Phone]) then Set nString = nString + char(9) + 'Phone: "' + Trim(OC.[Phone]) + '" changed to "' + Trim(NC.[Phone]) + '"'; endif; if (OC.[Resource] <> NC.[Resource]) then Set nString = nString + char(9) + 'Resource: "' + Trim(OC.[Resource]) + '" changed to "' + Trim(NC.[Resource]) + '"'; endif; if (OC.[Procedure Code] <> NC.[Procedure Code]) then Set nString = nString + char(9) + 'Procedure Code: "' + Trim(OC.[Procedure Code]) + '" changed to "' + Trim(NC.[Procedure Code]) + '"'; endif; if (OC.[Color] <> NC.[Color]) then Set nString = nString + char(9) + 'Color: "' + Trim(OC.[Color]) + '" changed to "' + Trim(NC.[Color]) + '"'; endif; if (OC.[Is Break] <> NC.[Is Break]) then if (OC.[Is Break] = True) then Set nString = nString + char(9) + 'Is Break: "True" changed to "False"'; else Set nString = nString + char(9) + 'Is Break: "False" changed to "True"'; endif; endif; if (OC.[All Columns] <> NC.[All Columns]) then if (OC.[All Columns] = True) then Set nString = nString + char(9) + 'All Columns: "True" changed to "False"'; else Set nString = nString + char(9) + 'All Columns: "False" changed to "True"'; endif; endif; if (OC.[Check In] <> NC.[Check In]) then if (OC.[Check In] = True) then Set nString = nString + char(9) + 'Check In: "True" changed to "False"'; else Set nString = nString + char(9) + 'Check In: "False" changed to "True"'; endif; endif; if (OC.[Case Number] <> NC.[Case Number]) then Set nString = nString + char(9) + 'Case Number: "' + Trim(Convert(OC.[Case Number], SQL_Char)) + '" changed to "' + Trim(Convert(NC.[Case Number], SQL_Char)) + '"'; endif; if (OC.[User Code] <> NC.[User Code]) then Set nString = nString + char(9) + 'User Code: "' + Trim(OC.[User Code]) + '" changed to "' + Trim(NC.[User Code]) + '"'; endif; if (OC.[Status] <> NC.[Status]) then Set nString = nString + char(9) + 'Status: "' + Trim(OC.[Status]) + '" changed to "' + Trim(NC.[Status]) + '"'; endif; if (OC.[Reason Code] <> NC.[Reason Code]) then Set nString = nString + char(9) + 'Reason Code: "' + Trim(OC.[Reason Code]) + '" changed to "' + Trim(NC.[Reason Code]) + '"'; endif; if (OC.[Check In Time] <> NC.[Check In Time]) then Set nString = nString + char(9) + 'Check In Time: "' + Trim(Convert(OC.[Check In Time], SQL_Char)) + '" changed to "' + Trim(Convert(NC.[Check In Time], SQL_Char)) + '"'; endif; if (OC.[Seen Time] <> NC.[Seen Time]) then Set nString = nString + char(9) + 'Seen Time: "' + Trim(Convert(OC.[Seen Time], SQL_Char)) + '" changed to "' + Trim(Convert(NC.[Seen Time], SQL_Char)) + '"'; endif; if (OC.[Check Out Time] <> NC.[Check Out Time]) then Set nString = nString + char(9) + 'Check Out Time: "' + Trim(Convert(OC.[Check Out Time], SQL_Char)) + '" changed to "' + Trim(Convert(NC.[Check Out Time], SQL_Char)) + '"'; endif; if (OC.[Need Referral] <> NC.[Need Referral]) then if (OC.[Need Referral] = True) then Set nString = nString + char(9) + 'Need Referral: "True" changed to "False"'; else Set nString = nString + char(9) + 'Need Referral: "False" changed to "True"'; endif; endif; if (OC.[Eligibility Verification Status] <> NC.[Eligibility Verification Status]) then Set nString = nString + char(9) + 'Eligibility Verification Status: "' + Trim(Convert(OC.[Eligibility Verification Status], SQL_Char)) + '" changed to "' + Trim(Convert(NC.[Eligibility Verification Status], SQL_Char)) + '"'; endif; if (OC.[ModifiedUser] <> NC.[ModifiedUser]) then Set nString = nString + char(9) + 'ModifiedUser: "' + Trim(OC.[ModifiedUser]) + '" changed to "' + Trim(NC.[ModifiedUser]) + '"'; endif; if (OC.[Cell Phone] <> NC.[Cell Phone]) then Set nString = nString + char(9) + 'Cell Phone: "' + Trim(OC.[Cell Phone]) + '" changed to "' + Trim(NC.[Cell Phone]) + '"'; endif; Insert into MWAudM([Table], [User], [Action], NDCApplication, [Chart Number], [Date Modified], Details) Values('Appointment', @UName, 'UPDATE', 0, Trim(OC.[Chart Number]), Now(), nString); END PRIORITY 1; CREATE TRIGGER OHAPPDELETE_AUD ON OHAPP BEFORE DELETE BEGIN Declare nString String; Declare OC Cursor as Select * from __Old; Declare @UName String; Declare iIdx Integer; Open OC; Fetch OC; Set nString = (Select User() from System.iota); iIdx = POSITION('mwmw' IN nString); IF (iIdx > 1) THEN nString = SUBSTRING(nString, 1, iIdx-1); ENDIF; Set @UName = nString; --(Select User() from System.iota); Set nString = ''; if (OC.[Chart Number] <> '') then Set nString = nString + 'Chart Number: "' + Trim(OC.[Chart Number]) + '" '; else Set nString = nString + 'Name: "' + Trim(OC.[Name]) + '" '; endif; Set nString = nString + 'ID: "' + Trim(Convert(OC.[ID], SQL_Char)) + '" '; Set nString = nString + 'Date: "' + Trim(Convert(OC.[Date], SQL_Char)) + '" '; Set nString = nString + 'Start Time: "' + Trim(Convert(OC.[Start Time], SQL_Char)) + '" '; Set nString = nString + 'Provider: "' + Trim(OC.[Provider]) + '"'; Insert into MWAudM([Table], [User], [Action], NDCApplication, [Chart Number], [Date Modified], Details) Values('Appointment', @UName, 'DELETE', 0, Trim(OC.[Chart Number]), Now(), nString); END PRIORITY 1; //end of ohapp //MWPAT CREATE TRIGGER MWPATUPDATE_AUD ON MWPAT BEFORE UPDATE BEGIN Declare NC Cursor as Select * from __New; Declare OC Cursor as Select * from __Old; Declare nString String; Declare @UName String; Declare iIdx Integer; Open NC; Fetch NC; Open OC; Fetch OC; Set nString = (Select User() from System.iota); iIdx = POSITION('mwmw' IN nString); IF (iIdx > 1) THEN nString = SUBSTRING(nString, 1, iIdx-1); ENDIF; Set @UName = nString; --(Select User() from System.iota); Set nString = ''; Set nString = nString + 'Chart Number: "' + Trim(OC.[Chart Number]) + '" '; Set nString = nString + 'Name: "' + Trim(OC.[Last Name]) + ', ' + Trim(OC.[First Name]) + ' ' + Trim(OC.[Middle Initial]) + '" '; Set nString = nString + 'Birthdate: "' + Trim(Convert(OC.[Date of Birth], SQL_Char)) + '"'; if (OC.[Chart Number] <> NC.[Chart Number]) then Set nString = nString + char(9) + 'Chart Number: "' + Trim(OC.[Chart Number]) + '" changed to "' + Trim(NC.[Chart Number]) + '"'; endif; if (OC.[Last Name] <> NC.[Last Name]) then Set nString = nString + char(9) + 'Last Name: "' + Trim(OC.[Last Name]) + '" changed to "' + Trim(NC.[Last Name]) + '"'; endif; if (OC.[First Name] <> NC.[First Name]) then Set nString = nString + char(9) + 'First Name: "' + Trim(OC.[First Name]) + '" changed to "' + Trim(NC.[First Name]) + '"'; endif; if (OC.[Middle Initial] <> NC.[Middle Initial]) then Set nString = nString + char(9) + 'Middle Initial: "' + Trim(OC.[Middle Initial]) + '" changed to "' + Trim(NC.[Middle Initial]) + '"'; endif; if (OC.[Street 1] <> NC.[Street 1]) then Set nString = nString + char(9) + 'Street 1: "' + Trim(OC.[Street 1]) + '" changed to "' + Trim(NC.[Street 1]) + '"'; endif; if (OC.[Street 2] <> NC.[Street 2]) then Set nString = nString + char(9) + 'Street 2: "' + Trim(OC.[Street 2]) + '" changed to "' + Trim(NC.[Street 2]) + '"'; endif; if (OC.[City] <> NC.[City]) then Set nString = nString + char(9) + 'City: "' + Trim(OC.[City]) + '" changed to "' + Trim(NC.[City]) + '"'; endif; if (OC.[State] <> NC.[State]) then Set nString = nString + char(9) + 'State: "' + Trim(OC.[State]) + '" changed to "' + Trim(NC.[State]) + '"'; endif; if (OC.[Zip Code] <> NC.[Zip Code]) then Set nString = nString + char(9) + 'Zip Code: "' + Trim(OC.[Zip Code]) + '" changed to "' + Trim(NC.[Zip Code]) + '"'; endif; if (OC.[Phone 1] <> NC.[Phone 1]) then Set nString = nString + char(9) + 'Phone 1: "' + Trim(OC.[Phone 1]) + '" changed to "' + Trim(NC.[Phone 1]) + '"'; endif; if (OC.[Phone 2] <> NC.[Phone 2]) then Set nString = nString + char(9) + 'Phone 2: "' + Trim(OC.[Phone 2]) + '" changed to "' + Trim(NC.[Phone 2]) + '"'; endif; if (OC.[Phone 3] <> NC.[Phone 3]) then Set nString = nString + char(9) + 'Phone 3: "' + Trim(OC.[Phone 3]) + '" changed to "' + Trim(NC.[Phone 3]) + '"'; endif; if (OC.[Phone 4] <> NC.[Phone 4]) then Set nString = nString + char(9) + 'Phone 4: "' + Trim(OC.[Phone 4]) + '" changed to "' + Trim(NC.[Phone 4]) + '"'; endif; if (OC.[Phone 5] <> NC.[Phone 5]) then Set nString = nString + char(9) + 'Phone 5: "' + Trim(OC.[Phone 5]) + '" changed to "' + Trim(NC.[Phone 5]) + '"'; endif; if (OC.[Social Security Number] <> NC.[Social Security Number]) then Set nString = nString + char(9) + 'Social Security Number: "' + Trim(OC.[Social Security Number]) + '" changed to "' + Trim(NC.[Social Security Number]) + '"'; endif; if (OC.[Signature on File] <> NC.[Signature on File]) then if (OC.[Signature on File] = True) then Set nString = nString + char(9) + 'Signature on File: "True" changed to "False"'; else Set nString = nString + char(9) + 'Signature on File: "False" changed to "True"'; endif; endif; if (OC.[Patient Type] <> NC.[Patient Type]) then Set nString = nString + char(9) + 'Patient Type: "' + Trim(OC.[Patient Type]) + '" changed to "' + Trim(NC.[Patient Type]) + '"'; endif; if (OC.[Patient ID #2] <> NC.[Patient ID #2]) then Set nString = nString + char(9) + 'Patient ID #2: "' + Trim(OC.[Patient ID #2]) + '" changed to "' + Trim(NC.[Patient ID #2]) + '"'; endif; if (OC.[Sex] <> NC.[Sex]) then Set nString = nString + char(9) + 'Sex: "' + Trim(OC.[Sex]) + '" changed to "' + Trim(NC.[Sex]) + '"'; endif; if (OC.[Date of Birth] <> NC.[Date of Birth]) then Set nString = nString + char(9) + 'Date of Birth: "' + Trim(Convert(OC.[Date of Birth], SQL_Char)) + '" changed to "' + Trim(Convert(NC.[Date of Birth], SQL_Char)) + '"'; endif; if (OC.[Assigned Provider] <> NC.[Assigned Provider]) then Set nString = nString + char(9) + 'Assigned Provider: "' + Trim(OC.[Assigned Provider]) + '" changed to "' + Trim(NC.[Assigned Provider]) + '"'; endif; if (OC.[Country] <> NC.[Country]) then Set nString = nString + char(9) + 'Country: "' + Trim(OC.[Country]) + '" changed to "' + Trim(NC.[Country]) + '"'; endif; if (OC.[Date of Last Payment] <> NC.[Date of Last Payment]) then Set nString = nString + char(9) + 'Date of Last Payment: "' + Trim(Convert(OC.[Date of Last Payment], SQL_Char)) + '" changed to "' + Trim(Convert(NC.[Date of Last Payment], SQL_Char)) + '"'; endif; if (OC.[Last Payment Amount] <> NC.[Last Payment Amount]) then Set nString = nString + char(9) + 'Last Payment Amount: "' + Trim(Convert(OC.[Last Payment Amount], SQL_Char)) + '" changed to "' + Trim(Convert(NC.[Last Payment Amount], SQL_Char)) + '"'; endif; if (OC.[Patient Reference Balance] <> NC.[Patient Reference Balance]) then Set nString = nString + char(9) + 'Patient Reference Balance: "' + Trim(Convert(OC.[Patient Reference Balance], SQL_Char)) + '" changed to "' + Trim(Convert(NC.[Patient Reference Balance], SQL_Char)) + '"'; endif; if (OC.[Employment Status] <> NC.[Employment Status]) then Set nString = nString + char(9) + 'Employment Status: "' + Trim(OC.[Employment Status]) + '" changed to "' + Trim(NC.[Employment Status]) + '"'; endif; if (OC.[Employer] <> NC.[Employer]) then Set nString = nString + char(9) + 'Employer: "' + Trim(OC.[Employer]) + '" changed to "' + Trim(NC.[Employer]) + '"'; endif; if (OC.[Employee Location] <> NC.[Employee Location]) then Set nString = nString + char(9) + 'Employee Location: "' + Trim(OC.[Employee Location]) + '" changed to "' + Trim(NC.[Employee Location]) + '"'; endif; if (OC.[Employee Retirement Date] <> NC.[Employee Retirement Date]) then Set nString = nString + char(9) + 'Employee Retirement Date: "' + Trim(Convert(OC.[Employee Retirement Date], SQL_Char)) + '" changed to "' + Trim(Convert(NC.[Employee Retirement Date], SQL_Char)) + '"'; endif; if (OC.[Work Phone] <> NC.[Work Phone]) then Set nString = nString + char(9) + 'Work Phone: "' + Trim(OC.[Work Phone]) + '" changed to "' + Trim(NC.[Work Phone]) + '"'; endif; if (OC.[Work Extension] <> NC.[Work Extension]) then Set nString = nString + char(9) + 'Work Extension: "' + Trim(OC.[Work Extension]) + '" changed to "' + Trim(NC.[Work Extension]) + '"'; endif; if (OC.[SOF Date] <> NC.[SOF Date]) then Set nString = nString + char(9) + 'SOF Date: "' + Trim(Convert(OC.[SOF Date], SQL_Char)) + '" changed to "' + Trim(Convert(NC.[SOF Date], SQL_Char)) + '"'; endif; if (OC.[Billing Code] <> NC.[Billing Code]) then Set nString = nString + char(9) + 'Billing Code: "' + Trim(OC.[Billing Code]) + '" changed to "' + Trim(NC.[Billing Code]) + '"'; endif; if (OC.[Patient Indicator] <> NC.[Patient Indicator]) then Set nString = nString + char(9) + 'Patient Indicator: "' + Trim(OC.[Patient Indicator]) + '" changed to "' + Trim(NC.[Patient Indicator]) + '"'; endif; if (OC.[User Code] <> NC.[User Code]) then Set nString = nString + char(9) + 'User Code: "' + Trim(OC.[User Code]) + '" changed to "' + Trim(NC.[User Code]) + '"'; endif; if (OC.[Unique Health ID] <> NC.[Unique Health ID]) then Set nString = nString + char(9) + 'Unique Health ID: "' + Trim(OC.[Unique Health ID]) + '" changed to "' + Trim(NC.[Unique Health ID]) + '"'; endif; if (OC.[EMail] <> NC.[EMail]) then Set nString = nString + char(9) + 'EMail: "' + Trim(OC.[EMail]) + '" changed to "' + Trim(NC.[EMail]) + '"'; endif; if (OC.[Contact Phone 1] <> NC.[Contact Phone 1]) then Set nString = nString + char(9) + 'Contact Phone 1: "' + Trim(OC.[Contact Phone 1]) + '" changed to "' + Trim(NC.[Contact Phone 1]) + '"'; endif; if (OC.[Contact Phone 2] <> NC.[Contact Phone 2]) then Set nString = nString + char(9) + 'Contact Phone 2: "' + Trim(OC.[Contact Phone 2]) + '" changed to "' + Trim(NC.[Contact Phone 2]) + '"'; endif; if (OC.[Contact Name] <> NC.[Contact Name]) then Set nString = nString + char(9) + 'Contact Name: "' + Trim(OC.[Contact Name]) + '" changed to "' + Trim(NC.[Contact Name]) + '"'; endif; if (OC.[Weight] <> NC.[Weight]) then Set nString = nString + char(9) + 'Weight: "' + Trim(Convert(OC.[Weight], SQL_Char)) + '" changed to "' + Trim(Convert(NC.[Weight], SQL_Char)) + '"'; endif; if (OC.[Weight Units] <> NC.[Weight Units]) then Set nString = nString + char(9) + 'Weight Units: "' + Trim(OC.[Weight Units]) + '" changed to "' + Trim(NC.[Weight Units]) + '"'; endif; if (OC.[Flag] <> NC.[Flag]) then Set nString = nString + char(9) + 'Flag: "' + Trim(Convert(OC.[Flag], SQL_Char)) + '" changed to "' + Trim(Convert(NC.[Flag], SQL_Char)) + '"'; endif; if (OC.[Inactive] <> NC.[Inactive]) then if (OC.[Inactive] = True) then Set nString = nString + char(9) + 'Inactive: "True" changed to "False"'; else Set nString = nString + char(9) + 'Inactive: "False" changed to "True"'; endif; endif; if (OC.[In Collections] <> NC.[In Collections]) then if (OC.[In Collections] = True) then Set nString = nString + char(9) + 'In Collections: "True" changed to "False"'; else Set nString = nString + char(9) + 'In Collections: "False" changed to "True"'; endif; endif; if (OC.[Payment Plan] <> NC.[Payment Plan]) then Set nString = nString + char(9) + 'Payment Plan: "' + Trim(OC.[Payment Plan]) + '" changed to "' + Trim(NC.[Payment Plan]) + '"'; endif; if (OC.[Last Patient Payment Date] <> NC.[Last Patient Payment Date]) then Set nString = nString + char(9) + 'Last Patient Payment Date: "' + Trim(Convert(OC.[Last Patient Payment Date], SQL_Char)) + '" changed to "' + Trim(Convert(NC.[Last Patient Payment Date], SQL_Char)) + '"'; endif; if (OC.[Last Patient Payment Amount] <> NC.[Last Patient Payment Amount]) then Set nString = nString + char(9) + 'Last Patient Payment Amount: "' + Trim(Convert(OC.[Last Patient Payment Amount], SQL_Char)) + '" changed to "' + Trim(Convert(NC.[Last Patient Payment Amount], SQL_Char)) + '"'; endif; if (OC.[Followed Plan] <> NC.[Followed Plan]) then if (OC.[Followed Plan] = True) then Set nString = nString + char(9) + 'Followed Plan: "True" changed to "False"'; else Set nString = nString + char(9) + 'Followed Plan: "False" changed to "True"'; endif; endif; if (OC.[EntityType] <> NC.[EntityType]) then Set nString = nString + char(9) + 'EntityType: "' + Trim(Convert(OC.[EntityType], SQL_Char)) + '" changed to "' + Trim(Convert(NC.[EntityType], SQL_Char)) + '"'; endif; if (OC.[Patient_Remainder_Balance] <> NC.[Patient_Remainder_Balance]) then Set nString = nString + char(9) + 'Patient_Remainder_Balance: "' + Trim(Convert(OC.[Patient_Remainder_Balance], SQL_Char)) + '" changed to "' + Trim(Convert(NC.[Patient_Remainder_Balance], SQL_Char)) + '"'; endif; if (OC.[Middle Name] <> NC.[Middle Name]) then Set nString = nString + char(9) + 'Middle Name: "' + Trim(OC.[Middle Name]) + '" changed to "' + Trim(NC.[Middle Name]) + '"'; endif; if (OC.[Medical Record Number] <> NC.[Medical Record Number]) then Set nString = nString + char(9) + 'Medical Record Number: "' + Trim(OC.[Medical Record Number]) + '" changed to "' + Trim(NC.[Medical Record Number]) + '"'; endif; Insert into MWAudM([Table], [User], [Action], NDCApplication, [Chart Number], [Date Modified], Details) Values('Patient', @UName, 'UPDATE', 0, OC.[Chart Number], Now(), nString); END PRIORITY 1; EXECUTE PROCEDURE sp_DisableTriggers( 'MWPATUPDATE_AUD', 'MWPAT', FALSE, 0 ); CREATE TRIGGER MWPATDELETE_AUD ON MWPAT BEFORE DELETE BEGIN Declare nString String; Declare OC Cursor as Select * from __Old; Declare @UName String; Declare iIdx Integer; Open OC; Fetch OC; Set nString = (Select User() from System.iota); iIdx = POSITION('mwmw' IN nString); IF (iIdx > 1) THEN nString = SUBSTRING(nString, 1, iIdx-1); ENDIF; Set @UName = nString; --(Select User() from System.iota); Set nString = ''; Set nString = nString + 'Chart Number: "' + Trim(OC.[Chart Number]) + '" '; Set nString = nString + 'Name: "' + Trim(OC.[Last Name]) + ', ' + Trim(OC.[First Name]) + ' ' + Trim(OC.[Middle Initial]) + '" '; Set nString = nString + 'Birthdate: "' + Trim(Convert(OC.[Date of Birth], SQL_Char)) + '"'; Insert into MWAudM([Table], [User], [Action], NDCApplication, [Chart Number], [Date Modified], Details) Values('Patient', @UName, 'DELETE', 0, OC.[Chart Number], Now(), nString); END PRIORITY 1; EXECUTE PROCEDURE sp_DisableTriggers( 'MWPATDELETE_AUD', 'MWPAT', FALSE, 0 );