Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: remove date_of_birth column from person model #173

Merged
merged 1 commit into from
Sep 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions models/contacts/contacts.yml
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,6 @@ models:
field: uuid
- name: saved_timestamp
data_type: timestamp
- name: date_of_birth
data_type: date
- name: sex
data_type: string
- name: patient_id
Expand Down
9 changes: 0 additions & 9 deletions models/contacts/person.sql
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,6 @@
SELECT
contact.uuid,
contact.saved_timestamp,
CASE
WHEN NULLIF(couchdb.doc->>'date_of_birth', '') IS NULL THEN NULL
WHEN couchdb.doc->>'date_of_birth' ~ '^\d{4}-(0[1-9]|1[0-2])-(0[1-9]|[12][0-9]|3[01])$' THEN
CASE
WHEN couchdb.doc->>'date_of_birth' IS NOT NULL AND TO_DATE(couchdb.doc->>'date_of_birth', 'YYYY-MM-DD')::text = couchdb.doc->>'date_of_birth' THEN TO_DATE(couchdb.doc->>'date_of_birth', 'YYYY-MM-DD')
ELSE NULL
END
ELSE NULL
END as date_of_birth,
couchdb.doc->>'sex' as sex,
couchdb.doc->>'phone' AS phone,
couchdb.doc->>'alternative_phone' AS phone2,
Expand Down
6 changes: 3 additions & 3 deletions tests/fixtures/person/person_initial_expected.csv
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
uuid,saved_timestamp,date_of_birth,sex,phone,phone2
p1,2024-08-01 00:00:00,1980-01-01,M,12345,54321
p2,2024-08-01 00:00:00,1990-05-15,F,67890,9876
uuid,saved_timestamp,sex,phone,phone2
p1,2024-08-01 00:00:00,M,12345,54321
p2,2024-08-01 00:00:00,F,67890,9876
Loading