Skip to content

Commit

Permalink
feat: remove date_of_birth column from person model
Browse files Browse the repository at this point in the history
  • Loading branch information
njuguna-n committed Sep 26, 2024
1 parent a8663e2 commit ec8343f
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 14 deletions.
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

0 comments on commit ec8343f

Please sign in to comment.