From dbb27fa74cebe298dd1654d76c6403a77a0b718b Mon Sep 17 00:00:00 2001 From: Furen Xiao Date: Thu, 12 Dec 2024 17:28:10 +0800 Subject: [PATCH] add 'Out' field to inpatient log --- ntuh/get_ward.py | 8 +++++++- .../migrations/0006_inpatientlog_out.py | 18 ++++++++++++++++++ ntuh/registry/models.py | 1 + 3 files changed, 26 insertions(+), 1 deletion(-) create mode 100644 ntuh/registry/migrations/0006_inpatientlog_out.py diff --git a/ntuh/get_ward.py b/ntuh/get_ward.py index 3034eb6..fd53907 100755 --- a/ntuh/get_ward.py +++ b/ntuh/get_ward.py @@ -26,7 +26,8 @@ logging.basicConfig(format=FORMAT, level=logging.INFO) def ScanWard(ward='08D'): logging.info('Scan %s' % (ward)) list = QueryInPatientByWard(ward) - TIME = datetime.datetime.now().strftime('%Y-%m-%d %H:%M') + NOW = datetime.datetime.now() + TIME = NOW.strftime('%Y-%m-%d %H:%M') for Pat in list: # logging.warning(json.dumps(Pat, indent=1)) @@ -43,6 +44,11 @@ def ScanWard(ward='08D'): lat = None if lat is None or lat.ChartNo != Pat['PatChartNo']: + + if lat: + lat.Out = NOW + lat.save() + logging.info('create %s %s'%(BedTime,Pat['PatChartNo'])) # print(len(BedTime)) p = InpatientLog.objects.create(BedTime = BedTime) diff --git a/ntuh/registry/migrations/0006_inpatientlog_out.py b/ntuh/registry/migrations/0006_inpatientlog_out.py new file mode 100644 index 0000000..07c030c --- /dev/null +++ b/ntuh/registry/migrations/0006_inpatientlog_out.py @@ -0,0 +1,18 @@ +# Generated by Django 4.1 on 2024-12-12 17:23 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('registry', '0005_alter_inpatientlog_bedtime'), + ] + + operations = [ + migrations.AddField( + model_name='inpatientlog', + name='Out', + field=models.DateTimeField(null=True), + ), + ] diff --git a/ntuh/registry/models.py b/ntuh/registry/models.py index 1631042..4061935 100755 --- a/ntuh/registry/models.py +++ b/ntuh/registry/models.py @@ -80,6 +80,7 @@ class InpatientLog(models.Model): BedTime = models.CharField(max_length=30, primary_key=True) Created = models.DateTimeField(auto_now_add = True) + Out = models.DateTimeField(null=True) Saved = models.DateTimeField(auto_now = True)