Merge branch 'main' of https://github.com/KnollFrank/HowBadIsMyBatch
This commit is contained in:
@@ -0,0 +1,13 @@
|
||||
import shutil
|
||||
from IOUtils import IOUtils
|
||||
|
||||
def saveDrugDescriptionsForPathologies(drugDescrByPathology, directory):
|
||||
shutil.rmtree(directory, ignore_errors = True)
|
||||
filenameByPathology = {}
|
||||
i = 0
|
||||
for pathology, drugDescr in drugDescrByPathology.items():
|
||||
i += 1
|
||||
filenameByPathology[pathology] = f'{i}'
|
||||
drugDescr['PATHOLOGY'] = pathology
|
||||
IOUtils.saveDictAsJson(drugDescr, f'{directory}/{i}.json')
|
||||
return filenameByPathology
|
||||
28
src/DrugsForPathologies/HtmlUpdater.py
Normal file
28
src/DrugsForPathologies/HtmlUpdater.py
Normal file
@@ -0,0 +1,28 @@
|
||||
from bs4 import BeautifulSoup
|
||||
from HtmlTransformerUtil import HtmlTransformerUtil
|
||||
from DateProvider import DateProvider
|
||||
from SymptomsCausedByVaccines.HtmlUtils import getOptionsWithDefaultOption
|
||||
from SymptomsCausedByVaccines.OptionsSetter import OptionsSetter
|
||||
|
||||
|
||||
def updateHtmlFile(filenameByPathology, htmlFile):
|
||||
options = getOptionsWithDefaultOption(
|
||||
defaultOptionText = 'Select Pathology',
|
||||
values = list(filenameByPathology.keys()),
|
||||
filenameByValue = filenameByPathology)
|
||||
_saveOptions(
|
||||
options = options,
|
||||
htmlFile = htmlFile,
|
||||
selectElementId = 'pathologySelect')
|
||||
|
||||
|
||||
def _saveOptions(options, htmlFile, selectElementId):
|
||||
HtmlTransformerUtil().applySoupTransformerToFile(
|
||||
file=htmlFile,
|
||||
soupTransformer = lambda soup:
|
||||
BeautifulSoup(
|
||||
OptionsSetter().setOptions(
|
||||
html = str(soup),
|
||||
selectElementId = selectElementId,
|
||||
options = options),
|
||||
'lxml'))
|
||||
0
src/DrugsForPathologies/__init__.py
Normal file
0
src/DrugsForPathologies/__init__.py
Normal file
@@ -608,9 +608,94 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "439c055f",
|
||||
"id": "be72f509",
|
||||
"metadata": {},
|
||||
"source": []
|
||||
"source": [
|
||||
"# Drugs for Pathologies"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"id": "c8190125",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"import pandas as pd\n",
|
||||
"import os\n",
|
||||
"from DrugsForPathologies.DrugDescriptionsForPathologiesPersister import saveDrugDescriptionsForPathologies\n",
|
||||
"from DrugsForPathologies.HtmlUpdater import updateHtmlFile as updateDrugsForPathologiesHtmlFile\n"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"id": "3f60c4f1",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"def getDrugDescrByPathology(drugs4Pathologies):\n",
|
||||
" def drugsTable2drugDescr(drugsTable):\n",
|
||||
" drugDescr = drugsTable.to_dict('list')\n",
|
||||
" del drugDescr['PATHOLOGY']\n",
|
||||
" return drugDescr\n",
|
||||
" \n",
|
||||
" return drugs4Pathologies.groupby('PATHOLOGY').apply(drugsTable2drugDescr)\n"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"id": "a092ecf7",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"def saveDrugDescriptionsForPathologiesAndUpdateHtmlFile(drugDescrByPathology, webAppBaseDir):\n",
|
||||
" filenameByPathology = saveDrugDescriptionsForPathologies(\n",
|
||||
" drugDescrByPathology = drugDescrByPathology,\n",
|
||||
" directory = os.path.normpath(webAppBaseDir + '/data/DrugDescriptionsForPathologies'))\n",
|
||||
" updateDrugsForPathologiesHtmlFile(\n",
|
||||
" filenameByPathology,\n",
|
||||
" htmlFile = os.path.normpath(webAppBaseDir + '/index.html'))\n"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"id": "a416e3b7",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"drugs4Pathologies = pd.read_excel(\n",
|
||||
" io = 'data/1000-pathologies.xlsx',\n",
|
||||
" converters = {\n",
|
||||
" 'PATHOLOGY': lambda text: text.strip(),\n",
|
||||
" 'DRUG': lambda text: text.strip() })\n",
|
||||
"drugs4Pathologies"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"id": "1c0166e6",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"drugDescrByPathology = getDrugDescrByPathology(drugs4Pathologies)\n",
|
||||
"drugDescrByPathology"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"id": "7652a551",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"saveDrugDescriptionsForPathologiesAndUpdateHtmlFile(\n",
|
||||
" drugDescrByPathology = drugDescrByPathology,\n",
|
||||
" webAppBaseDir = os.path.normpath(os.getcwd() + '/../docs/DrugsForPathologies'))"
|
||||
]
|
||||
}
|
||||
],
|
||||
"metadata": {
|
||||
|
||||
@@ -1,20 +1,20 @@
|
||||
import html
|
||||
|
||||
def getVaccineOptions(vaccines, filenameByDrug, defaultOptionText):
|
||||
return _getOptionsWithDefaultOption(
|
||||
return getOptionsWithDefaultOption(
|
||||
defaultOptionText = defaultOptionText,
|
||||
values = vaccines,
|
||||
filenameByValue = filenameByDrug)
|
||||
|
||||
|
||||
def getSymptomOptions(symptoms, filenameBySymptom):
|
||||
return _getOptionsWithDefaultOption(
|
||||
return getOptionsWithDefaultOption(
|
||||
defaultOptionText = 'Select Symptom',
|
||||
values = symptoms,
|
||||
filenameByValue = filenameBySymptom)
|
||||
|
||||
|
||||
def _getOptionsWithDefaultOption(defaultOptionText, values, filenameByValue):
|
||||
def getOptionsWithDefaultOption(defaultOptionText, values, filenameByValue):
|
||||
return ['<option hidden disabled selected value>{defaultOptionText}</option>'.format(defaultOptionText = defaultOptionText)] + _getOptions(values, filenameByValue)
|
||||
|
||||
|
||||
|
||||
BIN
src/data/1000-pathologies.xlsx
Normal file
BIN
src/data/1000-pathologies.xlsx
Normal file
Binary file not shown.
@@ -4,6 +4,7 @@ Local:
|
||||
- http://www.howbadismybatch.info/VaccineDistributionByZipcode.html
|
||||
- http://www.howbadismybatch.info/SymptomsCausedByVaccines/index.html
|
||||
- http://www.howbadismybatch.info/SymptomsCausedByDrugs/index.html
|
||||
- http://www.howbadismybatch.info/DrugsForPathologies/index.html
|
||||
|
||||
Live:
|
||||
- https://knollfrank.github.io/HowBadIsMyBatch/batchCodeTable.html
|
||||
@@ -11,6 +12,7 @@ Live:
|
||||
- https://knollfrank.github.io/HowBadIsMyBatch/VaccineDistributionByZipcode.html
|
||||
- https://knollfrank.github.io/HowBadIsMyBatch/SymptomsCausedByVaccines/index.html
|
||||
- https://knollfrank.github.io/HowBadIsMyBatch/SymptomsCausedByDrugs/index.html
|
||||
- https://knollfrank.github.io/HowBadIsMyBatch/DrugsForPathologies/index.html
|
||||
|
||||
jupyter notebook
|
||||
|
||||
|
||||
Reference in New Issue
Block a user