-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adds a management command to load in all lab tests since a defined da…
…te (27th of Dec 2019 00:00)
- Loading branch information
1 parent
50fd00c
commit 085ae3a
Showing
1 changed file
with
25 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |