Skip to content

Commit 8ebcd2b

Browse files
VIA-331 DB SB Log NHS number as a JSON field rather than embedded in a string, to make querying easier.
1 parent 546ea26 commit 8ebcd2b

File tree

3 files changed

+10
-14
lines changed

3 files changed

+10
-14
lines changed

src/services/eligibility-api/domain/eligibility-filter-service.test.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@ describe("eligibility-filter-service", () => {
212212
])
213213
.build();
214214

215-
const result = _generateActions(processedSuggestion);
215+
const result = _generateActions(processedSuggestion, VaccineTypes.RSV, nhsNumber);
216216

217217
expect(result).toEqual([
218218
{
@@ -230,7 +230,7 @@ describe("eligibility-filter-service", () => {
230230
])
231231
.build();
232232

233-
const result = _generateActions(processedSuggestion);
233+
const result = _generateActions(processedSuggestion, VaccineTypes.RSV, nhsNumber);
234234

235235
expect(result).toEqual([
236236
{
@@ -252,7 +252,7 @@ describe("eligibility-filter-service", () => {
252252
eligibilityCohorts: [],
253253
} as unknown as ProcessedSuggestion;
254254

255-
const result = _generateActions(suggestion);
255+
const result = _generateActions(suggestion, VaccineTypes.RSV, nhsNumber);
256256

257257
expect(result).toEqual([]);
258258
});

src/services/eligibility-api/domain/eligibility-filter-service.ts

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,7 @@ const getEligibilityForPerson = async (
3535
);
3636

3737
if (!suggestionForVaccine) {
38-
log.error(
39-
`EliD response validation error: Processed suggestion not found for vaccine type ${vaccineType}, NHS number ${nhsNumber}`,
40-
);
38+
log.error({ nhsNumber, vaccineType }, "EliD response validation error: Processed suggestion not found");
4139
return {
4240
eligibility: undefined,
4341
eligibilityError: EligibilityErrorTypes.ELIGIBILITY_LOADING_ERROR,
@@ -47,9 +45,7 @@ const getEligibilityForPerson = async (
4745
let summary: SummaryContent | undefined;
4846

4947
if (!suggestionForVaccine.eligibilityCohorts) {
50-
log.error(
51-
`EliD response validation error: Missing eligibilityCohorts element for vaccine type ${vaccineType}, NHS number ${nhsNumber}`,
52-
);
48+
log.error({ nhsNumber, vaccineType }, "EliD response validation error: Missing eligibilityCohorts element");
5349
} else if (suggestionForVaccine.eligibilityCohorts.length > 0) {
5450
summary = {
5551
heading: suggestionForVaccine.statusText as Heading,
@@ -58,7 +54,7 @@ const getEligibilityForPerson = async (
5854
};
5955
}
6056

61-
const actions: Action[] = _generateActions(suggestionForVaccine);
57+
const actions: Action[] = _generateActions(suggestionForVaccine, vaccineType, nhsNumber);
6258

6359
return {
6460
eligibility: {
@@ -77,7 +73,7 @@ const getEligibilityForPerson = async (
7773
eligibilityError: EligibilityErrorTypes.ELIGIBILITY_LOADING_ERROR,
7874
};
7975
} else {
80-
log.error(error, "Some random error");
76+
log.error({ nhsNumber, vaccineType, error }, "Unexpected error");
8177
return {
8278
eligibility: undefined,
8379
eligibilityError: EligibilityErrorTypes.UNKNOWN,
@@ -104,9 +100,9 @@ const _getStatus = (suggestion: ProcessedSuggestion): EligibilityStatus => {
104100
throw new Error("not yet implemented");
105101
};
106102

107-
const _generateActions = (suggestion: ProcessedSuggestion): Action[] => {
103+
const _generateActions = (suggestion: ProcessedSuggestion, vaccineType: VaccineTypes, nhsNumber: string): Action[] => {
108104
if (!suggestion.actions) {
109-
log.warn("Missing actions array");
105+
log.warn({ nhsNumber, vaccineType }, "Missing actions array");
110106
return [];
111107
}
112108

src/services/eligibility-api/gateway/fetch-eligibility-content.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ export const fetchEligibilityContent = async (nhsNumber: string): Promise<Eligib
1616

1717
const uri: string = `${apiEndpoint}${ELIGIBILITY_API_PATH_SUFFIX}${nhsNumber}`;
1818

19-
log.info("Fetching eligibility status from %s", uri);
19+
log.info({ nhsNumber }, "Fetching eligibility status from %s", uri);
2020
const response: AxiosResponse = await axios
2121
.get(uri, {
2222
headers: {

0 commit comments

Comments
 (0)