Skip to content

Instantly share code, notes, and snippets.

import csv
from django.utils import timezone
from opal.models import Patient, Episode
from opal.core.serialization import _temporal_thing_to_string
from plugins.imaging.models import Imaging
from plugins.labtests.models import Observation
from plugins.covid.episode_categories import CovidEpisode
from plugins.covid.models import CovidFollowUpCall
from plugins.covid.lab import COVID_19_TESTS
import datetime
from django.db.models import Count
from opal.models import Episode, Patient
from odonto.episode_categories import *
def get_dates(episode):
dates = [
# it does not seem to be the case that this causes conflicts
# episode.orthodonticassessment_set.all()[0].date_of_referral,
# episode.orthodonticassessment_set.all()[0].date_of_assessment,
# episode.orthodonticassessment_set.all()[0].date_of_appliance_fitted,
# episode.orthodontictreatment_set.all()[0].date_of_completion,
from opal.models import Episode
from opal.core.subrecords import episode_subrecords
from django.db import transaction
@transaction.atomic
def clone_episode(old):
new = Episode(
patient=old.patient,
active=old.active,
start=old.start,
FIELDS = [
"treatment_category",
"urgent_treatment",
"regulation_11_replacement_appliance",
"prescription_only",
"denture_repairs",
"bridge_repairs",
"arrest_of_bleeding",
"removal_of_sutures",
]
@fredkingham
fredkingham / generate_stats.py
Last active December 3, 2019 14:01
UDA and UOA numbers
from django.core.management.base import BaseCommand
from odonto.episode_categories import FP17Episode, FP17OEpisode
# FP17O calculations
def get_date(episode):
ass_date = episode.orthodonticassessment_set.get().date_of_assessment
if ass_date:
return ass_date
return episode.category.get_sign_off_date()
@fredkingham
fredkingham / generate_stats.py
Created December 3, 2019 13:53
UDA and UOA numbers
from django.core.management.base import BaseCommand
from odonto.episode_categories import FP17Episode, FP17OEpisode
# FP17O calculations
def get_date(episode):
ass_date = episode.orthodonticassessment.date_of_assessment
if ass_date:
return ass_date
return episode.category.get_sign_off_date()
Sunday 29 September 19
Blackhawks 1
Thames Valley Kings 1
13:20
Woking College
Sunday 6 October 19
Blackhawks 1
Jaguars 1
13:20
@fredkingham
fredkingham / parser.py
Created September 11, 2019 11:23
parse BH fixtures in to GCAL
"""
Expects a file that looks like
Saturday 7 December 19
Swansea Storm
Blackhawks 2
14:00
The LC Swansea, Oystermouth Road
Swansea, SA1 3ST
import xmltodict
import datetime
from odonto.odonto_submissions import models
def translate(response):
response_text = response.content.strip()[2:][:-1]
response_text = response_text.replace(
"\\n", "").replace("\\t", "").replace("\\r", ""
)
from django.shortcuts import render
# urls.py
pathway_urls = []
for pathway in Pathway.list():
pathway_urls += [
url(pathway.get_template_url(), PathwayTemplateView],
]
# pathway