Exemplo n.º 1
0
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;
}
Exemplo n.º 2
0
void ScanningWindow::Show(Patient scanned_patient)
{
  scanned_patient_ = scanned_patient;
  setWindowTitle("Scanning patient: " + scanned_patient.name() + " " + scanned_patient.surname());
  show();
}