From 0f59f5dd785ba97cce27102cc44814c6f528ec21 Mon Sep 17 00:00:00 2001 From: Paul-B98 <115164840+Paul-B98@users.noreply.github.com> Date: Sun, 17 Dec 2023 00:43:14 +0100 Subject: [PATCH] add pipeline --- icu_pipeline/pipeline.py | 27 +++++++++++++++++++++++++++ icu_pipeline/test.py | 23 +++++++++++++++++++++++ 2 files changed, 50 insertions(+) create mode 100644 icu_pipeline/pipeline.py create mode 100644 icu_pipeline/test.py diff --git a/icu_pipeline/pipeline.py b/icu_pipeline/pipeline.py new file mode 100644 index 0000000..e723a7f --- /dev/null +++ b/icu_pipeline/pipeline.py @@ -0,0 +1,27 @@ +from icu_pipeline.concept import AbstractSnomedConcept +from icu_pipeline.mapper.sink import AbstractSinkMapper, MappingFormat +from icu_pipeline.mapper.source import SourceMapperConfiguration, DataSource + + +class Pipeline: + def __init__( + self, + concepts: list[AbstractSnomedConcept], + sink_mapper: AbstractSinkMapper, + mapping_format: MappingFormat, + source_mapper_configs: dict[DataSource, SourceMapperConfiguration], + ) -> None: + self._concepts = concepts + self._sink_mapper = sink_mapper + self._mapping_format = mapping_format + self._source_mapper_configs = source_mapper_configs + + def transfrom(self): + for concept in self._concepts: + _concept = concept( + self._sink_mapper, + self._mapping_format, + self._source_mapper_configs, + ) + + _concept.map() diff --git a/icu_pipeline/test.py b/icu_pipeline/test.py new file mode 100644 index 0000000..5a684f9 --- /dev/null +++ b/icu_pipeline/test.py @@ -0,0 +1,23 @@ +from icu_pipeline.pipeline import ( + Pipeline, + DataSource, + MappingFormat, + SourceMapperConfiguration, +) +from icu_pipeline.mapper.sink.file import CSVFileSinkMapper +from icu_pipeline.concept.snomed import SerumCreatinine + +configs = { + DataSource.MIMIC: SourceMapperConfiguration( + "postgresql+psycopg://paul@localhost/mimiciv" + ), +} + +pipeline = Pipeline( + [SerumCreatinine], + CSVFileSinkMapper(), + MappingFormat.FHIR, + configs, +) + +pipeline.transfrom()