This repository has been archived by the owner on Jan 26, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #93 from aidh-ms/issue/76-rework-mimic-dosage-defi…
…nition Rework MIMIC
- Loading branch information
Showing
6 changed files
with
210 additions
and
23 deletions.
There are no files selected for viewing
Submodule conceptbase
updated
12 files
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
from typing import Callable | ||
from pandera.typing import Series, DataFrame | ||
from icu_pipeline.schema.fhir import Quantity | ||
from icu_pipeline.unit.converter import BaseConverter | ||
|
||
|
||
class LengthConverter(BaseConverter): | ||
SI_UNIT = "m" | ||
AVAILABLE_UNITS = ["cm", "m"] | ||
|
||
def _convertToSI( | ||
self, | ||
source_unit: str, | ||
data: Series[Quantity], | ||
dependencies: dict[str, DataFrame], | ||
): | ||
convert: Callable[[float], float] = lambda v: v | ||
# Data can have any Unit and will be transformed to m | ||
match source_unit: | ||
# Already SI-Unit | ||
case self.SI_UNIT: | ||
return data | ||
|
||
# Actual Conversions from case to cm | ||
case "cm": | ||
convert = lambda v: v * 100 | ||
|
||
# Not Implemented | ||
case _: | ||
raise NotImplementedError | ||
|
||
return data.apply( | ||
lambda q: Quantity(value=convert(q["value"]), unit=self.SI_UNIT) | ||
) | ||
|
||
def _convertToTarget( | ||
self, sink_unit: str, data: Series[Quantity], dependencies: dict[str, DataFrame] | ||
): | ||
convert: Callable[[float], float] = lambda v: v | ||
# Data uses m and can be transformed in to any Unit | ||
match sink_unit: | ||
# Already SI-Unit | ||
case self.SI_UNIT: | ||
return data | ||
|
||
# Actual Conversions | ||
case "cm": | ||
convert = lambda v: v / 100 | ||
|
||
# Not Implemented | ||
case _: | ||
raise NotImplementedError | ||
|
||
return data.apply(lambda q: Quantity(value=convert(q["value"]), unit=sink_unit)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
from typing import Callable | ||
from pandera.typing import Series, DataFrame | ||
from icu_pipeline.schema.fhir import Quantity | ||
from icu_pipeline.unit.converter import BaseConverter | ||
|
||
|
||
class NoUnitConverter(BaseConverter): | ||
SI_UNIT = "" | ||
AVAILABLE_UNITS = [ | ||
"" | ||
] # year is amiguous (365, 366 days). TODO - Ignore since error is small and mimic does it anyway? | ||
# REQUIRED_CONCEPTS = ["SystolicBloodPressure"] | ||
|
||
def _convertToSI( | ||
self, | ||
source_unit: str, | ||
data: Series[Quantity], | ||
dependencies: dict[str, DataFrame], | ||
): | ||
convert: Callable[[float], float] = lambda v: v | ||
# Data can use any unit and will be transformed to Hz | ||
match source_unit: | ||
# Already SI-Unit | ||
case self.SI_UNIT: | ||
return data | ||
|
||
# Actual Conversions | ||
case "": | ||
convert = lambda v: v | ||
|
||
# Not Implemented | ||
case _: | ||
raise NotImplementedError | ||
|
||
return data.apply( | ||
lambda q: Quantity(value=convert(q["value"]), unit=self.SI_UNIT) | ||
) | ||
|
||
def _convertToTarget( | ||
self, sink_unit: str, data: Series[Quantity], dependencies: dict[str, DataFrame] | ||
): | ||
convert: Callable[[float], float] = lambda v: v | ||
# Data contains Hz values and can be transformed into any Unit | ||
match sink_unit: | ||
# Already SI-Unit | ||
case self.SI_UNIT: | ||
return data | ||
|
||
# Actual Conversions | ||
case "": | ||
convert = lambda v: v | ||
|
||
# Not Implemented | ||
case _: | ||
raise NotImplementedError | ||
|
||
return data.apply(lambda q: Quantity(value=convert(q["value"]), unit=sink_unit)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
from typing import Callable | ||
from pandera.typing import Series, DataFrame | ||
from icu_pipeline.schema.fhir import Quantity | ||
from icu_pipeline.unit.converter import BaseConverter | ||
|
||
|
||
class LengthConverter(BaseConverter): | ||
SI_UNIT = "l" | ||
AVAILABLE_UNITS = ["l", "ml"] | ||
|
||
def _convertToSI( | ||
self, | ||
source_unit: str, | ||
data: Series[Quantity], | ||
dependencies: dict[str, DataFrame], | ||
): | ||
convert: Callable[[float], float] = lambda v: v | ||
# Data can have any Unit and will be transformed to m | ||
match source_unit: | ||
# Already SI-Unit | ||
case self.SI_UNIT: | ||
return data | ||
|
||
# Actual Conversions from case to cm | ||
case "ml": | ||
convert = lambda v: v * 100 | ||
|
||
# Not Implemented | ||
case _: | ||
raise NotImplementedError | ||
|
||
return data.apply( | ||
lambda q: Quantity(value=convert(q["value"]), unit=self.SI_UNIT) | ||
) | ||
|
||
def _convertToTarget( | ||
self, sink_unit: str, data: Series[Quantity], dependencies: dict[str, DataFrame] | ||
): | ||
convert: Callable[[float], float] = lambda v: v | ||
# Data uses m and can be transformed in to any Unit | ||
match sink_unit: | ||
# Already SI-Unit | ||
case self.SI_UNIT: | ||
return data | ||
|
||
# Actual Conversions | ||
case "ml": | ||
convert = lambda v: v / 100 | ||
|
||
# Not Implemented | ||
case _: | ||
raise NotImplementedError | ||
|
||
return data.apply(lambda q: Quantity(value=convert(q["value"]), unit=sink_unit)) |