-
-
Save Benmuiruri/f65fed390dc673f967f65a350c74df77 to your computer and use it in GitHub Desktop.
MOH - Mali
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { faker } from '@faker-js/faker'; | |
const YES_NO = ['yes', 'no']; | |
const DEFAULT_PHONE_NUMBER = '11111111'; | |
const getPlace = (context, contactType, nameSuffix) => { | |
return { | |
type: 'contact', | |
contact_type: contactType, | |
name: `${faker.location.city()} ${nameSuffix}`, | |
place_id: faker.string.numeric({ length: 5 }), | |
geolocation: '', | |
meta: { | |
created_by: context.username, | |
}, | |
reported_date: faker.date.recent({ days: 10 }).getTime(), | |
}; | |
}; | |
const getCentralLevel = (context) => { | |
return { | |
...getPlace(context, 'c10_central', 'Central Level'), | |
}; | |
}; | |
const getRegion = (context, { parent }) => { | |
return { | |
...getPlace(context, 'c20_region', 'Region'), | |
}; | |
}; | |
const getDistrict = (context, { parent }) => { | |
return { | |
...getPlace(context, 'c30_district', 'District'), | |
parent_place_id: parent._id | |
}; | |
}; | |
const getHealthArea = (context, { parent }) => { | |
return { | |
...getPlace(context, 'c40_health_area', 'Health Area'), | |
parent_place_id: parent._id, | |
}; | |
}; | |
const getSupervisionArea = (context, { parent }) => { | |
return { | |
...getPlace(context, 'c50_supervision_area', 'Supervision Area'), | |
parent_place_id: parent._id, | |
}; | |
}; | |
const getCHWSite = (context, { parent }) => { | |
return { | |
...getPlace(context, 'c60_chw_site', 'CHW Site'), | |
parent_place_id: parent._id, | |
}; | |
}; | |
const getVillage = (context, { parent }) => { | |
return { | |
...getPlace(context, 'c70_village', 'Village'), | |
}; | |
}; | |
const getConcession = (context, { parent }) => { | |
return { | |
...getPlace(context, 'c80_concession', 'Concession'), | |
family_number: '50', | |
family_geolocation: '' | |
}; | |
}; | |
const getHousehold = (context, { parent }) => { | |
return { | |
...getPlace(context, 'c90_household', 'Household'), | |
is_name_generated: 'yes' | |
}; | |
}; | |
const getPerson = ( | |
context, | |
contact_type, | |
{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(); | |
return { | |
type: 'contact', | |
contact_type: contact_type, | |
fist_name: firstName, | |
last_name: lastName, | |
name: firstName + ' ' + lastName, | |
date_of_birth: dobFormatted, | |
phone: DEFAULT_PHONE_NUMBER, | |
username: `${firstName.toLowerCase()}_${lastName.toLowerCase()}`, | |
meta: { | |
created_by: context.username, | |
}, | |
reported_date: faker.date.recent({ days: 25 }).getTime(), | |
}; | |
}; | |
const getCentralLevelPerson = (context, { parent }) => { | |
return { | |
...getPerson(context, 'c12_central'), | |
role: 'super_admin', | |
phone_required: DEFAULT_PHONE_NUMBER, | |
date_of_birth: '', | |
membership_structure: 'default', | |
}; | |
}; | |
const getRegionPerson = (context, { parent }) => { | |
return { | |
...getPerson(context, 'c22_region'), | |
role: 'administrator', | |
membership_structure: 'default', | |
}; | |
}; | |
const getDistrictPerson = (context, { parent }) => { | |
return { | |
...getPerson(context, 'c32_district'), | |
role: 'administrator', | |
membership_structure: 'default', | |
}; | |
}; | |
const getHealthAreaPerson = (context, { parent }) => { | |
return { | |
...getPerson(context, 'c42_health_area'), | |
role: 'dtc', | |
membership_structure: 'default', | |
}; | |
}; | |
const getSupervisorPerson = (context, { parent }) => { | |
return { | |
...getPerson(context, 'c52_supervisor'), | |
role: 'supervisor', | |
}; | |
}; | |
const getCHW = (context, { parent }) => { | |
const gender = faker.person.sex(); | |
return { | |
...getPerson(context, 'c62_chw'), | |
site_category: 'unexisting', | |
geolocalized: 'false', | |
sex: gender, | |
role: 'chw' | |
}; | |
}; | |
const getVillagePerson = (context, { parent }) => { | |
const gender = faker.person.sex(); | |
return { | |
...getPerson(context, 'c72_village'), | |
out_chw_area: 'false', | |
sex: gender, | |
role: 'village_head', | |
}; | |
}; | |
const getConcessionPerson = (context, { parent }) => { | |
const gender = faker.person.sex(); | |
return { | |
...getPerson(context, 'c82_concession'), | |
sex: gender, | |
role: 'concession_head', | |
}; | |
}; | |
const getHouseholdHead = (context, { parent }) => { | |
const gender = faker.person.sex(); | |
return { | |
...getPerson(context, 'c92_household'), | |
date_of_birth_method: 'approx', | |
sex: gender, | |
role: 'Household person', | |
adult: { | |
profession: 'teacher', | |
matrimonial_status: 'married', | |
relation_to_hh: 'head', | |
marital_status: 'monogamy', | |
}, | |
}; | |
}; | |
const getHouseholdPerson = (context, { parent }) => { | |
const gender = faker.person.sex(); | |
return { | |
...getPerson(context, 'c92_household'), | |
person_type_site: 'in_community', | |
sex: gender, | |
role: 'patient', | |
adult: { | |
profession: 'farmer', | |
adult_phone: DEFAULT_PHONE_NUMBER, | |
matrimonial_status: 'single', | |
relation_to_hh: 'other_relation', | |
}, | |
}; | |
}; | |
const getCareOfWomanReport = (context, { parent}) => { | |
const futureDate = faker.date.soon({ days: 2 }); | |
const futureDateLocal = `${futureDate.getDay()}/${futureDate.getMonth()}/${futureDate.getFullYear()}`; | |
return { | |
form: 'care_of_pregnant_women_and_others', | |
type: 'data_record', | |
content_type: 'xml', | |
reported_date: faker.date.recent({ days: 5 }).getTime(), | |
from: DEFAULT_PHONE_NUMBER, | |
fields: { | |
patient_uuid: parent._id, | |
patient_name: parent.name, | |
patient_sex: parent.sex, | |
is_pregnant: 'no', | |
s_reported: { | |
s_reported_today: 'yes', | |
s_reported_how_patient_found: 'home_visit', | |
}, | |
constant: { | |
constant_temperature: '38', | |
constant_weight: '56', | |
}, | |
complaints_history: { | |
number_days_has_history_fever: '5', | |
has_fever: 'yes', | |
has_received_treatment: 'no', | |
has_positive_tdr_past_15: 'yes', | |
}, | |
danger_sign_search: { | |
danger_sign_unconsciouness: 'no', | |
danger_sign_convulsion: 'yes', | |
danger_sign_drink_eat: 'yes', | |
danger_sign_vomiting: 'yes', | |
danger_sign_stand_sit: 'yes', | |
danger_sign_pallor: 'yes', | |
danger_sign_jaundice: 'yes', | |
danger_sign_breathing: 'yes', | |
danger_sign_bleeding: 'yes', | |
danger_sign_dark_urine: 'yes', | |
danger_sign_abdominal_pain: 'yes', | |
danger_sign_headaches: 'yes', | |
has_danger_sign: 'yes', | |
}, | |
tb_Signs: { | |
sign_chronic_cough_14_days: 'yes', | |
sign_visible_weight_loss: 'yes', | |
sign_hemoptysis: 'yes', | |
sign_prolonged_fever_21_days: 'yes', | |
}, | |
has_tb_signs: 'yes', | |
next_visit_72h: futureDateLocal, | |
patient_to_refer: 'yes', | |
summary: { | |
patient_is_referred: 'yes', | |
refer_cscom: 'yes', | |
}, | |
prescription_summary: { | |
type: 'data_record', | |
created_from_name: 'care_of_pregnant_women_and_others', | |
content_type: 'xml', | |
form: 'prescription_summary', | |
fields: { | |
paracetamol_tablet_500_used_in_care_of_pregnant_women_and_others: '1', | |
gant_used_in_care_of_pregnant_women_and_others: '1', | |
tdr_used_in_care_of_pregnant_women_and_others: '1', | |
}, | |
}, | |
}, | |
}; | |
}; | |
const getTBAssessmentReport = (context, { parent }) => { | |
return { | |
form: 'assessment_case_contact_tb', | |
type: 'data_record', | |
content_type: 'xml', | |
reported_date: faker.date.recent({ days: 1 }).getTime(), | |
from: DEFAULT_PHONE_NUMBER, | |
fields: { | |
inputs: { | |
contact: { | |
_id: parent._id, | |
}, | |
}, | |
patient_uuid: parent._id, | |
g_realisation: { | |
s_reported_today: 'yes', | |
has_patient_returned: 'yes', | |
why_has_patient_returned: 'worsening_health', | |
}, | |
information_note: { | |
filling_out_form: 'yes', | |
}, | |
tb_signs: { | |
person_tested_positive: 'Care', | |
signs_identified: { | |
sign_hiv_aids: 'yes', | |
sign_chronic_cough_14_days: 'yes', | |
sign_visible_weight_loss: 'yes', | |
sign_hemoptysis: 'yes', | |
sign_prolonged_fever_21_days: 'yes', | |
}, | |
}, | |
s_reported_date_time: '2024-02-19T17:00:40.980+03:00', | |
refer_to_cscom: 'yes', | |
}, | |
}; | |
}; | |
export default (context) => { | |
return [ | |
{ | |
designId: 'place-central-level', | |
amount: 1, | |
getDoc: () => getCentralLevel(context), | |
children: [ | |
{ | |
designId: 'central-level-person', | |
amount: 1, | |
getDoc: ({ parent }) => { | |
return getCentralLevelPerson(context, { parent }); | |
}, | |
}, | |
{ | |
designId: 'place-region', | |
amount: 1, | |
getDoc: ({ parent }) => getRegion(context, { parent }), | |
children: [ | |
{ | |
designId: 'region-person', | |
amount: 1, | |
getDoc: ({ parent }) => getRegionPerson(context, { parent }), | |
}, | |
{ | |
designId: 'place-district', | |
amount: 1, | |
getDoc: ({ parent }) => getDistrict(context, { parent }), | |
children: [ | |
{ | |
designId: 'district-person', | |
amount: 1, | |
getDoc: ({ parent }) => | |
getDistrictPerson(context, { parent }), | |
}, | |
{ | |
designId: 'place-health-area', | |
amount: 1, | |
getDoc: ({ parent }) => getHealthArea(context, { parent }), | |
children: [ | |
{ | |
designId: 'health-area-person', | |
amount: 1, | |
getDoc: ({ parent }) => | |
getHealthAreaPerson(context, { parent }), | |
}, | |
{ | |
designId: 'place-supervision-area', | |
amount: 1, | |
getDoc: ({ parent }) => | |
getSupervisionArea(context, { parent }), | |
children: [ | |
{ | |
designId: 'supervision-area-person', | |
amount: 1, | |
getDoc: ({ parent }) => | |
getSupervisorPerson(context, { parent }), | |
}, | |
{ | |
designId: 'place-chw-site', | |
amount: 1, | |
getDoc: ({ parent }) => | |
getCHWSite(context, { parent }), | |
children: [ | |
{ | |
designId: 'chw', | |
amount: 1, | |
getDoc: ({ parent }) => | |
getCHW(context, { parent }), | |
}, | |
{ | |
designId: 'place-village', | |
amount: 1, | |
getDoc: ({ parent }) => | |
getVillage(context, { parent }), | |
children: [ | |
{ | |
designId: 'village-person', | |
amount: 1, | |
getDoc: ({ parent }) => | |
getVillagePerson(context, { parent }), | |
}, | |
{ | |
designId: 'place-concession', | |
amount: 1, | |
getDoc: ({ parent }) => | |
getConcession(context, { parent }), | |
children: [ | |
{ | |
designId: 'concession-person', | |
amount: 1, | |
getDoc: ({ parent }) => | |
getConcessionPerson(context, { | |
parent, | |
}), | |
}, | |
{ | |
designId: 'place-household', | |
amount: 1, | |
getDoc: ({ parent }) => | |
getHousehold(context, { parent }), | |
children: [ | |
{ | |
designId: 'household-head', | |
amount: 1, | |
getDoc: ({ parent }) => | |
getHouseholdHead(context, { | |
parent, | |
}), | |
}, | |
{ | |
designId: 'household-person', | |
amount: 1, | |
getDoc: ({ parent }) => | |
getHouseholdPerson(context, { | |
parent, | |
}), | |
children: [ | |
{ | |
designId: | |
'care-of-pregnant-woman-report', | |
amount: 1, | |
getDoc: ({ parent }) => | |
getCareOfWomanReport(context, { | |
parent, | |
}), | |
}, | |
{ | |
designId: | |
'tb-assessment-report', | |
amount: 1, | |
getDoc: ({ parent }) => | |
getTBAssessmentReport(context, { | |
parent, | |
}), | |
}, | |
], | |
}, | |
], | |
}, | |
], | |
}, | |
], | |
}, | |
], | |
}, | |
], | |
}, | |
], | |
}, | |
], | |
}, | |
], | |
}, | |
], | |
}, | |
]; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment