-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #772 from palladiumkenya/feat/new-reporting-layer
updating master
- Loading branch information
Showing
43 changed files
with
867 additions
and
153 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
80 changes: 80 additions & 0 deletions
80
src/care-treatment/current-on-art/queries/handlers/get-ahd-screening.handler.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
import { IQueryHandler, QueryHandler } from '@nestjs/cqrs'; | ||
import { InjectRepository } from '@nestjs/typeorm'; | ||
import { Repository } from 'typeorm'; | ||
import { GetAhdScreeningQuery } from '../impl/get-ahd-screening.query'; | ||
import { LinelistFACTART } from '../../../common/entities/linelist-fact-art.model'; | ||
|
||
@QueryHandler(GetAhdScreeningQuery) | ||
export class GetAhdScreeningHandler implements IQueryHandler<GetAhdScreeningQuery> { | ||
constructor( | ||
@InjectRepository(LinelistFACTART, 'mssql') | ||
private readonly repository: Repository<LinelistFACTART>, | ||
) {} | ||
|
||
async execute(query: GetAhdScreeningQuery): Promise<any> { | ||
const ahdScreening = this.repository | ||
.createQueryBuilder('f') | ||
.select([` | ||
SUM(NewPatient) as NewPatient, | ||
-- ahd screened | ||
SUM(AHD) AS AHD, | ||
SUM(DoneCD4Test) AS DoneCD4Test, | ||
SUM(CD4Lessthan200) AS less200CD4, | ||
SUM(DoneTBLamTest) AS DoneTBLamTest, | ||
SUM(TBLamPositive) AS TBLamPositive, | ||
-- tb treatment initiated | ||
SUM(OntbTreatment) AS tbInitiated, | ||
SUM(DoneCrAgTest) AS DoneCrAgTest, | ||
SUM(CrAgPositive) AS CrAgPositive, | ||
SUM(CSFCrAg) AS CSFCrAg, | ||
SUM(CSFCrAgPositive) AS CSFCrAgPositive, | ||
SUM(InitiatedCMTreatment) AS InitiatedCMTreatment, | ||
SUM(PreemtiveCMTheraphy) AS PreemtiveCMTheraphy | ||
`]) | ||
.where(`StartARTDate >= DATEADD(MONTH, DATEDIFF(MONTH,0, GETDATE()) -1,0) and StartARTDate <DATEADD(MONTH,DATEDIFF(MONTH, 0, GETDATE()), 0)`); | ||
|
||
if (query.county) { | ||
ahdScreening.andWhere('f.County IN (:...counties)', { | ||
counties: query.county, | ||
}); | ||
} | ||
|
||
if (query.subCounty) { | ||
ahdScreening.andWhere('f.Subcounty IN (:...subCounties)', { | ||
subCounties: query.subCounty, | ||
}); | ||
} | ||
|
||
if (query.facility) { | ||
ahdScreening.andWhere('f.FacilityName IN (:...facilities)', { | ||
facilities: query.facility, | ||
}); | ||
} | ||
|
||
if (query.partner) { | ||
ahdScreening.andWhere('f.PartnerName IN (:...partners)', { | ||
partners: query.partner, | ||
}); | ||
} | ||
|
||
if (query.agency) { | ||
ahdScreening.andWhere('f.AgencyName IN (:...agencies)', { | ||
agencies: query.agency, | ||
}); | ||
} | ||
|
||
if (query.datimAgeGroup) { | ||
ahdScreening.andWhere('f.AgeGroup IN (:...ageGroups)', { | ||
ageGroups: query.datimAgeGroup, | ||
}); | ||
} | ||
|
||
if (query.gender) { | ||
ahdScreening.andWhere('f.Gender IN (:...genders)', { | ||
genders: query.gender, | ||
}); | ||
} | ||
|
||
return await ahdScreening.getRawOne(); | ||
} | ||
} |
9 changes: 9 additions & 0 deletions
9
src/care-treatment/current-on-art/queries/impl/get-ahd-screening.query.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
export class GetAhdScreeningQuery { | ||
county?: string[]; | ||
subCounty?: string[]; | ||
facility?: string[]; | ||
partner?: string[]; | ||
agency?: string[]; | ||
gender?: string[]; | ||
datimAgeGroup?: string[]; | ||
} |
66 changes: 66 additions & 0 deletions
66
src/care-treatment/otz/queries/handlers/get-alhiv-on-art-by-age-sex.handler.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
import { IQueryHandler, QueryHandler } from '@nestjs/cqrs'; | ||
import { InjectRepository } from '@nestjs/typeorm'; | ||
import { Repository } from 'typeorm'; | ||
import { LineListOTZEligibilityAndEnrollments } from '../../entities/line-list-otz-eligibility-and-enrollments.model'; | ||
import { GetAlhivOnArtByAgeSexQuery } from '../impl/get-alhiv-on-art-by-age-sex.query'; | ||
|
||
@QueryHandler(GetAlhivOnArtByAgeSexQuery) | ||
export class GetAlhivOnArtByAgeSexHandler | ||
implements IQueryHandler<GetAlhivOnArtByAgeSexQuery> { | ||
constructor( | ||
@InjectRepository(LineListOTZEligibilityAndEnrollments, 'mssql') | ||
private readonly repository: Repository< | ||
LineListOTZEligibilityAndEnrollments | ||
>, | ||
) {} | ||
|
||
async execute(query: GetAlhivOnArtByAgeSexQuery): Promise<any> { | ||
const CALHIVOnART = this.repository | ||
.createQueryBuilder('f') | ||
.select(['Count (*) CALHIVonART, AgeGroup, Gender']); | ||
|
||
if (query.county) { | ||
CALHIVOnART.andWhere('f.County IN (:...counties)', { | ||
counties: query.county, | ||
}); | ||
} | ||
|
||
if (query.subCounty) { | ||
CALHIVOnART.andWhere('f.SubCounty IN (:...subCounties)', { | ||
subCounties: query.subCounty, | ||
}); | ||
} | ||
|
||
if (query.facility) { | ||
CALHIVOnART.andWhere('f.FacilityName IN (:...facilities)', { | ||
facilities: query.facility, | ||
}); | ||
} | ||
|
||
if (query.partner) { | ||
CALHIVOnART.andWhere('f.PartnerName IN (:...partners)', { | ||
partners: query.partner, | ||
}); | ||
} | ||
|
||
if (query.agency) { | ||
CALHIVOnART.andWhere('f.AgencyName IN (:...agencies)', { | ||
agencies: query.agency, | ||
}); | ||
} | ||
|
||
if (query.datimAgeGroup) { | ||
CALHIVOnART.andWhere('f.AgeGroup IN (:...ageGroups)', { | ||
ageGroups: query.datimAgeGroup, | ||
}); | ||
} | ||
|
||
if (query.gender) { | ||
CALHIVOnART.andWhere('f.Gender IN (:...genders)', { | ||
genders: query.gender, | ||
}); | ||
} | ||
|
||
return await CALHIVOnART.groupBy('AgeGroup, Gender').getRawMany(); | ||
} | ||
} |
Oops, something went wrong.