Skip to content

Commit

Permalink
Adds a management command to load in all lab tests since a defined da…
Browse files Browse the repository at this point in the history
…te (27th of Dec 2019 00:00)
  • Loading branch information
fredkingham committed Dec 27, 2019
1 parent 50fd00c commit 085ae3a
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions intrahospital_api/management/commands/load_in_rows.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
"""
Randomise our admission dates over the last year.
"""
import datetime
from django.core.management.base import BaseCommand
from intrahospital_api.models import UpstreamLabTestRow
from intrahospital_api.apis.prod_api import ProdApi
from elcid.models import Demographics

SINCE = datetime.datetime(2019, 12, 27)


class Command(BaseCommand):

def handle(self, *args, **options):
api = ProdApi()
all_rows = api.execute_query(
api.all_data_since_query,
params=dict(since=SINCE)
)
for row in all_rows:
if Demographics.objects.filter(
hospital_number=row["Patient_Number"]
).exists():
UpstreamLabTestRow.create(row)

0 comments on commit 085ae3a

Please sign in to comment.