From 06c4178b118294bd832e9e71a0418ddb5fe98ff9 Mon Sep 17 00:00:00 2001 From: Stevan Earl Date: Wed, 22 Jul 2026 16:44:13 -0700 Subject: [PATCH] fix: implement solution to Problem #54 in the clean schema --- conversion/clean.sql | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/conversion/clean.sql b/conversion/clean.sql index e402450..c1a2224 100644 --- a/conversion/clean.sql +++ b/conversion/clean.sql @@ -278,6 +278,21 @@ UPDATE follow_arrival SET fa_type_of_cycle = 'MISS' WHERE fa_type_of_cycle IS NULL; +-- Problem #54: females younger than 8 with an adult swelling code +-- should use the adolescent swelling code. +UPDATE follow_arrival + SET fa_type_of_cycle = 'U' + FROM biography + WHERE biography.b_animid = follow_arrival.fa_b_arr_animid + AND biography.b_sex = 'F' + AND follow_arrival.fa_type_of_cycle + NOT IN ('0', 'U', 'MISS') + AND biography.b_birthdate + > (follow_arrival.fa_fol_date + - '8 years'::INTERVAL) + AND follow_arrival.fa_b_arr_animid + NOT IN ('MGF', 'MGF2', 'MGF3'); + -- The desired code is "n/a", not "NA" UPDATE follow_arrival SET fa_type_of_cycle = 'n/a' -- 2.34.1