Skip to content

Commit

Permalink
GMP | e-Signatures -- Switch from 6. REPORT to e-Signatures stage | r…
Browse files Browse the repository at this point in the history
…e-attachment directly form GMP Run Manager; needs testing; some logic questions/losse ends remain - TO DISCUSS...
  • Loading branch information
alexsav815 committed Jul 26, 2023
1 parent 3e98132 commit 6288fe5
Show file tree
Hide file tree
Showing 6 changed files with 131 additions and 85 deletions.
70 changes: 66 additions & 4 deletions programs/us_com_project/us_com_project_gui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -473,6 +473,7 @@ US_ComProjectMain::US_ComProjectMain() : US_Widgets()
connect( epanInit, SIGNAL( switch_to_editing_init( QMap < QString, QString > & ) ), this, SLOT( switch_to_editing( QMap < QString, QString > & ) ) );
connect( epanInit, SIGNAL( switch_to_analysis_init( QMap < QString, QString > & ) ), this, SLOT( switch_to_analysis( QMap < QString, QString > & ) ) );
connect( epanInit, SIGNAL( switch_to_report_init( QMap < QString, QString > & ) ), this, SLOT( switch_to_report( QMap < QString, QString > & ) ) );
connect( epanInit, SIGNAL( switch_to_esign_init( QMap < QString, QString > & ) ), this, SLOT( switch_to_esign( QMap < QString, QString > & ) ) );
connect( epanInit, SIGNAL( to_initAutoflow( ) ), this, SLOT( close_all( ) ) );

connect( this, SIGNAL( pass_used_instruments( QStringList & ) ), epanExp, SLOT( pass_used_instruments( QStringList &) ) );
Expand Down Expand Up @@ -506,6 +507,11 @@ US_ComProjectMain::US_ComProjectMain() : US_Widgets()
connect( this, SIGNAL( pass_to_report( QMap < QString, QString > & ) ), epanReport, SLOT( do_report( QMap < QString, QString > & ) ) );

connect( this, SIGNAL( reset_reporting() ), epanReport, SLOT( reset_reporting( ) ) );

//E-Signs
connect( epanReport, SIGNAL( switch_to_esign( QMap < QString, QString > & ) ), this, SLOT( switch_to_esign( QMap < QString, QString > & ) ) );
connect( this, SIGNAL( pass_to_esign( QMap < QString, QString > & ) ), epanSign, SLOT( do_esign( QMap < QString, QString > & ) ) );
connect( this, SIGNAL( reset_esigning() ), epanSign, SLOT( reset_esigning( ) ) );

setMinimumSize( QSize( 1350, 850 ) );
adjustSize();
Expand Down Expand Up @@ -619,9 +625,14 @@ void US_ComProjectMain::initPanels( int panx )
if ( curr_panx == 6 )
{
qDebug() << "Jumping from Report.";

emit reset_reporting();
}
}

if ( curr_panx == 7 )
{
qDebug() << "Jumping from e-Signs.";
emit reset_esigning();
}

xpn_viewer_closed_soft = false;
epanInit ->initAutoflowPanel();
Expand Down Expand Up @@ -1097,6 +1108,40 @@ void US_ComProjectMain::switch_to_report( QMap < QString, QString > & protocol_d
emit pass_to_report( protocol_details );
}

// Slot to switch to e-Signtab
void US_ComProjectMain::switch_to_esign( QMap < QString, QString > & protocol_details )
{
/** BEFORE going to e-Signatures: Check if user is among operators|reviewers|approvers**/

/*
Covered in list_all_autoflow_records():
-- isOperRev( user_id, autolfowId ): if false, run NOT shown in the GMP run list
Do we want to rather show all runs BUT not allow to switch to E-SIGN if ( !isOperRev( user_id, autolfowId )) ??
*/

/****************************************************************************************/

tabWidget->setCurrentIndex( 7 ); // Maybe lock this panel from now on? i.e. tabWidget->tabBar()-setEnabled(false) ??
curr_panx = 7;

// ALEXEY: Temporariy NOT lock here... Will need later

for (int i = 1; i < tabWidget->count(); ++i )
{
if ( i == 7 )
tabWidget->tabBar()->setTabEnabled(i, true);
else
tabWidget->tabBar()->setTabEnabled(i, false);
}


qApp->processEvents();
// ALEXEY: Make a record to 'autoflow' table: stage# = 4;

emit pass_to_esign( protocol_details );
}



// Function to Call initiation of the Autoflow Record Dialogue form _main.cpp
void US_ComProjectMain::call_AutoflowDialogue( void ) //<--- Entry point from main
Expand Down Expand Up @@ -1790,6 +1835,13 @@ void US_InitDialogueGui::initRecordsDialogue( void )

}

if ( stage == "E-SIGNATURES" )
{
qDebug() << "To E-SIGNS SWITCH ";
emit switch_to_esign_init( protocol_details );

}

//and so on...
}

Expand Down Expand Up @@ -3545,8 +3597,8 @@ US_eSignaturesGui::US_eSignaturesGui( QWidget* topw )
sdiag = new US_eSignaturesGMP( "AUTO" );
sdiag->setParent(this, Qt::Widget);

connect( this, SIGNAL( start_report( QMap < QString, QString > & ) ), sdiag, SLOT( loadRun_auto ( QMap < QString, QString > & ) ) );
connect( this, SIGNAL( reset_reporting_passed( ) ), sdiag, SLOT( reset_report_panel ( ) ) );
connect( this, SIGNAL( start_esign( QMap < QString, QString > & ) ), sdiag, SLOT( initPanel_auto ( QMap < QString, QString > & ) ) );
connect( this, SIGNAL( reset_esigning_passed( ) ), sdiag, SLOT( reset_esign_panel ( ) ) );

offset = 0;
sdiag->move(offset, 2*offset);
Expand Down Expand Up @@ -3585,3 +3637,13 @@ void US_eSignaturesGui::resizeEvent(QResizeEvent *event)

QWidget::resizeEvent(event);
}

void US_eSignaturesGui::do_esign( QMap < QString, QString > & protocol_details )
{
emit start_esign( protocol_details );
}

void US_eSignaturesGui::reset_esigning( void )
{
emit reset_esigning_passed();
}
13 changes: 9 additions & 4 deletions programs/us_com_project/us_com_project_gui.h
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@ class US_InitDialogueGui : public US_WidgetsDialog
void switch_to_editing_init( QMap < QString, QString > & protocol_details );
void switch_to_analysis_init( QMap < QString, QString > & protocol_details );
void switch_to_report_init( QMap < QString, QString > & protocol_details );
void switch_to_esign_init( QMap < QString, QString > & protocol_details );
void to_initAutoflow( void );

};
Expand Down Expand Up @@ -363,6 +364,7 @@ class US_ReportStageGui : public US_WidgetsDialog
signals:
void start_report( QMap < QString, QString > & );
void reset_reporting_passed ( void );
void switch_to_esign( QMap < QString, QString > & );
};


Expand All @@ -385,12 +387,12 @@ class US_eSignaturesGui: public US_WidgetsDialog
void resizeEvent(QResizeEvent *event) override;

private slots:
// void do_report( QMap < QString, QString > & );
// void reset_reporting( void );
void do_esign( QMap < QString, QString > & );
void reset_esigning( void );

signals:
// void start_report( QMap < QString, QString > & );
// void reset_reporting_passed ( void );
void start_esign( QMap < QString, QString > & );
void reset_esigning_passed ( void );
};


Expand Down Expand Up @@ -478,6 +480,7 @@ private slots:
void switch_to_editing( QMap < QString, QString > & protocol_details );
void switch_to_analysis( QMap < QString, QString > & protocol_details );
void switch_to_report( QMap < QString, QString > & protocol_details );
void switch_to_esign( QMap < QString, QString > & );


//void switch_to_experiment( QString & protocolName );
Expand Down Expand Up @@ -505,6 +508,7 @@ private slots:
void pass_to_editing( QMap < QString, QString > & protocol_details );
void pass_to_analysis( QMap < QString, QString > & protocol_details );
void pass_to_report( QMap < QString, QString > & protocol_details );
void pass_to_esign( QMap < QString, QString > & protocol_details );


//void clear_experiment( QString & protocolName);
Expand All @@ -514,6 +518,7 @@ private slots:
void reset_data_editing( void );
void reset_live_update( void );
void reset_reporting( void );
void reset_esigning( void );
};


Expand Down
62 changes: 12 additions & 50 deletions programs/us_esigner_gmp/us_esigner_gmp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -330,8 +330,8 @@ US_eSignaturesGMP::US_eSignaturesGMP( QString a_mode ) : US_Widgets()
/***************/
}

//slot to execute when switching form REPORT:
void US_eSignaturesGMP::initPanel_auto( QMap < QString, QString > & protocol_details )
//reset eSign mod. constructor
void US_eSignaturesGMP::reset_esign_panel( void )
{
//reset inernals && clear GUI:
if ( eSignersGrid_auto != NULL && eSignersGrid_auto->layout() != NULL )
Expand All @@ -357,6 +357,15 @@ void US_eSignaturesGMP::initPanel_auto( QMap < QString, QString > & protocol_det
}
//End cleaning layouts

qApp->processEvents();
}

//slot to execute when switching form REPORT:
void US_eSignaturesGMP::initPanel_auto( QMap < QString, QString > & protocol_details )
{
//clear all GUI, internals
reset_esign_panel();

//Now, initialize main internal layouts:
eSignersGrid_auto = new QGridLayout();
eSignersGrid_auto ->setSpacing ( 2 );
Expand Down Expand Up @@ -391,54 +400,7 @@ void US_eSignaturesGMP::initPanel_auto( QMap < QString, QString > & protocol_det
//&& Set defined Operator/Reviewers (if any)
display_reviewers_auto( row, eSign_record_auto, "operatorListJson" );
display_reviewers_auto( row, eSign_record_auto, "reviewersListJson" );
//display_reviewers( "approversListJson" );

// if ( eSign_record_auto. contains("operatorListJson") )
// {
// QJsonDocument jsonDocOperList = QJsonDocument::fromJson( eSign_record_auto[ "operatorListJson" ] .toUtf8() );
// QJsonArray jsonDocOperList_array = jsonDocOperList.array();
// for (int i=0; i < jsonDocOperList_array.size(); ++i )
// {
// QString current_reviewer = jsonDocOperList_array[i].toString();
// //uname = oID + ": " + olname + ", " + ofname;

// QLineEdit* le_name = us_lineedit( current_reviewer, 0, true );
// le_name -> setObjectName( "name: " + current_reviewer );
// QLineEdit* le_role = us_lineedit( tr("Operator"), 0, true );

// QLineEdit* le_stat = check_eSign_status_for_gmpReport_auto( current_reviewer, eSign_record_auto );
// le_stat -> setObjectName( "status: " + current_reviewer );

// qDebug() << "Object Name of le_stat -- " << le_stat->objectName();

// eSignersGrid_auto -> addWidget( le_name, row, 0, 1, 4 );
// eSignersGrid_auto -> addWidget( le_role, row, 4, 1, 2 );
// eSignersGrid_auto -> addWidget( le_stat, row++, 6, 1, 2 );
// }
// }

// if ( eSign_record_auto. contains("reviewersListJson") )
// {
// QJsonDocument jsonDocRevList = QJsonDocument::fromJson( eSign_record_auto[ "reviewersListJson" ] .toUtf8() );
// QJsonArray jsonDocRevList_array = jsonDocRevList.array();
// for (int i=0; i < jsonDocRevList_array.size(); ++i )
// {
// QString current_reviewer = jsonDocRevList_array[i].toString();

// QLineEdit* le_name = us_lineedit( current_reviewer, 0, true );
// le_name -> setObjectName( current_reviewer );
// QLineEdit* le_role = us_lineedit( tr("Reviewer"), 0, true );

// QLineEdit* le_stat = check_eSign_status_for_gmpReport_auto( current_reviewer, eSign_record_auto );
// le_stat -> setObjectName( "status: " + current_reviewer );

// eSignersGrid_auto -> addWidget( le_name, row, 0, 1, 4 );
// eSignersGrid_auto -> addWidget( le_role, row, 4, 1, 2 );
// eSignersGrid_auto -> addWidget( le_stat, row++, 6, 1, 2 );

// }
// }
//Maybe later add Approver's section...
//display_reviewers_auto( row, eSign_record_auto, "approversListJson" ); // Approvers also? [TO BE ADDED]

//rigth section: actions
QLabel* bn_act = us_banner( tr( "e-Sign: Actions:" ), 1 );
Expand Down
2 changes: 2 additions & 0 deletions programs/us_esigner_gmp/us_esigner_gmp.h
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,8 @@ class US_eSignaturesGMP : public US_Widgets
QString check_eSign_status_for_gmpReport( void );
QLineEdit* check_eSign_status_for_gmpReport_auto( QString, QMap< QString, QString> );
void write_download_eSignatures_DB( QString, QString );

void reset_esign_panel ( void );


signals:
Expand Down
66 changes: 40 additions & 26 deletions programs/us_reporter_gmp/us_reporter_gmp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -452,6 +452,7 @@ void US_ReporterGMP::loadRun_auto ( QMap < QString, QString > & protocol_details
AutoflowID_auto = protocol_details[ "autoflowID" ];
analysisIDs = protocol_details[ "analysisIDs" ];
autoflowStatusID = protocol_details[ "statusID" ];
optimaName = protocol_details[ "OptimaName" ] ;

QString full_runname = protocol_details[ "filename" ];
FullRunName_auto = runName + "-run" + runID;
Expand Down Expand Up @@ -1320,6 +1321,7 @@ void US_ReporterGMP::load_gmp_run ( void )
intensityID = protocol_details[ "intensityID" ];
analysisIDs = protocol_details[ "analysisIDs" ];
autoflowStatusID = protocol_details[ "statusID" ];
optimaName = protocol_details[ "OptimaName" ];

progress_msg->setValue( 1 );
qApp->processEvents();
Expand Down Expand Up @@ -1638,9 +1640,11 @@ QMap< QString, QString> US_ReporterGMP::read_autoflow_record( int autoflowID )

protocol_details[ "analysisIDs" ] = db->value( 19 ).toString();
protocol_details[ "intensityID" ] = db->value( 20 ).toString();

protocol_details[ "statusID" ] = db->value( 21 ).toString();

protocol_details[ "failedID" ] = db->value( 22 ).toString();
protocol_details[ "operatorID" ] = db->value( 23 ).toString();
protocol_details[ "devRecord" ] = db->value( 24 ).toString();
protocol_details[ "gmpReviewID" ] = db->value( 25 ).toString();
}
}

Expand Down Expand Up @@ -3005,32 +3009,16 @@ void US_ReporterGMP::generate_report( void )

pb_view_report_auto->setVisible( true );

/******* NOTES ********************
1. Check if GMP Report is set for e-Signature:
-- if operator(s) / reviewer(s) are assigned:
/******* NOTES *******************************************
2. If YES, assigned:
1. For assigned oper/rev/appr. cases (default):
-- inform user that they are assigned && those assignees will re-attach later;
-- do NOT let to proceed to 7. e-Signatures
-- still enable to View GMP Report
-- update autoflow's status to 'E-SIGNATURE'
3. If NOT, not assiged:
-- if ADMIN (OR, an admin who can assign reviewer(s)), offer to assign:
** add button to open us_esigner [assigner section]
** while assigned, inform that assignees will re-attach later;
** do NOT let to proceed to 7. e-Signatures
** still enable to View GMP Report
** update autoflow's status to 'E-SIGNATURE'
-- if NON-ADMIN:
** just enable to View
** update autoflow's status to 'E-SIGNATURE'
***************************/
************************************************************/

//copy autoflow record to autoflowHistory table:
//INSERT INTO autoflowHistory SELECT * FROM autoflow WHERE ID=${ID}//
//Update autoflow status to 'E-SIGNATURES':
US_Passwd pw;
US_DB2* db = new US_DB2( pw.getPasswd() );

Expand All @@ -3041,10 +3029,33 @@ void US_ReporterGMP::generate_report( void )
tr( "DB Connection Problem" ),
tr( "AutoflowHistory: there was an error connecting to the database:\n" )
+ db->lastError() );

return;
}

QStringList qry;
qry << "update_autoflow_at_report"
<< runID
<< optimaName;
//db->query( qry );

int status = db->statusQuery( qry );

if ( status == US_DB2::NO_AUTOFLOW_RECORD )
{
QMessageBox::warning( this,
tr( "Autoflow Record Not Updated" ),
tr( "No autoflow record\n"
"associated with this experiment." ) );
return;
}


/** Do NOT delete anythign here !!!!!!! *****/
/** WILL BE DELETED/COPIED to HISTORY after e-Signing!!!!! ***********/
/************************************************************************
//copy autoflow record to autoflowHistory table:
//INSERT INTO autoflowHistory SELECT * FROM autoflow WHERE ID=${ID}//
QStringList qry;
qry << "new_autoflow_history_record" << AutoflowID_auto;
qDebug() << "Query for autoflowHistory -- " << qry;
Expand All @@ -3060,8 +3071,11 @@ void US_ReporterGMP::generate_report( void )
qry << "delete_autoflow_stages_record" << AutoflowID_auto;
db->statusQuery( qry );
//END of copy to History, deletion of primary autoflow record


***************************************************************************/

//IF user is NOT among reviewers, inform that can NOT proceed to e-SIGNS stage!
//IF user IS among reviewers, offer to View Report and / OR proceed to e-SIGNS, OR re-attach later!!!

//Inform user of the PDF location
QMessageBox msgBox_a;
msgBox_a.setText(tr("Report PDF Ready!"));
Expand Down
3 changes: 2 additions & 1 deletion programs/us_reporter_gmp/us_reporter_gmp.h
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,8 @@ class US_ReporterGMP : public US_Widgets
QString intensityID;
QString analysisIDs;
QString autoflowStatusID;

QString optimaName;

QString current_date;

QString duration_str;
Expand Down

0 comments on commit 6288fe5

Please sign in to comment.