Skip to content

Commit

Permalink
Merge pull request #683 from palladiumkenya/feat/new-reporting-layer
Browse files Browse the repository at this point in the history
Feat/new reporting layer
  • Loading branch information
cbrianbet authored Dec 19, 2023
2 parents 5e741ed + 0d9b260 commit ec2dceb
Show file tree
Hide file tree
Showing 30 changed files with 326 additions and 82 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -42,5 +42,5 @@ export class AggregateAdverseEvents {
Severity: string;

@Column('int')
AdverseEventCount: string;
AdverseEventsCount: string;
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export class GetAdultsAdverseEventsHandler implements IQueryHandler<GetAdultsAdv
const adultsAEs = this.repository
.createQueryBuilder('f')
.select(
'SUM([AdverseEventCount]) total, DATIMAgeGroup, Gender, CAST((cast(SUM([AdverseEventCount]) as decimal (9,2))/ (SUM(SUM([AdverseEventCount])) OVER (PARTITION BY DATIMAgeGroup ORDER BY DATIMAgeGroup))*100) as decimal(9,2)) AS adverseEventsByAgeGroup',
'SUM([AdverseEventsCount]) total, DATIMAgeGroup, Gender, CAST((cast(SUM([AdverseEventsCount]) as decimal (9,2))/ (SUM(SUM([AdverseEventsCount])) OVER (PARTITION BY DATIMAgeGroup ORDER BY DATIMAgeGroup))*100) as decimal(9,2)) AS adverseEventsByAgeGroup',
)
.where(
"[DATIMAgeGroup] NOT IN (' Under 1', '01 to 04', '05 to 09', '10 to 14')",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export class GetAdverseEventsHandler implements IQueryHandler<GetAdverseEventsQu
const adultsAEs = this.repository
.createQueryBuilder('f')
.select(
'SUM([AdverseEventCount]) total, DATIMAgeGroup, Gender, CAST((cast(SUM([AdverseEventCount]) as decimal (9,2))/ (SUM(SUM([AdverseEventCount])) OVER (PARTITION BY DATIMAgeGroup ORDER BY DATIMAgeGroup))*100) as decimal(9,2)) AS adverseEventsByAgeGroup',
'SUM([AdverseEventsCount]) total, DATIMAgeGroup, Gender, CAST((cast(SUM([AdverseEventsCount]) as decimal (9,2))/ (SUM(SUM([AdverseEventsCount])) OVER (PARTITION BY DATIMAgeGroup ORDER BY DATIMAgeGroup))*100) as decimal(9,2)) AS adverseEventsByAgeGroup',
)
.where('[DATIMAgeGroup] IS NOT NULL');

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export class GetAeActionsByDrugsNewHandler implements IQueryHandler<GetAeActions
const aeActionsByDrugsNew = this.repository
.createQueryBuilder('f')
.select(
'[AdverseEventCause], [AdverseEventActionTaken], SUM([AdverseEventCount]) total, DATIMAgeGroup ageGroup',
'[AdverseEventCause], [AdverseEventActionTaken], SUM([AdverseEventsCount]) total, DATIMAgeGroup ageGroup',
)
.where('[MFLCode] > 0')
.andWhere('[AdverseEventCause] IS NOT NULL')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export class GetAeActionsByDrugsHandler implements IQueryHandler<GetAeActionsByD
const aeActionsByDrugs = this.repository
.createQueryBuilder('f')
.select(
'[Severity], [AdverseEventCause], SUM([AdverseEventCount]) total, DATIMAgeGroup ageGroup',
'[Severity], [AdverseEventCause], SUM([AdverseEventsCount]) total, DATIMAgeGroup ageGroup',
)
.where('[AdverseEventCause] IS NOT NULL');

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export class GetAeActionsBySeverityHandler implements IQueryHandler<GetAeActions
"WHEN [AdverseEventActionTaken] = 'Select' OR [AdverseEventActionTaken] IS NULL OR [AdverseEventActionTaken] = 'Other' THEN 'Undocumented' " +
"WHEN [AdverseEventActionTaken] = 'Severe' OR [AdverseEventActionTaken] = 'Mild' OR [AdverseEventActionTaken] = 'Moderate' THEN 'Undocumented' " +
'ELSE [AdverseEventActionTaken] END,' +
'SUM([AdverseEventCount]) total, DATIMAgeGroup ageGroup',
'SUM([AdverseEventsCount]) total, DATIMAgeGroup ageGroup',
)
.where("ISNULL([Severity],'') <> ''");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export class GetAeSeverityGradingHandler
const aeSeverityGrading = this.repository
.createQueryBuilder('f')
.select(
'[Severity], DATIMAgeGroup ageGroup, SUM([AdverseEventCount]) total',
'[Severity], DATIMAgeGroup ageGroup, SUM([AdverseEventsCount]) total',
)
.where("ISNULL([Severity],'') <> ''");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export class GetAeTypeBySeverityHandler implements IQueryHandler<GetAeTypeBySeve
const aeTypesBySeverity = this.repository
.createQueryBuilder('f')
.select(
'[Severity], [AdverseEvent], SUM([AdverseEventCount]) total',
'[Severity], [AdverseEvent], SUM([AdverseEventsCount]) total',
)
.where("ISNULL([Severity],'') <> ''");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export class GetChildrenAdverseEventsHandler implements IQueryHandler<GetChildre
const childrenAEs = this.repository
.createQueryBuilder('f')
.select(
'SUM([AdverseEventCount]) total, DATIMAgeGroup, Gender, CAST((cast(SUM([AdverseEventCount]) as decimal (9,2))/ (SUM(SUM([AdverseEventCount])) OVER (PARTITION BY DATIMAgeGroup ORDER BY DATIMAgeGroup))*100) as decimal(9,2)) AS adverseEventsByAgeGroup',
'SUM([AdverseEventsCount]) total, DATIMAgeGroup, Gender, CAST((cast(SUM([AdverseEventsCount]) as decimal (9,2))/ (SUM(SUM([AdverseEventsCount])) OVER (PARTITION BY DATIMAgeGroup ORDER BY DATIMAgeGroup))*100) as decimal(9,2)) AS adverseEventsByAgeGroup',
)
.where("[DATIMAgeGroup] IN (' Under 1', '01 to 04', '05 to 09', '10 to 14')");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export class GetNumberAeReportedInAdultsOver15Handler implements IQueryHandler<G
async execute(query: GetNumberAeReportedInAdultsOver15Query): Promise<any> {
const noOfReportedAeinAdults = this.repository
.createQueryBuilder('f')
.select('SUM([AdverseEventCount]) total')
.select('SUM([AdverseEventsCount]) total')
.where(
"[DATIMAgeGroup] NOT IN (' Under 1', '01 to 04', '05 to 09', '10 to 14')",
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export class GetNumberAeReportedInChildrenOver15Handler implements IQueryHandler
async execute(query: GetNumberAeReportedInChildrenOver15Query): Promise<any> {
const noOfReportedAeinChildren = this.repository
.createQueryBuilder('f')
.select('SUM([AdverseEventCount]) total')
.select('SUM([AdverseEventsCount]) total')
.where("[DATIMAgeGroup] IN (' Under 1', '01 to 04', '05 to 09', '10 to 14')");

if (query.county) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export class GetProportionOfPlHIVOnArtWithAeByTypeOfSuspectedCausativeDrugsHandl
const proportionOfPlHIVByCausativeDrugs = this.repository
.createQueryBuilder('f')
.select([
'AdverseEventCause adverseEventCause, SUM(AdverseEventCount) count_cat',
'AdverseEventCause adverseEventCause, SUM(AdverseEventsCount) count_cat',
])
.andWhere('f.MFLCode IS NOT NULL');

Expand Down Expand Up @@ -51,7 +51,7 @@ export class GetProportionOfPlHIVOnArtWithAeByTypeOfSuspectedCausativeDrugsHandl

return await proportionOfPlHIVByCausativeDrugs
.groupBy('f.AdverseEventCause')
.orderBy('SUM(AdverseEventCount)', 'DESC')
.orderBy('SUM(AdverseEventsCount)', 'DESC')
.getRawMany();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export class GetProportionOfPLHIVWithAeRelatedToArtHandler implements IQueryHand
const proportionOfPlHIVWithAeRelatedToArt = this.repository
.createQueryBuilder('f')
.select([
'AdverseEventCause adverseEventCause, SUM(AdverseEventCount) count_cat',
'AdverseEventCause adverseEventCause, SUM(AdverseEventsCount) count_cat',
])
.andWhere(
"AdverseEventCause IN ('Dolutegravir','Atazanavir','TLE','Efavirenz','Tenofavir','Didanosin','Lamivudine','Lamivudine','Lopinavir','Abacavir','TLD','Nevirapine','Zidovudine','Stavudine')",
Expand Down Expand Up @@ -56,7 +56,7 @@ export class GetProportionOfPLHIVWithAeRelatedToArtHandler implements IQueryHand

return await proportionOfPlHIVWithAeRelatedToArt
.groupBy('f.AdverseEventCause')
.orderBy('SUM(AdverseEventCount)', 'DESC')
.orderBy('SUM(AdverseEventsCount)', 'DESC')
.getRawMany();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export class GetProportionOfPLHIVWithAeWhoseRegimenChangedHandler implements IQu
const proportionOfPLHIVWithAeWhoseRegimenChanged = this.repository
.createQueryBuilder('f')
.select(
'AdverseEventActionTaken adverseEventActionTaken, SUM(AdverseEventCount) numberOfPatientsAe',
'AdverseEventActionTaken adverseEventActionTaken, SUM(AdverseEventsCount) numberOfPatientsAe',
)
.andWhere(
`f.AdverseEventActionTaken in ('Medicine causing AE substituted/withdrawn', 'SUBSTITUTED DRUG|SUBSTITUTED DRUG', 'Drug Substituted', 'Drug Withdrawn')`,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export class GetProportionOfPLHIVWithAeWhoseRegimenWasNotAlteredHandler implemen
const proportionOfPLHIVWithAeWhoseRegimenNotAltered = this.repository
.createQueryBuilder('f')
.select(
'AdverseEventActionTaken adverseEventActionTaken, SUM(AdverseEventCount) numberOfPatientsAe',
'AdverseEventActionTaken adverseEventActionTaken, SUM(AdverseEventsCount) numberOfPatientsAe',
)
.andWhere('f.AdverseEventActionTaken in (:...AdverseEventActionTaken)', {
AdverseEventActionTaken: ['Medicine not changed', 'Drug not Changed'],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export class GetProportionOfPLHIVWithAeWhoseRegimenWasStoppedHandler implements
const proportionOfPLHIVWithAeWhoseRegimenWasStopped = this.repository
.createQueryBuilder('f')
.select(
'AdverseEventActionTaken adverseEventActionTaken, SUM(AdverseEventCount) numberOfPatientsAe',
'AdverseEventActionTaken adverseEventActionTaken, SUM(AdverseEventsCount) numberOfPatientsAe',
)
.andWhere('f.AdverseEventActionTaken = (:...AdverseEventActionTaken)', {
AdverseEventActionTaken: ['All drugs stopped'],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export class GetReportedAesWithSeverityLevelsHandler implements IQueryHandler<Ge
const reportedAesWithSeverity = this.repository
.createQueryBuilder('f')
.select(
"[AdverseEvent], [Severity] = CASE WHEN ISNULL([Severity],'') = '' THEN 'Unknown' ELSE [Severity] END, SUM([AdverseEventCount]) total, DATIMAgeGroup ageGroup",
"[AdverseEvent], [Severity] = CASE WHEN ISNULL([Severity],'') = '' THEN 'Unknown' ELSE [Severity] END, SUM([AdverseEventsCount]) total, DATIMAgeGroup ageGroup",
)
.where('[AdverseEvent] IS NOT NULL');

Expand Down Expand Up @@ -55,7 +55,7 @@ export class GetReportedAesWithSeverityLevelsHandler implements IQueryHandler<Ge

return await reportedAesWithSeverity
.groupBy('[AdverseEvent], [Severity], DATIMAgeGroup')
.orderBy('SUM([AdverseEventCount])')
.orderBy('SUM([AdverseEventsCount])')
.getRawMany();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export class GetReportedCausesOfAeHandler implements IQueryHandler<GetReportedCa
async execute(query: GetReportedCausesOfAeQuery): Promise<any> {
const reportedCausesOfAes = this.repository
.createQueryBuilder('f')
.select('[AdverseEventCause], SUM([AdverseEventCount]) total')
.select('[AdverseEventCause], SUM([AdverseEventsCountt]) total')
.where('[AdverseEventCause] IS NOT NULL');

if (query.county) {
Expand Down
17 changes: 17 additions & 0 deletions src/manifests/entities/emr-info.entity.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import { Entity, PrimaryColumn, Column } from 'typeorm';

@Entity('mfl_interface_db.facilities_emr_info')
export class EMRInfo {
@PrimaryColumn({ type: 'uuid' })
manifestId: string;
@Column({ type: 'datetime' })
timeId: Date;
@Column({ type: 'int' })
facilityId: number;
@Column({ type: 'text' })
emrId: string;
@Column({ type: 'text' })
docketId: string;
@Column({ type: 'int' })
upload: number;
}
17 changes: 17 additions & 0 deletions src/manifests/entities/facility-info.entity.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import { Entity, PrimaryColumn, Column } from 'typeorm';

@Entity('mfl_interface_db.facilities_facility_info')
export class FacilityInfo {
@PrimaryColumn({ type: 'uuid' })
manifestId: string;
@Column({ type: 'datetime' })
timeId: Date;
@Column({ type: 'int' })
facilityId: number;
@Column({ type: 'text' })
emrId: string;
@Column({ type: 'text' })
docketId: string;
@Column({ type: 'int' })
upload: number;
}
Loading

0 comments on commit ec2dceb

Please sign in to comment.