From 876fc8acc396eebde4c53c9d63e88895a79145f3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stanis=C5=82aw=20Zakrzewski?= Date: Wed, 5 Apr 2023 14:52:44 +0200 Subject: [PATCH 1/8] wip add back latitude and longitude --- .../ui/src/api/models/Day0Case.ts | 5 +++++ .../ui/src/components/CaseForm.tsx | 4 ++++ .../ui/src/components/ViewCase.tsx | 13 +++++++++++++ .../new-case-form-fields/Location.tsx | 18 ++++++++++++++++++ 4 files changed, 40 insertions(+) diff --git a/verification/curator-service/ui/src/api/models/Day0Case.ts b/verification/curator-service/ui/src/api/models/Day0Case.ts index 8f43d143..88d48e93 100644 --- a/verification/curator-service/ui/src/api/models/Day0Case.ts +++ b/verification/curator-service/ui/src/api/models/Day0Case.ts @@ -71,6 +71,7 @@ export interface Location { // this variable is needed in the API in order to geocode properly query?: string; name?: string; + geometry?: { longitude?: number; latitude?: number }; } export interface Events { @@ -223,6 +224,10 @@ export interface Day0CaseFormValues { city?: string; geocodeLocation?: GeocodeLocation; query?: string; + geometry?: { + longitude?: number; + latitude?: number; + }; }; events: Events; symptoms?: string[]; diff --git a/verification/curator-service/ui/src/components/CaseForm.tsx b/verification/curator-service/ui/src/components/CaseForm.tsx index 0bb0fe80..f9a818d2 100644 --- a/verification/curator-service/ui/src/components/CaseForm.tsx +++ b/verification/curator-service/ui/src/components/CaseForm.tsx @@ -81,6 +81,10 @@ const initialValuesFromCase = ( countryISO2: '', location: '', city: '', + geometry: { + latitude: undefined, + longitude: undefined, + }, }, events: { dateEntry: null, diff --git a/verification/curator-service/ui/src/components/ViewCase.tsx b/verification/curator-service/ui/src/components/ViewCase.tsx index c48a3e30..1a6332c4 100644 --- a/verification/curator-service/ui/src/components/ViewCase.tsx +++ b/verification/curator-service/ui/src/components/ViewCase.tsx @@ -368,6 +368,19 @@ function CaseDetails(props: CaseDetailsProps): JSX.Element { + + + + + diff --git a/verification/curator-service/ui/src/components/new-case-form-fields/Location.tsx b/verification/curator-service/ui/src/components/new-case-form-fields/Location.tsx index 6faaa67f..5735e99d 100644 --- a/verification/curator-service/ui/src/components/new-case-form-fields/Location.tsx +++ b/verification/curator-service/ui/src/components/new-case-form-fields/Location.tsx @@ -89,6 +89,24 @@ export default function Location(): JSX.Element { component={TextField} sx={{ minWidth: '13rem' }} /> + + ); } From 8fc7c537a19807bf0653d8d056277c7a40ae364d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stanis=C5=82aw=20Zakrzewski?= Date: Thu, 6 Apr 2023 15:51:58 +0200 Subject: [PATCH 2/8] wip update structure --- data-serving/data-service/src/model/location.ts | 8 ++++++++ .../curator-service/ui/src/api/models/Day0Case.ts | 12 +++++++----- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/data-serving/data-service/src/model/location.ts b/data-serving/data-service/src/model/location.ts index a10fdc1a..50ee9b67 100644 --- a/data-serving/data-service/src/model/location.ts +++ b/data-serving/data-service/src/model/location.ts @@ -17,6 +17,10 @@ export const locationSchema = new mongoose.Schema( city: String, query: String, name: String, + geometry: { + latitude: Number, + longitude: Number, + }, }, { _id: false }, ); @@ -28,4 +32,8 @@ export type LocationDocument = mongoose.Document & { city?: string; query?: string; name?: string; + geometry?: { + latitude?: number; + longitude?: number; + }; }; diff --git a/verification/curator-service/ui/src/api/models/Day0Case.ts b/verification/curator-service/ui/src/api/models/Day0Case.ts index 88d48e93..d4a14b30 100644 --- a/verification/curator-service/ui/src/api/models/Day0Case.ts +++ b/verification/curator-service/ui/src/api/models/Day0Case.ts @@ -63,6 +63,11 @@ export interface GeocodeLocation { limitToResolution?: string; } +export interface Geometry { + longitude?: number; + latitude?: number; +} + export interface Location { country: string; countryISO2: string; @@ -71,7 +76,7 @@ export interface Location { // this variable is needed in the API in order to geocode properly query?: string; name?: string; - geometry?: { longitude?: number; latitude?: number }; + geometry?: Geometry; } export interface Events { @@ -224,10 +229,7 @@ export interface Day0CaseFormValues { city?: string; geocodeLocation?: GeocodeLocation; query?: string; - geometry?: { - longitude?: number; - latitude?: number; - }; + geometry?: Geometry; }; events: Events; symptoms?: string[]; From 084c94fdb5785975ab418a1edb3e6b7e038ba5c5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stanis=C5=82aw=20Zakrzewski?= Date: Thu, 6 Apr 2023 16:38:03 +0200 Subject: [PATCH 3/8] Use latitude and longitude when it is present --- data-serving/data-service/src/controllers/case.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/data-serving/data-service/src/controllers/case.ts b/data-serving/data-service/src/controllers/case.ts index 10cdf4b8..2eb36359 100644 --- a/data-serving/data-service/src/controllers/case.ts +++ b/data-serving/data-service/src/controllers/case.ts @@ -949,6 +949,9 @@ export class CasesController { location: any, canBeFuzzy: boolean, ): Promise { + if (location?.geometry?.latitude && location.geometry?.longitude) { + return location; + } if (!location?.query) { if (canBeFuzzy) { // no problem, just give back what we received From 99827d436b44f6d2b9dfff19eb88d9f90fae9b4d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stanis=C5=82aw=20Zakrzewski?= Date: Mon, 10 Apr 2023 07:16:17 +0200 Subject: [PATCH 4/8] add back georesolution --- .../data-service/src/model/location.ts | 1 + .../new-case-form-fields/Location.tsx | 26 +++++++++++++++++-- 2 files changed, 25 insertions(+), 2 deletions(-) diff --git a/data-serving/data-service/src/model/location.ts b/data-serving/data-service/src/model/location.ts index 50ee9b67..80f39a94 100644 --- a/data-serving/data-service/src/model/location.ts +++ b/data-serving/data-service/src/model/location.ts @@ -28,6 +28,7 @@ export const locationSchema = new mongoose.Schema( export type LocationDocument = mongoose.Document & { country: string; countryISO2: string; + geoResolution: string; location?: string; city?: string; query?: string; diff --git a/verification/curator-service/ui/src/components/new-case-form-fields/Location.tsx b/verification/curator-service/ui/src/components/new-case-form-fields/Location.tsx index 5735e99d..e0b2ca28 100644 --- a/verification/curator-service/ui/src/components/new-case-form-fields/Location.tsx +++ b/verification/curator-service/ui/src/components/new-case-form-fields/Location.tsx @@ -1,6 +1,9 @@ -import { TextField } from 'formik-mui'; +import { Select, TextField } from 'formik-mui'; +import { MenuItem } from '@mui/material'; import { FastField, useFormikContext } from 'formik'; +import FormControl from '@mui/material/FormControl'; +import InputLabel from '@mui/material/InputLabel'; import makeStyles from '@mui/styles/makeStyles'; import { Day0CaseFormValues } from '../../api/models/Day0Case'; import { useEffect } from 'react'; @@ -10,10 +13,10 @@ const styles = makeStyles(() => ({ root: { display: 'flex', flexWrap: 'wrap', - marginTop: '2rem', }, field: { marginRight: '1em', + marginTop: '1em', width: '8em', }, mapContainer: { @@ -51,6 +54,25 @@ export default function Location(): JSX.Element { return (
+ Geo resolution

} + component={Select} + sx={{ minWidth: '13rem' }} + > + {['Point', 'Admin3', 'Admin2', 'Admin1', 'Country'].map( + (res) => ( + + {res} + + ), + )} +
Date: Tue, 11 Apr 2023 08:31:06 +0200 Subject: [PATCH 5/8] Restore geoResolution --- data-serving/data-service/src/model/location.ts | 1 + data-serving/data-service/src/util/case.ts | 6 ++++++ .../test/model/data/location.full.json | 6 +++++- data-serving/data-service/test/util/case.test.ts | 16 ++++++++++++++++ .../ui/src/api/models/Day0Case.ts | 2 ++ .../ui/src/components/CaseForm.tsx | 1 + .../ui/src/components/ViewCase.tsx | 4 ++++ .../new-case-form-fields/Location.test.tsx | 4 ++++ 8 files changed, 39 insertions(+), 1 deletion(-) diff --git a/data-serving/data-service/src/model/location.ts b/data-serving/data-service/src/model/location.ts index 80f39a94..395080f6 100644 --- a/data-serving/data-service/src/model/location.ts +++ b/data-serving/data-service/src/model/location.ts @@ -12,6 +12,7 @@ export const locationSchema = new mongoose.Schema( minLength: 2, maxLength: 2, }, + geoResolution: String, // Location represents a precise location, such as an establishment or POI. location: String, city: String, diff --git a/data-serving/data-service/src/util/case.ts b/data-serving/data-service/src/util/case.ts index d010b203..ecae5c94 100644 --- a/data-serving/data-service/src/util/case.ts +++ b/data-serving/data-service/src/util/case.ts @@ -252,7 +252,13 @@ function denormalizeLocationFields( denormalizedData['location.countryISO2'] = doc.countryISO2 || ''; denormalizedData['location.location'] = doc.location || ''; denormalizedData['location.city'] = doc.city || ''; + denormalizedData['location.geoResolution'] = doc.geoResolution || ''; + denormalizedData['location.geometry.latitude'] = + doc.geometry?.latitude || ''; + denormalizedData['location.geometry.longitude'] = + doc.geometry?.longitude || ''; denormalizedData['location.query'] = doc.query || ''; + return denormalizedData; } diff --git a/data-serving/data-service/test/model/data/location.full.json b/data-serving/data-service/test/model/data/location.full.json index 114ffda2..597f362c 100644 --- a/data-serving/data-service/test/model/data/location.full.json +++ b/data-serving/data-service/test/model/data/location.full.json @@ -5,5 +5,9 @@ "location": "Brooklyn", "geoResolution": "Point", "name": "Kings County Hospital Center", - "query": "Brooklyn, New York" + "query": "Brooklyn, New York", + "geometry": { + "latitude": 40.6809611, + "longitude": -73.9740028 + } } diff --git a/data-serving/data-service/test/util/case.test.ts b/data-serving/data-service/test/util/case.test.ts index d11b3b61..eb5b68e8 100644 --- a/data-serving/data-service/test/util/case.test.ts +++ b/data-serving/data-service/test/util/case.test.ts @@ -268,6 +268,9 @@ describe('Case', () => { expect(denormalizedCase['location.countryISO2']).toEqual(''); expect(denormalizedCase['location.location']).toEqual(''); expect(denormalizedCase['location.city']).toEqual(''); + expect(denormalizedCase['location.geoResolution']).toEqual(''); + expect(denormalizedCase['location.geometry.latitude']).toEqual(''); + expect(denormalizedCase['location.geometry.longitude']).toEqual(''); expect(denormalizedCase['pathogen']).toEqual(''); expect(denormalizedCase['caseStatus']).toEqual(''); @@ -457,6 +460,10 @@ describe('Case', () => { name: 'Tbilisi', city: 'Tibilisi', geoResolution: 'Point', + geometry: { + latitude: 41.7151, + longitude: 44.8271, + }, } as LocationDocument; const caseDoc = { @@ -483,6 +490,15 @@ describe('Case', () => { ); expect(denormalizedCase['location.countryISO2']).toEqual('GE'); expect(denormalizedCase['location.city']).toEqual(locationDoc.city); + expect(denormalizedCase['location.geoResolution']).toEqual( + locationDoc.geoResolution, + ); + expect(denormalizedCase['location.geometry.latitude']).toEqual( + locationDoc.geometry.latitude, + ); + expect(denormalizedCase['location.geometry.longitude']).toEqual( + locationDoc.geometry.longitude, + ); }); it('denormalizes preexisting conditions fields', async () => { const conditionsDoc = { diff --git a/verification/curator-service/ui/src/api/models/Day0Case.ts b/verification/curator-service/ui/src/api/models/Day0Case.ts index d4a14b30..5c752f26 100644 --- a/verification/curator-service/ui/src/api/models/Day0Case.ts +++ b/verification/curator-service/ui/src/api/models/Day0Case.ts @@ -69,6 +69,7 @@ export interface Geometry { } export interface Location { + geoResolution: string; country: string; countryISO2: string; location?: string; @@ -223,6 +224,7 @@ export interface Day0CaseFormValues { healthcareWorker?: YesNo | ''; }; location: { + geoResolution: string; country: string; countryISO2: string; location?: string; diff --git a/verification/curator-service/ui/src/components/CaseForm.tsx b/verification/curator-service/ui/src/components/CaseForm.tsx index f9a818d2..42079317 100644 --- a/verification/curator-service/ui/src/components/CaseForm.tsx +++ b/verification/curator-service/ui/src/components/CaseForm.tsx @@ -77,6 +77,7 @@ const initialValuesFromCase = ( healthcareWorker: '', }, location: { + geoResolution: '', country: '', countryISO2: '', location: '', diff --git a/verification/curator-service/ui/src/components/ViewCase.tsx b/verification/curator-service/ui/src/components/ViewCase.tsx index 1a6332c4..25fd6a4b 100644 --- a/verification/curator-service/ui/src/components/ViewCase.tsx +++ b/verification/curator-service/ui/src/components/ViewCase.tsx @@ -351,6 +351,10 @@ function CaseDetails(props: CaseDetailsProps): JSX.Element { Location + + { { , ); + expect(screen.getByDisplayValue(/point/i)).toBeInTheDocument(); expect(screen.getByDisplayValue(/united States/i)).toBeInTheDocument(); expect(screen.getByDisplayValue(/Chicago/i)).toBeInTheDocument(); + expect(screen.getByDisplayValue(/53.426588/i)).toBeInTheDocument(); }); From bb0c6dc5f1027e05ec804d52882099028739bdef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stanis=C5=82aw=20Zakrzewski?= Date: Tue, 11 Apr 2023 16:46:27 +0200 Subject: [PATCH 6/8] Fixed tests --- data-serving/data-service/test/model/data/case.full.json | 3 ++- .../ui/cypress/e2e/components/Curator.spec.ts | 2 ++ verification/curator-service/ui/src/api/models/Day0Case.ts | 4 ++-- verification/curator-service/ui/src/components/CaseForm.tsx | 2 +- .../ui/src/components/new-case-form-fields/Location.test.tsx | 2 +- .../ui/src/components/new-case-form-fields/Location.tsx | 5 ++--- 6 files changed, 10 insertions(+), 8 deletions(-) diff --git a/data-serving/data-service/test/model/data/case.full.json b/data-serving/data-service/test/model/data/case.full.json index 7b0152eb..dfeadc9d 100644 --- a/data-serving/data-service/test/model/data/case.full.json +++ b/data-serving/data-service/test/model/data/case.full.json @@ -33,7 +33,8 @@ "countryISO2": "FR", "query": "France", "name": "France", - "geoResolution": "Country" + "geoResolution": "Country", + "geometry": { "latitude": 42.42, "longitude": 11.11 } }, "events": { "dateEntry": "2020-01-10", diff --git a/verification/curator-service/ui/cypress/e2e/components/Curator.spec.ts b/verification/curator-service/ui/cypress/e2e/components/Curator.spec.ts index f4eb2362..20f53281 100644 --- a/verification/curator-service/ui/cypress/e2e/components/Curator.spec.ts +++ b/verification/curator-service/ui/cypress/e2e/components/Curator.spec.ts @@ -87,6 +87,8 @@ describe('Curator', function () { .clear() .type('Germany'); cy.contains('Germany').click(); + cy.get('div[data-testid="location.geoResolution"]').click() + cy.get('li[data-value="Country"').click(); // EVENTS cy.get('input[name="events.dateEntry"]').type('2020-01-01'); diff --git a/verification/curator-service/ui/src/api/models/Day0Case.ts b/verification/curator-service/ui/src/api/models/Day0Case.ts index 5c752f26..dc71827f 100644 --- a/verification/curator-service/ui/src/api/models/Day0Case.ts +++ b/verification/curator-service/ui/src/api/models/Day0Case.ts @@ -69,7 +69,7 @@ export interface Geometry { } export interface Location { - geoResolution: string; + geoResolution?: string; country: string; countryISO2: string; location?: string; @@ -224,7 +224,7 @@ export interface Day0CaseFormValues { healthcareWorker?: YesNo | ''; }; location: { - geoResolution: string; + geoResolution?: string; country: string; countryISO2: string; location?: string; diff --git a/verification/curator-service/ui/src/components/CaseForm.tsx b/verification/curator-service/ui/src/components/CaseForm.tsx index 42079317..328d81e9 100644 --- a/verification/curator-service/ui/src/components/CaseForm.tsx +++ b/verification/curator-service/ui/src/components/CaseForm.tsx @@ -77,7 +77,7 @@ const initialValuesFromCase = ( healthcareWorker: '', }, location: { - geoResolution: '', + geoResolution: undefined, country: '', countryISO2: '', location: '', diff --git a/verification/curator-service/ui/src/components/new-case-form-fields/Location.test.tsx b/verification/curator-service/ui/src/components/new-case-form-fields/Location.test.tsx index 78d5e0cb..509bf97a 100644 --- a/verification/curator-service/ui/src/components/new-case-form-fields/Location.test.tsx +++ b/verification/curator-service/ui/src/components/new-case-form-fields/Location.test.tsx @@ -8,7 +8,7 @@ it('shows location when passed location information', async () => { Geo resolution

} component={Select} From 65d847304d5387a73cbe874fad40f4555fb00918 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stanis=C5=82aw=20Zakrzewski?= Date: Wed, 12 Apr 2023 15:02:28 +0200 Subject: [PATCH 7/8] Additional tests --- .../data-service/src/controllers/case.ts | 24 ++- .../test/controllers/case.test.ts | 179 +++++++++++++++++- .../ui/src/components/CaseForm.tsx | 3 + .../new-case-form-fields/Location.tsx | 4 + 4 files changed, 205 insertions(+), 5 deletions(-) diff --git a/data-serving/data-service/src/controllers/case.ts b/data-serving/data-service/src/controllers/case.ts index 6852ce9c..d46230af 100644 --- a/data-serving/data-service/src/controllers/case.ts +++ b/data-serving/data-service/src/controllers/case.ts @@ -817,9 +817,6 @@ export class CasesController { location: any, canBeFuzzy: boolean, ): Promise { - if (location?.geometry?.latitude && location.geometry?.longitude) { - return location; - } if (!location?.query) { if (canBeFuzzy) { // no problem, just give back what we received @@ -861,9 +858,28 @@ export class CasesController { } // Currently a 1:1 match between the GeocodeResult and the data service API. // We also store the original query to match it later on and help debugging. + let found_location = features[0]; + + // If latitude and longitude was specified by used we want to use it + // and set geoResolution to Point + if (location?.geometry?.latitude && location.geometry?.longitude) { + found_location = { + ...found_location, + geometry: location.geometry, + geoResolution: Resolution.Point, + }; + } + + // If geoResolution was provided by curator we want to use it + if (location?.geoResolution) { + found_location = { + ...found_location, + geoResolution: location.geoResolution, + }; + } return { query: location?.query, - ...features[0], + ...found_location, }; } throw new GeocodeNotFoundError( diff --git a/data-serving/data-service/test/controllers/case.test.ts b/data-serving/data-service/test/controllers/case.test.ts index 2941b184..0c7b32c5 100644 --- a/data-serving/data-service/test/controllers/case.test.ts +++ b/data-serving/data-service/test/controllers/case.test.ts @@ -405,6 +405,183 @@ describe('POST', () => { .expect(201); expect(await Day0Case.collection.countDocuments()).toEqual(1); }); + it('create with only required location fields should complete with data from geocoding', async () => { + seedFakeGeocodes('Canada', { + country: 'CA', + geoResolution: 'Country', + geometry: { latitude: 42.42, longitude: 11.11 }, + name: 'Canada', + }); + + const minimalLocationRequest = { + ...minimalRequest, + location: { countryISO2: 'CA', country: 'Canada', query: 'Canada' }, + }; + + const expectedLocation = { + country: 'CA', + countryISO2: 'CA', + geoResolution: 'Country', + geometry: { latitude: 42.42, longitude: 11.11 }, + name: 'Canada', + query: 'Canada', + }; + + const res = await request(app) + .post('/api/cases') + .send(minimalLocationRequest) + .expect('Content-Type', /json/) + .expect(201); + + expect(res.body.location).toEqual(expectedLocation); + }); + it('create with overrided geoResolution', async () => { + seedFakeGeocodes('Canada', { + country: 'CA', + geoResolution: 'Country', + geometry: { latitude: 42.42, longitude: 11.11 }, + name: 'Canada', + }); + + const minimalLocationRequest = { + ...minimalRequest, + location: { + countryISO2: 'CA', + country: 'Canada', + query: 'Canada', + geoResolution: 'Admin3', + }, + }; + + const expectedLocation = { + country: 'CA', + countryISO2: 'CA', + geoResolution: 'Admin3', + geometry: { latitude: 42.42, longitude: 11.11 }, + name: 'Canada', + query: 'Canada', + }; + + const res = await request(app) + .post('/api/cases') + .send(minimalLocationRequest) + .expect('Content-Type', /json/) + .expect(201); + + expect(res.body.location).toEqual(expectedLocation); + }); + it('create with minimal + city should complete rest with geocoding', async () => { + seedFakeGeocodes('Montreal, Canada', { + country: 'CA', + geoResolution: 'Admin3', + geometry: { latitude: 45.5019, longitude: 73.5674 }, + name: 'Montreal, Canada', + }); + + const minimalLocationRequest = { + ...minimalRequest, + location: { + countryISO2: 'CA', + country: 'Canada', + query: 'Montreal, Canada', + city: 'Montreal', + }, + }; + + const expectedLocation = { + country: 'CA', + city: 'Montreal', + countryISO2: 'CA', + geoResolution: 'Admin3', + geometry: { latitude: 45.5019, longitude: 73.5674 }, + name: 'Montreal, Canada', + query: 'Montreal, Canada', + }; + + const res = await request(app) + .post('/api/cases') + .send(minimalLocationRequest) + .expect('Content-Type', /json/) + .expect(201); + + expect(res.body.location).toEqual(expectedLocation); + }); + it('create with minimal + city + location should complete rest with geocoding', async () => { + seedFakeGeocodes('Jacques Cartier Bridge, Montreal, Canada', { + country: 'CA', + geoResolution: 'Admin3', + geometry: { latitude: 45.5218, longitude: 73.5418 }, + name: 'Jacques Cartier Bridge, Montreal, Canada', + }); + + const minimalLocationRequest = { + ...minimalRequest, + location: { + countryISO2: 'CA', + country: 'Canada', + query: 'Jacques Cartier Bridge, Montreal, Canada', + city: 'Montreal', + location: 'Jacques Cartier Bridge', + }, + }; + + const expectedLocation = { + country: 'CA', + city: 'Montreal', + location: 'Jacques Cartier Bridge', + countryISO2: 'CA', + geoResolution: 'Admin3', + geometry: { latitude: 45.5218, longitude: 73.5418 }, + name: 'Jacques Cartier Bridge, Montreal, Canada', + query: 'Jacques Cartier Bridge, Montreal, Canada', + }; + + const res = await request(app) + .post('/api/cases') + .send(minimalLocationRequest) + .expect('Content-Type', /json/) + .expect(201); + + expect(res.body.location).toEqual(expectedLocation); + }); + + it('create with minimal + city + latitude + longitude should automatically set geoResolution to Point', async () => { + seedFakeGeocodes('Jacques Cartier Bridge, Montreal, Canada', { + country: 'CA', + geoResolution: 'Admin3', + geometry: { latitude: 45.5019, longitude: 73.5674 }, + name: 'Jacques Cartier Bridge, Montreal, Canada', + }); + + const minimalLocationRequest = { + ...minimalRequest, + location: { + countryISO2: 'CA', + country: 'Canada', + query: 'Jacques Cartier Bridge, Montreal, Canada', + city: 'Montreal', + geometry: { latitude: 45.5018, longitude: 73.5673 }, + }, + }; + + const expectedLocation = { + country: 'CA', + city: 'Montreal', + countryISO2: 'CA', + geoResolution: 'Point', + geometry: { latitude: 45.5018, longitude: 73.5673 }, + name: 'Jacques Cartier Bridge, Montreal, Canada', + query: 'Jacques Cartier Bridge, Montreal, Canada', + }; + + const res = await request(app) + .post('/api/cases') + .send(minimalLocationRequest) + .expect('Content-Type', /json/) + .expect(201); + + expect(res.body.location).toEqual(expectedLocation); + }); it('create with valid input should bucket the age range', async () => { seedFakeGeocodes('Canada', { country: 'CA', @@ -1547,4 +1724,4 @@ describe('DELETE', () => { expect(await Day0Case.collection.countDocuments()).toEqual(3); expect(await CaseRevision.collection.countDocuments()).toEqual(0); }); -}); +}); \ No newline at end of file diff --git a/verification/curator-service/ui/src/components/CaseForm.tsx b/verification/curator-service/ui/src/components/CaseForm.tsx index 328d81e9..63a5537d 100644 --- a/verification/curator-service/ui/src/components/CaseForm.tsx +++ b/verification/curator-service/ui/src/components/CaseForm.tsx @@ -319,6 +319,9 @@ export default function CaseForm(props: Props): JSX.Element { const diseaseName = useAppSelector(selectDiseaseName); const submitCase = async (values: Day0CaseFormValues): Promise => { + if (values.location.geoResolution === '') { + values.location.geoResolution = undefined; + } if (values.caseReference && values.caseReference.sourceId === '') { try { const newCaseReference = await submitSource({ diff --git a/verification/curator-service/ui/src/components/new-case-form-fields/Location.tsx b/verification/curator-service/ui/src/components/new-case-form-fields/Location.tsx index 6cc1dbae..d1fa9866 100644 --- a/verification/curator-service/ui/src/components/new-case-form-fields/Location.tsx +++ b/verification/curator-service/ui/src/components/new-case-form-fields/Location.tsx @@ -62,8 +62,12 @@ export default function Location(): JSX.Element { type="text" label={

Geo resolution

} component={Select} + isClearable="true" sx={{ minWidth: '13rem' }} > + + None + {['Point', 'Admin3', 'Admin2', 'Admin1', 'Country'].map( (res) => ( From b86d8a7ba5b16b8f21f1caaa67c230046692466b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stanis=C5=82aw=20Zakrzewski?= Date: Wed, 12 Apr 2023 15:15:42 +0200 Subject: [PATCH 8/8] Fix unused imports --- .../ui/src/components/new-case-form-fields/Location.tsx | 2 -- 1 file changed, 2 deletions(-) diff --git a/verification/curator-service/ui/src/components/new-case-form-fields/Location.tsx b/verification/curator-service/ui/src/components/new-case-form-fields/Location.tsx index d1fa9866..8e7ba859 100644 --- a/verification/curator-service/ui/src/components/new-case-form-fields/Location.tsx +++ b/verification/curator-service/ui/src/components/new-case-form-fields/Location.tsx @@ -2,8 +2,6 @@ import { Select, TextField } from 'formik-mui'; import { MenuItem } from '@mui/material'; import { FastField, useFormikContext } from 'formik'; -import FormControl from '@mui/material/FormControl'; -import InputLabel from '@mui/material/InputLabel'; import makeStyles from '@mui/styles/makeStyles'; import { Day0CaseFormValues } from '../../api/models/Day0Case'; import { useEffect } from 'react';