From 41df21deaa1ffce609df71d5ad290a7a8fe6a4ad Mon Sep 17 00:00:00 2001 From: Aled Jones Date: Wed, 31 Jul 2019 12:08:15 +0100 Subject: [PATCH] requesteddate->daterequested --- forms/s02_NGSTest | 74 +++++++++++++++++++++++------------------------ 1 file changed, 37 insertions(+), 37 deletions(-) diff --git a/forms/s02_NGSTest b/forms/s02_NGSTest index f6e8b388..9ef48d2a 100644 --- a/forms/s02_NGSTest +++ b/forms/s02_NGSTest @@ -7,12 +7,12 @@ Private Sub Form_AfterInsert() Dim S As String Dim date_now As String Dim computername As String - Dim username As String - username = VBA.Environ("USERNAME") + Dim UserName As String + UserName = VBA.Environ("USERNAME") computername = VBA.Environ("COMPUTERNAME") date_now = Format(Now, "dd/mmm/yyyy Hh:Nn:ss") Set Q = New ADODB.Recordset - S = "INSERT INTO PatientLog(InternalPatientID, LogEntry, [Date], Login, PCName) VALUES(" + CStr(Me![InternalPatientID]) + ",'NGS test: " + Me![ReferralID].Column(1) + " " + Me![NGSPanelID].Column(1) + " request added " + CStr(Me![RequestedDate]) + "',#" + date_now + "#,'" + username + "','" + computername + "')" + S = "INSERT INTO PatientLog(InternalPatientID, LogEntry, [Date], Login, PCName) VALUES(" + CStr(Me![InternalPatientID]) + ",'NGS test: " + Me![ReferralID].Column(1) + " " + Me![NGSPanelID].Column(1) + " request added " + CStr(Me![DateRequested]) + "',#" + date_now + "#,'" + UserName + "','" + computername + "')" Q.Open S, CurrentProject.Connection Set Q = Nothing @@ -31,12 +31,12 @@ Private Sub Form_Delete(Cancel As Integer) Dim S As String Dim date_now As String Dim computername As String - Dim username As String - username = VBA.Environ("USERNAME") + Dim UserName As String + UserName = VBA.Environ("USERNAME") computername = VBA.Environ("COMPUTERNAME") date_now = Format(Now, "dd/mmm/yyyy Hh:Nn:ss") Set Q = New ADODB.Recordset - S = "INSERT INTO PatientLog(InternalPatientID, LogEntry, [Date], Login, PCName) VALUES(" + CStr(Me![InternalPatientID]) + ",'NGS test: " + Me![ReferralID].Column(1) + " " + Me![NGSPanelID].Column(1) + " request deleted (requested " + CStr(Me![DateRequested]) + ")',#" + date_now + "#,'" + username + "','" + computername + "')" + S = "INSERT INTO PatientLog(InternalPatientID, LogEntry, [Date], Login, PCName) VALUES(" + CStr(Me![InternalPatientID]) + ",'NGS test: " + Me![ReferralID].Column(1) + " " + Me![NGSPanelID].Column(1) + " request deleted (requested " + CStr(Me![DateRequested]) + ")',#" + date_now + "#,'" + UserName + "','" + computername + "')" Q.Open S, CurrentProject.Connection Set Q = Nothing If [Form_02 Patient Details]![s_StatusOverall] = 1202218798 Then @@ -50,12 +50,12 @@ Private Sub NGSPanelID_AfterUpdate() Dim S As String Dim date_now As String Dim computername As String - Dim username As String + Dim UserName As String computername = VBA.Environ("COMPUTERNAME") - username = VBA.Environ("USERNAME") + UserName = VBA.Environ("USERNAME") date_now = Format(Now, "dd/mmm/yyyy Hh:Nn:ss") Set Q = New ADODB.Recordset - S = "INSERT INTO PatientLog(InternalPatientID, LogEntry, [Date], Login, PCName) VALUES(" + CStr(Me![InternalPatientID]) + ",'NGS test: Panel changed to " + Me![NGSPanelID].Column(1) + "',#" + date_now + "#,'" + username + "','" + computername + "')" + S = "INSERT INTO PatientLog(InternalPatientID, LogEntry, [Date], Login, PCName) VALUES(" + CStr(Me![InternalPatientID]) + ",'NGS test: Panel changed to " + Me![NGSPanelID].Column(1) + "',#" + date_now + "#,'" + UserName + "','" + computername + "')" Q.Open S, CurrentProject.Connection Set Q = Nothing @@ -69,15 +69,15 @@ End Sub Private Sub ReferralID_DblClick(Cancel As Integer) ' define variables Dim rsCopyNGSTest As ADODB.Recordset -Dim Sql As String +Dim sql As String Dim date_now As String Dim computername As String -Dim username As String +Dim UserName As String Dim NewTestID As String -Dim logentry As String +Dim LogEntry As String computername = VBA.Environ("COMPUTERNAME") -username = VBA.Environ("USERNAME") +UserName = VBA.Environ("USERNAME") date_now = Format(Now, "dd/mmm/yyyy Hh:Nn:ss") ' open prompt to confirm test is to be failed and new test created from copy of this testID @@ -85,17 +85,17 @@ msgb = MsgBox("You are about to fail NGSest ID " & Me.NGSTestID & " and create a If msgb = vbYes Then '' Create a new NGSTest record using fields from the failed test 'build sql to create a copy of all the required fields -Sql = "INSERT INTO ngstest (internalpatientid, referralid, ngspanelid, ngspanelid_b, ngspanelid_c, statusid, daterequested, bookby, resultbuild, bookingauthoriseddate, bookingauthorisedbyid, service, costcentre, department, priority) " & _ +sql = "INSERT INTO ngstest (internalpatientid, referralid, ngspanelid, ngspanelid_b, ngspanelid_c, statusid, daterequested, bookby, resultbuild, bookingauthoriseddate, bookingauthorisedbyid, service, costcentre, department, priority) " & _ "SELECT internalpatientid, referralid, ngspanelid, ngspanelid_b, ngspanelid_c, 1202218803, daterequested, bookby, resultbuild, bookingauthoriseddate, bookingauthorisedbyid, service, costcentre, department, priority " & _ "FROM ngstest " & _ "WHERE ngstestid =" & Me.NGSTestID Debug.Print "inserting new NGStest" -Debug.Print Sql +Debug.Print sql ' create new recordset - A recordset is used over DoCmd as we need to return the key of newly inserted row. Set rsCopyNGSTest = New ADODB.Recordset ' run the sql to copy test -rsCopyNGSTest.Open Sql, CurrentProject.Connection +rsCopyNGSTest.Open sql, CurrentProject.Connection 'Get ID of new entry rsCopyNGSTest.Open "SELECT @@identity", CurrentProject.Connection, adOpenKeyset NewTestID = rsCopyNGSTest.Fields(0).Value @@ -103,64 +103,64 @@ Debug.Print "Newtestid = " & NewTestID Set rsCopyNGSTest = Nothing '' copy all ngstest files, adding a prefix to description to make it clear copied from prev test -Sql = "INSERT INTO ngstestfile(ngstestid,description,ngstestfile,dateadded,vcf_filter_import) " & _ +sql = "INSERT INTO ngstestfile(ngstestid,description,ngstestfile,dateadded,vcf_filter_import) " & _ "SELECT " & NewTestID & ",'copy_from_NGSTest'+'" & Me.NGSTestID & "'+'_'+description, ngstestfile, dateadded, vcf_filter_import " & _ "FROM ngstestfile " & _ "WHERE ngstestid = " & Me.NGSTestID Debug.Print "copying NGSTestfiles" -Debug.Print Sql +Debug.Print sql ' turn off warnings so doesn't warn about appending rows DoCmd.SetWarnings False -DoCmd.RunSQL Sql +DoCmd.RunSQL sql DoCmd.SetWarnings True '' copy panels in NGSTestPanelSelection -Sql = "INSERT INTO ngstestpanelselection(ngstestid, selectiontype, selectionid, analysisab) " & _ +sql = "INSERT INTO ngstestpanelselection(ngstestid, selectiontype, selectionid, analysisab) " & _ "SELECT " & NewTestID & ", selectiontype, selectionid, analysisab " & _ "FROM ngstestpanelselection " & _ "WHERE ngstestid = " & Me.NGSTestID Debug.Print "copying panels" -Debug.Print Sql +Debug.Print sql ' turn off warnings so doesn't warn about appending rows DoCmd.SetWarnings False -DoCmd.RunSQL Sql +DoCmd.RunSQL sql DoCmd.SetWarnings True '' update patient log to say new test copied from a failed test -logentry = "NGS: New test request (NGSTestID" & NewTestID & ") created from failed NGSTestID" & Me.NGSTestID & " (including testfiles)" -Sql = "INSERT INTO patientlog(internalpatientid, logentry, [date], login, pcname) " & _ - "VALUES (" & CStr(Me![InternalPatientID]) & ",'" + logentry + "',#" + date_now + "#,'" + username + "','" + computername + "')" +LogEntry = "NGS: New test request (NGSTestID" & NewTestID & ") created from failed NGSTestID" & Me.NGSTestID & " (including testfiles)" +sql = "INSERT INTO patientlog(internalpatientid, logentry, [date], login, pcname) " & _ + "VALUES (" & CStr(Me![InternalPatientID]) & ",'" + LogEntry + "',#" + date_now + "#,'" + UserName + "','" + computername + "')" Debug.Print "updating patient log with copying NGSTestfiles" -Debug.Print logentry -Debug.Print Sql +Debug.Print LogEntry +Debug.Print sql ' turn off warnings so doesn't warn about appending rows DoCmd.SetWarnings False -DoCmd.RunSQL Sql +DoCmd.RunSQL sql DoCmd.SetWarnings True '' Deactivate failed test ' set status = 1202218816 (test failed) -Sql = "UPDATE ngstest " & _ +sql = "UPDATE ngstest " & _ "SET statusid = 1202218816 " & _ "WHERE NGSTestID = " & Me.NGSTestID Debug.Print "setting status to test failed" -Debug.Print Sql +Debug.Print sql ' turn off warnings so doesn't warn about appending rows DoCmd.SetWarnings False -DoCmd.RunSQL Sql +DoCmd.RunSQL sql DoCmd.SetWarnings True '' update patient log to say test status set to failed -logentry = "NGS: Status changed to ""test failed"" for NGSTestID" & Me.NGSTestID -Sql = "INSERT INTO patientlog(internalpatientid, logentry, [date], login, pcname) " & _ - "VALUES (" + CStr(Me![InternalPatientID]) + ",'" + logentry + "',#" + date_now + "#,'" + username + "','" + computername + "')" +LogEntry = "NGS: Status changed to ""test failed"" for NGSTestID" & Me.NGSTestID +sql = "INSERT INTO patientlog(internalpatientid, logentry, [date], login, pcname) " & _ + "VALUES (" + CStr(Me![InternalPatientID]) + ",'" + LogEntry + "',#" + date_now + "#,'" + UserName + "','" + computername + "')" Debug.Print "updating patient log to record setting test status to test failed" -Debug.Print logentry -Debug.Print Sql +Debug.Print LogEntry +Debug.Print sql ' turn off warnings so doesn't warn about appending rows DoCmd.SetWarnings False -DoCmd.RunSQL Sql +DoCmd.RunSQL sql DoCmd.SetWarnings True ' refresh form to reflect changes applied above