Skip to content

Instantly share code, notes, and snippets.

@Benmuiruri
Created February 19, 2024 17:07
Show Gist options
  • Save Benmuiruri/992a1602c69b45c26d6e3e15f699ca50 to your computer and use it in GitHub Desktop.
Save Benmuiruri/992a1602c69b45c26d6e3e15f699ca50 to your computer and use it in GitHub Desktop.
MOH Uganda
import { faker } from '@faker-js/faker';
const YES_NO = ['yes', 'no'];
const getPlace = (contact_type, nameSuffix) => {
return {
type: contact_type,
name: `${faker.location.city()} ${nameSuffix}`,
reported_date: faker.date.recent({ days: 10 }).getTime(),
};
};
const getHealthFacility = (context, parent) => {
return {
...getPlace('district_hospital', 'Health Facility'),
parent: parent,
meta: {
created_by: context.username,
created_by_person_uuid: '',
created_by_place_uuid: '',
},
};
};
const getVHTArea = () => {
return {
...getPlace('health_center', 'VHT Area'),
district: faker.location.city(),
sub_district: faker.location.city(),
county: faker.location.city(),
sub_county: faker.location.city(),
parish: faker.location.city(),
village: faker.location.city(),
};
};
const getHousehold = () => {
return {
...getPlace('clinic', 'Household'),
want_to_capture_gps: 'no',
group_wash: {
hh_in_sanitary_dwelling_house: faker.helpers.arrayElement(YES_NO),
hh_access_safe_water_source: faker.helpers.arrayElement(YES_NO),
hh_have_safe_drinking_water: faker.helpers.arrayElement(YES_NO),
hh_have_sanitary_kitchen: faker.helpers.arrayElement(YES_NO),
hh_have_drying_rack: faker.helpers.arrayElement(YES_NO),
hh_have_backyard_garden: faker.helpers.arrayElement(YES_NO),
hh_have_rubbish_pit: faker.helpers.arrayElement(YES_NO),
hh_have_bath_shelter: faker.helpers.arrayElement(YES_NO),
hh_sanitary_facility: 'flush',
hh_floor_of_toilet_or_latrine: 'tile',
hh_toilet_conected_to_sewer: 'yes_connected_to_sewer',
hh_handwashing_near_toilet_latrine: 'no',
hh_is_odf: 'yes',
},
};
};
const getVHT = ({ ageRange = { min: 20, max: 60 } } = {}) => {
const dobRaw = faker.date.birthdate({ mode: 'age', ...ageRange });
const dobFormatted = `${dobRaw.getFullYear()}-${dobRaw.getMonth()}-${dobRaw.getDay()}`;
const firstName = faker.person.firstName();
const lastName = faker.person.lastName();
const name = `${firstName} ${lastName}`;
return {
type: 'person',
name: name,
date_of_birth: dobFormatted,
date_of_birth_method: 'approx',
reported_date: faker.date.recent({ days: 5 }).getTime(),
sex: 'male',
};
};
const getHouseholdPerson = () => {
const firstName = faker.person.firstName();
const lastName = faker.person.lastName();
return {
type: 'person',
name: `${firstName} ${lastName}`,
date_of_birth: '1984-02-16',
sex: 'female',
today_d: '16',
c_name: `${firstName} ${lastName}`,
c_sex: 'female',
dob_method: 'approx',
age_years: '40',
ephemeral_years: '1984',
dob_approx: '1984-02-16',
dob_raw: '1984-02-16',
c_dob_iso: '1984-02-16',
current_age: '40',
date_vht_visit: '2024-02-16',
has_disability: 'no',
test_for_hiv_last3months: 'yes',
hiv_test_result: 'negative',
has_tb: 'no',
p_date_vht_visit: '2024-02-16',
relationship_with_hh: 'sister',
client_category: 'national',
p_has_disability: 'no',
child_in_school: 'no',
p_test_for_hiv_last3months: 'yes',
hiv_test_result_label: 'What was the result of the HIV test?',
p_hiv_test_result: 'negative',
p_has_tb: 'no',
takes_alcohol: 'no',
has_hypertension: 'no',
has_sickle_cell: 'no',
uses_tobacco: 'no',
sleep_under_llin: 'yes',
using_fp_method: 'no',
reported_date: faker.date.recent({ days: 10 }).getTime(),
};
};
const getANCReferralReport = ({parent}) => {
return {
form: 'screening',
type: 'data_record',
content_type: 'xml',
reported_date: faker.date.recent({ days: 2 }).getTime(),
fields: {
patient_id: parent._id,
is_of_child_bearing_age: 'true',
group_pregnancy_screening: {
is_pregnant: 'yes',
has_started_anc: 'no',
referred_to_health_facility_anc: 'yes',
},
group_hiv_screening: {
test_for_hiv_last3months: 'yes',
hiv_test_result: 'negative',
tested_hiv: 'negative',
},
group_tb_screening: {
has_tb: 'no',
},
group_other_screening: {
has_hypertension: 'yes',
has_sickle_cell: 'yes',
uses_tobacco: 'yes',
sleep_under_llin: 'yes',
},
group_summary: {
hiv_test_summary: 'Tested in the last 3 months',
},
},
};
};
const getFamilyPlanningReport = ({parent}) => {
return {
form: 'fp_registration',
type: 'data_record',
content_type: 'xml',
reported_date: faker.date.recent({ days: 2 }).getTime(),
fields: {
inputs: {
source: 'contact',
contact: {
_id: parent._id,
},
},
patient_uuid: parent._id,
current_fp_method_label: 'None',
current_fp_method: 'none',
coc_given: '0',
condoms_given: '0',
pop_given: '0',
dmpa_given: '0',
contraceptives_given: '0',
needs_method_change: 'false',
has_been_referred: 'true',
fp_registration: {
fp_method: 'none',
enrol_on_fp_method: 'yes',
patient_referred: 'yes',
referral_follow_up_date: faker.date.recent({ days: 5 }).toISOString(),
supply_item_name: 'None',
supply_limit: '0',
},
},
};
};
const getPregnancyRegistrationReport = ({ parent }) => {
const futureDate = faker.date.soon({ days: 180 });
const futureDateStd = `${futureDate.getFullYear()}-${futureDate.getMonth()}-${futureDate.getDay()}`;
const futureDateLocal = `${futureDate.getDay()}/${futureDate.getMonth()}/${futureDate.getFullYear()}`;
return {
form: 'pregnancy',
type: 'data_record',
content_type: 'xml',
reported_date: faker.date.recent({ days: 2 }).getTime(),
fields: {
is_of_child_bearing_age: 'true',
patient_id: parent._id,
patient_name: parent.name,
edd_std: futureDateStd,
edd_local: futureDateLocal,
referred_for_nutrition_follow_up: 'no',
group_gestational_Age: {
pregnancy_report_method: 'no_information',
pregnancy_age_in_weeks: '4',
},
group_past_anc_visits: {
number_of_anc_visits: 'none',
},
group_scheduled_anc_visits: {
has_upcoming_anc_visits: 'no',
},
group_danger_sign_check: {
vaginal_bleeding: 'no',
lower_abdomen_pain: 'no',
severe_headache: 'no',
very_pale: 'no',
fever: 'no',
blurred_vision: 'no',
swelling: 'no',
breathlessness: 'no',
},
group_nutrition_status: {
taken_muac: 'no',
micro_nutrient_supplementation_received: 'vitamin_a',
on_nutrition_follow_up: 'no',
},
group_safe_pregnancy_practices: {
using_llin: 'yes',
has_tt_card: 'no',
tt_refer_ack: 'yes',
},
},
};
};
export default (context) => {
const TOP_PARENT = {
_id: 'my_district_id',
parent: {
_id: 'north_central',
},
};
return [
{
designId: 'place-health-facility',
amount: 1,
getDoc: () => getHealthFacility(context, TOP_PARENT),
children: [
{
designId: 'place-vht-area',
amount: 1,
getDoc: () => getVHTArea(),
children: [
{
designId: 'vht-person',
amount: 1,
getDoc: () => getVHT(),
},
{
designId: 'place-household',
amount: 100,
getDoc: () => getHousehold(),
children: [
{
designId: 'household-person',
amount: 8,
getDoc: () => getHouseholdPerson(),
children: [
{
designId: 'anc-referral',
amount: 3,
getDoc: ({ parent }) => getANCReferralReport({ parent }),
},
{
designId: 'family-planning',
amount: 3,
getDoc: ({ parent }) =>
getFamilyPlanningReport({ parent }),
},
{
designId: 'pregnancy-registration',
amount: 3,
getDoc: ({ parent }) =>
getPregnancyRegistrationReport({ parent }),
},
],
},
],
},
],
},
],
},
];
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment