Medial Code Documentation
|
A Class which creates registry based on readcode lists. More...
#include <MedRegistry.h>
Public Member Functions | |
void | init (MedRepository &rep, int start_dur, int end_durr, int max_repo, const vector< RegistrySignal * > signal_conditions, const string &skip_pid_file="", const unordered_map< int, int > *pid_to_censor_dates=NULL) |
The init function in code API. | |
int | init (map< string, string > &map) |
the initializtion params. | |
void | clear_create_variables () |
clears the signal_filters | |
void | get_registry_records (int pid, int bdate, vector< UniversalSigVec_mem > &usv, vector< MedRegistryRecord > &results) |
![]() | |
void | write_text_file (const string &file_path) const |
Writes the file to text file in tab delimeted format: PID, Start_Date, End_Date, min_allowed_date, max_allowed_date, Age, RegistryValue. | |
void | read_text_file (const string &file_path) |
Reads the file in text format in tab delimeted. | |
void | create_registry (MedPidRepository &dataManager, medial::repository::fix_method method=medial::repository::fix_method::none, vector< RepProcessor * > *rep_processors=NULL) |
Creates vector of registry using already initialized MedPidRepository with signals in parallel manner for each patient. | |
void | get_registry_creation_codes (vector< string > &signal_codes) const |
returns the signal codes used to create the registry - to load from rep | |
void | get_registry_use_codes (vector< string > &signal_codes) const |
returns the signal codes used to create the registry - to use in create_registry command as input | |
void | get_pids (vector< int > &pids) const |
returns all patients ids from registry - unique patient ids | |
void | merge_records () |
Merges registry record with same registry values (and continues in time) | |
void * | new_polymorphic (string dname) |
for polymorphic classes that want to be able to serialize/deserialize a pointer * to the derived class given its type one needs to implement this function to return a new to the derived class given its type (as in my_type) | |
MedRegistry () | |
Default Ctor. | |
virtual bool | get_pid_records (PidRec &rec, int bDateCode, const vector< int > &used_sigs, vector< MedRegistryRecord > &results) |
void | set_rep_for_init (MedRepository &rep) |
Sets Repository object to initialize all registry object, if not given will try to use repository path to read and initialize repository. | |
![]() | |
virtual int | version () const |
Relevant for serializations. | |
virtual string | my_class_name () const |
For better handling of serializations it is highly recommended that each SerializableObject inheriting class will implement the next method. | |
virtual void | serialized_fields_name (vector< string > &field_names) const |
The names of the serialized fields. | |
virtual void | pre_serialization () |
virtual void | post_deserialization () |
virtual size_t | get_size () |
Gets bytes sizes for serializations. | |
virtual size_t | serialize (unsigned char *blob) |
Serialiazing object to blob memory. return number ob bytes wrote to memory. | |
virtual size_t | deserialize (unsigned char *blob) |
Deserialiazing blob to object. returns number of bytes read. | |
size_t | serialize_vec (vector< unsigned char > &blob) |
size_t | deserialize_vec (vector< unsigned char > &blob) |
virtual size_t | serialize (vector< unsigned char > &blob) |
virtual size_t | deserialize (vector< unsigned char > &blob) |
virtual int | read_from_file (const string &fname) |
read and deserialize model | |
virtual int | write_to_file (const string &fname) |
serialize model and write to file | |
virtual int | read_from_file_unsafe (const string &fname) |
read and deserialize model without checking version number - unsafe read | |
int | init_from_string (string init_string) |
Init from string. | |
int | init_params_from_file (string init_file) |
int | init_param_from_file (string file_str, string ¶m) |
int | update_from_string (const string &init_string) |
virtual int | update (map< string, string > &map) |
Virtual to update object from parsed fields. | |
virtual string | object_json () const |
Data Fields | |
int | start_buffer_duration |
the duration buffer form start | |
int | end_buffer_duration |
the duration buffer from last date | |
int | max_repo_date |
the maximal date for the repository | |
bool | allow_prediciton_in_case |
If True will allow to give prediciton after\in case time range. | |
bool | seperate_cases |
If true will seperate each "case" time zone. | |
vector< RegistrySignal * > | signal_filters |
the signal filters | |
ADD_SERIALIZATION_FUNCS(time_unit, registry_records, start_buffer_duration, end_buffer_duration, max_repo_date, allow_prediciton_in_case, seperate_cases) private unordered_map< int, int > | pid_to_max_allowed |
< black list of patients mask | |
bool | init_called |
a flag to mark that init was called | |
![]() | |
vector< MedRegistryRecord > | registry_records |
the registry records vector | |
int | time_unit |
The time unit. | |
Additional Inherited Members | |
![]() | |
static MedRegistry * | make_registry (const string ®istry_type, const string &init_str="") |
creates registry type and initialize it if init_str is not empty Use "binary" for MedRegistryCodesList and "categories" for MedRegistryCategories. | |
static MedRegistry * | make_registry (const string ®istry_type, MedRepository &rep, const string &init_str="") |
creates registry type and initialize it if init_str is not empty Use "binary" for MedRegistryCodesList and "categories" for MedRegistryCategories. | |
static MedRegistry * | create_registry_full (const string ®istry_type, const string &init_str, const string &repository_path, MedModel &model_with_rep_processor, medial::repository::fix_method method=medial::repository::fix_method::none) |
Creates vector of registry records - handles everything for you in parallel manner for each patient - uses create_registry. | |
![]() | |
vector< string > | signalCodes_names |
the signals codes by name | |
bool | need_bdate |
If true Bdate is also used in registry creation. | |
medial::repository::fix_method | resolve_conlicts = medial::repository::fix_method::none |
resolve conflicts in registry method | |
MedRepository * | rep_for_init = NULL |
repository pointer to init dicts | |
A Class which creates registry based on readcode lists.
Important: must be initialized by init_lists first
|
virtual |
clears the signal_filters
Reimplemented from MedRegistry.
|
virtual |
Reimplemented from MedRegistry.
|
virtual |
the initializtion params.
it has also "config_signals_rules", "pid_to_censor_dates", "rep" file paths.
rep | the repository path |
pid_to_censor_dates | file path to pid censors. each line is pid TAB censor_date |
config_signals_rules | file path to RegistrySignal rules. parsing is done with MedRegistryCodesList::parse_registry_rules The parsed fields from init command. if (it->first == "rep")
rep_path = it->second;
else if (it->first == "start_buffer_duration")
start_buffer_duration = stoi(it->second);
else if (it->first == "end_buffer_duration")
end_buffer_duration = stoi(it->second);
else if (it->first == "max_repo_date")
max_repo_date = stoi(it->second);
else if (it->first == "allow_prediciton_in_case")
allow_prediciton_in_case = stoi(it->second) > 0;
else if (it->first == "seperate_cases")
seperate_cases = stoi(it->second) > 0;
else if (it->first == "pid_to_censor_dates") {
ifstream fr(it->second);
if (!fr.good())
MTHROW_AND_ERR("Error in MedRegistryCodesList::init - unable to open %s for reading.",
it->second.c_str());
string line;
while (getline(fr, line)) {
boost::trim(line);
if (line.empty() || line.at(0) == '#')
continue;
vector<string> tokens;
boost::split(tokens, line, boost::is_any_of("\t"));
if (tokens.size() != 2)
MTHROW_AND_ERR("Error in MedRegistryCodesList::init - in parsing pid_to_censor_dates file"
" - %s excpeting TAB for line:\n%s\n", it->second.c_str(), line.c_str());
pid_to_max_allowed[stoi(tokens[0])] > stoi(tokens[1]))
pid_to_max_allowed[stoi(tokens[0])] = stoi(tokens[1]);
}
fr.close();
}
else if (it->first == "config_signals_rules")
registry_file_path = it->second;
else
MTHROW_AND_ERR("Error in MedRegistryCodesList::init - Unsupported init param \"%s\"\n", it->first.c_str());
int start_buffer_duration the duration buffer form start Definition MedRegistry.h:363 int end_buffer_duration the duration buffer from last date Definition MedRegistry.h:364 bool seperate_cases If true will seperate each "case" time zone. Definition MedRegistry.h:367 ADD_SERIALIZATION_FUNCS(time_unit, registry_records, start_buffer_duration, end_buffer_duration, max_repo_date, allow_prediciton_in_case, seperate_cases) private unordered_map< int, int > pid_to_max_allowed < black list of patients mask Definition MedRegistry.h:414 int max_repo_date the maximal date for the repository Definition MedRegistry.h:365 bool allow_prediciton_in_case If True will allow to give prediciton after\in case time range. Definition MedRegistry.h:366 |
Reimplemented from SerializableObject.
void MedRegistryCodesList::init | ( | MedRepository & | rep, |
int | start_dur, | ||
int | end_durr, | ||
int | max_repo, | ||
const vector< RegistrySignal * > | signal_conditions, | ||
const string & | skip_pid_file = "" , |
||
const unordered_map< int, int > * | pid_to_censor_dates = NULL |
||
) |
The init function in code API.
rep | initialized repository with MedDictionry for initialization |
start_dur | a minimal time for patient to enter registry from first signal after birth |
end_durr | a minimal time for patient to leave registry from last signal |
max_repo | the last date in the repositry - censor after this date |
signal_conditions | vector of rules to calc when we turn patient into case |
skip_pid_file | a file with blacklist of patient ids to skip |
pid_to_censor_dates | an object to map between each patient and censor date for him |
ADD_SERIALIZATION_FUNCS (time_unit, registry_records, start_buffer_duration, end_buffer_duration, max_repo_date, allow_prediciton_in_case, seperate_cases) private unordered_map<int, int> MedRegistryCodesList::pid_to_max_allowed |
< black list of patients mask
max date allowed to each pid constrain