if(pid is None):
(ok, data)=patient.create(cursor, request.form)
if(not ok):
- raise Exception(data)
+ if(isinstance(data, sqlite3.IntegrityError)):
+ data=request.form
+ (ok, center)=multicenter.list(cursor)
+ if(not ok):
+ raise exception(center)
+ (ok, last)=patient.last(cursor)
+ if(not ok):
+ raise Exception(last)
+ data.lastCid=last["cid"]
+ return render_template("patient-edit.html", data=data, center=center, action="uniq")
+ else:
+ raise Exception(data)
pid=data
else:
(ok, data)=patient.update(cursor, pid, request.form)
</div>
<script src="/static/bootstrap/js/bootstrap.bundle.min.js"></script>
<script src="/static/script.js"></script>
- {% if data and data["lastCid"] %}
- <script>lastCid="{{data["lastCid"]}}"</script>
- <script src="/static/card-id.js"></script>
- {% endif %}
</body>
</html>
{% block content %}
<div class="content">
- <form method="post">
+ <form method="post" id="form-edit">
<div class="mb-2 row">
<label class="form-label col-sm-3">Card ID</label>
<div class="col-sm-9">
<button type="submit" class="btn btn-primary">Save</button>
</form>
</div>
+{% if data["lastCid"] %}
+<script>lastCid="{{data["lastCid"]}}"</script>
+<script src="/static/card-id.js"></script>
+{% endif %}
+{% if action=="uniq" %}
+<script>
+ if(confirm("Card ID already exists. Resubmit with new card ID?\n"+lastCid)){
+ document.getElementById("form-edit").submit()
+ }
+</script>
+{% endif %}
<script>
function insertByAge(){
age=prompt("Enter age:")