import sys import csv from xhtml2pdf import pisa import os import pandas as pd rptData = {} rptData['Person Name'] = "row['Name']" rptData['Age'] = "row['Age']" rptData['Gender'] = "row['Gender']" rptData['Age / Sex'] = "Male" rptData['Sample type'] = 'Capillary Whole Blood' rptData['Family History of Sickle Cell Anemia'] = 'Unknown' rptData['Marital Status'] = "row['Marital Status']" rptData['Test Date'] = "date" rptData['Patient ID'] = "row['ABHA ID']" rptData['Sample ID'] = "row['_id']" rptData['value'] = "row['Measured Deovix Ratio']" rd = rptData # template_path = os.path.join(THIS_DIR, 'report_template.html') report_template =r'''
Person Name: {{ reportData["Person Name"] }}
Age / Sex: {{reportData['Age']}} / {{reportData['Gender']}}
Sample type:{{ reportData["Sample type"] }}
Family History of Sickle Cell Anemia:{{ reportData["Family History of Sickle Cell Anemia"] }}
Marital Status:{{ reportData["Marital Status"] }}
Test Date:{{ reportData["Test Date"] }}
ABHA ID:{{ reportData["Patient ID"] }}
Sample ID:{{ reportData["Sample ID"] }}
POINT OF CARE SICKLE CELL ANEMIA TEST
Test Description RESULT REFERENCE RANGES
Sickle Cell Anemia
(Method: HPOS)
Ra = {{ reportData["value"] }}
< 0.16: Normal (HbA)
0.165 – 0.235: Sickle-cell Trait (HbAS)
> 0.24: Sickle-cell Disease (HbSS)
0.16-0.165: Inconclusive (Negative Borderline)
0.235 – 0.24: Inconclusive (Positive Borderline)
Test Principle: This point of care quantitative diagnostic test for sickle-cell anemia works on the principle of absorption spectroscopy. The test helps in differentiating heterozygous/homozygous hemoglobin from normal hemoglobin.
Method: High Performance Optical Spectroscopy (HPOS) for detection of Sickle cell trait and sickle cell disease in whole blood capillary blood samples.
Note: Borderline cases are reported as inconclusive. It may occur due to several factors such as medication, transfusion, field conditions and assay process. Further clinical tests are recommended in these cases for diagnosis.
*** END OF REPORT ***
This is an electronically generated report. Generated at HH:MM hrs on DD-MMM-YYYY.
Note: Assay results should be correlated clinically with other clinical findings
''' # rptHtml = j2_env.from_string(report_template).render(reportData=rd) reportFile = open('report.pdf','w+b') pisa_status = pisa.CreatePDF(report_template, dest=reportFile) if not pisa_status.err: print("Created PDF report %s." % outFilename) #os.remove(rd['qrcodeImgFile'])