diff --git a/src/SymptomsCausedByVaccines/Analyzer.py b/src/SymptomsCausedByVaccines/Analyzer.py index 36b5577d978..8953fd1abe2 100644 --- a/src/SymptomsCausedByVaccines/Analyzer.py +++ b/src/SymptomsCausedByVaccines/Analyzer.py @@ -7,3 +7,6 @@ class Analyzer: def getSymptomsForVaccine(self, vaxType): return self.symptomByVaccine.loc[vaxType] + + def getVaccinesForSymptom(self, symptom): + return self.symptomByVaccine[symptom] diff --git a/src/SymptomsCausedByVaccines/AnalyzerTest.py b/src/SymptomsCausedByVaccines/AnalyzerTest.py index 6988d9c14c9..18c46ab852f 100644 --- a/src/SymptomsCausedByVaccines/AnalyzerTest.py +++ b/src/SymptomsCausedByVaccines/AnalyzerTest.py @@ -6,7 +6,6 @@ from SymptomsCausedByVaccines.Analyzer import Analyzer class AnalyzerTest(unittest.TestCase): - # input a vaccine name, and see which symptoms are strongest for it. def test_getSymptomsForVaccine(self): # Given symptomByVaccine = TestHelper.createDataFrame( @@ -31,3 +30,31 @@ class AnalyzerTest(unittest.TestCase): '17-hydroxyprogesterone': 0.4 })) + def test_getVaccinesForSymptom(self): + # Given + symptomByVaccine = TestHelper.createDataFrame( + columns = ['11-beta-hydroxylase deficiency'], + data = [ [0.6], + [0.3]], + index = pd.Index( + name = 'VAX_TYPE', + data = [ + '6VAX-F', + 'ADEN' + ])) + + analyzer = Analyzer(symptomByVaccine) + + # When + vaccinesForSymptom = analyzer.getVaccinesForSymptom('11-beta-hydroxylase deficiency') + + # Then + assert_series_equal( + vaccinesForSymptom, + TestHelper.createSeries( + name = '11-beta-hydroxylase deficiency', + data = { + '6VAX-F': 0.6, + 'ADEN': 0.3 + }, + indexName = 'VAX_TYPE')) diff --git a/src/TestHelper.py b/src/TestHelper.py index 8069e409015..fe0f1634edd 100644 --- a/src/TestHelper.py +++ b/src/TestHelper.py @@ -6,3 +6,9 @@ class TestHelper: @staticmethod def createDataFrame(columns, data, dtypes={}, **kwargs): return pd.DataFrame(columns=columns, data=data, **kwargs).astype(dtypes) + + @staticmethod + def createSeries(indexName, **kwargs): + series = pd.Series(**kwargs) + series.index.name = indexName + return series diff --git a/src/help.txt b/src/help.txt index d06173d2974..ceef7ae7be8 100644 --- a/src/help.txt +++ b/src/help.txt @@ -5,6 +5,9 @@ FK-FIXME: FK-TODO: - add google captcha to batchCodeTable.html - Symptomhistogramm +- create an interface where people + 1. could input a symptom, and see which vaccines are worst, or + 2. input a vaccine name, and see which symptoms are strongest for it. anacron job: sudo cp src/intensivstationen_howbadismybatch.sh /etc/cron.daily/intensivstationen_howbadismybatch