Medial Code Documentation
Loading...
Searching...
No Matches
Public Member Functions | Data Fields
RepCreateRegistry Class Reference
Inheritance diagram for RepCreateRegistry:
RepProcessor SerializableObject

Public Member Functions

int init (map< string, string > &mapper)
 Init from map.
 
void init_lists ()
 Required/Affected signals.
 
void post_deserialization ()
 
void init_tables (MedDictionarySections &dict, MedSignals &sigs)
 Init required tables : Should be implemented for inheriting classes that have such tables.
 
int _learn (MedPidRepository &rep, MedSamples &samples, vector< RepProcessor * > &prev_processors)
 In this class there's never learning - we return 0 immediately.
 
int _apply (PidDynamicRec &rec, vector< int > &time_points, vector< vector< float > > &attributes_mat)
 apply processing on a single PidDynamicRec at a set of time-points : Should be implemented for all inheriting classes
 
void get_required_signal_categories (unordered_map< string, vector< string > > &signal_categories_in_use) const
 returns for each used signal it's used categories
 
void make_summary ()
 
void init_ht_registry_tables (MedDictionarySections &dict, MedSignals &sigs)
 
void ht_registry_apply (PidDynamicRec &rec, vector< int > &time_points, int iver, vector< UniversalSigVec > &usvs, vector< vector< float > > &all_v_vals, vector< vector< int > > &all_v_times, vector< int > &final_sizes)
 
void ht_init_defaults ()
 
void fillLookupTableForHTDrugs (MedDictionary &dict, vector< char > &lut, vector< string > &sets, char val)
 
void buildLookupTableForHTDrugs (MedDictionary &dict, vector< char > &lut)
 
void init_dm_registry_tables (MedDictionarySections &dict, MedSignals &sigs)
 
void dm_registry_apply (PidDynamicRec &rec, vector< int > &time_points, int iver, vector< UniversalSigVec > &usvs, vector< vector< float > > &all_v_vals, vector< vector< int > > &all_v_times, vector< int > &final_sizes)
 
void init_proteinuria_registry_tables (MedDictionarySections &dict, MedSignals &sigs)
 
void proteinuria_registry_apply (PidDynamicRec &rec, vector< int > &time_points, int iver, vector< UniversalSigVec > &usvs, vector< vector< float > > &all_v_vals, vector< vector< int > > &all_v_times, vector< int > &final_sizes)
 
void init_ckd_registry_tables (MedDictionarySections &dict, MedSignals &sigs)
 
void ckd_registry_apply (PidDynamicRec &rec, vector< int > &time_points, int iver, vector< UniversalSigVec > &usvs, vector< vector< float > > &all_v_vals, vector< vector< int > > &all_v_times, vector< int > &final_sizes)
 
void custom_registry_apply (PidDynamicRec &rec, vector< int > &time_points, int iver, const vector< UniversalSigVec > &usvs, vector< vector< float > > &all_v_vals, vector< vector< int > > &all_v_times, vector< int > &final_sizes)
 
- Public Member Functions inherited from RepProcessor
virtual void clear ()
 
virtual int init (void *params)
 initialize from a params object : Should be implemented for inheriting classes that have parameters
 
virtual void init_defaults ()
 initialize to default values : Should be implemented for inheriting classes that have parameters
 
virtual void set_signal (const string &_signalName)
 set signal-name : Should be implemented for inheriting classes that have signalName
 
virtual void set_signal_ids (MedSignals &sigs)
 set signal-ids : Should be implemented for inheriting classes that have signalId
 
virtual void get_required_signal_names (unordered_set< string > &signalNames)
 Append required signal names to set : parent function just uses req_signals.
 
virtual void get_required_signal_names (unordered_set< string > &signalNames, unordered_set< string > preReqSignals)
 Append required signal names to set only if processor is actually required to produce any of preReqSignals : parent function just uses req_signals.
 
virtual void set_required_signal_ids (MedDictionarySections &dict)
 Fill req_signal_ids : parent function just fills from req_signals.
 
virtual void add_virtual_signals (map< string, int > &_virtual_signals, map< string, string > &_virtual_signals_generic) const
 rep processors CREATING virtual signals need to implement this: adding their signals to the pile
 
virtual void get_required_signal_ids (unordered_set< int > &signalIds)
 Append required signal names to set : parent function just uses req_signals.
 
virtual void get_required_signal_ids (unordered_set< int > &signalIds, unordered_set< int > preReqSignals)
 Append required signal names to set only if processor is actually required to produce any of preReqSignals : parent function just uses req_signals.
 
virtual void set_affected_signal_ids (MedDictionarySections &dict)
 Fill aff_signal_ids : parent function just fills from aff_signals.
 
bool is_signal_affected (int signalId)
 Check if a signal is affected by processor </summray>

Returns
true if affected, false if not

 
bool is_signal_affected (string &signalName)
 
virtual void fit_for_repository (MedPidRepository &rep)
 make changes to RepProcessor according to available signals in Repository
 
virtual void register_virtual_section_name_id (MedDictionarySections &dict)
 Register section id to section name of new virtual signals.
 
virtual bool filter (unordered_set< string > &reqSignals)
 Check if processor (and 'sub'-processors within) should be applied according to set of required signals </summray>

Returns
true if processor is not required and can be filtered, false otherwise

 
virtual void init_attributes ()
 Init attributes information : Should be implemented for inheriting classes that have attributes.
 
virtual int _conditional_learn (MedPidRepository &rep, MedSamples &samples, vector< RepProcessor * > &prev_processors, unordered_set< int > &neededSignalIds)
 learn processing model on a subset of samples only if required. Apply set of preceeding processors on DynamicPidRec before learning :
 
int learn (MedPidRepository &rep, MedSamples &samples, vector< RepProcessor * > &prev_processors)
 learn processing model on a subset of ids. Apply set of preceeding processors on DynamicPidRec before learning
 
int learn (MedPidRepository &rep)
 learn on all pids in repository, using fake samples - works only for repProcessors that ignore sample dates
 
int learn (MedPidRepository &rep, MedSamples &samples)
 learn on subset of samples without preceesing processors
 
virtual int conditional_learn (MedPidRepository &rep, MedSamples &samples, vector< RepProcessor * > &prev_processors, unordered_set< int > &neededSignalIds)
 learn processing model on a subset of samples only if required. Apply set of preceeding processors on DynamicPidRec before learning :
 
int conditional_learn (MedPidRepository &rep, MedSamples &samples, unordered_set< int > &neededSignalIds)
 learn processing model on a subset of ids only if required without preceesing processors
 
virtual int _conditional_apply (PidDynamicRec &rec, vector< int > &time_points, unordered_set< int > &neededSignalIds, vector< vector< float > > &attributes_vals)
 apply processing on a single PidDynamicRec at a set of time-points only if required : May be implemented for inheriting classes
 
virtual int _apply_simple (PidDynamicRec &rec, vector< int > &time_points)
 
int apply (PidDynamicRec &rec, vector< int > &time_points, vector< vector< float > > &attributes_vals)
 apply processing on a single PidDynamicRec at a set of time-points
 
int conditional_apply (PidDynamicRec &rec, vector< int > &time_points, unordered_set< int > &neededSignalIds, vector< vector< float > > &attributes_vals)
 apply processing on a single PidDynamicRec at a set of time-points only if required : if any of the signals in neededSignalIds is actually affected by processor
 
int apply (PidDynamicRec &rec, MedIdSamples &samples)
 apply processing on a single PidDynamicRec at a set of time-points given by samples
 
int conditional_apply (PidDynamicRec &rec, MedIdSamples &samples, unordered_set< int > &neededSignalIds)
 apply processing on a single PidDynamicRec at a set of time-points given by samples only if required
 
int conditional_apply_without_attributes (PidDynamicRec &rec, const MedIdSamples &samples, unordered_set< int > &neededSignalIds)
 apply processing on a single PidDynamicRec at a set of time-points given by samples only if required, not affecting attributes
 
virtual void dprint (const string &pref, int rp_flag)
 used for debug prints, each inheriting class can overload this one to get a more precise debug print.
 
void * new_polymorphic (string derived_class_name)
 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)
 
size_t get_processor_size ()
 get size of processor + processor_type
 
size_t processor_serialize (unsigned char *blob)
 seialize processor + processor_type
 
virtual void print ()
 optional printing of processor
 
- Public Member Functions inherited from SerializableObject
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 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 &param)
 
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

RegistryTypes registry
 type of registry to create
 
vector< string > names
 name(s) of registry signal(s) to create
 
vector< string > signals
 Vector of required signals, to override default ones.
 
vector< string > registry_values
 values of registry (to appear in relevant section of dictionary)
 
int time_unit = -1
 time-unit of registry
 
bool verbose = false
 verbosity
 
bool ht_systolic_first = false
 
vector< string > ht_identifiers
 identifiers (ReadCodes) of HT
 
vector< string > chf_identifiers
 identifiers (ReadCodes) of CHF
 
vector< string > mi_identifiers
 identifiers (ReadCodes) of MI
 
vector< string > af_identifiers
 identifiers (ReadCodes) of AF
 
bool ht_identifiers_given = false
 
bool chf_identifiers_given = false
 
bool mi_identifiers_given = false
 
bool af_identifiers_given = false
 
vector< string > ht_drugs = { "ATC_C08C____","ATC_C07B____","ATC_C07C____","ATC_C07D____","ATC_C07F____","ATC_C07A_G__","ATC_C09B____","ATC_C09D____", "ATC_C02D_A01" }
 drugs indicative of HT
 
vector< string > ht_chf_drugs = { "ATC_C03_____" }
 drugs indicative of HT, unless CHF
 
vector< string > ht_dm_drugs = { "ATC_C09A____", "ATC_C09C____" }
 drugs indicative of HT, unless DM
 
vector< string > ht_extra_drugs = { "ATC_C07A_A__", "ATC_C07A_B__" }
 drugs indicative of HT, unless CHF/MI/AF.
 
int ht_drugs_gap = 120
 Gap (in days) from drug input to following indication.
 
string dm_drug_sig = "Drug"
 
vector< string > dm_drug_sets = { "ATC_A10_____" }
 
string dm_diagnoses_sig = "RC"
 
vector< string > dm_diagnoses_sets
 
string dm_glucose_sig = "Glucose"
 
string dm_hba1c_sig = "HbA1C"
 
int dm_diagnoses_severity = 4
 
int dm_bio_mode = 0
 
vector< string > urine_tests_categories
 
string ckd_egfr_sig = "eGFR_CKD_EPI"
 
string ckd_proteinuria_sig = "Proteinuria_State"
 
string registry_custom_type = ""
 
string registry_custom_args = ""
 
ADD_SERIALIZATION_FUNCS(processor_type, registry, names, signals, time_unit, req_signals, aff_signals, virtual_signals, virtual_signals_generic, registry_values, ht_identifiers, chf_identifiers, mi_identifiers, af_identifiers, ht_identifiers_given, chf_identifiers_given, mi_identifiers_given, af_identifiers_given, ht_drugs, ht_chf_drugs, ht_dm_drugs, ht_extra_drugs, ht_drugs_gap, dm_drug_sig, dm_drug_sets, dm_diagnoses_sig, dm_diagnoses_sets, dm_glucose_sig, dm_hba1c_sig, dm_diagnoses_severity, urine_tests_categories, ckd_egfr_sig, ckd_proteinuria_sig, registry_custom_type, registry_custom_args, custom_registry, ht_systolic_first) private int bDateCode = -1
 
vector< int > create_custom_input_sigs
 
string registry_name
 
int found_op_ht = 0
 
int num_ht_measurements = 0
 
const map< string, RegistryTypes > name2type = { { "dm" , REP_REGISTRY_DM },{ "ht", REP_REGISTRY_HT },{ "proteinuria", REP_REGISTRY_PROTEINURIA },{ "ckd", REP_REGISTRY_CKD },{ "custom", REP_REGISTRY_CUSTOM } }
 registry name to type
 
const map< RegistryTypes, vector< pair< string, string > > > type2Virtuals
 
const map< RegistryTypes, vector< string > > type2reqSigs
 
set< int > sig_ids_s
 
vector< int > sig_ids
 ids of signals used as input by the calculator (for faster usage at run time: save name conversions)
 
vector< int > virtual_ids
 ids of signals created by the calculator (for faster usage at run time: save name conversions)
 
int dm_drug_idx = -1
 
int dm_diagnoses_idx = -1
 
vector< char > dm_drug_lut
 
vector< char > dm_diagnoses_lut
 
int dm_glucose_idx = -1
 
int dm_hba1c_idx = -1
 
vector< string > dm_reg_values = { "DM_Registry_Non_diabetic", "DM_Registry_Pre_diabetic", "DM_Registry_Diabetic" }
 
vector< string > proteinuria_reg_values = { "Proteinuria_Normal", "Proteinuria_Medium" , "Proteinuria_Severe" }
 
vector< RegistryDecisionRangesproteinuria_ranges
 
vector< string > ckd_reg_values = { "CKD_State_Normal" , "CKD_State_Level_1", "CKD_State_Level_2", "CKD_State_Level_3", "CKD_State_Level_4" }
 
int ckd_egfr_idx = -1
 
int ckd_proteinuria_idx = -1
 
vector< int > signal_time_units
 time-units of all signals
 
vector< string > ht_def_values = { "HT_Registry_Non_Hypertensive","HT_Registry_Hypertensive" }
 
int bp_idx = 0
 
int rc_idx = 1
 
int drug_idx = 2
 
int bdate_idx = 3
 
int dm_registry_idx = 4
 
vector< char > htLut
 
vector< char > chfLut
 
vector< char > miLut
 
vector< char > afLut
 
vector< char > htDrugLut
 
- Data Fields inherited from RepProcessor
RepProcessorTypes processor_type = REP_PROCESS_LAST
 type of repository processor
 
unordered_set< string > req_signals
 names of signals required for processsing
 
unordered_set< int > req_signal_ids
 ids of signals required for processing
 
unordered_set< string > aff_signals
 names of signals affected by processing
 
unordered_set< int > aff_signal_ids
 ids of signals affected by processing
 
bool unconditional = false
 indicated that processor should ALWAYS be applied
 
vector< string > attributes
 attributes generated by the processor (optional)
 
vector< pair< string, int > > virtual_signals
 virtual signals are created only in rep processors but can be used by any rep processor that comes after or any feture generator as a regular signal.
 
vector< pair< string, string > > virtual_signals_generic
 

Additional Inherited Members

- Static Public Member Functions inherited from RepProcessor
static RepProcessormake_processor (string name)
 create a new repository processor from name
 
static RepProcessormake_processor (string type, string params)
 create a new repository processor from name and a parameters string
 
static RepProcessormake_processor (RepProcessorTypes type)
 create a new repository processor from type
 
static RepProcessormake_processor (RepProcessorTypes type, string params)
 create a new repository processor from type and a parameters string
 
static RepProcessorcreate_processor (string &params)
 create a new repository processor from parameters string which contains rp_type
 

Member Function Documentation

◆ _apply()

int RepCreateRegistry::_apply ( PidDynamicRec rec,
vector< int > &  time_points,
vector< vector< float > > &  attributes_mat 
)
virtual

apply processing on a single PidDynamicRec at a set of time-points : Should be implemented for all inheriting classes

Reimplemented from RepProcessor.

◆ _learn()

int RepCreateRegistry::_learn ( MedPidRepository rep,
MedSamples samples,
vector< RepProcessor * > &  prev_processors 
)
inlinevirtual

In this class there's never learning - we return 0 immediately.

Reimplemented from RepProcessor.

◆ get_required_signal_categories()

void RepCreateRegistry::get_required_signal_categories ( unordered_map< string, vector< string > > &  signal_categories_in_use) const
virtual

returns for each used signal it's used categories

Reimplemented from RepProcessor.

◆ init()

int RepCreateRegistry::init ( map< string, string > &  mapper)
virtual

Init from map.

if (field == "registry") registry_name = entry.second;
else if (field == "names") boost::split(names, entry.second, boost::is_any_of(","));
else if (field == "signals") boost::split(signals, entry.second, boost::is_any_of(","));
else if (field == "time_unit") time_unit = med_time_converter.string_to_type(entry.second);
else if (field == "registry_values") boost::split(registry_values, entry.second, boost::is_any_of(","));
else if (field == "verbose") verbose = stoi(entry.second);
// Diabetes
else if (field == "dm_drug_sig") dm_drug_sig = entry.second;
else if (field == "dm_drug_sets") {
//MLOG("drug_sets: %s\n", entry.second.c_str());
boost::split(dm_drug_sets, entry.second, boost::is_any_of(","));
}
else if (field == "dm_diagnoses_sig") dm_diagnoses_sig = entry.second;
else if (field == "dm_diagnoses_sets") boost::split(dm_diagnoses_sets, entry.second, boost::is_any_of(","));
else if (field == "dm_glucose_sig") dm_glucose_sig = entry.second;
else if (field == "dm_hba1c_sig") dm_hba1c_sig = entry.second;
else if (field == "dm_diagnoses_severity") dm_diagnoses_severity = stoi(entry.second);
else if (field == "dm_bio_mode") dm_bio_mode = stoi(entry.second);
// Hypertension
else if (field == "ht_identifiers") { boost::split(ht_identifiers, entry.second, boost::is_any_of(",")); ht_identifiers_given = true; }
else if (field == "chf_identifiers") { boost::split(chf_identifiers, entry.second, boost::is_any_of(",")); chf_identifiers_given = true; }
else if (field == "mi_identifiers") { boost::split(mi_identifiers, entry.second, boost::is_any_of(",")); mi_identifiers_given = true; }
else if (field == "af_identifiers") { boost::split(af_identifiers, entry.second, boost::is_any_of(",")); af_identifiers_given = true; }
else if (field == "ht_drugs") boost::split(ht_drugs, entry.second, boost::is_any_of(","));
else if (field == "ht_chf_drugs") boost::split(ht_chf_drugs, entry.second, boost::is_any_of(","));
else if (field == "ht_dm_drugs") boost::split(ht_dm_drugs, entry.second, boost::is_any_of(","));
else if (field == "ht_extra_drugs") boost::split(ht_extra_drugs, entry.second, boost::is_any_of(","));
else if (field == "ht_drugs_gap") ht_drugs_gap = stoi(entry.second);
else if (field == "ht_systolic_first") ht_systolic_first = stoi(entry.second) > 0;
// Prteinuria
else if (field == "urine_tests_categories") boost::split(urine_tests_categories, entry.second, boost::is_any_of("/"));
// ckd
else if (field == "ckd_egfr_sig") ckd_egfr_sig = entry.second;
else if (field == "ckd_proteinuria_sig") ckd_proteinuria_sig = entry.second;
//custom
else if (field == "registry_custom_type") registry_custom_type = entry.second;
else if (field == "registry_custom_args") registry_custom_args = entry.second;
else if (field == "rp_type") {}
else MTHROW_AND_ERR("Error in RepCreateRegistry::init - Unsupported param \"%s\"\n", field.c_str());
int string_to_type(const string &str)
Convert string to type.
Definition MedTime.cpp:358
vector< string > names
name(s) of registry signal(s) to create
Definition RepCreateRegistry.h:56
int ht_drugs_gap
Gap (in days) from drug input to following indication.
Definition RepCreateRegistry.h:78
vector< string > registry_values
values of registry (to appear in relevant section of dictionary)
Definition RepCreateRegistry.h:59
vector< string > af_identifiers
identifiers (ReadCodes) of AF
Definition RepCreateRegistry.h:70
vector< string > ht_drugs
drugs indicative of HT
Definition RepCreateRegistry.h:73
vector< string > ht_identifiers
identifiers (ReadCodes) of HT
Definition RepCreateRegistry.h:67
vector< string > ht_dm_drugs
drugs indicative of HT, unless DM
Definition RepCreateRegistry.h:75
vector< string > chf_identifiers
identifiers (ReadCodes) of CHF
Definition RepCreateRegistry.h:68
vector< string > signals
Vector of required signals, to override default ones.
Definition RepCreateRegistry.h:58
vector< string > ht_chf_drugs
drugs indicative of HT, unless CHF
Definition RepCreateRegistry.h:74
bool verbose
verbosity
Definition RepCreateRegistry.h:62
vector< string > ht_extra_drugs
drugs indicative of HT, unless CHF/MI/AF.
Definition RepCreateRegistry.h:76
vector< string > mi_identifiers
identifiers (ReadCodes) of MI
Definition RepCreateRegistry.h:69
int time_unit
time-unit of registry
Definition RepCreateRegistry.h:60

[RepCreateRegistry::init]

[RepCreateRegistry::init]

Reimplemented from RepProcessor.

◆ init_tables()

void RepCreateRegistry::init_tables ( MedDictionarySections dict,
MedSignals sigs 
)
virtual

Init required tables : Should be implemented for inheriting classes that have such tables.

Reimplemented from RepProcessor.

◆ make_summary()

void RepCreateRegistry::make_summary ( )
virtual

Reimplemented from RepProcessor.

◆ post_deserialization()

void RepCreateRegistry::post_deserialization ( )
virtual

Reimplemented from SerializableObject.

Field Documentation

◆ type2reqSigs

const map<RegistryTypes, vector<string> > RepCreateRegistry::type2reqSigs
Initial value:
= { { REP_REGISTRY_DM,{ "Glucose","HbA1C","Drug","RC" } },
{ REP_REGISTRY_HT,{ "BP","RC","Drug","BDATE","DM_Registry" } },
{ REP_REGISTRY_PROTEINURIA ,{ "Urine_Microalbumin", "UrineTotalProtein" , "UrineAlbumin" , "Urine_dipstick_for_protein" , "Urinalysis_Protein" , "Urine_Protein_Creatinine" , "UrineAlbumin_over_Creatinine" } },
{ REP_REGISTRY_CKD,{ "Proteinuria_State", "eGFR_CKD_EPI" } } }

◆ type2Virtuals

const map<RegistryTypes, vector<pair<string, string> > > RepCreateRegistry::type2Virtuals
Initial value:
= { { REP_REGISTRY_DM,{ { "DM_Registry", "T(l,l),V(f)" } } },
{ REP_REGISTRY_HT,{ { "HT_Registry", "T(l,l),V(f)" } } },
{ REP_REGISTRY_PROTEINURIA,{ { "Proteinuria_State", "T(i),V(f)" } } } ,
{ REP_REGISTRY_CKD,{ { "CKD_Registry", "T(i),V(f)" } } },
{ REP_REGISTRY_CUSTOM,{ { "CUSTOM_Registry", "T(l,l),V(f)" } } } }

◆ urine_tests_categories

vector<string> RepCreateRegistry::urine_tests_categories
Initial value:
= {
"Urine_Microalbumin:1:0,30:30,300:300,1000000",
"UrineTotalProtein:1:0,0.15:0.15,0.60:0.60,1000000",
"UrineAlbumin:1:0,30:30,300:300,1000000",
"Urine_dipstick_for_protein:0:Urine_dipstick_for_protein_normal:Urine_dipstick_for_protein_medium:Urine_dipstick_for_protein_severe",
"Urinalysis_Protein:0:Urinalysis_Protein_normal:Urinalysis_Protein_medium:Urinalysis_Protein_severe",
"Urine_Protein_Creatinine:1:0,15:15,100:100,1000000",
"UrineAlbumin_over_Creatinine:1:0,3.5:3.5,27:27,1000000" }

The documentation for this class was generated from the following files: