LBDbWorkEntry::LBDbWorkEntry( const LQuery & cluster ) : LDbWorkEntry( cluster.readString( "barcode" ), cluster.readInt( "project_cid" ), cluster.readInt( "sample_id" ), cluster.readDateTime( "in_date" ), cluster.readInt( "test_id" ) ) { limits.setAnalyserID( cluster.readInt( "machine_cid" ) ); limits.setPrivate( cluster.readString( "private_result" ) == "Y" ); limits.setRange( cluster.readString( "min_value" ), cluster.readString( "max_value" ) ); limits.setWarnLevels( cluster.readString( "lower_warning" ), cluster.readString( "upper_warning" ) ); int trigger = cluster.readInt( "trigger_id" ); if( trigger != 0 ) { limits.setTriggerLimits( trigger, cluster.readString( "trigger_lower_limit" ), cluster.readString( "trigger_upper_limit" ) ); } int pid = 0; const LPDbProfiles & profiles = LPDbProfiles::records( getProjectID() ); if( !profiles.empty() ) { String reason = cluster.readString( "profile_name" ); if( reason.Length() > 3 && reason.Pos( "re-run" ) == 0 ) { const LPDbProfile * pp = profiles.findByName( reason ); if( pp != NULL ) pid = pp -> getID(); } } setProfileID( pid ); resultID = duplicate = cluster.readInt( "duplicate" ); if( duplicate < nextRerun ) nextRerun = duplicate - 1; // try to keep unique setCategoryID( cluster.readInt( "category_id" ) ); setTimeStamp( cluster.readDateTime( "time_stamp" ) ); if( cluster.readChar( "buddy_read" ) == LCDbWorkEntry::FINISHED ) setStage( LDbStage::TRANSMITTED ); else setStage( makeStage( cluster.readChar( "status" ) ) ); }
void App::printApplicationIdentifier() { std::cout << getProjectID() << std::endl; }
LCDbWorkEntry::LCDbWorkEntry( const LQuery & central ) : LDbIdBase( central.readInt( "record_no" ) ), LDbWorkEntry( central.readString( "barcode" ), central.readInt( "project_cid" ), central.readInt( "sample_id" ), central.readDateTime( "in_date" ), central.readInt( "test_cid" ) ), groupID( central.readInt( "group_id" ) ), profileName( central.readString( "profile_name" ) ) { const LPDbProfile * pp = NULL; const LPDbProfiles & profiles = LPDbProfiles::records( getProjectID() ); if( !profiles.empty() ) { if( central.fieldExists( "profile_id" ) ) { int ppid = central.readInt( "profile_id" ); if( ppid != 0 ) pp = profiles.findByID( ppid ); } if( pp == NULL && profileName.Length() > 2 ) pp = profiles.findByName( profileName ); } setProfileID( pp == NULL ? 0 : pp -> getID() ); limits.setAnalyserID( central.readInt( "machine_cid" ) ); limits.setPrivate( central.readChar( "private_result" ) == 'Y' ); if( central.fieldExists( "min_value" ) && central.fieldExists( "max_value" ) ) { limits.setRange( central.readDouble( "min_value" ), central.readDouble( "max_value" ) ); } if( central.fieldExists( "lower_warning" ) && central.fieldExists( "upper_warning" ) ) { limits.setWarnLevels( central.readDouble( "lower_warning" ), central.readDouble( "upper_warning" ) ); } int trigger = central.readInt( "trigger_id" ); if( trigger != 0 && central.fieldExists( "lower_trigger_limit" ) && central.fieldExists( "upper_trigger_limit" ) ) { limits.setTriggerLimits( trigger, central.readDouble( "lower_trigger_limit" ), central.readDouble( "upper_trigger_limit" ) ); } setTimeStamp( central.readDateTime( "time_stamp" ) ); setCategoryID( central.readInt( "category_id" ) ); if( central.fieldExists( "buddy_result_id" ) ) setDilution( central.readDouble( "buddy_result_id" ) ); else setDilution( 0 ); if( central.fieldExists( "diluent" ) ) setDilution( central.readDouble( "diluent" ) ); else setDilution( 0 ); switch( central.readChar( "buddy_read" ) ) { case LCDbWorkEntry::COPIED: copied = true; setStage( makeStage( central.readChar( "status" ) ) ); break; case LCDbWorkEntry::HELD: copied = true; setStage( LDbStage::L0_HELD ); break; case LCDbWorkEntry::FINISHED: copied = true; setStage( LDbStage::TRANSMITTED ); break; default: copied = false; setStage( makeStage( central.readChar( "status" ) ) ); } }
bool LBDbWorkEntry::createRecord( LQuery cluster, String reason ) { int machine = limits.getAnalyserID(); if( machine == 0 ) { // QCs should stay on the same analyser; others on cluster machine = LCDbAnalysers::getCurrentID(); const LCDbAnalyser * an = LCDbAnalysers::records().findByID( machine ); if( an != NULL && !isQC() ) { std::set< int > machineIDs = an -> getClusterIDs(); if( !machineIDs.empty() ) machine = *(machineIDs.begin()); } limits.setAnalyserID( machine ); } if( reason.IsEmpty() && getProfileID() != 0 ) { const LPDbProfiles & profiles = LPDbProfiles::records( getProjectID() ); const LPDbProfile * pp = profiles.findByID( getProfileID() ); if( pp != NULL ) reason = pp -> getName(); } setTimeStamp( Now() ); char fromCentral = LCDbWorkEntry::NEW_RECORD; switch( getStage() ) { case NEW_ENTRY: break; case RE_RUN: resultID = nextRerun --; break; case TRIGGERED: resultID = TRIGGER_ID; break; default: fromCentral = LCDbWorkEntry::COPIED; } cluster.setSQL( "Insert into buddy_worklist (machine_cid, barcode, duplicate, test_name, test_id," " sample_id, range_set, min_value, max_value, status, project_cid, profile_name," " buddy_read, in_date, time_stamp, lower_warning, upper_warning, trigger_id," " trigger_lower_limit, trigger_upper_limit, private_result, delete_status, category_id)" " values ( :mid, :bar, :dup, :tnm, :tid, :aid, :rs, :min, :max, :sts, :prj," " :prn, :brd, :ind, :dts, :wlo, :wup, :trd, :tlo, :tup, :prv, 0, :cat )" ); cluster.setParam( "mid", machine ); cluster.setParam( "bar", getBarcode() ); cluster.setParam( "dup", resultID ); std::pair< int, int > specimen = getSpecimen(); cluster.setParam( "prj", specimen.first ); cluster.setParam( "aid", specimen.second ); const LCDbTest & test = LCDbTests::records().get( limits.getID() ); cluster.setParam( "tid", test.getID() ); cluster.setParam( "tnm", test.getName() ); cluster.setParam( "prn", reason ); std::pair< double, double > range = limits.getRange().asDoubles(); cluster.setParam( "min", range.first ); cluster.setParam( "max", range.second ); cluster.setParam( "rs", (range.first == 0 && range.second == 0) ? 'N' : 'Y' ); cluster.setParam( "sts", makeStatus( getStage() ) ); cluster.setParam( "brd", fromCentral ); cluster.setParam( "ind", getInDate() ); cluster.setParam( "dts", getTimeStamp() ); cluster.setParam( "trd", limits.getTriggerProfile() ); if( limits.getTriggerProfile() == 0 ) { cluster.setParam( "tup", "0" ); cluster.setParam( "tlo", "0" ); } else { range = limits.getTriggerLimits().asDoubles(); cluster.setParam( "tlo", range.first ); cluster.setParam( "tup", range.second ); } range = limits.getWarnLevels().asDoubles(); cluster.setParam( "wlo", range.first ); cluster.setParam( "wup", range.second ); cluster.setParam( "prv", limits.isPrivate() ? 'Y' : 'N' ); cluster.setParam( "cat", getCategoryID() ); if( cluster.execSQL() != 1 ) { return false; } duplicate = resultID; LBDbWorkList::records().insert( *this ); return true; }