Last active
December 16, 2020 21:21
-
-
Save brandones/9a220f4236553c3aae984ec011245781 to your computer and use it in GitHub Desktop.
Config schema for esm-patient-registration
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 { Type, validator, validators } from '@openmrs/esm-module-config'; | |
const builtInFields = ['name', 'gender', 'dob', 'address', 'id', 'death'] | |
export const schema = { | |
sections: { | |
_type: Type.Array, | |
_default: ['demographics', 'contact', 'ids', 'death'], | |
_description: "An array of strings which are the keys from 'sectionDefinitions'", | |
_elements: { | |
_type: Type.String | |
} | |
}, | |
sectionDefinitions: { | |
_type: Type.Object, | |
_elements: { | |
name: { | |
_type: Type.String, | |
_default: "", | |
_description: "The title to display at the top of the section." | |
}, | |
fields: { | |
_type: Type.Array, | |
_default: [], | |
_description: `The parts to include in the section. Can be any of the following built-in fields: ${builtInFields.join(', ')}. Can also be any of the keys from the fieldDefinitions object, which you can use to define custom fields.`, | |
_elements: { _type: Type.String } // another validator at top level | |
} | |
}, | |
_default: { | |
demographics: { name: "Demographics", fields: ["name", "gender", "dob"] }, | |
contact: { name: "Contact Info", fields: ["address"] }, | |
ids: { name: "Identifiers", fields: ["id"] }, | |
death: { name: "Death Info", fields: ["death"] } | |
} | |
}, | |
fieldDefinitions: { | |
_type: Type.Object, | |
_elements: { | |
// Right now only patientAttributes are supported. We'll have to elaborate on this in order to support concepts. | |
label: { _type: Type.String, description: 'The label of the input' }, | |
uuid: { | |
_type: Type.UUID | |
_description: 'Person attributetype uuid used to save the attribute', | |
}, | |
placeholder: { | |
_type: Type.String, | |
_default: "", | |
_description: 'Placeholder that will appear in the input.' | |
}, | |
validation: { | |
required: { _type: Type.Boolean, _default: false }, | |
matches: { _type: Type.String, _default: null, _description: 'Optional RegEx for testing the validity of the input.' }, | |
}, | |
}, | |
_default: {}, | |
_description: "Definitions for custom fields that can be used in sectionDefinitions. Can also be used to override built-in fields." | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
So the config that would be needed in order to add a telephone number field to "Contact Info" would be