Skip to content

Commit

Permalink
add parameter for patient ID and populate creation date
Browse files Browse the repository at this point in the history
  • Loading branch information
Jeffer Peng committed Aug 5, 2020
1 parent 6dbd9e8 commit f5dd628
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 5 deletions.
11 changes: 8 additions & 3 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,9 @@ Agruments
[--imagefile]
required field, the name of the patient chest X-Ray image
[--patientId]
patient's id
Run
----
Expand All @@ -73,15 +76,17 @@ Now, prefix all calls with

.. code:: bash
docker run --rm -v $(pwd)/out:/outgoing \
local/pl-pdfgeneration pdfgeneration.py \
docker run --rm -v $(pwd)/in:/incoming -v $(pwd)/out:/outgoing \
local/pl-pdfgeneration pdfgeneration.py --imagefile ex-covid.jpeg \
--patientId 1234567 /incoming /outgoing \
Examples
--------


docker build -t local/pl-pdfgeneration .

docker run --rm -v $(pwd)/in:/incoming -v $(pwd)/out:/outgoing local/pl-pdfgeneration pdfgeneration.py --imagefile ex-covid.jpeg /incoming /outgoing
docker run --rm -v $(pwd)/in:/incoming -v $(pwd)/out:/outgoing local/pl-pdfgeneration pdfgeneration.py --imagefile ex-covid.jpeg --patientId 1234567 /incoming /outgoing

docker run --rm local/pl-pdfgeneration pdfgeneration.py --json
11 changes: 11 additions & 0 deletions pdfgeneration/pdfgeneration.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import json
import shutil
import pdfkit
import datetime
from pyvirtualdisplay import Display
sys.path.append(os.path.dirname(__file__))

Expand Down Expand Up @@ -140,6 +141,11 @@ def define_parameters(self):
type = str,
optional = False,
help = 'Name of image file submitted to the analysis')
self.add_argument('--patientId',
dest = 'patientId',
type = str,
optional = False,
help = 'Patient ID')

def run(self, options):
"""
Expand All @@ -166,11 +172,16 @@ def run(self, options):
with open("pdftemplate/{}".format(template_file)) as f:
txt = f.read()
# replace the values
txt = txt.replace("${PATIENT_TOKEN}", options.patientId)
txt = txt.replace("${PREDICTION_CLASSIFICATION}", classification_data['prediction'])
txt = txt.replace("${COVID-19}", classification_data['COVID-19'])
txt = txt.replace("${NORMAL}", classification_data['Normal'])
txt = txt.replace("${PNEUMONIA}", classification_data['Pneumonia'])
txt = txt.replace("${X-RAY-IMAGE}", options.imagefile)

time = datetime.datetime.now()
txt = txt.replace("${month-date}", time.strftime("%c"))
txt = txt.replace("${year}", time.strftime("%Y"))
# add the severity value if prediction is covid
if template_file == "pdf-covid-positive-template.html":
txt = txt.replace("${GEO_SEVERITY}", severityScores["Geographic severity"])
Expand Down
2 changes: 1 addition & 1 deletion pdfgeneration/pdftemplate/pdf-covid-negative-template.html
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ <h3>Pneumonia: <span>${PNEUMONIA}</span></h3>
<hr>
<div class="layout--half">
<div class="footer-text">
<p>Output generated by COVID-Net on the ChRIS platform on $Day $Month $Year $HH:$MM $AM/PM.</p>
<p>Output generated by COVID-Net on the ChRIS platform on ${month-date}</p>
</div>
<div class="footer-text">
<p>For more information about COVID-NET: <a href="https://github.com/lindawangg/COVID-Net/">https://github.com/lindawangg/COVID-Net/</a></p>
Expand Down
2 changes: 1 addition & 1 deletion pdfgeneration/pdftemplate/pdf-covid-positive-template.html
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ <h3>Severity Scores</h3>
<hr>
<div class="layout--half">
<div class="footer-text">
<p>Output generated by COVID-Net on the ChRIS platform on $Day $Month $Year $HH:$MM $AM/PM.</p>
<p>Output generated by COVID-Net on the ChRIS platform on ${month-date}</p>
</div>
<div class="footer-text">
<p>For more information about COVID-NET: <a href="https://github.com/lindawangg/COVID-Net/">https://github.com/lindawangg/COVID-Net/</a></p>
Expand Down

0 comments on commit f5dd628

Please sign in to comment.