-
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 #732 from cbrianbet/feat/new-reporting-layer
His deployment backend
- Loading branch information
Showing
15 changed files
with
461 additions
and
0 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
39 changes: 39 additions & 0 deletions
39
src/common/queries/handlers/get-facility-by-infrastructure.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,39 @@ | ||
import { IQueryHandler, QueryHandler } from '@nestjs/cqrs'; | ||
import { InjectRepository } from '@nestjs/typeorm'; | ||
import { Repository } from 'typeorm'; | ||
import { AllEmrSites } from '../../../care-treatment/common/entities/all-emr-sites.model'; | ||
import { GetFacilityByInfrastructureQuery } from '../impl/get-facility-by-infrastructure.query'; | ||
|
||
@QueryHandler(GetFacilityByInfrastructureQuery) | ||
export class GetFacilityByInfrastructureHandler implements IQueryHandler<GetFacilityByInfrastructureQuery> { | ||
constructor( | ||
@InjectRepository(AllEmrSites, 'mssql') | ||
private readonly repository: Repository<AllEmrSites>, | ||
) {} | ||
|
||
async execute(query: GetFacilityByInfrastructureQuery): Promise<any> { | ||
const projects = this.repository | ||
.createQueryBuilder('q') | ||
.select('COUNT(1) facilities, InfrastructureType, PartnerName') | ||
.where('InfrastructureType is not null'); | ||
|
||
if (query.county) { | ||
projects.andWhere('q.County IN (:...county)', { | ||
county: [query.county], | ||
}); | ||
} | ||
|
||
if (query.subCounty) { | ||
projects.andWhere('q.SubCounty IN (:...subCounty)', { | ||
subCounty: [query.subCounty], | ||
}); | ||
} | ||
|
||
|
||
return await projects | ||
.groupBy('q.InfrastructureType, PartnerName') | ||
.orderBy('PartnerName') | ||
.distinct(true) | ||
.getRawMany(); | ||
} | ||
} |
40 changes: 40 additions & 0 deletions
40
src/common/queries/handlers/get-facility-level-by-ownership-county.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,40 @@ | ||
import { IQueryHandler, QueryHandler } from '@nestjs/cqrs'; | ||
import { InjectRepository } from '@nestjs/typeorm'; | ||
import { Repository } from 'typeorm'; | ||
import { AllEmrSites } from '../../../care-treatment/common/entities/all-emr-sites.model'; | ||
import { GetFacilityLevelByOwnershipCountyQuery } from '../impl/get-facility-level-by-ownership-county.query'; | ||
|
||
@QueryHandler(GetFacilityLevelByOwnershipCountyQuery) | ||
export class GetFacilityLevelByOwnershipCountyHandler implements IQueryHandler<GetFacilityLevelByOwnershipCountyQuery> { | ||
constructor( | ||
@InjectRepository(AllEmrSites, 'mssql') | ||
private readonly repository: Repository<AllEmrSites>, | ||
) {} | ||
|
||
async execute(query: GetFacilityLevelByOwnershipCountyQuery): Promise<any> { | ||
const projects = this.repository | ||
.createQueryBuilder('q') | ||
.select('COUNT(1) facilities, County, Keph_level') | ||
.where('Keph_level is not null'); | ||
|
||
if (query.county) { | ||
projects.andWhere('q.County IN (:...county)', { | ||
county: [query.county], | ||
}); | ||
} | ||
|
||
if (query.subCounty) { | ||
projects.andWhere('q.SubCounty IN (:...subCounty)', { | ||
subCounty: [query.subCounty], | ||
}); | ||
} | ||
|
||
|
||
return await projects | ||
.groupBy('q.County, Keph_level') | ||
.orderBy('Keph_level') | ||
.orderBy('County') | ||
.distinct(true) | ||
.getRawMany(); | ||
} | ||
} |
40 changes: 40 additions & 0 deletions
40
src/common/queries/handlers/get-facility-level-by-ownership-partner.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,40 @@ | ||
import { IQueryHandler, QueryHandler } from '@nestjs/cqrs'; | ||
import { InjectRepository } from '@nestjs/typeorm'; | ||
import { Repository } from 'typeorm'; | ||
import { AllEmrSites } from '../../../care-treatment/common/entities/all-emr-sites.model'; | ||
import { GetFacilityLevelByOwnershipPartnerQuery } from '../impl/get-facility-level-by-ownership-partner.query'; | ||
|
||
@QueryHandler(GetFacilityLevelByOwnershipPartnerQuery) | ||
export class GetFacilityLevelByOwnershipPartnerHandler implements IQueryHandler<GetFacilityLevelByOwnershipPartnerQuery> { | ||
constructor( | ||
@InjectRepository(AllEmrSites, 'mssql') | ||
private readonly repository: Repository<AllEmrSites>, | ||
) {} | ||
|
||
async execute(query: GetFacilityLevelByOwnershipPartnerQuery): Promise<any> { | ||
const projects = this.repository | ||
.createQueryBuilder('q') | ||
.select('COUNT(1) facilities, PartnerName, Keph_level') | ||
.where('Keph_level is not null'); | ||
|
||
if (query.county) { | ||
projects.andWhere('q.County IN (:...county)', { | ||
county: [query.county], | ||
}); | ||
} | ||
|
||
if (query.subCounty) { | ||
projects.andWhere('q.SubCounty IN (:...subCounty)', { | ||
subCounty: [query.subCounty], | ||
}); | ||
} | ||
|
||
|
||
return await projects | ||
.groupBy('q.PartnerName, Keph_level') | ||
.orderBy('Keph_level') | ||
.orderBy('PartnerName') | ||
.distinct(true) | ||
.getRawMany(); | ||
} | ||
} |
41 changes: 41 additions & 0 deletions
41
src/common/queries/handlers/get-facility-linelist.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,41 @@ | ||
import { IQueryHandler, QueryHandler } from '@nestjs/cqrs'; | ||
import { InjectRepository } from '@nestjs/typeorm'; | ||
import { Repository } from 'typeorm'; | ||
import { AllEmrSites } from '../../../care-treatment/common/entities/all-emr-sites.model'; | ||
import { GetFacilityLinelistQuery } from '../impl/get-facility-linelist.query'; | ||
|
||
@QueryHandler(GetFacilityLinelistQuery) | ||
export class GetFacilityLinelistHandler implements IQueryHandler<GetFacilityLinelistQuery> { | ||
constructor( | ||
@InjectRepository(AllEmrSites, 'mssql') | ||
private readonly repository: Repository<AllEmrSites>, | ||
) {} | ||
|
||
async execute(query: GetFacilityLinelistQuery): Promise<any> { | ||
const projects = this.repository | ||
.createQueryBuilder('q') | ||
.select( | ||
`MFLCode, FacilityName, SubCounty, County, | ||
[PartnerName], [AgencyName],[EMR_Status],[EMR] | ||
,[owner],[InfrastructureType], [KEPH_Level]` | ||
); | ||
|
||
if (query.county) { | ||
projects.andWhere('q.County IN (:...county)', { | ||
county: [query.county], | ||
}); | ||
} | ||
|
||
if (query.subCounty) { | ||
projects.andWhere('q.SubCounty IN (:...subCounty)', { | ||
subCounty: [query.subCounty], | ||
}); | ||
} | ||
|
||
|
||
return await projects | ||
.orderBy('MFLCode') | ||
.distinct(true) | ||
.getRawMany(); | ||
} | ||
} |
Oops, something went wrong.