add model evaluation feature

This commit is contained in:
Gokul Mohanarangan
2023-08-10 11:40:55 +05:30
parent e1b33b6857
commit 8cab94cda1
8 changed files with 3357 additions and 0 deletions

View File

View File

@@ -0,0 +1,220 @@
import json
import os
import re
from dataclasses import dataclass
from pathlib import Path
from typing import List, Union
from jiwer import wer
from Levenshtein import distance
from tqdm.auto import tqdm
from whisper.normalizers import EnglishTextNormalizer
@dataclass
class EvaluationResult:
"""
Result object of the model evaluation
"""
accuracy = float
total_test_samples = int
def __init__(self, accuracy, total_test_samples):
self.accuracy = accuracy
self.total_test_samples = total_test_samples
def __repr__(self):
return (
"EvaluationResult("
+ json.dumps(
{
"accuracy": self.accuracy,
"total_test_samples": self.total_test_samples,
}
)
+ ")"
)
@dataclass
class EvaluationTestSample:
"""
Represents one test sample
"""
reference_text = str
predicted_text = str
def __init__(self, reference_text, predicted_text):
self.reference_text = reference_text
self.predicted_text = predicted_text
def update(self, reference_text, predicted_text):
self.reference_text = reference_text
self.predicted_text = predicted_text
class TestDatasetLoader:
"""
Test samples loader
"""
parent_dir = None
total_samples = 0
def __init__(self, parent_dir: Union[Path | str]):
if isinstance(parent_dir, str):
self.parent_dir = Path(parent_dir)
else:
self.parent_dir = parent_dir
def _load_test_data(self) -> tuple[str, str]:
"""
Loader function to validate inout files and generate samples
"""
PREDICTED_TEST_SAMPLES_DIR = self.parent_dir / "predicted_texts"
REFERENCE_TEST_SAMPLES_DIR = self.parent_dir / "reference_texts"
for filename in os.listdir(PREDICTED_TEST_SAMPLES_DIR.as_posix()):
match = re.search(r"(\d+)\.txt$", filename)
if match:
sample_id = match.group(1)
pred_file_path = (PREDICTED_TEST_SAMPLES_DIR / filename).as_posix()
ref_file_name = "ref_sample_" + str(sample_id) + ".txt"
ref_file_path = (REFERENCE_TEST_SAMPLES_DIR / ref_file_name).as_posix()
if os.path.exists(ref_file_path):
self.total_samples += 1
yield ref_file_path, pred_file_path
def __iter__(self) -> EvaluationTestSample:
"""
Iter method for the test loader
"""
for pred_file_path, ref_file_path in self._load_test_data():
with open(pred_file_path, "r", encoding="utf-8") as file:
pred_text = file.read()
with open(ref_file_path, "r", encoding="utf-8") as file:
ref_text = file.read()
yield EvaluationTestSample(ref_text, pred_text)
class ModelEvaluator:
"""
Class that comprises all model evaluation related processes and methods
"""
# The 2 popular methods of WER differ slightly. More dimensions of accuracy
# will be added. For now, the average of these 2 will serve as the metric.
WEIGHTED_WER_LEVENSHTEIN = 0.0
WER_LEVENSHTEIN = []
WEIGHTED_WER_JIWER = 0.0
WER_JIWER = []
normalizer = None
accuracy = None
test_dataset_loader = None
test_directory = None
evaluation_config = {}
def __init__(self, **kwargs):
self.evaluation_config = {k: v for k, v in kwargs.items() if v is not None}
if "normalizer" not in self.evaluation_config:
self.normalizer = EnglishTextNormalizer()
self.evaluation_config["normalizer"] = str(type(self.normalizer))
if "parent_dir" not in self.evaluation_config:
self.test_directory = Path(__file__).parent
self.test_dataset_loader = TestDatasetLoader(self.test_directory)
self.evaluation_config["test_directory"] = str(self.test_directory)
def __repr__(self):
return "ModelEvaluator(" + json.dumps(self.describe(), indent=4) + ")"
def describe(self) -> dict:
"""
Returns the parameters defining the evaluator
"""
return self.evaluation_config
def _normalize(self, sample: EvaluationTestSample) -> None:
"""
Normalize both reference and predicted text
"""
sample.update(
self.normalizer(sample.reference_text),
self.normalizer(sample.predicted_text),
)
def _calculate_wer(self, sample: EvaluationTestSample) -> float:
"""
Based on weights for (insert, delete, substitute), calculate
the Word Error Rate
"""
levenshtein_distance = distance(
s1=sample.reference_text,
s2=sample.predicted_text,
weights=(
self.evaluation_config["insertion_penalty"],
self.evaluation_config["deletion_penalty"],
self.evaluation_config["substitution_penalty"],
),
)
wer = levenshtein_distance / len(sample.reference_text)
return wer
def _calculate_wers(self) -> None:
"""
Compute WER
"""
for sample in tqdm(self.test_dataset_loader, desc="Evaluating", ncols=100):
self._normalize(sample)
wer_item_l = {
"wer": self._calculate_wer(sample),
"no_of_words": len(sample.reference_text),
}
wer_item_j = {
"wer": wer(sample.reference_text, sample.predicted_text),
"no_of_words": len(sample.reference_text),
}
self.WER_LEVENSHTEIN.append(wer_item_l)
self.WER_JIWER.append(wer_item_j)
def _calculate_weighted_wer(self, wers: List[float]) -> float:
"""
Calculate the weighted WER from WER
"""
total_wer = 0.0
total_words = 0.0
for item in wers:
total_wer += item["no_of_words"] * item["wer"]
total_words += item["no_of_words"]
return total_wer / total_words
def _calculate_model_accuracy(self) -> None:
"""
Compute model accuracy
"""
self._calculate_wers()
weighted_wer_levenshtein = self._calculate_weighted_wer(self.WER_LEVENSHTEIN)
weighted_wer_jiwer = self._calculate_weighted_wer(self.WER_JIWER)
final_weighted_wer = (weighted_wer_levenshtein + weighted_wer_jiwer) / 2
self.accuracy = (1 - final_weighted_wer) * 100
def evaluate(self, recalculate: bool = False) -> EvaluationResult:
"""
Triggers the model evaluation
"""
if not self.accuracy or recalculate:
self._calculate_model_accuracy()
return EvaluationResult(self.accuracy, self.test_dataset_loader.total_samples)
eval_config = {"insertion_penalty": 1, "deletion_penalty": 2, "substitution_penalty": 1}
evaluator = ModelEvaluator(**eval_config)
evaluation = evaluator.evaluate()
print(evaluator)
print(evaluation)
print("Model accuracy : {:.2f} %".format(evaluation.accuracy))

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,620 @@
Technologies ticker symbol w-e-l-l on
the TSX recently reported its 2023 q1
results beating the streets consensus
estimate for revenue and adjusted ebitda
and in a report issued this week Raymond
James analyst said quote we're impressed
by Wells capacity to drive powerful
growth across its diverse business units
in the absence of M A joining me today
is CEO Hamed chabazi to look at what's
next for well health good to see you sir
how are you great to see you Richard
thanks very much for having me great to
have you uh congratulations on your 17th
consecutive quarter of record Revenue
can you share some insights into what's
Driven these results historically and in
the past quarter as well
yeah thank you we we're very excited
about our uh q1 2023 results and as you
mentioned uh we've had a long you know
successful uh string of of uh you know
continued growth and record growth
um we also had accelerating organic
growth and I think um a big part of the
success of our franchise here is the
incredibly sticky and predictable
Revenue that we have you know well over
90 of our business is either highly
reoccurring as in uh the you know highly
predictable uh results of our two-sided
network of patients and providers or
truly recurring as in scheduled or
subscribed revenues and this allows us
to essentially make sure that that uh
you know we're on track it obviously you
know like any other business things
happen uh and sometimes it's hard to
meet those results but what's really
being unique about our platform is we do
have exposure to all kinds of different
aspects of healthcare you know we have
Prime primary care and Specialized Care
on both sides of the Border in the US
and Canada so we have exposure to
different types of business models we
have exposure to the U.S payer Network
which has higher per unit economics than
Canada and of course the stability and
uh and and sort of higher Fidelity uh
kind of Collections and revenue cycle
process that Canada has over the United
States where you don't have to kind of
deal with all of that uh at that payment
noise so just a lot of I think strength
built into the platform because of the
diversity of different Healthcare
businesses that we support
and uh where do you see Well's future
growth coming from which part of the
business uh excites you the most right
now yeah well look the centrifugal force
of well is the healthcare provider and
we exist to uh Tech enable and
ameliorate the business of that of that
Tech of that healthcare provider uh and
and and that's what we're laser focused
on and and what we're seeing is
providers not wanting to run businesses
anymore it's very simple and so we have
a digital platform and providers can
either acquire what they want and need
from our digital platform and implement
it themselves
or they can decide that they don't want
to run a business anymore they don't
want to configure and manage technology
which is becoming a bigger and bigger
part of their world every single day and
when we see what we've seen with that
Dynamic is that uh is that a lot of them
are now just wanting to work in a place
where where all the technology is
configured for them it's wrapped around
them and they have a competent operating
partner that is supporting the organ the
the practice uh and and taking care of
the front office in the back office so
that they can focus on providing care
this results in them seeing more
patients uh and and being happier
because you know they became doctors to
see patients not so they can manage uh
workers and and deal with HR issues and
deal with labs and all that kind of
stuff excellent and I know too that
Acquisitions have played a key role in
well can you share any insights into how
the Acquisitions fit into Wells growth
strategy
sure in in look in 2020 and 2021 we did
a lot of Acquisitions in 2022 we took a
bit of a breather and we've really
focused on integration and I think
that's one of the reasons why you saw
this accelerating organic growth we
really were able to demonstrate that we
could bring together the different
elements of our technology platform we
started to sell bundles we started to
really derive Synergy uh and activate uh
you know more sales as a result of
selling uh all the different products
and services with one voice with One
Vision uh so we made it easier for
providers to use their technology and I
think that was a big reason uh for our
growth now M A as you know where Capital
allocation company we're never far from
it and so we did continue to have you
know tuck-ins here and there and in fact
today uh we announced that we've
acquired uh the Alberta operations of uh
MCI one Health and other publicly traded
company uh who was looking to raise
funds to support their business we're
very pleased with with this acquisition
it just demonstrates our continued
discipline these are you know great
primary care clinics in in Canada right
in the greater Calgary area and uh uh
you know just allows us to grow our
footprint in Alberta which is an
important Province for us and it it's
it's if you look at the price if you
look at what we're getting uh you know
it's just demonstrative of our continued
uh discipline and just you know a few
days ago at our conference call I
mentioned uh that we had you know a
really strong lineup of Acquisitions uh
and you know they're starting to uh uh I
think uh come to fruition for us
a company on the grown-up question I you
recently announced a new AI investment
program last month what specific areas
of healthcare technology or AI are you
focusing on and what's the strategy when
it comes to AI
yes uh look AI as as I'm sure you're
aware is it's become you know really uh
an incredibly important topic in in all
aspects of of business and and you know
not just business socially as well
everyone's talking about uh this this
new breakthrough disruptive technology
the large language models and generative
AI
um I mean look AI uh has been about a 80
year old overnight success a lot of
people have been working on this for a
long time generative AI is just sort of
you know the culmination of a lot of
things coming together and working uh
but it is uncorked enormous uh
Innovation and and we think that um this
there's a very good news story about
this in healthcare particularly where we
were looking to look we were looking to
unlock uh the value of of the data that
that we all produce every single day
um as as humans and and so we've
established an AI investment program
because no one company can can tackle
all of these Innovations themselves and
what well has done too is it's taken a
very much an ecosystem approach by
establishing its apps.health Marketplace
and so we're very excited about not only
uh allocating Capital into promising
young AI companies that are focused on
digital health and solving Healthcare
problems but also giving them access to
um you know safely and securely to our
provider Network to our uh you know to
to our Outpatient Clinic Network which
is the largest owned and operated
Network in Canada by far uh so
um and and when these and it's it was
remarkable when we announced this
program we've had just in the in the
first uh week to 10 days we've had over
a hundred uh inbound prospects come in
uh that that wanted to you know
collaborate with us and again I don't
think that's necessarily for the money
you know we're saying we would invest a
minimum of a quarter of a million
dollars you know a lot of them will
likely be higher than a quarter of a
million dollars
so it's not life-changing money but but
our structural advantages and and and
the benefits that we have in the Well
Network those are extremely hard to come
by uh and I think and I think uh uh
you'll see us uh you know help some of
these companies uh succeed and they will
help us drive uh you know more
Innovation to that helps the provider
but speaking of this very interesting AI
I know your company just launched well
AI voice this is super interesting tell
me what it is and the impact it could
have on health care providers
yeah thanks for uh asking Richard our
providers uh are thrilled with this you
know we've we've had a number of of of
our own well providers testing this
technology and it it it really feels
like magic to them it's essentially an
ambient AI powered scribe so it's a it's
a service that with the consent of the
parties involved listens to the
conversation between a patient and
provider and then uh essentially
condenses that into a medically relevant
note for the chart files uh typically
that is a lengthy process a doctor has
to transcribe notes then review those
notes and make sure that uh a a a a
appropriate medically oriented and
structured node is is is uh prepared and
put into the chart and that could take
you know sometimes more than more time
than the actual consultation uh time and
so we believe that on average if it's
used regularly and consistently this can
give providers back at least a third of
their day
um and and it's it's just a game changer
uh and and uh we have now gone into
General release with this product it's
widely available in Canada uh it has
been integrated into our EMR which makes
it even more valuable tools like this
are going to start popping up but if
they're not integrated into your
practice management system then you have
to kind of have data in in more than one
place and and move that around a little
bit which which makes it a little bit
more difficult especially with HIPAA
requirements and and regulations so
again I think this is the first of many
types of different products and services
that allow doctors to place more
emphasis and focus on the patient
experience instead of having their head
in a laptop and looking at you once in a
while they'll be looking at you and
speaking to their practice management
system and I think this you know think
about it as Alexa for for our doctors uh
you know this this ability to speak uh
and and have you know uh you know Voice
driven AI assistant that does things
like this I think are going to be you
know incredibly helpful and valuable uh
for for healthcare providers
super fascinating I mean we're just
hearing you know more about AI maybe AI
for the first time but here you are with
a product already on the market in the
in the healthcare field that's going to
be pretty attractive to be out there uh
right ahead of many other people right
thank you Richard thanks for that
recognition that's been Our intention we
we want to demonstrate that we uh you
know that we're all in on ensuring that
technology that benefits providers uh is
is is accelerated and uh de-risked and
provided uh you know um in in a timely
way you know providers need this help we
we have a healthcare crisis in the
country that is generally characterized
as a as a lack of doctors and so imagine
if we can get our doctors to be 20 or 30
percent more productive through the use
of these types of tools well they're
going to just see more patience and and
that's going to help all of us and uh
and look if you step back Wells business
model is all about having exposure to
the success of doctors and doing our
best to help them be more successful
because we're in a revenue share
relationship with most of the doctors
that we work with and so this uh this is
good for the ecosystem it's great for
the provider and it's great for well as
well super fascinating I'm Ed shabazzi
CEO well Health Technologies ticker
w-e-l-l great to catch up again thank
you sir
thank you Richard appreciate you having
me
[Music]
thank you

View File

@@ -0,0 +1,970 @@
learning medicine is hard work osmosis
makes it easy it takes our lectures and
notes to create a personalized study
plan with exclusive videos practice
questions and flashcards and so much
more try it free today
in diabetes mellitus your body has
trouble moving glucose which is the type
of sugar from your blood into your cells
this leads to high levels of glucose in
your blood and not enough of it in your
cells and remember that your cells need
glucose as a source of energy so not
letting the glucose enter means that the
cells star for energy despite having
glucose right on their doorstep in
general the body controls how much
glucose is in the blood relative to how
much gets into the cells with two
hormones insulin and glucagon insulin is
used to reduce blood glucose levels and
glucagon is used to increase blood
glucose levels both of these hormones
are produced by clusters of cells in the
pancreas called islets of langerhans
insulin is secreted by beta cells in the
center of these islets and glucagon is
secreted by alpha cells in the periphery
of the islets insulin reduces the amount
of glucose in the blood by binding to
insulin receptors embedded in the cell
membrane of various insulin responsive
tissues like muscle cells in adipose
tissue when activated the insulin
receptors cause vesicles containing
glucose transporter that are inside the
cell to fuse with the cell membrane
allowing glucose to be transported into
the cell glucagon does exactly the
opposite it raises the blood glucose
levels by getting the liver to generate
new molecules of glucose from other
molecules and also break down glycogen
into glucose so that I can all get
dumped into the blood diabetes mellitus
is diagnosed when blood glucose levels
get too high and this is seen among 10
percent of the world population there
are two types of diabetes type 1 and
type 2 and the main difference between
them is the underlying mechanism that
causes the blood glucose levels to rise
about 10% of people with diabetes have
type 1 and the remaining 90% of people
with diabetes have type 2 let's start
with type 1 diabetes mellitus sometimes
just called type 1 diabetes in this
situation the body doesn't make enough
insulin the reason this happens is that
in type 1 diabetes there's a type 4
hypersensitivity response or a cell
mediated immune response where a
person's own T cells at
the pancreas as a quick review remember
that the immune system has T cells that
react to all sorts of antigens which are
usually small peptides polysaccharides
or lipids and that some of these
antigens are part of our own body cells
it doesn't make sense to allow T cells
that will attack our own cells to hang
around until there's this process to
eliminate them called self tolerance in
type 1 diabetes there's a genetic
abnormality that causes a loss of self
tolerance among T cells that
specifically target the beta cell
antigens losing self tolerance means
that these T cells are allowed to
recruit other immune cells and
coordinate an attack on these beta cells
losing beta cells means less insulin and
less insulin means that glucose piles up
in the blood because it can't enter the
body's cells one really important group
of genes involved in regulation of the
immune response is the human leukocyte
antigen system or HLA system even though
it's called a system it's basically this
group of genes on chromosome 6 that
encode the major histocompatibility
complex or MHC which is a protein that's
extremely important in helping the
immune system recognize foreign
molecules as well as maintaining self
tolerance MHC is like the serving
platter that antigens are presented to
the immune cells on interestingly people
with type 1 diabetes often have specific
HLA genes in common with each other one
called
HLA dr3 and another called HLA dr4 but
this is just a genetic clue right
because not everyone with HLA dr3 and
HLA dr4 develops diabetes in diabetes
mellitus type 1 destruction of beta
cells usually starts early in life but
sometimes up to 90% of the beta cells
are destroyed before symptoms crop up
for clinical symptoms of uncontrolled
diabetes that all sound similar our
polyphagia glycosuria polyuria and
polydipsia let's go through them one by
one even though there's a lot of glucose
in the blood it cannot get into the
cells which leaves cells starved for
energy so in response adipose tissue
starts breaking down fat called
lipolysis
and muscle tissue starts breaking down
proteins both of which results in weight
loss for someone with uncontrolled
diabetes this catabolic state leaves
people feeling hungry
also known as poly fascia Faiza means
eating and poly means a lot now with
high glucose levels that means that when
blood gets filtered through the kidneys
some of it starts to spill into the
urine called glycosuria glyco surfers to
glucose and urea the urine since glucose
is osmotically active water tends to
follow it resulting in an increase in
urination or polyuria poly again refers
to a lot and urea again refers to urine
finally because there's so much
urination people with uncontrolled
diabetes become dehydrated and thirsty
or polydipsia poly means a lot and dip
SIA means thirst even though people with
diabetes are not able to produce their
own insulin they can still respond to
insulin so treatment involves lifelong
insulin therapy to regulate their blood
glucose levels and basically enable
their cells to use glucose
one really serious complication with
type 1 diabetes is called diabetic
ketoacidosis or DKA to understand it
let's go back to the process of
lipolysis where fat is broken down into
free fatty acids after that happens the
liver turns the fatty acids into ketone
bodies like Osito acetic acid in beta
hydroxy butyrate acid a seed of acetic
acid is a keto acid because it has a
ketone group in a carboxylic acid group
beta hydroxy rhetoric acid on the other
hand even though it's still one of the
ketone bodies isn't technically a keto
acid since its ketone group has been
reduced to a hydroxyl group these ketone
bodies are important because they can be
used by cells for energy but they also
increase the acidity of the blood which
is why it's called ketoacidosis and the
blood becoming really acidic can have
major effects throughout the body
individuals can develop custom all
respiration which is a deep and labored
breathing as the body tries to move
carbon dioxide out of the blood in an
effort to reduce its acidity cells also
have a transporter that exchanges
hydrogen ions or protons for potassium
when the blood gets acidic it's by
definition loaded with protons that get
sent into cells while potassium gets
sent into the fluid outside cells
another thing to keep in mind is that in
addition to helping glucose enter cells
insulin stimulates the sodium potassium
ATPase --is which help potassium get
into the cells and so without insulin
more potassium stays in the fluid
outside cells both of these mechanisms
lead to increased potassium in the fluid
outside cells which quickly makes it
into the blood and causes hyperkalemia
the potassium is then excreted so over
time even though the blood potassium
levels remain high over all stores of
potassium in the body which include
potassium inside cells starts to run low
individuals will also have a high anion
gap which reflects a large difference in
the unmeasured negative and positive
ions in the serum largely due to the
build-up of ketoacids
diabetic ketoacidosis can happen even in
people who have already been diagnosed
with diabetes and currently have some
sort of insulin therapy
in states of stress like an infection
the body releases epinephrine which in
turn stimulates the release of glucagon
too much glucagon can tip the delicate
hormonal balance of glucagon and insulin
in favor of elevating blood sugars and
can lead to a cascade of events we just
described increased glucose in the blood
loss of glucose in the urine loss of
water dehydration and in parallel and
need for alternative energy generation
of ketone bodies and ketoacidosis
interestingly both ketone bodies break
down into acetone and escape as a gas by
getting breathed out the lungs which
gives us sweet fruity smell to a
person's breath in general though that's
the only sweet thing about this illness
which also causes nausea vomiting and if
severe mental status changes and acute
cerebral edema
treatment of a DKA episode involves
giving plenty of fluids which helps with
dehydration insulin which helps lower
blood glucose levels and replacement of
electrolytes like potassium all of which
help to reverse the acidosis now let's
switch gears and talk about type 2
diabetes which is where the body makes
insulin but the tissues don't respond as
well to it the exact reason why cells
don't respond isn't fully understood
essentially the body's providing the
normal amount of insulin but the cells
don't move their glucose transporters to
their membrane in response which
remember is needed for the glucose to
get into the cells these cells therefore
have insulin resistance some risk
factors for insulin resistance are
obesity lack of exercise and
hypertension the exact mechanisms are
still being explored for example in
excess of adipose tissue or fat is
thought to cause the release of free
fatty acids in so-called edible kinds
which are signaling molecules that can
cause inflammation which seems related
to insulin resistance
however many people that are obese are
not diabetic so genetic factors probably
play a major role as well we see this
when we look at twin studies as well
we're having a twin with type-2 diabetes
increases the risk of developing type 2
diabetes completely independently of
other environmental risk factors in type
2 diabetes since tissues don't respond
as well to normal levels of insulin the
body ends up producing more insulin in
order to get the same effect and move
glucose out of the blood
they do this through beta cell
hyperplasia an increased number of beta
cells and beta cell hypertrophy where
they actually grow in size all in this
attempt to pump out more insulin this
works for a while and by keeping insulin
levels higher than normal blood glucose
levels can be kept normal called normal
glycemia now along with insulin beta
cells also secrete islet amyloid
polypeptide or amylin so while beta
cells are cranking out insulin they also
secrete an increased amount of amylin
over time Emlyn builds up and aggregates
in the islets this beta cell
compensation though is not sustainable
and over time those maxed out beta cells
get exhausted and they become
dysfunctional and undergo hypo trophy
and get smaller as well as hypoplasia
and die off as beta cells are lost in
insulin levels decrease glucose levels
in the blood start to increase in
patients develop hyperglycemia which
leads to similar clinical signs that we
mentioned before like Paul aphasia
glycosuria polyuria polydipsia but
unlike type 1 diabetes there's generally
some circulating insulin in type 2
diabetes from the beta cells that are
trying to compensate for the insulin
resistance this means that the insulin
glucagon balances such that diabetic
ketoacidosis does not usually develop
having said that a complication called
hyperosmolar hyperglycemic state or HHS
is much more common in type 2 diabetes
than type 1 diabetes and it causes
increased plasma osmolarity due to
extreme dehydration and concentration of
the blood to help understand this
remember that glucose is a polar
molecule that cannot passively diffuse
across cell membranes which means that
it acts as a solute so when levels of
glucose are super high in the blood
meaning it's a hyperosmolar State water
starts to leave the body cells and enter
the blood vessels leaving the cells were
relatively dry in travailed rather than
plump and juicy blood vessels that are
full of water lead to increased
urination and total body dehydration and
this is a very serious situation because
the dehydration of the body's cells and
in particular the brain can cause a
number of symptoms including mental
status changes in HHS you can sometimes
see mild ketone emia and acidosis but
not to the extent that it's seen in DKA
and in DKA you can see some hyper
osmolarity so there's definitely overlap
between these two syndromes
besides type 1 and type 2 diabetes there
are also a couple other subtypes of
diabetes mellitus gestational diabetes
is when pregnant women have increased
blood glucose which is particularly
during the third trimester although
ultimately unknown the cause is thought
to be related to pregnancy hormones that
interfere with insulins action on
insulin receptors also sometimes people
can develop drug-induced diabetes which
is where medications have side effects
that tend to increase blood glucose
levels the mechanism for both of these
is thought to be related to insulin
resistance like type 2 diabetes rather
than an autoimmune destruction process
like in type 1 diabetes diagnosing type
1 or type 2 diabetes is done by getting
a sense for how much glucose is floating
around in the blood and has specific
standards that the World Health
Organization uses very commonly a
fasting glucose test is taken where the
person doesn't eat or drink except the
water that's okay for a total of eight
hours and then has their blood tested
for glucose levels levels of 100
milligrams per deciliter to 120
five milligrams per deciliter indicates
pre-diabetes and 126 milligrams per
deciliter or higher indicates diabetes a
non fasting a random glucose test can be
done at any time with 200 milligrams per
deciliter or higher being a red flag for
diabetes another test is called an oral
glucose tolerance test where person is
given glucose and then blood samples are
taken at time intervals to figure out
how well it's being cleared from the
blood the most important interval being
two hours later levels of 140 milligrams
per deciliter to 199 milligrams per
deciliter indicate pre-diabetes
and 200 or above indicates diabetes
another thing to know is that when blood
glucose levels get high the glucose can
also stick to proteins that are floating
around in the blood or in cells so that
brings us to another type of test that
can be done which is the hba1c test
which tests for the proportion of
hemoglobin in red blood cells that has
glucose stuck to it called glycated
hemoglobin hba1c levels of 5.7% 26.4%
indicate pre-diabetes
and 6.5 percent or higher indicates
diabetes this proportion of glycated
hemoglobin doesn't change day to day so
it gives a sense for whether the blood
glucose levels have been high over the
past two to three months finally we have
the c-peptide test which tests for
byproducts of insulin production if the
level of c-peptide is low or absent it
means the pancreas is no longer
producing enough insulin and the glucose
cannot enter the cells
for type one diabetes insulin is the
only treatment option for type 2
diabetes on the other hand lifestyle
changes like weight loss and exercise
along with a healthy diet and an oral
anti-diabetic medication like metformin
in several other classes can sometimes
be enough to reverse some of that
insulin resistance and keep blood sugar
levels in check however if oral
anti-diabetic medications fail type 2
diabetes can also be treated with
insulin something to bear in mind is
that insulin treatment comes with a risk
of hypoglycemia especially if insulin is
taken without a meal symptoms of
hypoglycemia can be mild like weakness
hunger and shaking but they can progress
to a loss of consciousness in seizures
in severe cases in mild cases drinking
juices or eating candy or sugar might be
enough to bring blood sugar up but in
severe cases intravenous glucose should
be given as soon as possible
the FDA has also recently approved
intranasal glucagon as a treatment for
severe hypoglycemia all right now over
time high glucose levels can cause
damage to tiny blood vessels while the
micro vasculature in arterioles a
process called hyaline
arteriolosclerosis is where the walls of
the arterioles develop hyaline deposits
which are deposits of proteins and these
make them hard and inflexible in
capillaries the basement membrane can
thicken and make it difficult for oxygen
to easily move from the capillary to the
tissues causing hypoxia
one of the most significant effects is
that diabetes increases the risk of
medium and large arterial wall damage
and subsequent atherosclerosis which can
lead to heart attacks and strokes which
are major causes of morbidity and
mortality for patients with diabetes in
the eyes diabetes can lead to
retinopathy and evidence of that can be
seen on a fundus copic exam that shows
cotton-wool spots or flare hemorrhages
and can eventually cause blindness in
the kidneys the a ferrant and efferent
arterioles as well as the glomerulus
itself can get damaged which can lead to
an F Radek syndrome that slowly
diminishes the kidneys ability to filter
blood over time and can ultimately lead
to dialysis diabetes can also affect the
function of nerves causing symptoms like
a decrease in sensation in the toes and
fingers sometimes called a stocking
glove distribution as well as causes the
autonomic nervous system to malfunction
and that system controls a number of
body functions
everything from sweating to passing gas
finally both the poor blood supply and
nerve damage can lead to ulcers
typically on the feet that don't heal
quickly and can get pretty severe and
need to be amputated these are some of
the complications of uncontrolled
diabetes which is why it's important to
diagnose and control diabetes through a
healthy lifestyle medications to reduce
insulin resistance and even insulin
therapy if beta cells have been
exhausted while type 1 diabetes cannot
be prevented type 2 diabetes can in fact
many people with diabetes can control
their blood sugar levels really
effectively and live a full and active
life without any of the complications
thanks for watching if you're interested
in a deeper dive on this topic take a
look at as Moses org where we have
flashcards questions and other awesome
tools to help you learn medicine
you