Skip to content

Commit

Permalink
Merge branch 'main' into 18-upload-progress-bar
Browse files Browse the repository at this point in the history
  • Loading branch information
kennsippell authored Feb 9, 2024
2 parents 077ab52 + a568dd2 commit 7e21778
Show file tree
Hide file tree
Showing 8 changed files with 41 additions and 17 deletions.
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
18 changes: 14 additions & 4 deletions src/config/chis-ug/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": [
{
Expand All @@ -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",
Expand Down Expand Up @@ -82,7 +92,7 @@
"required": true
},
{
"friendly_name": "VHT Phone",
"friendly_name": "Phone Number",
"property_name": "phone",
"type": "phone",
"parameter": "UG",
Expand Down
12 changes: 12 additions & 0 deletions src/config/chis-ug/gross.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { PlacePayload } from '../../lib/cht-api';

export default async function mutate(payload: PlacePayload): Promise<PlacePayload> {
if (payload.contact_type === 'health_center') {
// during replacement, the name is optional
if (payload.name) {
payload.name += ` Area (${payload.village})`;
}
}

return payload;
}
4 changes: 3 additions & 1 deletion src/config/chis-ug/index.ts
Original file line number Diff line number Diff line change
@@ -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;
4 changes: 2 additions & 2 deletions src/lib/validator-gender.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(?<!fem|wom)/i);
const isValid = (!!isFemale || !!isMale) && !(isFemale && isMale);
const gender = isMale ? 'Male' : 'Female';
const gender = isMale ? 'male' : 'female';
return { isValid, gender };
}
}
2 changes: 1 addition & 1 deletion src/services/upload-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ export class UploadManager extends EventEmitter {
console.log(`successfully created ${JSON.stringify(place.creationDetails)}`);
this.eventedPlaceStateChange(place, PlaceUploadState.SUCCESS);
} catch (err: any) {
const errorDetails = err.response?.data.toString() || err.toString();
const errorDetails = err.response?.data.error || err.toString();
console.log('error when creating user', errorDetails);
place.uploadError = errorDetails;
this.eventedPlaceStateChange(place, PlaceUploadState.FAILURE);
Expand Down
12 changes: 6 additions & 6 deletions test/lib/validation.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,12 @@ const scenarios: Scenario[] = [
{ type: 'name', prop: 'Sam\'s CHU', propertyParameter: ['CHU', 'Comm Unit'], isValid: true, altered: 'Sam\'s' },
{ type: 'name', prop: 'Jonathan M.Barasa', isValid: true, altered: 'Jonathan M Barasa' },

{ type: 'gender', prop: 'Man', isValid: true, altered: 'Male' },
{ type: 'gender', prop: 'male', isValid: true, altered: 'Male' },
{ type: 'gender', prop: 'F', isValid: true, altered: 'Female' },
{ type: 'gender', prop: 'Female', isValid: true, altered: 'Female' },
{ type: 'gender', prop: 'Woman', isValid: true, altered: 'Female' },
{ type: 'gender', prop: 'X', isValid: false, error: 'Male' },
{ type: 'gender', prop: 'Man', isValid: true, altered: 'male' },
{ type: 'gender', prop: 'male', isValid: true, altered: 'male' },
{ type: 'gender', prop: 'F', isValid: true, altered: 'female' },
{ type: 'gender', prop: 'Female', isValid: true, altered: 'female' },
{ type: 'gender', prop: 'Woman', isValid: true, altered: 'female' },
{ type: 'gender', prop: 'X', isValid: false, error: 'male' },
];

describe('lib/validation', () => {
Expand Down

0 comments on commit 7e21778

Please sign in to comment.