add 'Out' field to inpatient log
This commit is contained in:
parent
db0abd883b
commit
dbb27fa74c
3 changed files with 26 additions and 1 deletions
|
@ -26,7 +26,8 @@ logging.basicConfig(format=FORMAT, level=logging.INFO)
|
||||||
def ScanWard(ward='08D'):
|
def ScanWard(ward='08D'):
|
||||||
logging.info('Scan %s' % (ward))
|
logging.info('Scan %s' % (ward))
|
||||||
list = QueryInPatientByWard(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:
|
for Pat in list:
|
||||||
# logging.warning(json.dumps(Pat, indent=1))
|
# logging.warning(json.dumps(Pat, indent=1))
|
||||||
|
@ -43,6 +44,11 @@ def ScanWard(ward='08D'):
|
||||||
lat = None
|
lat = None
|
||||||
|
|
||||||
if lat is None or lat.ChartNo != Pat['PatChartNo']:
|
if lat is None or lat.ChartNo != Pat['PatChartNo']:
|
||||||
|
|
||||||
|
if lat:
|
||||||
|
lat.Out = NOW
|
||||||
|
lat.save()
|
||||||
|
|
||||||
logging.info('create %s %s'%(BedTime,Pat['PatChartNo']))
|
logging.info('create %s %s'%(BedTime,Pat['PatChartNo']))
|
||||||
# print(len(BedTime))
|
# print(len(BedTime))
|
||||||
p = InpatientLog.objects.create(BedTime = BedTime)
|
p = InpatientLog.objects.create(BedTime = BedTime)
|
||||||
|
|
18
ntuh/registry/migrations/0006_inpatientlog_out.py
Normal file
18
ntuh/registry/migrations/0006_inpatientlog_out.py
Normal file
|
@ -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),
|
||||||
|
),
|
||||||
|
]
|
|
@ -80,6 +80,7 @@ class InpatientLog(models.Model):
|
||||||
BedTime = models.CharField(max_length=30, primary_key=True)
|
BedTime = models.CharField(max_length=30, primary_key=True)
|
||||||
|
|
||||||
Created = models.DateTimeField(auto_now_add = True)
|
Created = models.DateTimeField(auto_now_add = True)
|
||||||
|
Out = models.DateTimeField(null=True)
|
||||||
Saved = models.DateTimeField(auto_now = True)
|
Saved = models.DateTimeField(auto_now = True)
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue