Skip to content
Snippets Groups Projects
Commit 850bd595 authored by Jakub Dylag's avatar Jakub Dylag
Browse files

rename error log columns, moved omop code definitions to parse.py

parent 3c0f4c4a
No related branches found
No related tags found
No related merge requests found
......@@ -24,8 +24,8 @@ def log_invalid_code(codes, mask, code_type=None, file_path=None, cause=None):
# print("ERROR WITH CODES", file_path, codes[~mask])
errors = pd.DataFrame([])
errors["CODE"] = codes[~mask].astype(str)
errors["CODE_TYPE"] = code_type
errors["CONCEPT"] = codes[~mask].astype(str)
errors["VOCABULARY"] = code_type
errors["SOURCE"] = file_path
errors["CAUSE"] = cause
......
......@@ -17,6 +17,7 @@ from parse import Opcs4_code
from parse import Atc_code
from parse import Med_code
from parse import code_types
from parse import omop_vocab_types
pd.set_option('mode.chained_assignment', None)
......@@ -356,20 +357,9 @@ def run_all(mapping_file, target_code_type,
if output_path == "atlas":
#Export to DB
db_path = "codes/omop_54.sqlite"
vocab_output = "MELDB"
vocab_types = {
"read2_code": "Read",
"read3_code": None,
"icd10_code": "ICD10CM",
"snomed_code": "SNOMED",
"opcs4_code": "OPCS4",
"atc_code": "ATC",
"med_code": None,
"cprd_code": None,
}
omop_publish_concept_sets(out, db_path, vocab_output, vocab_types[target_code_type])
vocab_output = "MELDB" #TODO: parameterise output name
omop_publish_concept_sets(out, db_path, vocab_output, omop_vocab_types[target_code_type])
else:
# export as CSV to /output
out.to_csv(output_path, index=False)
......@@ -379,7 +369,7 @@ def run_all(mapping_file, target_code_type,
if os.path.exists(log_errors_path):
error_df = pd.read_csv(log_errors_path)
error_df = error_df.drop_duplicates() #Remove Duplicates from Error file
error_df = error_df.sort_values(by=["SOURCE", "VOCABULARY", "CODE"])
error_df = error_df.sort_values(by=["SOURCE", "VOCABULARY", "CONCEPT"])
error_df.to_csv(log_errors_path, index=False)
......
......@@ -354,3 +354,14 @@ code_types = {
"med_code": Med_code,
"cprd_code": Cprd_code,
}
omop_vocab_types = {
"read2_code": "Read",
"read3_code": None,
"icd10_code": "ICD10CM",
"snomed_code": "SNOMED",
"opcs4_code": "OPCS4",
"atc_code": "ATC",
"med_code": None,
"cprd_code": None,
}
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment