-
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 branch 'master' of https://github.com/palladiumkenya/dwh-portal…
…-backend into dependabot/npm_and_yarn/npm_and_yarn-security-group-fe5fdaf2a1
- Loading branch information
Showing
8 changed files
with
5,568 additions
and
9,569 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
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
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
38 changes: 38 additions & 0 deletions
38
src/common/queries/handlers/get-facility-txcurr.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,38 @@ | ||
import { IQueryHandler, QueryHandler } from '@nestjs/cqrs'; | ||
import { InjectRepository } from '@nestjs/typeorm'; | ||
import { Repository } from 'typeorm'; | ||
import { GetFacilityTxcurrQuery } from '../impl/get-facility-txcurr.query'; | ||
import { LinelistFACTART } from '../../../care-treatment/common/entities/linelist-fact-art.model'; | ||
|
||
@QueryHandler(GetFacilityTxcurrQuery) | ||
export class GetFacilityTxcurrHandler implements IQueryHandler<GetFacilityTxcurrQuery> { | ||
constructor( | ||
@InjectRepository(LinelistFACTART, 'mssql') | ||
private readonly repository: Repository<LinelistFACTART>, | ||
) {} | ||
|
||
async execute(query: GetFacilityTxcurrQuery): Promise<any> { | ||
const facilities = this.repository | ||
.createQueryBuilder('q') | ||
.select('count (*) TxCurr, KEPH_Level') | ||
.leftJoin('all_EMRSites', 'e', 'e.MFLCode = q.SiteCode') | ||
.where(`ARTOutcomeDescription='Active'`); | ||
|
||
if (query.county) { | ||
facilities.andWhere('q.County IN (:...county)', { | ||
county: [query.county], | ||
}); | ||
} | ||
|
||
if (query.subCounty) { | ||
facilities.andWhere('q.SubCounty IN (:...subCounty)', { | ||
subCounty: [query.subCounty], | ||
}); | ||
} | ||
|
||
|
||
return await facilities | ||
.groupBy('KEPH_Level') | ||
.getRawMany(); | ||
} | ||
} |
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,7 @@ | ||
export class GetFacilityTxcurrQuery { | ||
county?: string[]; | ||
subCounty?: string[]; | ||
facility?: string[]; | ||
partner?: string[]; | ||
agency?: string[]; | ||
} |
Oops, something went wrong.