Last active
January 16, 2017 16:46
-
-
Save fredkingham/364fd1c037ef5b30058c06b67068ebab to your computer and use it in GitHub Desktop.
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
import datetime | |
from opal.core import patient_lists | |
from opal.models import Episode | |
def get_episodes(): | |
subtags = [ | |
getattr(i, "subtag", None) or getattr(i, "tag", None) for i in patient_lists.TaggedPatientList.list() | |
] | |
fix_release = datetime.datetime(2016, 11, 11) | |
issue_release = datetime.datetime(2016, 5, 24) | |
subtags = [i for i in subtags if not i.startswith("opat")] | |
subtags = [i for i in subtags if not i.startswith("walkin")] | |
episodes = Episode.objects.filter( | |
tagging__value__in=subtags | |
).exclude(created=None).filter(date_of_admission=None) | |
return episodes.filter(created__range=[issue_release, fix_release]) | |
def update_episodes(): | |
episodes = get_episodes() | |
for episode in episodes: | |
episode.date_of_admission = episode.created.date() | |
episode.save() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment