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/SymptomsCausedByVaccines/__pycache__
|
||||||
src/HowBadIsMyBatch.py
|
src/HowBadIsMyBatch.py
|
||||||
src/data/prrByDrugAndSymptom-EudraVigilance.csv
|
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": [],
|
"outputs": [],
|
||||||
"source": [
|
"source": [
|
||||||
"import pandas as pd\n",
|
"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",
|
"cell_type": "code",
|
||||||
"execution_count": null,
|
"execution_count": null,
|
||||||
"id": "5bd7d025",
|
"id": "5535345f",
|
||||||
"metadata": {},
|
"metadata": {},
|
||||||
"outputs": [],
|
"outputs": [],
|
||||||
"source": [
|
"source": [
|
||||||
"webAppBaseDir = os.path.normpath(os.getcwd() + '/../docs/DrugsForPathologies')\n",
|
"def saveDrugDescriptionsForPathologiesAndUpdateHtmlFile(drugDescrByPathology, webAppBaseDir):\n",
|
||||||
"webAppBaseDir"
|
" 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": {},
|
"metadata": {},
|
||||||
"outputs": [],
|
"outputs": [],
|
||||||
"source": [
|
"source": [
|
||||||
"filenameByPathology = saveDrugDescriptionsForPathologies(\n",
|
"saveDrugDescriptionsForPathologiesAndUpdateHtmlFile(\n",
|
||||||
" drugDescrByPathology = drugDescrByPathology,\n",
|
" drugDescrByPathology = drugDescrByPathology[:2],\n",
|
||||||
" directory = os.path.normpath(webAppBaseDir + '/data/DrugDescriptionsForPathologies'))\n"
|
" webAppBaseDir = os.path.normpath(os.getcwd() + '/../docs/DrugsForPathologies'))"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"execution_count": null,
|
"execution_count": null,
|
||||||
"id": "013ffd05",
|
"id": "a2398b3a",
|
||||||
"metadata": {},
|
"metadata": {},
|
||||||
"outputs": [],
|
"outputs": [],
|
||||||
"source": [
|
"source": []
|
||||||
"filenameByPathology"
|
|
||||||
]
|
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"metadata": {
|
"metadata": {
|
||||||
|
|||||||
@@ -1,20 +1,20 @@
|
|||||||
import html
|
import html
|
||||||
|
|
||||||
def getVaccineOptions(vaccines, filenameByDrug, defaultOptionText):
|
def getVaccineOptions(vaccines, filenameByDrug, defaultOptionText):
|
||||||
return _getOptionsWithDefaultOption(
|
return getOptionsWithDefaultOption(
|
||||||
defaultOptionText = defaultOptionText,
|
defaultOptionText = defaultOptionText,
|
||||||
values = vaccines,
|
values = vaccines,
|
||||||
filenameByValue = filenameByDrug)
|
filenameByValue = filenameByDrug)
|
||||||
|
|
||||||
|
|
||||||
def getSymptomOptions(symptoms, filenameBySymptom):
|
def getSymptomOptions(symptoms, filenameBySymptom):
|
||||||
return _getOptionsWithDefaultOption(
|
return getOptionsWithDefaultOption(
|
||||||
defaultOptionText = 'Select Symptom',
|
defaultOptionText = 'Select Symptom',
|
||||||
values = symptoms,
|
values = symptoms,
|
||||||
filenameByValue = filenameBySymptom)
|
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)
|
return ['<option hidden disabled selected value>{defaultOptionText}</option>'.format(defaultOptionText = defaultOptionText)] + _getOptions(values, filenameByValue)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user