adding pathology options to html file

This commit is contained in:
Frank Knoll
2024-07-27 18:24:12 +02:00
parent 951ea58982
commit e47aefd9bf
5 changed files with 48 additions and 14 deletions

2
.gitignore vendored
View File

@@ -15,3 +15,5 @@ src/GoogleAnalytics/__pycache__
src/SymptomsCausedByVaccines/__pycache__
src/HowBadIsMyBatch.py
src/data/prrByDrugAndSymptom-EudraVigilance.csv
src/DrugsForPathologies/__pycache__

View 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'))

View File

View File

@@ -622,7 +622,8 @@
"outputs": [],
"source": [
"import pandas as pd\n",
"import os"
"import os\n",
"from DrugsForPathologies.HtmlUpdater import updateHtmlFile as updateDrugsForPathologiesHtmlFile\n"
]
},
{
@@ -709,12 +710,17 @@
{
"cell_type": "code",
"execution_count": null,
"id": "5bd7d025",
"id": "5535345f",
"metadata": {},
"outputs": [],
"source": [
"webAppBaseDir = os.path.normpath(os.getcwd() + '/../docs/DrugsForPathologies')\n",
"webAppBaseDir"
"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"
]
},
{
@@ -724,20 +730,18 @@
"metadata": {},
"outputs": [],
"source": [
"filenameByPathology = saveDrugDescriptionsForPathologies(\n",
" drugDescrByPathology = drugDescrByPathology,\n",
" directory = os.path.normpath(webAppBaseDir + '/data/DrugDescriptionsForPathologies'))\n"
"saveDrugDescriptionsForPathologiesAndUpdateHtmlFile(\n",
" drugDescrByPathology = drugDescrByPathology[:2],\n",
" webAppBaseDir = os.path.normpath(os.getcwd() + '/../docs/DrugsForPathologies'))"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "013ffd05",
"id": "a2398b3a",
"metadata": {},
"outputs": [],
"source": [
"filenameByPathology"
]
"source": []
}
],
"metadata": {

View File

@@ -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)