Files
DCMV/DIDKit/App/DICOMPropertiesStore.cpp
2022-09-23 13:13:41 +08:00

67 lines
2.0 KiB
C++

//
// Created by Krad on 2022/9/23.
//
#include "DICOMPropertiesStore.h"
#include "IO/DICOM/ExtendMedicalImageProperties.h"
void DICOMPropertiesStore::addProperty(ExtendMedicalImageProperties *property) {
std::string patient_name = property->GetPatientName();
std::string study_uid = property->GetStudyUID();
std::string series_uid = property->GetSeriesUID();
//patient level
PatientInfo_t* patient = nullptr;
//get from store
if (m_patients.count(patient_name)>0){
patient = m_patients[patient_name];
}
else{
//create new
patient = new PatientInfo_t();
patient->patient_name = property->GetPatientName();
patient->birth_date = property->GetPatientBirthDate();
patient->studies = new StudiesMapType();
m_patients[property->GetPatientID()] = patient;
}
StudyInfo_t* study = nullptr;
//get from store
if (patient->studies->count(study_uid)>0){
study = patient->studies->at(study_uid);
}
else{
//create new
study = new StudyInfo_t();
patient->studies->insert({study_uid, study});
study->study_description = property->GetStudyDescription();
study->study_date = property->GetStudyDate();
study->study_time = property->GetStudyTime();
study->series = new SeriesMapType();
}
//TODO:need add Image set logic
if (study->series->count(series_uid)>0){
study->series->at(series_uid)->insert({property->GetUniqueID(),property});
property->Register(m_Holder);
}
else {
ImageSetMapType* v = new ImageSetMapType;
v->insert({property->GetUniqueID(),property});
study->series->insert({series_uid,v});
property->Register(m_Holder);
}
}
void DICOMPropertiesStore::reset() {
m_patients.clear();
if (m_Holder)m_Holder->Delete();
m_Holder = vtkObject::New();
}
DICOMPropertiesStore::DICOMPropertiesStore() {
m_Holder = vtkObject::New();
}
DICOMPropertiesStore::~DICOMPropertiesStore() {
if (m_Holder)m_Holder->Delete();
}