From a568dd2785bddc75df327b191cd272bb7543f73d Mon Sep 17 00:00:00 2001 From: Kenn Sippell Date: Fri, 9 Feb 2024 14:59:44 +0700 Subject: [PATCH] Update Uganda config to match VHT template (#40) --- package-lock.json | 4 ++-- package.json | 2 +- src/config/chis-ug/config.json | 18 ++++++++++++++---- src/config/chis-ug/gross.ts | 12 ++++++++++++ src/config/chis-ug/index.ts | 4 +++- src/lib/validator-gender.ts | 4 ++-- src/services/upload-manager.ts | 2 +- test/lib/validation.spec.ts | 12 ++++++------ 8 files changed, 41 insertions(+), 17 deletions(-) create mode 100644 src/config/chis-ug/gross.ts diff --git a/package-lock.json b/package-lock.json index 11aa4583..6dbc11ea 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "cht-user-management", - "version": "1.0.8", + "version": "1.0.9", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "cht-user-management", - "version": "1.0.8", + "version": "1.0.9", "license": "ISC", "dependencies": { "@fastify/autoload": "^5.8.0", diff --git a/package.json b/package.json index 87a09b47..6fb07286 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "cht-user-management", - "version": "1.0.8", + "version": "1.0.9", "main": "dist/index.js", "dependencies": { "@fastify/autoload": "^5.8.0", diff --git a/src/config/chis-ug/config.json b/src/config/chis-ug/config.json index f4e5340f..30bad92a 100644 --- a/src/config/chis-ug/config.json +++ b/src/config/chis-ug/config.json @@ -2,16 +2,25 @@ { "domains": [ { - "friendly": "UG VHT", + "friendly": "eCHIS Uganda", "domain": "echis.health.go.ug" + }, + { + "friendly": "eCHIS Uganda Dev", + "domain": "vhtapp-4x.dev.medicmobile.org" + }, + { + "friendly": "eCHIS Uganda Training", + "domain": "moh-ug-test.dev.medicmobile.org" } ], + "contact_types": [ { "name": "health_center", "friendly": "VHT Area", "contact_type": "person", - "user_role": "district_admin", + "user_role": "vht", "username_from_place": true, "hierarchy": [ { @@ -34,9 +43,10 @@ "friendly_name": "VHT Area Name", "property_name": "name", "type": "name", - "parameter": [], + "parameter": ["\\sArea", "\\s\\(.*\\)"], "required": true }, + { "friendly_name": "District", "property_name": "district", @@ -82,7 +92,7 @@ "required": true }, { - "friendly_name": "VHT Phone", + "friendly_name": "Phone Number", "property_name": "phone", "type": "phone", "parameter": "UG", diff --git a/src/config/chis-ug/gross.ts b/src/config/chis-ug/gross.ts new file mode 100644 index 00000000..1f3944b2 --- /dev/null +++ b/src/config/chis-ug/gross.ts @@ -0,0 +1,12 @@ +import { PlacePayload } from '../../lib/cht-api'; + +export default async function mutate(payload: PlacePayload): Promise { + if (payload.contact_type === 'health_center') { + // during replacement, the name is optional + if (payload.name) { + payload.name += ` Area (${payload.village})`; + } + } + + return payload; +} diff --git a/src/config/chis-ug/index.ts b/src/config/chis-ug/index.ts index 4bec1725..a43bcbce 100644 --- a/src/config/chis-ug/index.ts +++ b/src/config/chis-ug/index.ts @@ -1,8 +1,10 @@ import { PartnerConfig } from '..'; import config from './config.json'; +import mutate from './gross'; const partnerConfig: PartnerConfig = { - config + config, + mutate, }; export default partnerConfig; diff --git a/src/lib/validator-gender.ts b/src/lib/validator-gender.ts index ddd3359b..391fb5a2 100644 --- a/src/lib/validator-gender.ts +++ b/src/lib/validator-gender.ts @@ -16,14 +16,14 @@ export default class ValidatorGender implements IValidator { } get defaultError(): string { - return `Must be either 'Male' or 'Female'`; + return `Must be either 'male' or 'female'`; } private parseGenders(input: string): { gender: string; isValid: boolean } { const isFemale = input?.match(/[fw]/i); const isMale = input?.match(/m(? {