adding pathology options to html file
This commit is contained in:
2
.gitignore
vendored
2
.gitignore
vendored
@@ -15,3 +15,5 @@ src/GoogleAnalytics/__pycache__
|
||||
src/SymptomsCausedByVaccines/__pycache__
|
||||
src/HowBadIsMyBatch.py
|
||||
src/data/prrByDrugAndSymptom-EudraVigilance.csv
|
||||
src/DrugsForPathologies/__pycache__
|
||||
|
||||
|
||||
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
@@ -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": {
|
||||
|
||||
@@ -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)
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user