.
This commit is contained in:
@@ -9,4 +9,5 @@
|
|||||||
<a href="{% url 'oef:questions' %}">Questions</a> /
|
<a href="{% url 'oef:questions' %}">Questions</a> /
|
||||||
<a href="{% url 'oef:subspecialties' %}">By subspecialty</a> /
|
<a href="{% url 'oef:subspecialties' %}">By subspecialty</a> /
|
||||||
<a href="{% url 'oef:replace_questions' %}">Replace Questions</a> /
|
<a href="{% url 'oef:replace_questions' %}">Replace Questions</a> /
|
||||||
|
<a href="{% url 'oef:output' %}">Output</a> /
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
@@ -15,19 +15,23 @@
|
|||||||
<th>Field Label</th>
|
<th>Field Label</th>
|
||||||
<th>Field Name</th>
|
<th>Field Name</th>
|
||||||
<th>Field Status</th>
|
<th>Field Status</th>
|
||||||
|
<th>Field Type</th>
|
||||||
<th>Field Codeset</th>
|
<th>Field Codeset</th>
|
||||||
</tr>
|
</tr>
|
||||||
{% for format in formats %}
|
{% for output in outputs %}
|
||||||
<li>
|
|
||||||
<a href="{% url 'oef:format_update' format.id %}">{{ format.name }}</a>
|
|
||||||
<a href="{% url 'oef:formats_apply' format.id %}">apply</a> [{{ format.get_entries.count }}]
|
|
||||||
|
|
||||||
{% if request.user.is_superuser %}
|
<tr>
|
||||||
<a href="{% url 'oef:formats_delete' format.id %}">(delete)</a>
|
<td>{{output.name}}</td>
|
||||||
|
<td>Order</td>
|
||||||
|
<td>{{output.field_seq}}</td>
|
||||||
|
|
||||||
{% endif %}
|
<td>{{output.field_label}}</td>
|
||||||
|
<td>{{output.field_name}}</td>
|
||||||
|
<td>{{output.field_status}}</td>
|
||||||
|
<td>{{output.field_type}}</td>
|
||||||
|
<td>{{output.field_codeset}}</td>
|
||||||
|
|
||||||
</li>
|
</tr>
|
||||||
|
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</table>
|
</table>
|
||||||
|
|||||||
+66
-2
@@ -1,3 +1,4 @@
|
|||||||
|
from dataclasses import dataclass
|
||||||
from difflib import HtmlDiff, SequenceMatcher
|
from difflib import HtmlDiff, SequenceMatcher
|
||||||
from django import forms
|
from django import forms
|
||||||
from django.http import HttpResponse, JsonResponse
|
from django.http import HttpResponse, JsonResponse
|
||||||
@@ -52,14 +53,77 @@ class EntryTableView(SingleTableMixin, FilterView):
|
|||||||
|
|
||||||
filterset_class = EntryFilter
|
filterset_class = EntryFilter
|
||||||
|
|
||||||
|
@dataclass
|
||||||
|
class FormatOutput:
|
||||||
|
name: str
|
||||||
|
action: str=""
|
||||||
|
field_seq: int=100
|
||||||
|
field_label:str=""
|
||||||
|
field_name:str=""
|
||||||
|
field_status:str=""
|
||||||
|
field_type:str=""
|
||||||
|
field_codeset:str=""
|
||||||
|
|
||||||
|
|
||||||
def output(request):
|
def output(request):
|
||||||
formats = Formats.objects.all()
|
formats = Formats.objects.all()
|
||||||
|
|
||||||
|
formats = sorted(formats, key=lambda x: len(x.format))
|
||||||
|
|
||||||
|
outputs = []
|
||||||
|
|
||||||
|
codesets = []
|
||||||
|
codeset_start = 100000
|
||||||
|
|
||||||
|
|
||||||
for format in formats:
|
for format in formats:
|
||||||
questions = format.format
|
seq = 100
|
||||||
|
questions = format.format.strip().split("---")
|
||||||
|
|
||||||
|
for question in questions:
|
||||||
|
print(question)
|
||||||
|
if not question:
|
||||||
|
continue
|
||||||
|
|
||||||
|
name, *other = question.strip().splitlines()
|
||||||
|
|
||||||
|
status = "OPTIONAL"
|
||||||
|
if name.endswith("*"):
|
||||||
|
status = "REQUIRED"
|
||||||
|
name = name[:-1]
|
||||||
|
|
||||||
|
field_type = ""
|
||||||
|
match other:
|
||||||
|
case ["Yes", "No"]:
|
||||||
|
field_type = "YES/NO"
|
||||||
|
case ["Date/Time"]:
|
||||||
|
field_type = "DATE/TIME"
|
||||||
|
case ["Freetext"]:
|
||||||
|
field_type = "ALPHANUMERIC"
|
||||||
|
case [*codeset]:
|
||||||
|
field_type = "CODESET"
|
||||||
|
case _:
|
||||||
|
field_type = "unknown"
|
||||||
|
|
||||||
|
o = FormatOutput(format.name, field_label=name, field_name=name, field_seq=seq, field_status=status, field_type=field_type)
|
||||||
|
|
||||||
|
|
||||||
return render(request, "oef/output.html", {"formats": formats})
|
if field_type == "CODESET":
|
||||||
|
o.field_codeset = codeset_start
|
||||||
|
|
||||||
|
codeset_start = codeset_start + 1
|
||||||
|
|
||||||
|
outputs.append(o)
|
||||||
|
|
||||||
|
|
||||||
|
seq = seq + 100
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
return render(request, "oef/output.html", {"formats": formats, "outputs": outputs})
|
||||||
|
|
||||||
def formats_view(request):
|
def formats_view(request):
|
||||||
formats = Formats.objects.all()
|
formats = Formats.objects.all()
|
||||||
|
|||||||
Reference in New Issue
Block a user