Skip to content

Commit

Permalink
add substance use
Browse files Browse the repository at this point in the history
  • Loading branch information
Amy Chen committed Oct 29, 2024
1 parent 64c36e7 commit 7c9dcd5
Show file tree
Hide file tree
Showing 11 changed files with 354 additions and 15 deletions.
2 changes: 1 addition & 1 deletion src/db/build/LeafDB.Init.sql
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ INSERT [ref].[Shape] ([Id], [Variant], [Schema]) VALUES (-1, N'Dynamic', N'{"fie
INSERT [ref].[Shape] ([Id], [Variant], [Schema]) VALUES (1, N'Observation', N'{"fields":[{"name":"category","type":"String","phi":false,"mask":false,"required":true},{"name":"code","type":"String","phi":false,"mask":false,"required":true},{"name":"effectiveDate","type":"DateTime","phi":true,"mask":true,"required":true},{"name":"encounterId","type":"String","phi":true,"mask":true,"required":true},{"name":"referenceRangeLow","type":"Numeric","phi":false,"mask":false,"required":false},{"name":"referenceRangeHigh","type":"Numeric","phi":false,"mask":false,"required":false},{"name":"specimenType","type":"String","phi":false,"mask":false,"required":false},{"name":"valueString","type":"String","phi":false,"mask":false,"required":true},{"name":"valueQuantity","type":"Numeric","phi":false,"mask":false,"required":false},{"name":"valueUnit","type":"String","phi":false,"mask":false,"required":false},{"name":"personId","type":"String","phi":true,"mask":true,"required":true}]}')
INSERT [ref].[Shape] ([Id], [Variant], [Schema]) VALUES (2, N'Encounter', N'{"fields":[{"name":"admitDate","type":"DateTime","phi":true,"mask":true,"required":true},{"name":"admitSource","type":"String","phi":false,"mask":false,"required":false},{"name":"class","type":"String","phi":false,"mask":false,"required":true},{"name":"dischargeDate","type":"DateTime","phi":true,"mask":true,"required":true},{"name":"dischargeDisposition","type":"String","phi":false,"mask":false,"required":false},{"name":"encounterId","type":"String","phi":true,"mask":true,"required":true},{"name":"location","type":"String","phi":false,"mask":false,"required":true},{"name":"status","type":"String","phi":false,"mask":false,"required":false},{"name":"personId","type":"String","phi":true,"mask":true,"required":true}]}')
INSERT [ref].[Shape] ([Id], [Variant], [Schema]) VALUES (3, N'Demographic', N'{"fields":[{"name":"addressPostalCode","type":"String","phi":false,"mask":false,"required":true},{"name":"addressState","type":"String","phi":false,"mask":false,"required":true},{"name":"ethnicity","type":"String","phi":false,"mask":false,"required":true},{"name":"gender","type":"String","phi":false,"mask":false,"required":true},
{"name":"sex","type":"String","phi":false,"mask":false,"required":true},{"name":"age","type":"Numeric","phi":false,"mask":false,"required":true},{"name":"language","type":"String","phi":false,"mask":false,"required":true},{"name":"maritalStatus","type":"String","phi":false,"mask":false,"required":true},{"name":"race","type":"String","phi":false,"mask":false,"required":true},{"name":"religion","type":"String","phi":false,"mask":false,"required":true},{"name":"marriedBoolean","type":"Bool","phi":false,"mask":false,"required":true},{"name":"hispanicBoolean","type":"Bool","phi":false,"mask":false,"required":true},{"name":"deceasedBoolean","type":"Bool","phi":false,"mask":false,"required":true},{"name":"birthDate","type":"DateTime","phi":true,"mask":true,"required":false},{"name":"deceasedDateTime","type":"DateTime","phi":true,"mask":true,"required":false},{"name":"name","type":"String","phi":true,"mask":false,"required":false},{"name":"mrn","type":"String","phi":true,"mask":false,"required":false},{"name":"personId","type":"String","phi":true,"mask":true,"required":true}]}')
{"name":"sex","type":"String","phi":false,"mask":false,"required":true},{"name":"age","type":"Numeric","phi":false,"mask":false,"required":true},{"name":"language","type":"String","phi":false,"mask":false,"required":true},{"name":"maritalStatus","type":"String","phi":false,"mask":false,"required":true},{"name":"race","type":"String","phi":false,"mask":false,"required":true},{"name":"religion","type":"String","phi":false,"mask":false,"required":true},{"name":"marriedBoolean","type":"Bool","phi":false,"mask":false,"required":true},{"name":"hispanicBoolean","type":"Bool","phi":false,"mask":false,"required":true},{"name":"deceasedBoolean","type":"Bool","phi":false,"mask":false,"required":true},{"name":"birthDate","type":"DateTime","phi":true,"mask":true,"required":false},{"name":"deceasedDateTime","type":"DateTime","phi":true,"mask":true,"required":false},{"name":"name","type":"String","phi":true,"mask":false,"required":false},{"name":"mrn","type":"String","phi":true,"mask":false,"required":false},{"name":"coccur","type":"Numeric","required":true},{"name":"methcur","type":"Numeric","required":true},{"name":"opicur","type":"Numeric","required":true},{"name":"potcur","type":"Numeric","required":true},{"name":"sedcur","type":"Numeric","required":true},{"name":"inhcur","type":"Numeric","required":true},{"name":"stimcur","type":"Numeric","required":true},{"name":"halcur","type":"Numeric","required":true},{"name":"personId","type":"String","phi":true,"mask":true,"required":true}]}')
INSERT [ref].[Shape] ([Id], [Variant], [Schema]) VALUES (4, N'Condition', N'{"fields":[{"name":"abatementDateTime","type":"DateTime","phi":true,"mask":true,"required":false},{"name":"category","type":"String","phi":false,"mask":false,"required":true},{"name":"code","type":"String","phi":false,"mask":false,"required":true},{"name":"coding","type":"String","phi":false,"mask":false,"required":true},{"name":"encounterId","type":"String","phi":true,"mask":true,"required":true},{"name":"onsetDateTime","type":"DateTime","phi":true,"mask":true,"required":true},{"name":"recordedDate","type":"DateTime","phi":true,"mask":true,"required":false},{"name":"text","type":"String","phi":false,"mask":false,"required":true}]}')
INSERT [ref].[Shape] ([Id], [Variant], [Schema]) VALUES (5, N'Procedure', N'{"fields":[{"name":"category","type":"String","phi":false,"mask":false,"required":true},{"name":"code","type":"String","phi":false,"mask":false,"required":true},{"name":"coding","type":"String","phi":false,"mask":false,"required":true},{"name":"encounterId","type":"String","phi":true,"mask":true,"required":true},{"name":"performedDateTime","type":"DateTime","phi":true,"mask":true,"required":true},{"name":"text","type":"String","phi":false,"mask":false,"required":true}]}')
INSERT [ref].[Shape] ([Id], [Variant], [Schema]) VALUES (6, N'Immunization', N'{"fields":[{"name":"vaccineCode","type":"String","phi":false,"mask":false,"required":true},{"name":"coding","type":"String","phi":false,"mask":false,"required":true},{"name":"doseQuantity","type":"Numeric","phi":false,"mask":false,"required":false},{"name":"doseUnit","type":"String","phi":false,"mask":false,"required":false},{"name":"encounterId","type":"String","phi":true,"mask":true,"required":true},{"name":"occurrenceDateTime","type":"DateTime","phi":true,"mask":true,"required":true},{"name":"route","type":"String","phi":false,"mask":false,"required":false},{"name":"text","type":"String","phi":false,"mask":false,"required":true}]}')
Expand Down
20 changes: 18 additions & 2 deletions src/server/Model/Cohort/DatasetRecord.cs
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,15 @@ public PatientDemographic ToIdentifiedPatientDemographic()
BirthDate = BirthDate,
DeceasedDateTime = DeceasedDateTime,
Name = Name.ValueElseUnknown(),
Mrn = Mrn.ValueElseUnknown()
Mrn = Mrn.ValueElseUnknown(),
Coccur = Coccur,
Methcur = Methcur,
Opicur = Opicur,
Potcur = Potcur,
Sedcur = Sedcur,
Inhcur = Inhcur,
Stimcur = Stimcur,
Halcur = Halcur
};
}

Expand All @@ -310,7 +318,15 @@ public PatientDemographic ToAnonymousPatientDemographic()
Religion = Religion.ValueElseUnknown(),
IsMarried = IsMarried,
IsHispanic = IsHispanic,
IsDeceased = IsDeceased
IsDeceased = IsDeceased,
Coccur = Coccur,
Methcur = Methcur,
Opicur = Opicur,
Potcur = Potcur,
Sedcur = Sedcur,
Inhcur = Inhcur,
Stimcur = Stimcur,
Halcur = Halcur
};
}
}
Expand Down
224 changes: 223 additions & 1 deletion src/server/Model/Cohort/DemographicAggregator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,62 @@ public class DemographicAggregator
Right = new BinarySplit { Label = "Not Married", Value = 0 }
};

readonly BinarySplitPair CoccurSplit = new BinarySplitPair
{
Category = "CurrentCocaineUse",
Left = new BinarySplit { Label = "Using Cocaine/crack", Value = 0 },
Right = new BinarySplit { Label = "Not Using Cocaine/crack", Value = 0 }
};

readonly BinarySplitPair MethcurSplit = new BinarySplitPair
{
Category = "CurrentMethUse",
Left = new BinarySplit { Label = "Using Meth", Value = 0 },
Right = new BinarySplit { Label = "Not Using Meth", Value = 0 }
};

readonly BinarySplitPair OpicurSplit = new BinarySplitPair
{
Category = "CurrentOpioidUse",
Left = new BinarySplit { Label = "Using Opioid", Value = 0 },
Right = new BinarySplit { Label = "Not Using Opioid", Value = 0 }
};

readonly BinarySplitPair SedcurSplit = new BinarySplitPair
{
Category = "CurrentSedUse",
Left = new BinarySplit { Label = "Using Sedative", Value = 0 },
Right = new BinarySplit { Label = "Not Using Sedative", Value = 0 }
};

readonly BinarySplitPair StimcurSplit = new BinarySplitPair
{
Category = "CurrentStimUse",
Left = new BinarySplit { Label = "Using Stimulant", Value = 0 },
Right = new BinarySplit { Label = "Not Using Stimulant", Value = 0 }
};

readonly BinarySplitPair HalcurSplit = new BinarySplitPair
{
Category = "CurrentHalUse",
Left = new BinarySplit { Label = "Using Hallucinogen", Value = 0 },
Right = new BinarySplit { Label = "Not Using Hallucinogen", Value = 0 }
};

readonly BinarySplitPair PotcurSplit = new BinarySplitPair
{
Category = "CurrentPotUse",
Left = new BinarySplit { Label = "Using Cannabis", Value = 0 },
Right = new BinarySplit { Label = "Not Using Cannabis", Value = 0 }
};

readonly BinarySplitPair InhcurSplit = new BinarySplitPair
{
Category = "CurrentInhUse",
Left = new BinarySplit { Label = "Using Inhalant", Value = 0 },
Right = new BinarySplit { Label = "Not Using Inhalant", Value = 0 }
};

readonly DistributionData<AgeByGenderBucket> AgeBreakdown = new DistributionData<AgeByGenderBucket>(ageBuckets);

readonly VariableBucketSet LanguageByHeritage = new VariableBucketSet();
Expand Down Expand Up @@ -87,11 +143,33 @@ public DemographicStatistics Aggregate()
RecordGender(patient);
RecordNih(patient);
RecordAge(patient);
RecordCoccur(patient);
RecordMethcur(patient);
RecordOpicur(patient);
RecordPotcur(patient);
RecordSedcur(patient);
RecordInhcur(patient);
RecordStimcur(patient);
RecordHalcur(patient);
}

return new DemographicStatistics
{
BinarySplitData = new List<BinarySplitPair> { GenderSplit, VitalSplit, AARPSplit, HispanicSplit, MarriedSplit },
BinarySplitData = new List<BinarySplitPair> {
GenderSplit,
VitalSplit,
AARPSplit,
HispanicSplit,
MarriedSplit,
CoccurSplit,
MethcurSplit,
OpicurSplit,
PotcurSplit,
SedcurSplit,
InhcurSplit,
StimcurSplit,
HalcurSplit
},
AgeByGenderData = AgeBreakdown,
LanguageByHeritageData = LanguageByHeritage,
ReligionData = Religion,
Expand Down Expand Up @@ -169,6 +247,150 @@ BinarySplit RecordMarried(PatientDemographic patient)
return side;
}

BinarySplit RecordCoccur(PatientDemographic patient)
{
if (patient.Coccur == null)
{
return null;
}

BinarySplit side = CoccurSplit.Right;

if (patient.Coccur >= 1)
{
side = CoccurSplit.Left;
}

side.Value++;
return side;
}

BinarySplit RecordMethcur(PatientDemographic patient)
{
if (patient.Methcur == null)
{
return null;
}

BinarySplit side = MethcurSplit.Right;

if (patient.Methcur >= 1)
{
side = MethcurSplit.Left;
}

side.Value++;
return side;
}

BinarySplit RecordOpicur(PatientDemographic patient)
{
if (patient.Opicur == null)
{
return null;
}

BinarySplit side = OpicurSplit.Right;

if (patient.Opicur >= 1)
{
side = OpicurSplit.Left;
}

side.Value++;
return side;
}

BinarySplit RecordPotcur(PatientDemographic patient)
{
if (patient.Potcur == null)
{
return null;
}

BinarySplit side = PotcurSplit.Right;

if (patient.Potcur >= 1)
{
side = PotcurSplit.Left;
}

side.Value++;
return side;
}

BinarySplit RecordSedcur(PatientDemographic patient)
{
if (patient.Sedcur == null)
{
return null;
}

BinarySplit side = SedcurSplit.Right;

if (patient.Sedcur >= 1)
{
side = SedcurSplit.Left;
}

side.Value++;
return side;
}

BinarySplit RecordInhcur(PatientDemographic patient)
{
if (patient.Inhcur == null)
{
return null;
}

BinarySplit side = InhcurSplit.Right;

if (patient.Inhcur >= 1)
{
side = InhcurSplit.Left;
}

side.Value++;
return side;
}

BinarySplit RecordStimcur(PatientDemographic patient)
{
if (patient.Stimcur == null)
{
return null;
}

BinarySplit side = StimcurSplit.Right;

if (patient.Stimcur >= 1)
{
side = StimcurSplit.Left;
}

side.Value++;
return side;
}

BinarySplit RecordHalcur(PatientDemographic patient)
{
if (patient.Halcur == null)
{
return null;
}

BinarySplit side = HalcurSplit.Right;

if (patient.Halcur >= 1)
{
side = HalcurSplit.Left;
}

side.Value++;
return side;
}

void RecordLanguageByHeritage(PatientDemographic patient)
{
LanguageByHeritage.Increment(patient.Race, patient.Language);
Expand Down
49 changes: 49 additions & 0 deletions src/server/Model/Cohort/MarshalPlan.cs
Original file line number Diff line number Diff line change
Expand Up @@ -574,6 +574,14 @@ public sealed class DemographicMarshalPlan : MarshalPlan
public SchemaField Name { get; set; }
public SchemaField Mrn { get; set; }
public SchemaField Sex { get; set; }
public SchemaField Coccur { get; set;}
public SchemaField Methcur { get; set;}
public SchemaField Opicur { get; set;}
public SchemaField Potcur { get; set;}
public SchemaField Sedcur { get; set;}
public SchemaField Inhcur { get; set;}
public SchemaField Stimcur { get; set;}
public SchemaField Halcur { get; set;}

public DemographicMarshalPlan()
{
Expand Down Expand Up @@ -671,6 +679,47 @@ public DemographicMarshalPlan(DatasetResultSchema schema) : base(schema)
{
Age = age;
}

if (schema.TryGet(DemographicColumns.Coccur, out var coccur))
{
Coccur = coccur;
}

if (schema.TryGet(DemographicColumns.Methcur, out var methcur))
{
Methcur = methcur;
}

if (schema.TryGet(DemographicColumns.Opicur, out var opicur))
{
Opicur = opicur;
}

if (schema.TryGet(DemographicColumns.Potcur, out var potcur))
{
Potcur = potcur;
}

if (schema.TryGet(DemographicColumns.Sedcur, out var sedcur))
{
Sedcur = sedcur;
}

if (schema.TryGet(DemographicColumns.Inhcur, out var inhcur))
{
Inhcur = inhcur;
}

if (schema.TryGet(DemographicColumns.Stimcur, out var stimcur))
{
Stimcur = stimcur;
}

if (schema.TryGet(DemographicColumns.Halcur, out var halcur))
{
Halcur = halcur;
}

}
}
}
24 changes: 24 additions & 0 deletions src/server/Model/Cohort/PatientDemographic.cs
Original file line number Diff line number Diff line change
Expand Up @@ -63,5 +63,29 @@ public class PatientDemographic : ShapedDataset

[Field(Name = DemographicColumns.Mrn, Type = LeafType.String, Phi = true, Mask = false)]
public string Mrn { get; set; }

[Field(Name = DemographicColumns.Coccur, Type = LeafType.Numeric, Required = true)]
public int? Coccur { get; set; }

[Field(Name = DemographicColumns.Methcur, Type = LeafType.Numeric, Required = true)]
public int? Methcur { get; set; }

[Field(Name = DemographicColumns.Opicur, Type = LeafType.Numeric, Required = true)]
public int? Opicur { get; set; }

[Field(Name = DemographicColumns.Potcur, Type = LeafType.Numeric, Required = true)]
public int? Potcur { get; set; }

[Field(Name = DemographicColumns.Sedcur, Type = LeafType.Numeric, Required = true)]
public int? Sedcur { get; set; }

[Field(Name = DemographicColumns.Inhcur, Type = LeafType.Numeric, Required = true)]
public int? Inhcur { get; set; }

[Field(Name = DemographicColumns.Stimcur, Type = LeafType.Numeric, Required = true)]
public int? Stimcur { get; set; }

[Field(Name = DemographicColumns.Halcur, Type = LeafType.Numeric, Required = true)]
public int? Halcur { get; set; }
}
}
8 changes: 8 additions & 0 deletions src/server/Model/Compiler/Shape.cs
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,14 @@ public static class DemographicColumns
public const string Name = "name";
public const string Mrn = "mrn";
public const string Sex = "sex";
public const string Coccur = "coccur";
public const string Methcur = "methcur";
public const string Opicur = "opicur";
public const string Potcur = "potcur";
public const string Sedcur = "sedcur";
public const string Inhcur = "inhcur";
public const string Stimcur = "stimcur";
public const string Halcur = "halcur";
}

public static class ConditionColumns
Expand Down
Loading

0 comments on commit 7c9dcd5

Please sign in to comment.