Skip to content

Instantly share code, notes, and snippets.

from odonto.models import Demographics
from odonto.episode_categories import FP17Episode
from opal.models import Episode
from dateutil.relativedelta import relativedelta
import datetime
from odonto import episode_categories
from odonto.odonto_submissions import models
def dupe_nhs_numbers(episode):
NorthEast
current seats
BREXIT_PARTY=2, LAB=1
current votes
BREXIT_PARTY=36.8%, LAB=30.0%, LIB_DEM=11.3%, CON=8.5%, GREEN=5.0%, CHANGE_UK=4.0%, UKIP=3.3%
worst result: seats

BREXIT_PARTY=2, LAB=1, CHANGE_UK=0, GREEN=0, LIB_DEM=0
worst result: votes
BREXIT_PARTY=36.8%, LAB=30.0%, LIB_DEM=18.4%, CON=8.5%, UKIP=3.3%, GREEN=1.9%, CHANGE_UK=0.0%
import copy
from collections import defaultdict
def calculate_seats(_party_dict, seat_number):
"""
takes in the parties as a dictionary to % of vote
returns a dictionary of the parties to seat numbers
"""
party_dict = copy.copy(_party_dict)
@fredkingham
fredkingham / micro_tests.json
Created February 6, 2019 12:53
OPAL looks up lists for the investigations field.
{
"micro_test_leishmaniasis_pcr": [
{
"synonyms": [],
"name": "Leishmaniasis PCR"
},
{
"synonyms": [],
"name": "Malaria PCR"
}
import datetime
from lab import models
from opal.models import Patient
import csv
def get_demographics_dict(patient):
result = {}
demographics = patient.demographics_set.first()
result["name"] = "{} {}".format(demographics.first_name, demographics.surname)
result["hospital_number"] = demographics.hospital_number
accountsservice, 0.6.29-1ubuntu8
adduser, 3.113+nmu3ubuntu1
apparmor, 2.8.0-0ubuntu11
apt, 0.9.7.7ubuntu4
apt-transport-https, 0.9.7.7ubuntu4
"""
Compare
"""
test = [[c for c in p.split(' ') if c] for p in open('test.pkg', 'r').readlines() if p != '\n']
prod = [[c for c in p.split(' ') if c] for p in open('prod.pkg', 'r').readlines() if p != '\n']
prodversions = {}
for p in prod:
prodversions[p[1]] = p[2]
from lab.models import LabTest
from opal.models import Patient
from collections import defaultdict
from django.db import transaction
def get_problematic_lab_tests():
all_lab_tests = LabTest.objects.all()
by_patient_bloodtest = defaultdict(list)
import datetime
import json
def read_date(line):
dt = line[line.index('[') + 1: line.index(']')]
dt = dt.split(" ")[0]
return datetime.strptime(dt, '%d/%b/%Y:%H:%M:%S')
#!/bin/bash
#
# ./deploy_prod.sh $branch_name $previous_branch_name
#
fab clone_branch:$1 2>1 | tee /usr/lib/ohc/deployment.log
cd /usr/lib/ohc/elcidrfh-$1
fab deploy_prod:$2 2>1 | tee /usr/lib/ohc/deployment.log