Skip to content

Commit

Permalink
[105] na fields (#158)
Browse files Browse the repository at this point in the history
* Update UI YesNo enums to remove Na

* Update Curator.spec.ts

* Update data service

* Update openapi.yaml

* Update dockerfile

* Update configuration for CI tests

* Update make_superuser.sh
  • Loading branch information
stanislaw-zakrzewski authored Jan 13, 2025
1 parent 8db28d3 commit 4fb80a3
Show file tree
Hide file tree
Showing 20 changed files with 129 additions and 129 deletions.
33 changes: 13 additions & 20 deletions data-serving/data-service/api/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -656,6 +656,9 @@ paths:
$ref: '#/components/responses/500'
components:
schemas:
YesNo:
type: string
enum: ['Y', 'N', '']
BatchUpdateResponse:
description: Response to batch update cases API requests
properties:
Expand Down Expand Up @@ -766,8 +769,7 @@ components:
occupation:
type: string
healthcareWorker:
type: string
enum: ['Y', 'N', 'NA']
$ref: '#/components/schemas/YesNo'
location:
$ref: '#/components/schemas/Location'
events:
Expand All @@ -788,8 +790,7 @@ components:
dateOfFirstConsult:
$ref: '#/components/schemas/Date'
hospitalized:
type: string
enum: ['Y', 'N', 'NA']
$ref: '#/components/schemas/YesNo'
reasonForHospitalization:
type: string
enum: [monitoring, treatment, unknown]
Expand All @@ -798,18 +799,15 @@ components:
dateDischargeHospital:
$ref: '#/components/schemas/Date'
intensiveCare:
type: string
enum: ['Y', 'N', 'NA']
$ref: '#/components/schemas/YesNo'
dateAdmissionICU:
$ref: '#/components/schemas/Date'
dateDischargeICU:
$ref: '#/components/schemas/Date'
homeMonitoring:
type: string
enum: ['Y', 'N', 'NA']
$ref: '#/components/schemas/YesNo'
isolated:
type: string
enum: ['Y', 'N', 'NA']
$ref: '#/components/schemas/YesNo'
dateIsolation:
$ref: '#/components/schemas/Date'
outcome:
Expand All @@ -825,21 +823,18 @@ components:
type: object
properties:
previousInfection:
type: string
enum: ['Y', 'N', 'NA']
$ref: '#/components/schemas/YesNo'
coInfection:
type: string
preexistingCondition:
type: string
pregnancyStatus:
type: string
enum: ['Y', 'N', 'NA']
$ref: '#/components/schemas/YesNo'
transmission:
type: object
properties:
contactWithCase:
type: string
enum: ['Y', 'N', 'NA']
$ref: '#/components/schemas/YesNo'
contactId:
type: string
contactSetting:
Expand All @@ -854,8 +849,7 @@ components:
type: object
properties:
travelHistory:
type: string
enum: ['Y', 'N', 'NA']
$ref: '#/components/schemas/YesNo'
travelHistoryEntry:
$ref: '#/components/schemas/Date'
travelHistoryStart:
Expand All @@ -875,8 +869,7 @@ components:
type: object
properties:
vaccination:
type: string
enum: ['Y', 'N', 'NA']
$ref: '#/components/schemas/YesNo'
vaccineName:
type: string
vaccineDate:
Expand Down
2 changes: 1 addition & 1 deletion data-serving/data-service/src/types/enums.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export enum CaseStatus {
export enum YesNo {
Y = 'Y',
N = 'N',
NA = 'NA',
None = '',
}

export enum Role {
Expand Down
25 changes: 13 additions & 12 deletions data-serving/data-service/test/util/case.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import mongoose from 'mongoose';
import { MongoMemoryServer } from 'mongodb-memory-server';
import { GenomeSequenceDocument } from '../../src/model/genome-sequence';
import { EventsDocument } from '../../src/model/events';
import { YesNo } from '../../src/types/enums';

let mongoServer: MongoMemoryServer;

Expand Down Expand Up @@ -368,7 +369,7 @@ describe('Case', () => {
ageBuckets: [anAgeBucket._id],
gender: 'male',
occupation: 'Anesthesiologist',
healthcareWorker: 'Y',
healthcareWorker: YesNo.Y,
} as DemographicsDocument;

const caseDoc = {
Expand All @@ -395,7 +396,7 @@ describe('Case', () => {
expect(denormalizedCase['demographics.occupation']).toEqual(
'Anesthesiologist',
);
expect(denormalizedCase['demographics.healthcareWorker']).toEqual('Y');
expect(denormalizedCase['demographics.healthcareWorker']).toEqual(YesNo.Y);
});
it('denormalizes events fields', async () => {
const eventsDoc = {
Expand Down Expand Up @@ -507,10 +508,10 @@ describe('Case', () => {
});
it('denormalizes preexisting conditions fields', async () => {
const conditionsDoc = {
previousInfection: 'Y',
previousInfection: YesNo.Y,
coInfection: 'Flu',
preexistingCondition: '',
pregnancyStatus: 'NA',
pregnancyStatus: YesNo.None,
} as PreexistingConditionsDocument;

const caseDoc = {
Expand All @@ -533,7 +534,7 @@ describe('Case', () => {
const denormalizedCase = await denormalizeFields(caseDoc);
expect(
denormalizedCase['preexistingConditions.previousInfection'],
).toEqual('Y');
).toEqual(YesNo.Y);
expect(denormalizedCase['preexistingConditions.coInfection']).toEqual(
'Flu',
);
Expand All @@ -542,11 +543,11 @@ describe('Case', () => {
).toEqual('');
expect(
denormalizedCase['preexistingConditions.pregnancyStatus'],
).toEqual('NA');
).toEqual(YesNo.None);
});
it('denormalizes transmission fields', async () => {
const transmissionDoc = {
contactWithCase: 'Y',
contactWithCase: YesNo.Y,
contactId: 'abc123',
contactSetting: 'setting',
contactAnimal: 'animal',
Expand All @@ -572,7 +573,7 @@ describe('Case', () => {

const denormalizedCase = await denormalizeFields(caseDoc);

expect(denormalizedCase['transmission.contactWithCase']).toEqual('Y');
expect(denormalizedCase['transmission.contactWithCase']).toEqual(YesNo.Y);
expect(denormalizedCase['transmission.contactId']).toEqual('abc123');
expect(denormalizedCase['transmission.contactSetting']).toEqual(
'setting',
Expand All @@ -589,7 +590,7 @@ describe('Case', () => {
});
it('denormalizes travel history fields', async () => {
const travelHistoryDoc = {
travelHistory: 'Y',
travelHistory: YesNo.Y,
travelHistoryEntry: new Date('2020-11-01'),
travelHistoryStart: 'start',
travelHistoryLocation: 'London',
Expand All @@ -614,7 +615,7 @@ describe('Case', () => {

const denormalizedCase = await denormalizeFields(caseDoc);

expect(denormalizedCase['travelHistory.travelHistory']).toEqual('Y');
expect(denormalizedCase['travelHistory.travelHistory']).toEqual(YesNo.Y);
expect(denormalizedCase['travelHistory.travelHistoryEntry']).toEqual(
formatDateWithoutTime(travelHistoryDoc.travelHistoryEntry),
);
Expand All @@ -630,7 +631,7 @@ describe('Case', () => {
});
it('denormalizes vaccine fields', async () => {
const vaccinationDoc = {
vaccination: 'Y',
vaccination: YesNo.Y,
vaccineName: 'Pfizer',
vaccineDate: new Date('2020-11-01'),
vaccineSideEffects: 'cough',
Expand All @@ -653,7 +654,7 @@ describe('Case', () => {
} as CaseDocument;

const denormalizedCase = await denormalizeFields(caseDoc);
expect(denormalizedCase['vaccination.vaccination']).toEqual('Y');
expect(denormalizedCase['vaccination.vaccination']).toEqual(YesNo.Y);
expect(denormalizedCase['vaccination.vaccineName']).toEqual('Pfizer');
expect(denormalizedCase['vaccination.vaccineDate']).toEqual(
formatDateWithoutTime(vaccinationDoc.vaccineDate),
Expand Down
2 changes: 1 addition & 1 deletion dev/make_superuser.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@ cd `dirname "$0"`
# Pass database name as the first parameter
DB="${GDH_DATABASE:-$1}"
# Pass email of user to grant an admin role as second parameter
docker-compose -f docker-compose.yml -f docker-compose.dev.yml exec mongo mongosh "${DB}" --eval "var email='$2'; var roles=['admin', 'curator'];" /verification/scripts/roles.js
docker compose -f docker-compose.yml -f docker-compose.dev.yml exec mongo mongosh "${DB}" --eval "var email='$2'; var roles=['admin', 'curator'];" /verification/scripts/roles.js
# Restore directory.
popd
4 changes: 2 additions & 2 deletions geocoding/location-service/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM python:3.10-slim
FROM python:3.10-bullseye

RUN apt-get update -y
RUN apt-get install -y python3-pip
Expand All @@ -14,7 +14,7 @@ WORKDIR /usr/src/app/geocoding/location-service
USER flask

# install dependencies
RUN pip install poetry
RUN pip install poetry==1.8.5
COPY geocoding/location-service/pyproject.toml .
COPY geocoding/location-service/poetry.lock .
RUN /home/flask/.local/bin/poetry install
Expand Down
2 changes: 1 addition & 1 deletion geocoding/location-service/Dockerfile-test
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# `python-base` sets up all our shared environment variables
FROM python:3.10-slim as python-base
FROM python:3.10-bullseye as python-base

ENV PYTHONUNBUFFERED=1 \
# prevents python creating .pyc files
Expand Down
33 changes: 13 additions & 20 deletions verification/curator-service/api/openapi/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1283,6 +1283,9 @@ paths:

components:
schemas:
YesNo:
type: string
enum: [ 'Y', 'N', '' ]
Parser:
description: A parser for automated ingestion
type: object
Expand Down Expand Up @@ -1593,8 +1596,7 @@ components:
occupation:
type: string
healthcareWorker:
type: string
enum: ['Y', 'N', 'NA', undefined]
$ref: '#/components/schemas/YesNo'
location:
$ref: '#/components/schemas/Location'
events:
Expand All @@ -1615,8 +1617,7 @@ components:
dateOfFirstConsult:
$ref: '#/components/schemas/Date'
hospitalized:
type: string
enum: ['Y', 'N', 'NA', undefined]
$ref: '#/components/schemas/YesNo'
reasonForHospitalization:
type: string
enum: [monitoring, treatment, unknown]
Expand All @@ -1625,18 +1626,15 @@ components:
dateDischargeHospital:
$ref: '#/components/schemas/Date'
intensiveCare:
type: string
enum: ['Y', 'N', 'NA', undefined]
$ref: '#/components/schemas/YesNo'
dateAdmissionICU:
$ref: '#/components/schemas/Date'
dateDischargeICU:
$ref: '#/components/schemas/Date'
homeMonitoring:
type: string
enum: ['Y', 'N', 'NA', undefined]
$ref: '#/components/schemas/YesNo'
isolated:
type: string
enum: ['Y', 'N', 'NA', undefined]
$ref: '#/components/schemas/YesNo'
dateIsolation:
$ref: '#/components/schemas/Date'
outcome:
Expand All @@ -1653,22 +1651,19 @@ components:
type: object
properties:
previousInfection:
type: string
enum: ['Y', 'N', 'NA', undefined]
$ref: '#/components/schemas/YesNo'
coInfection:
type: string
preexistingCondition:
type: string
pregnancyStatus:
type: string
enum: ['Y', 'N', 'NA', undefined]
$ref: '#/components/schemas/YesNo'
transmission:
description: How this case got infected and by who if known
type: object
properties:
contactWithCase:
type: string
enum: ['Y', 'N', 'NA', undefined]
$ref: '#/components/schemas/YesNo'
contactId:
type: string
contactSetting:
Expand All @@ -1684,8 +1679,7 @@ components:
description: Travel history of the patient if known
properties:
travelHistory:
type: string
enum: ['Y', 'N', 'NA', undefined]
$ref: '#/components/schemas/YesNo'
travelHistoryEntry:
$ref: '#/components/schemas/Date'
travelHistoryStart:
Expand All @@ -1709,8 +1703,7 @@ components:
type: object
properties:
vaccination:
type: string
enum: ['Y', 'N', 'NA', undefined]
$ref: '#/components/schemas/YesNo'
vaccineName:
type: string
vaccineDate:
Expand Down
Loading

0 comments on commit 4fb80a3

Please sign in to comment.