diff --git a/ntuh/getop.py b/ntuh/getop.py index 39344c6..9c8f91a 100755 --- a/ntuh/getop.py +++ b/ntuh/getop.py @@ -105,7 +105,7 @@ def ScanOPSchedule(year=False, month=False): # if starts.month != ends.month: # SaveOP(vs, end, end) # print vs, start, end - OPSchedule.objects.filter(Complete__in=['NO', 'OO']).update(Complete="完成") + OPSchedule.objects.filter(Complete__in=['NO', 'OO', 'OO,OS,OE']).update(Complete="完成") diff --git a/ntuh/getpatho.py b/ntuh/getpatho.py index 8c45b2e..8ca9f9d 100755 --- a/ntuh/getpatho.py +++ b/ntuh/getpatho.py @@ -42,9 +42,11 @@ def SavePathology(ChartNo, SESSION = None): p.PersonID = r['PersonID'] # p.PathCode = r['PathCode'] p.SpecimenGetDate = r['SpecimenGetDate'].replace('/', '-').split(' ')[0] - p.ReportDate = r['ReportDate'].replace('/', '-').split(' ')[0] + # p.ReportDate = r['ReportDate'].replace('/', '-').split(' ')[0] + p.ReportDate = datetime.strptime(r['ReportDate'], "%Y/%m/%d %H:%M") p.url = r['url'] p.html = r['html'] + # print(r['ReportDate'], p.ReportDate) p.save() def ScanPathology(days = False): diff --git a/ntuh/new_window.png b/ntuh/new_window.png index 636a929..c568d10 100755 Binary files a/ntuh/new_window.png and b/ntuh/new_window.png differ diff --git a/ntuh/ntuh/settings.py b/ntuh/ntuh/settings.py index 2c6f011..586c10e 100755 --- a/ntuh/ntuh/settings.py +++ b/ntuh/ntuh/settings.py @@ -402,6 +402,8 @@ ALLOWED_HOSTS = [ '192.168.26.10', ] +DEFAULT_AUTO_FIELD='django.db.models.AutoField' + ########## HAYSTACK # HAYSTACK_CONNECTIONS = { # 'default': { diff --git a/ntuh/ntuh/urls.py b/ntuh/ntuh/urls.py index f57ff3e..841b890 100755 --- a/ntuh/ntuh/urls.py +++ b/ntuh/ntuh/urls.py @@ -7,17 +7,16 @@ from django.views.generic import TemplateView import fileupload.views -# Uncomment the next two lines to enable the admin: -# from django.contrib import admin -# admin.autodiscover() - -from django.contrib import admin -admin.autodiscover() #from fileupload.views import PictureCreateView, PictureDeleteView, multiple_uploader #from registry.views import PictureCreateView, PictureDeleteView, multiple_uploader from registry import views as registry_views +from registry.views import * + +from django.contrib import admin +admin.autodiscover() + urlpatterns = [ # Examples: @@ -45,7 +44,8 @@ urlpatterns = [ re_path(r'^registry/op_note/(?P\d+)/(?P\d{4}-\d\d-\d\d)/', registry_views.op_note), - re_path(r'^registry/patho_report/(?P\d+)/(?P\d{4}-\d\d-\d\d)/', registry_views.patho_report), + # re_path(r'^registry/patho_report/(?P\d+)/(?P\d{4}-\d\d-\d\d)/', registry_views.patho_report), + re_path(r'^registry/patho_report/(?P.+)/', registry_views.patho_report), re_path(r'^registry/op_prepare/', registry_views.op_prepare), @@ -53,7 +53,10 @@ urlpatterns = [ re_path(r'^registry/op_edit/', registry_views.op_edit), re_path(r'^registry/op_search/', registry_views.op_search), + re_path(r'^registry/patho_search/', registry_views.patho_search), + path('pathology/search/', PathologyReportSearchView.as_view(), name='pathology_search'), + re_path(r'^registry/op_uncategorized/', registry_views.op_uncategorized), re_path(r'^registry/op_month/', registry_views.op_month), re_path(r'^registry/op_year/', registry_views.op_year), diff --git a/ntuh/old_window.png b/ntuh/old_window.png index f0e4bd6..b6d6a7f 100755 Binary files a/ntuh/old_window.png and b/ntuh/old_window.png differ diff --git a/ntuh/rReportTab_lsvReportBody_ctrl0_ctl00_tblDisplay.txt b/ntuh/rReportTab_lsvReportBody_ctrl0_ctl00_tblDisplay.txt new file mode 100644 index 0000000..b611120 --- /dev/null +++ b/ntuh/rReportTab_lsvReportBody_ctrl0_ctl00_tblDisplay.txt @@ -0,0 +1,107 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ 病理號 + + S0219316 + + + 收件日 + + 2002/08/12 + + 報告日 + + 2002/08/13 00:00 +
+ 檢體 + + b + 科別 + + SURG + 病床 + + 04B10801 +
+ 組織由來 + + +
+ 臨床診斷 + + Neurotic tumor +
+
01
器官與術式Lung,left,apex,excision
組織學診斷1schwannoma
診斷描述1
+
+ 檢查報告 + +
+ + The specimen submitted consists of 3 tissue fragments measuring up to
3.5 x 3.0 x 2.5 cm. in size fixed in formalin.

Grossly, they are yellowish white and elastic.



All for section. Jar 0



Microscopically, it shows schwannoma. Prominent Antoni A and Antoni B areas are
seen. Same areas of hyalinization and hemorrhage are also noted.



Ref.S02-19242
+
+ + + +
+ 執行醫師 + + 林中梧(病解專醫字第0279號) + + 負責醫師 + + 王逸平 + + 覆閱醫師 + + +
+ +
\ No newline at end of file diff --git a/ntuh/registry/forms.py b/ntuh/registry/forms.py new file mode 100644 index 0000000..2beae34 --- /dev/null +++ b/ntuh/registry/forms.py @@ -0,0 +1,24 @@ + +from django import forms + +from haystack.forms import SearchForm, ModelSearchForm + +class PathologyReportForm(SearchForm): +# class PathologyReportForm(ModelSearchForm): + q = forms.CharField( + required=False, + # label=_("Search"), + widget=forms.TextInput(attrs={"type": "search"}), + ) + # def __init__(self, *args, **kwargs): + # super().__init__(*args, **kwargs) + # self.fields["models"] = forms.MultipleChoiceField( + # choices=[ + # # ('registry.opnote', 'Op notes'), + # ('registry.pathologyreport', 'Pathology reports') + # ], + # required=False, + # # label=_("Search In"), + # widget=forms.CheckboxSelectMultiple, + # ) + diff --git a/ntuh/registry/templatetags/__init__.py b/ntuh/registry/templatetags/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/ntuh/registry/templatetags/pathology.py b/ntuh/registry/templatetags/pathology.py new file mode 100644 index 0000000..9fc4446 --- /dev/null +++ b/ntuh/registry/templatetags/pathology.py @@ -0,0 +1,29 @@ +from django import template +from pyquery import PyQuery + +register = template.Library() + +@register.filter +def patho_short(html): + doc = PyQuery(html) + report_text = doc('#rReportTab_lsvReportBody_ctrl0_ctl00_TextBox2').text().strip() + if not report_text: + # report_text = doc('#ContentContainer').text().strip() + # report_text = doc('#rReportTab_lsvReportBody_ctrl0_ctl00_tblDisplay').text().strip() + # report_text = doc( + # '#rReportTab_lsvReportBody_ctrl0_ctl00_tblDisplay > tbody:nth-child(1) > tr:nth-child(5) > td:nth-child(1) > table:nth-child(1)' + # ).text().strip() + report_text = doc('#rReportTab_lsvReportBody_ctrl0_ctl00_lblResult').text().strip() + return report_text + +@register.filter +def patho_long(html): + doc = PyQuery(html) + report_text = doc('#rReportTab_lsvReportBody_ctrl0_ctl00_tblDisplay').text().strip() + return report_text + +@register.filter +def DOB(html): + doc = PyQuery(html) + report_text = doc('.patientInfo > table:nth-child(1) > tbody:nth-child(1) > tr:nth-child(2) > td:nth-child(6)').text().strip() + return report_text diff --git a/ntuh/registry/views.py b/ntuh/registry/views.py index e0067a4..293289c 100755 --- a/ntuh/registry/views.py +++ b/ntuh/registry/views.py @@ -8,6 +8,7 @@ import re from django.contrib.auth import * from django.contrib.auth.decorators import * +from django.contrib.auth.mixins import LoginRequiredMixin from django.core import serializers from django.http import * @@ -22,6 +23,7 @@ from categories.models import * from dateutil.relativedelta import * from excel_response import ExcelResponse +from haystack.generic_views import SearchView from haystack.inputs import AutoQuery, Raw from haystack.query import SearchQuerySet, SQ @@ -30,6 +32,8 @@ from pyquery import PyQuery from ntuh import settings from registry.models import * + +from .forms import * from .utils import RenewSchedule #from multiuploader.models import * @@ -171,13 +175,29 @@ def op_note(request, PatChartNo, date): return HttpResponse() @login_required -def patho_report(request, PatChartNo, date): - for patho in PathologyReport.objects.filter(ChartNo = PatChartNo).order_by('-SpecimenGetDate'): - matches = re.findall('()', patho.html, re.DOTALL) + # matches = re.findall('(
月報
  • 年報
  • 手術搜尋
  • -
  • 病理搜尋
  • + +
  • 病理搜尋
  • 緊急到院處理費
  • 更新日誌
  • Logout
  • diff --git a/ntuh/templates/registry/patho_search.html b/ntuh/templates/registry/patho_search.html index 44775f5..97e4687 100755 --- a/ntuh/templates/registry/patho_search.html +++ b/ntuh/templates/registry/patho_search.html @@ -143,7 +143,7 @@ - + @@ -158,9 +158,9 @@ - + - + diff --git a/ntuh/templates/registry/pathology_search.html b/ntuh/templates/registry/pathology_search.html new file mode 100644 index 0000000..7696f52 --- /dev/null +++ b/ntuh/templates/registry/pathology_search.html @@ -0,0 +1,183 @@ +{% extends 'base.html' %} + +{% load pathology %} + +{% block head %} + + + +{% endblock %} + +{% block logo %} +

    {{specialty}} 病理報告搜尋

    +{% endblock %} + +{% block content %} +

    Search

    + +
    +
    +
    +
    + + query language +
    +
    +
    +
    +
    counter 病歷號ReportKey PersonID 病理號
    {{forloop.counter}} {{report.ChartNo}}{{report.ReportKey|slice:"-8:"}} {{report.PersonID}}{{report.PersonID}} {{report.html|DOB}} {{report.PathCode}} {{report.SpecimenGetDate|date:"Y-m-d"}} {{report.ReportDate|date:"Y-m-d"}}
    + + + + + +
    單一關鍵字(非100%精確)e.g. meningioma, metastatic, schwannoma"malignant meningioma"
    含任一關鍵字metastases OR metastasis OR metastaticSSTR2a OR EMA
    含所有關鍵字meningioma malignancymeningioma AND malignancy
    排除關鍵字(慎用)meningioma NOT atypical NOT malignancymeningioma NOT (atypical OR malignancy)
    萬用字元(慢)metasta*metastas?s
    + + + + + + +
    + + {{ form.as_table }} + + + + +
      + + + +
    + + {% if query %} +

    Results - {{page_obj.paginator.count}} Page: {{page_obj.number}}/{{page_obj.paginator.num_pages}}

    + + {% with page=page_obj %} + + {% if page.has_previous or page.has_next %} + + {% endif %} + + + + + + + + + + + + + + + + + {% for result in page.object_list %} + + + + + + + + + + + + + {% empty %} +

    No results found.

    + {% endfor %} + +
    病歷號生日病理號收件日報告日html
    {{ result.object.ChartNo }}{{ result.object.html|DOB }}{{ result.object.PathCode }}{{ result.object.SpecimenGetDate|date:"Y-m-d" }}{{ result.object.ReportDate|date:"Y-m-d" }} + {{result.object.html|patho_short|truncatewords:20}} +
    + + {% if page.has_previous or page.has_next %} + + {% endif %} + + {% endwith %} + {% else %} + {# Show some example queries to run, maybe query syntax, something else? #} + {% endif %} +
    +{% endblock %}