QList<Patient*> LocalDatabaseStudyDAL::queryPatientStudy(const DicomMask &patientStudyMaskToQuery, QDate lastAccessDateMinor, QDate lastAccessDateEqualOrMajor) { int columns, rows; char **reply = NULL; char **error = NULL; QList<Patient*> patientList; m_lastSqliteError = sqlite3_get_table(m_dbConnection->getConnection(), qPrintable(buildSqlSelectStudyPatient(patientStudyMaskToQuery, lastAccessDateMinor, lastAccessDateEqualOrMajor)), &reply, &rows, &columns, error); if (getLastError() != SQLITE_OK) { logError (buildSqlSelectStudyPatient(patientStudyMaskToQuery, lastAccessDateMinor, lastAccessDateEqualOrMajor)); return patientList; } // index = 1 ignorem les capçaleres for (int index = 1; index <= rows; index++) { Patient *patient = fillPatient(reply, index, columns); patient->addStudy(fillStudy(reply, index, columns)); patientList.append(patient); } sqlite3_free_table(reply); return patientList; }
void ExamModelXmlReader::BuildPatient(Examination* exam){ Patient* tmp = new Patient(GetPatientName()); DateTime* birth = new DateTime(GetPatientBirthdate()); tmp->SetBirthdate(*birth); exam->SetPatient(*tmp); }
bool PatientTreeModel::Create(Patient data) { //Calculate Patient_ID = md5(datetime + patient:name) QString raw_id = QDateTime::currentDateTime().toString() + data.name() + data.surname(); QString patient_id = QString(QCryptographicHash::hash(raw_id.toAscii(), QCryptographicHash::Md5).toHex()); data.set_id(patient_id); //Create directory ./data/patients/Patient_ID QDir patient_dir(root_path_ + patient_id); if (!patient_dir.exists()) { if (!patient_dir.mkpath(".")) return false; } // Create directory for patient's scans ./data/patients/Patient_ID/scans QDir scans_dir(root_path_ + patient_id + "/scans"); if (!scans_dir.exists()) { if (!scans_dir.mkpath(".")) return false; } //Create patient's metadata file in ./data/patients/Patient_ID/metadata.json QFile metadata_file(root_path_ + patient_id + "/metadata.json"); if (!metadata_file.open(QIODevice::WriteOnly)) return false; metadata_file.write(QtJson::serialize(data.AsJsonObject())); metadata_file.close(); patients_.push_back(data); // Rebuild tree model clear(); Build(); return true; }
void Lobotomizer::apply(Patient& patient) { patient.modify_mental_health(LOB_MENTAL_HEALTH_MODIFIER); patient.modify_physical_health(LOB_PHYSICAL_HEALTH_MODIFIER); if(rand()%100 < LOB_KILL_BRAIN_CHANCE) patient.modify_mental_health(-patient.get_mental_health()); if(rand()%100 < LOB_RENAME_CHANCE) patient.add_to_name(get_random_name()); m_num_uses++; return; }
int main() { Patient quidam; double poids, taille; do { cout << "Entrez un poids (kg) et une taille (m) : "; cin >> poids >> taille; quidam.init(poids, taille); quidam.afficher(); cout << "IMC : " << quidam.imc() << endl; } while (poids * taille != 0.0); return 0; }
BetProcedureFrame::BetProcedureFrame(wxWindow* parent, const Patient& patient) : BaseProcedureFrame(parent), currents_graphic_( wxBitmap(wxT("graphic_small"), wxBITMAP_TYPE_PNG_RESOURCE).ConvertToImage(), 20, 15, 680, 120, DURATION_LIMIT + 30 * 60, //30min. for closing procedure 80, { wxColor(13, 193, 184), wxColor(0, 0, 255), wxColor(125, 0, 255), wxColor(255, 0, 0), wxColor(255, 125, 0), wxColor(80, 170, 80) }), voltage_graphic_( wxBitmap(wxT("graphic_big"), wxBITMAP_TYPE_PNG_RESOURCE).ConvertToImage(), 26, 15, 674, 240, DURATION_LIMIT + 30 * 60, 120, { wxColor(0, 0, 225), wxColor(125, 0, 0), wxColor(0, 125, 0), wxColor(125, 0, 125) }), lightR_(wxT("lightr"), wxBITMAP_TYPE_PNG_RESOURCE), lightG_( wxT("lightg"), wxBITMAP_TYPE_PNG_RESOURCE), lightS_(wxT("lights"), wxBITMAP_TYPE_PNG_RESOURCE), switch1_( SW_OFF), switch2_(SW_OFF), switch3_(SW_OFF), switch4_(SW_OFF), switch5_(SW_OFF), switch6_( SW_OFF), cable_(CABLE_OUT), key_(KEY_ON), polarity_(false), voltage_(0), decrease_speed_(0.1), time_to_end_(60), q_( 0), duration_(0), state_( STATE_INITIAL), conf_channel_alarm_wait_(10){ for (int i = 0; i < 7; i++) { voltages_[i] = 0; currents_[i] = 0; } patient_id_ = patient.getPatientNumber(); m_txtPatientName->SetLabel(patient.getFullName()); m_txtTreatmentNumber->SetLabel(wxString::Format("%i", patient.getTreatmentCount() + 1)); m_bmpElectrodes->SetBitmap(currents_graphic_.getImage()); m_bmpVoltage->SetBitmap(voltage_graphic_.getImage()); my_timer_.SetOwner(this); m_bmpInd1->SetBitmap(lightS_); m_bmpInd2->SetBitmap(lightS_); m_bmpInd3->SetBitmap(lightS_); m_bmpInd4->SetBitmap(lightS_); m_bmpInd5->SetBitmap(lightS_); m_bmpInd6->SetBitmap(lightS_); updateFloatValue(voltage_, m_txtVoltage); updateIntegerValue(0, m_txtCurrent); updateDurationValue(time_to_end_, m_txtDuration); parseOptions(); Bind(wxEVT_TIMER, &BetProcedureFrame::OnTimer, this); if (options_.find(std::string("port")) == options_.end() ) throw std::runtime_error("port not specified in configuration file"); protocol_.start(options_[std::string("port")].as<std::string>()); decrease_speed_ = options_[std::string("decrease_speed")].as<float>(); regulator_speed_ = options_[std::string("regulator_speed")].as<float>(); conf_channel_alarm_wait_ = options_[std::string("channel_alarm_wait")].as<unsigned int>(); Bind(wxEVT_KEY_DOWN, &BetProcedureFrame::OnKeyEvent, this, wxID_ANY); DoGoInInitialState(); my_timer_.Start(1000); wxGetApp().setProcedureFrame(this); }
bool AddPatient(Patient p) { QSqlQuery query; query.exec("select * from TPatient"); query.last(); int id=query.value(0).toInt()+1; QString sql="insert into TPatient values(" +QString::number(id)+","+"'" +p.getNom()+"' , '" +p.getPrenom() +"' , '" +p.getAdresse() +"' , '" +p.getVille()+"' , '" +QString::number(p.getCP())+"' , '" +p.getCommentaire()+"' , '" +p.getTelephone()+"' , '" +p.getDateDebut().toString("yyyy-MM-dd")+"' , '" +QString::number(p.getDuree())+"' , '" +QString::number(p.getPriorite())+"')"; bool b_test=query.exec(sql); if(!b_test) { qDebug() << query.lastError().text(); qDebug() << "Insertion de données dans TPatient impossible !\n"; return false; } query.exec("select Id from TConsult"); query.last(); int idc=query.value(0).toInt()+1; for(int n=0; n<p.vIdRessource.size(); n++,idc++){ b_test=query.exec("insert into TConsult values(" +QString::number(idc)+"," +QString::number(id)+"," +QString::number(p.vIdRessource.at(n)) +")"); if(!b_test) { qDebug() << query.lastError().text(); qDebug() << "Insertion de données dans TConsult impossible !\n"; return false; } } return true; }
bool ModifierPatient(Patient p,QString id) { QSqlQuery query; QString sql="update TPatient set Nom='"+p.getNom()+"' , " +"Prenom='"+p.getPrenom() +"' , " +"Adresse='"+p.getAdresse() +"' , " +"Ville='"+p.getVille()+"' , " +"CP='"+QString::number(p.getCP())+"' , " +"Commentaire='"+p.getCommentaire()+"' , " +"Tel='"+p.getTelephone()+"' , " +"DateConsultation='"+p.getDateDebut().toString("yyyy-MM-dd")+"' , " +"DureeConsultation="+QString::number(p.getDuree())+" , " +"Priorite="+QString::number(p.getPriorite()) +" where id="+id; bool b_test= query.exec(sql); if(!b_test) { qDebug() << query.lastError().text(); qDebug() << "Modifier de données dans TPatient impossible !\n"; return false; } query.exec("delete from TConsult where IdPatient="+id); query.exec("select Id from TConsult"); query.last(); int idc=query.value(0).toInt()+1; for(int n=0; n<p.vIdRessource.size(); n++,idc++){ b_test=query.exec("insert into TConsult values(" +QString::number(idc)+"," +id+"," +QString::number(p.vIdRessource.at(n)) +")"); if(!b_test) { qDebug() << query.lastError().text(); qDebug() << "Insertion de données dans TConsult impossible !\n"; return false; } } return true; }
void QInputOutputDicomdirWidget::view() { QList<QPair<DicomMask, DICOMSource> > selectedDICOMITems = m_studyTreeWidget->getDicomMaskOfSelectedItems(); DicomMask patientToProcessMask; Patient *patient; QList<Patient*> selectedPatientsList; if (selectedDICOMITems.isEmpty()) { QMessageBox::warning(this, ApplicationNameString, tr("Select at least one study to view.")); return; } QApplication::setOverrideCursor(Qt::WaitCursor); for (int index = 0; index < selectedDICOMITems.count(); index++) { patientToProcessMask.setStudyInstanceUID(selectedDICOMITems.at(index).first.getStudyInstanceUID()); patient = m_readDicomdir.retrieve(patientToProcessMask); if (patient) { patient->setSelectedSeries(selectedDICOMITems.at(index).first.getSeriesInstanceUID()); selectedPatientsList << patient; } else { DEBUG_LOG("No s'ha pogut obtenir l'estudi amb UID " + selectedDICOMITems.at(index).first.getStudyInstanceUID()); } } QApplication::restoreOverrideCursor(); if (!selectedPatientsList.isEmpty()) { DEBUG_LOG("Llançat signal per visualitzar estudi del pacient " + patient->getFullName()); emit viewPatients(selectedPatientsList); } else { QMessageBox::warning(this, ApplicationNameString, tr("No valid data found. Maybe some files are missing or corrupted.")); } }
//-------------------------------------------------- Builder / Destructor SensorSimulatorSunSpot::SensorSimulatorSunSpot(int id, Subject* r, float minL, float maxL, float minT, float maxT, float minM, float maxM) : SensorSimulator(id, EnOceanSensorAPI::ORG_4BS, r), minLum(minL), maxLum(maxL), minTemp(minT), maxTemp(maxT), minMov(minM), maxMov(maxM) { // illuminance = rand()%(int)(maxLum-minLum) - minLum; // voltage = rand()%(int)(maxV-minV) - minV; // pirStatus = false; // occupancy = false; Patient* patient = dynamic_cast<Patient*>(r); if (patient != 0) { float t, i, m; t = patient->getTemperature(); i = patient->getRoom()->getLuminosity(); m = patient->getMovement(); EnOceanSensorAPI::setIlluminance(&frame, i, minLum, maxLum); EnOceanSensorAPI::setTemperature(&frame, t, minT, maxT); EnOceanSensorAPI::setMovement(&frame, m, minM, maxM); cout << "<Sensor Simu n°" << id << "> Créé - Sunspot\n"; } else { subject = NULL; } } //----- End of SensorSimulatorSunSpot
//!---------------------------------------------------------------------------------------------------- //! //! \brief Patients::findPatientExisted //! int Patients::findPatientExisted(){ QDir patientsPath(this->patients_path); patientsPath.setFilter(QDir::Dirs); QFileInfoList list = patientsPath.entryInfoList(); for(unsigned char cpt = 0; cpt < list.size(); cpt++){ if(list.at(cpt).filePath().contains(".") || list.at(cpt).filePath().contains("..")){ continue; } Patient *patient = new Patient(list.at(cpt).filePath(), id); patient->setImageProcessingFactory(this->imageProcessingFactory); patients.append(patient); id++; } return id; }
void SensorSimulatorSunSpot::update() { // float voltage = t; // if (voltage > maxV) { t = maxV; } // else if (voltage < minV) { t = minV; } Patient* patient = dynamic_cast<Patient*>(subject); if (patient != 0) { float t, i, m; t = patient->getTemperature(); if (t > maxTemp) { t = maxTemp; } else if (t < minTemp) { t = minTemp; } i = patient->getRoom()->getLuminosity(); if (i > maxLum) { i = maxLum; } else if (i < minLum) { i = minLum; } m = patient->getMovement(); if (m > maxMov) { m = maxMov; } else if (m < minMov) { m = minMov; } EnOceanSensorAPI::setIlluminance(&frame, i, minLum, maxLum); EnOceanSensorAPI::setTemperature(&frame, t, minTemp, maxTemp); EnOceanSensorAPI::setMovement(&frame, m, minMov, maxMov); } }
void EmergencyRoom::reviewPatient() { system("cls"); for (int i = 0; i < 80; i++) cout << "="; cout << "| PATIENT REVIEW |"; for (int i = 0; i < 80; i++) cout << "="; char answer = ' '; cout << "Doc, would you like to review any of the patients files? (Y/N): "; cin >> answer; while (answer == 'Y' || answer == 'y'){ string userInput = ""; cout << "Enter the name of the patient whose file you wish to review: "; cin >> userInput; bool found = false; Patient *foundPatient = nullptr; for (int currentIndex = 0; currentIndex <= patientCount; currentIndex++){ if (userInput == patients[currentIndex].getName()){ foundPatient = &patients[currentIndex]; cout << "Name: " << foundPatient->getName() << endl; cout << "Severity: " << foundPatient->getPriorityValue() << endl; cout << "Arrival Time: " << timeInString(foundPatient->getArrivalTime()) << endl; found = true; break; } } if (!found){ cout << userInput << " has not been found!" << endl; } cout << "Is there another patient whose file you would like to review? (Y/N): "; cin >> answer; cout << endl; } }
// Copy constructor. Patient::Patient(const Patient & p) { id = p.id; first_name = p.first_name; last_name = p.last_name; // Add xrays. list<Xray> xrs = p.getXrays(); list<Xray>::const_iterator xi; for (xi = xrs.begin(); xi != xrs.end(); ++xi) { xrays.push_back(*xi); } }
bool PatientPrivate ::submitAll() { if(cData.size() == 0) return false; QHashIterator<int,QString> it(cData); while(it.hasNext()) { it.next(); if(it.value() == "true") { r->modifyRow(it.key(),"checked",it.value()); } } return true; }
string RepoModel::getPatientTableCommand() { stringstream statement; Patient dummy; list<Property*>* props = dummy.getProperties(); bool first = true; statement << "CREATE TABLE " << Patient::TABLE_NAME << "("; for(list<Property*>::iterator it = props->begin(); it != props->end(); it++) { string name = (*it)->getName(); if(first) { if(name == "patientid") { statement << name << " INTEGER PRIMARY KEY"; } else { statement << name << " TEXT DEFAULT NULL"; } } else if(name == "patientid") { statement << ", " << name << " INTEGER PRIMARY KEY"; } else { statement << ", " << name << " TEXT DEFAULT NULL"; } first = false; } statement << ", " << OBJECT_TYPE_PROPERTY_NAME << " TEXT DEFAULT NULL"; statement << ");"; return statement.str(); }
/** * Helper function to loadModel * * @param afacility that will contain patients parsed in this step * * @param n is an xml node of the first patient in the facility * */ void StorageHandler::parseFacility(Facility* aFacility, QDomNode* n){ QDomElement e; QDomNode node; while( !n->isNull() ) { e = n->toElement(); QString healthCardNumber = e.attribute( "healthCardNumber", "1111111111" ); QString firstName = e.attribute( "firstName", "noFirstName" ); QString lastName = e.attribute( "lastName", "noLastName" ); int reqCare = e.attribute("reqCare", "0").toInt(); int occCare = e.attribute("occCare", "0").toInt(); QDate dateAdmitted = Convenience::fromXML(e.attribute("dateAdded", "2000-02-02")); Logger::infoMessage("storageHandler","parseWaitingList", "Patient added to a facility pName= ", firstName); Patient* p = new Patient(healthCardNumber, firstName, lastName, Convenience::intToCareType(reqCare)); p->setAdmissionDate(dateAdmitted); aFacility->addPatientToBed(p, Convenience::intToCareType(occCare)); node = e.nextSibling(); n = &(node); } }
Patient* LocalDatabasePatientDAL::fillPatient(char **reply, int row, int columns) { Patient *patient = new Patient(); patient->setDatabaseID(QString(reply[0 + row * columns]).toLongLong()); patient->setID(reply[1 + row * columns]); patient->setFullName(reply[2 + row * columns]); patient->setBirthDate(reply[3 + row * columns]); patient->setSex(reply[4 + row * columns]); return patient; }
void ScanningWindow::Show(Patient scanned_patient) { scanned_patient_ = scanned_patient; setWindowTitle("Scanning patient: " + scanned_patient.name() + " " + scanned_patient.surname()); show(); }
void CSVConverter::convertBGJ389(const QString& filename) { CSVFile file; if (!file.read(filename)) { return; } // skip header line file.parseNextLine(); while (!file.atEnd()) { QList<QVariant> data = file.parseNextLine(); if (data.size() < 10 || data.first().type() != QVariant::Int) continue; Patient pat; pat.surname = data[2].toString(); pat.firstName = data[3].toString(); pat.dateOfBirth = data[5].toDate(); pat.gender = (data[4].toString() == "m") ? Patient::Male : Patient::Female; if (!pat.isValid()) { qDebug() << "invalid patient" << pat.surname; continue; } QString entity = data[7].toString(); Pathology path; path.context = PathologyContextInfo(PathologyContextInfo::ScreeningBGJ398).id; if (entity == "NSCLC") path.entity = Pathology::PulmonarySquamous; else if (entity == "Mamma") path.entity = Pathology::Breast; else if (entity == "Bladder") path.entity = Pathology::TransitionalCell; else { qDebug() << "Unhandled entity" << entity; continue; } QString sampleOrigin = data[10].toString(); if (sampleOrigin == "Primär") { path.sampleOrigin = Pathology::Primary; } else if (sampleOrigin == "LK") { path.sampleOrigin = Pathology::LocalLymphNode; } else if (sampleOrigin.contains("Metastase")) { path.sampleOrigin = Pathology::Metastasis; } else { qDebug() << "Unhandled sampleOrigin" << sampleOrigin; continue; } QString result = data[15].toString(); bool hasAmplification; if (result.contains("neg")) { hasAmplification = false; } else if (result.contains("pos")) { hasAmplification = true; } else // "NA" { qDebug() << "invalid result" << result; continue; } Property prop; PathologyPropertyInfo info(PathologyPropertyInfo::Fish_FGFR1); ValueTypeCategoryInfo catInfo(info.valueType); prop.property = info.id; prop.value = catInfo.toPropertyValue(hasAmplification); path.properties << prop; //qDebug() << pat.surname << path.entity << path.sampleOrigin << hasAmplification; QList<Patient::Ptr> ps = PatientManager::instance()->findPatients(pat); Patient::Ptr p; if (ps.isEmpty()) { p = PatientManager::instance()->addPatient(pat); } else { p = ps.first(); } if (!p->hasDisease()) { p->diseases << Disease(); } p->diseases.first().pathologies << path; PatientManager::instance()->updateData(p, PatientManager::ChangedPathologyData | PatientManager::ChangedDiseaseMetadata | PatientManager::ChangedPatientProperties); } }
void CSVConverter::convertBestRx(const QString& filename) { CSVFile file; if (!file.read(filename)) { return; } // skip header line file.parseNextLine(); while (!file.atEnd()) { QList<QVariant> data = file.parseNextLine(); if (data.size() < 40 || data.first().toString().isEmpty()) continue; Patient pat; QStringList names = data[0].toString().split(',', QString::SkipEmptyParts); if (names.size() != 2) { qDebug() << "Failed to parse" << data[0]; continue; } pat.surname = names.first().trimmed(); pat.firstName = names.last().trimmed(); pat.dateOfBirth = data[5].toDate(); pat.gender = (data[10].toString() == "M") ? Patient::Male : Patient::Female; if (!pat.isValid()) { qDebug() << "invalid patient" << pat.surname; continue; } QString entity = data[7].toString(); Pathology path; path.context = PathologyContextInfo(PathologyContextInfo::BestRx).id; path.entity = Pathology::Breast; QDate date; QList<int> fields; fields << 17 << 21 << 25; foreach (int f, fields) { if (data[f].isValid() && data[f].type() == QVariant::Date) { path.date = data[f].toDate(); break; } } if (!path.date.isValid()) { qDebug() << "Pathology date not available" << pat.surname; //continue; } QString sampleOrigin = data[35].toString(); if (sampleOrigin.contains("Primär") || sampleOrigin.contains("Zytologie")) { path.sampleOrigin = Pathology::Primary; } else if (sampleOrigin == "LK") { path.sampleOrigin = Pathology::LocalLymphNode; } else if (sampleOrigin.contains("Metastase")) { path.sampleOrigin = Pathology::Metastasis; } else { qDebug() << "Unhandled sampleOrigin" << sampleOrigin; } // FGFR1 if (data[23].toString().contains("amplified", Qt::CaseInsensitive)) { bool fgfr1Amplified = data[18].toString() == "Amplified"; path.properties << toProperty(PathologyPropertyInfo::Fish_FGFR1, fgfr1Amplified); } // PIK3Ca mut. if (data[22].toString().contains("Wild Type") || data[22].toString().contains("Mutant")) { bool pik3mutant = data[22].toString().contains("Mutant"); QString mutation; if (pik3mutant) { mutation = data[22].toString().remove("Mutant").trimmed(); } path.properties << toProperty(PathologyPropertyInfo::Mut_PIK3CA_10_21, pik3mutant, mutation); } // PIK3ca Ampl. if (data[23].toString().contains("Amplified", Qt::CaseInsensitive)) { bool pik3Amplified = data[23].toString() == "Amplified"; path.properties << toProperty(PathologyPropertyInfo::Fish_PIK3CA, pik3Amplified); } // PTEN if (data[29].toString().contains("PTEN staining", Qt::CaseInsensitive)) { bool ptenLoss = data[29].toString().contains("PTEN loss"); path.properties << toProperty(PathologyPropertyInfo::IHC_PTEN, !ptenLoss); } // ER, PR, Her2 if (data[36].toString() == "+" || data[36].toString() == "-") { bool er = data[36].toString() == "+"; path.properties << toProperty(PathologyPropertyInfo::IHC_ER, er); } if (data[37].toString() == "+" || data[37].toString() == "-") { bool pr = data[37].toString() == "+"; path.properties << toProperty(PathologyPropertyInfo::IHC_PR, pr); } if (data[38].toString().contains("+") || data[38].toString() == "0") { int her2ihc = data[38].toString().remove("+").toInt(); path.properties << toProperty(PathologyPropertyInfo::IHC_HER2_DAKO, her2ihc); } if (data[39].toString().contains("amplified", Qt::CaseInsensitive)) { bool her2fish = data[39].toString() == "amplified"; path.properties << toProperty(PathologyPropertyInfo::Fish_HER2, her2fish); } /*qDebug() << pat.surname << pat.firstName; foreach (const Property& prop, path.properties) { PathologyPropertyInfo info = PathologyPropertyInfo::info(prop.property); ValueTypeCategoryInfo catInfo(info); qDebug() << info.label << catInfo.toString(catInfo.toValue(prop.value)) << prop.detail; }*/ QList<Patient::Ptr> ps = PatientManager::instance()->findPatients(pat); Patient::Ptr p; if (ps.isEmpty()) { p = PatientManager::instance()->addPatient(pat); } else { p = ps.first(); } if (!p->hasDisease()) { p->diseases << Disease(); } p->diseases.first().pathologies << path; if (!p->diseases.first().initialDiagnosis.isValid()) { bool ok; int year = data[31].toInt(&ok); if (ok) { p->diseases.first().initialDiagnosis = QDate(year, 1, 1); } } PatientManager::instance()->updateData(p, PatientManager::ChangedPathologyData | PatientManager::ChangedDiseaseMetadata | PatientManager::ChangedPatientProperties); } }
void Lobotomizer::charge_patient(Patient& patient) const { patient.pay_out(m_cost_per_use); return; }
/** I made too simple 'engine', I mean that it is totally randomized */ void Gynecologist::diagnose(Patient &patient){ std::cout << sizeof(possible_illnesses) / sizeof(possible_illnesses[0]); patient.setDiagnose(possible_illnesses[ (int) (static_cast <float>(y_years_of_practice * rand()) / (static_cast <float> (RAND_MAX / (sizeof(possible_illnesses) / sizeof(possible_illnesses[0]))))) % (sizeof(possible_illnesses) / sizeof(possible_illnesses[0]))]); }
bool operator==(const Patient& patientl, const Patient& patientr){ return patientl.getPatientNumber() == patientr.getPatientNumber(); }
/** * \author Jules Gorny - ALCoV team, ISIT, UMR 6284 UdA – CNRS **/ void fillPatientFromXMLFile(Patient &pat, QString xmlPath, Ui::MainWindow *ui) { addProgressMessage(ui,"Retrieving data from database...\n", Qt::black, "", false); QString tab = " "; QFile f(xmlPath); if(!f.open(QIODevice::ReadOnly)) addProgressMessage(ui,"Can't read the existing database.\n", Qt::red, "", true); QTextStream in(&f); Image* img = NULL; Study* study = NULL; Series* series = NULL; Extract* extr = NULL; File* file = NULL; while(!in.atEnd()) { QString line = in.readLine(); if( line.endsWith(">") && !line.contains("</") ) { //Image if( line.startsWith(tab + "<") ) { if( line.contains("<Property") ) { QString tag, tagName, value; int start = line.indexOf("tag=")+5, end = line.indexOf("\"", start); tag = line.mid(start, end-start); start = line.indexOf("tagName=")+9; end = line.indexOf("\"", start); tagName = line.mid(start, end-start); start = line.indexOf("value=")+7; end = line.indexOf("\"", start); value = line.mid(start, end-start); Property prop(tag, tagName, value); pat.addProperty(prop); } else { line = line.trimmed(); int start = line.indexOf("<")+1, end = line.lastIndexOf(">"); QString imgType = line.mid(start, end-start); img = new Image(imgType); pat.addImage(img); } } //Study else if( line.startsWith(tab + tab + "<") ) { line = line.trimmed(); study = new Study(); int start = line.indexOf("\"")+1, end = line.lastIndexOf("\""); QString descr = line.mid(start, end-start); study->setDescription(descr); img->addStudy(study); } //Series else if( line.startsWith(tab + tab + tab + "<") ) { if( line.contains("<Property") ) { QString tag, tagName, value; int start = line.indexOf("tag=")+5, end = line.indexOf("\"", start); tag = line.mid(start, end-start); start = line.indexOf("tagName=")+9; end = line.indexOf("\"", start); tagName = line.mid(start, end-start); start = line.indexOf("value=")+7; end = line.indexOf("\"", start); value = line.mid(start, end-start); Property prop(tag, tagName, value); study->addProperty(prop); } else if( line.contains("<Series") ) { line = line.trimmed(); series = new Series(); int start = line.indexOf("\"")+1, end = line.lastIndexOf("\""); QString descr = line.mid(start, end-start); series->setDescription(descr); study->addSeries(series); } } //Extract else if( line.startsWith(tab + tab + tab + tab + "<") ) { if( line.contains("<Property") ) { QString tag, tagName, value; int start = line.indexOf("tag=")+5, end = line.indexOf("\"", start); tag = line.mid(start, end-start); start = line.indexOf("tagName=")+9; end = line.indexOf("\"", start); tagName = line.mid(start, end-start); start = line.indexOf("value=")+7; end = line.indexOf("\"", start); value = line.mid(start, end-start); Property prop(tag, tagName, value); series->addProperty(prop); } else if( line.contains("<Extract") ) { line = line.trimmed(); int start = line.indexOf("\"")+1, end = line.lastIndexOf("\""); extr = new Extract(line.mid(start, end-start).toInt()); series->addExtract(extr); } } //File or Property (from Extract) else if( line.startsWith(tab + tab + tab + tab + tab + "<") ) { if( line.contains("<Property") ) { QString tag, tagName, value; int start = line.indexOf("tag=")+5, end = line.indexOf("\"", start); tag = line.mid(start, end-start); start = line.indexOf("tagName=")+9; end = line.indexOf("\"", start); tagName = line.mid(start, end-start); start = line.indexOf("value=")+7; end = line.indexOf("\"", start); value = line.mid(start, end-start); Property prop(tag, tagName, value); extr->addProperty(prop); } else if( line.contains("<File") ) { line = line.trimmed(); int start = line.indexOf("\"")+1, end = line.lastIndexOf("\""); QString location = line.mid(start, end-start); file = new File(location); extr->addFile(file); } } //Property else if( line.startsWith(tab + tab + tab + tab + tab + tab + "<") ) { line = line.trimmed(); QString tag, tagName, value; int start = line.indexOf("tag=")+5, end = line.indexOf("\"", start); tag = line.mid(start, end-start); start = line.indexOf("tagName=")+9; end = line.indexOf("\"", start); tagName = line.mid(start, end-start); start = line.indexOf("value=")+7; end = line.indexOf("\"", start); value = line.mid(start, end-start); Property prop(tag, tagName, value); file->addProperty(prop); } } } f.close(); }