with open(source, "r") as source_file, open(target, "w") as target_file:
with open(template) as template_file:
template_data = Template(template_file.read())
- data=json.loads(source_file.read())
+ data=self.process_medication(json.loads(source_file.read()))
try:
data["date"]=datetime.datetime.strptime(data["date"], "%Y-%m-%d %H:%M:%S")
except Exception as e:
output=template_data.render(data)
target_file.write(output)
return(target)
+
+ def process_medication(self, data):
+ medication_list=[]
+ for line in data["medication"].splitlines():
+ if(line):
+ medication_list.append([m.strip() for m in line.replace(")", "").split("(")])
+ data["medication_list"]=medication_list
+ return data
<p>{{note}}</p>
<p>{{report}}</p>
</td>
- <td class="formatted lbordered">
- <p>{{medication}}</p>
- <p>{{investigation}}</p>
- <p>{{advice}}</p>
+ <td class="lbordered">
+ <div>
+ <ol>
+ {% for med in medication_list %}
+ <li><strong>{{med[0]}}</strong><br>
+ <small><em>{{med[1]}}</em></small></li>
+ <hr>
+ {% endfor %}
+ </ol>
+ </div>
+ <div class="formatted">
+ <p>{{investigation}}</p>
+ <p>{{advice}}</p>
+ </div>
</td>
</tr>
</table>