Skip to content

Commit

Permalink
Merge pull request #713 from cbrianbet/feat/new-reporting-layer
Browse files Browse the repository at this point in the history
added extra filter for pbfw u=u
  • Loading branch information
cbrianbet authored Mar 21, 2024
2 parents 8e92c29 + 3853581 commit 6adcadc
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,26 @@ export class GetVlCategorizationUToUHandler
}

if (query.pbfw) {
let pbfw = []
let ispreg = []
query.pbfw.forEach(cat => {
let splitCategories = cat.split('|');
pbfw.push(splitCategories[0])
ispreg.push(splitCategories[1])
})

vlUptake.andWhere('f.PBFWCategory IN (:...pbfws)', {
pbfws: query.pbfw,
pbfws: pbfw,
});
if (ispreg.includes("Yes") && ispreg.includes("No")) {
vlUptake.andWhere(`f.Pregnant = 'Yes' OR f.Breastfeeding = 'Yes'`);
}
else if (ispreg.includes("Yes")) {
vlUptake.andWhere(`f.Pregnant = 'Yes'`);
}
else if (ispreg.includes("No")) {
vlUptake.andWhere(`f.Breastfeeding = 'Yes'`);
}
}

return await vlUptake
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { InjectRepository } from '@nestjs/typeorm';
import { IQueryHandler, QueryHandler } from '@nestjs/cqrs';
import { Repository } from 'typeorm';
import { GetVlUptakeUToUQuery } from '../impl/get-vl-uptake-U-to-U.query';
import { AggregateVLDurable } from './../../entities/aggregate-vl-durable.model';
import { AggregateVLDurable } from '../../entities/aggregate-vl-durable.model';

@QueryHandler(GetVlUptakeUToUQuery)
export class GetVlUptakeUToUHandler
Expand All @@ -27,7 +27,7 @@ export class GetVlUptakeUToUHandler
if (query.county) {
vlUptake.andWhere('f.County IN (:...counties)', {
counties: query.county,

});
}

Expand Down Expand Up @@ -68,9 +68,26 @@ export class GetVlUptakeUToUHandler
}

if (query.pbfw) {
let pbfw = []
let ispreg = []
query.pbfw.forEach(cat => {
let splitCategories = cat.split('|');
pbfw.push(splitCategories[0])
ispreg.push(splitCategories[1])
})

vlUptake.andWhere('f.PBFWCategory IN (:...pbfws)', {
pbfws: query.pbfw,
pbfws: pbfw,
});
if (ispreg.includes("Yes") && ispreg.includes("No")) {
vlUptake.andWhere(`(f.Pregnant = 'Yes' OR f.Breastfeeding = 'Yes')`);
}
else if (ispreg.includes("Yes")) {
vlUptake.andWhere(`f.Pregnant = 'Yes'`);
}
else if (ispreg.includes("No")) {
vlUptake.andWhere(`f.Breastfeeding = 'Yes'`);
}
}

return await vlUptake.getRawOne();
Expand Down

0 comments on commit 6adcadc

Please sign in to comment.