-
Notifications
You must be signed in to change notification settings - Fork 30
Adding a New Visit Template
Although called a "Visit Template", such a template is actually modeled using an encounter. A Visit Template consists of multiple small forms, but behind the scenes the data is stored within a single encounter (with a few exceptions).
So when adding a Visit Template, the first thing to do is to add a new Encounter Type.
We need to add any new forms that we wish to include as sections within the Visit Template. By convention, these new forms go in the htmlforms folder in the PIH Core module. Generally, visit templates are specific to country, so you should put your new forms in the country-specific subdirectory.
Note that by convention, section forms are named section-[form_name].xml. Look in the haiti subdirectory off the htmlforms directory for examples.
Next, we need to create form for editing the basic encounter info: date, provider, and location, for this new Visit Template. Generally you can just copy an existing basic form for an existing Visit Template (for and example see this form), modifying the formUuid, formEncounterType, and formName attributes in the htmlform tag as well as the header text.
To make sure that the New Forms are loaded (and reloaded) on startup, add the forms to the HtmlFormSetup page in the Mirebalais module.
To do this you specify the path to the form, like pihcore:htmlforms/patientRegistration.xml
where the content to the left of the colon in the module the form is found in, and the content to the right is the path to form relative to the "webapps/resources" directory in the omod directory of the module.
Now that we've added the forms for the new sections, we can define the new sections in EncounterTypeConfig. Generally you can follow the pattern for an existing section. The parameters to specify are:
- type: should be "encounter-section"
- id: unique key
- label: message code (or raw text) for the label
- icon: font awesome icon to use
- shortTemplate: template to use when showing the section unexpanded;
- longTemplate: template to use when showing the section expanded; usually
"templates/sections/viewSectionWithHtmlFormLong.page"
- templateModelUrl: this defines the URL used to load the model to back the templates; the "viewSectionWithHtmlFormLong" template requires this to be set in order to load the Html Form Entry representation of a form; you can usually copy the editUrl for an existing section, remembering to replace the definitionUriResource parameter with the URI to your form (in the same format as defined in the Load the New Forms on Startup section)
- editUrl: url for editing the form; you can copy the templateModelUrl for an existing section, remembering to replace the definitionUriResource parameter as described above; also note that you can chose the "editHtmlFormWithStandardUi" or "editHtmlFormWithSimpleUi" depending on whether you want to the standard or simple (one question per screen) interface
Next we need to create the component that defines which sections should appear within the Visit Template, and what order they should appear in. This can be done within encounterTypeConfig.js by adding a new element to the encouterTypeConfig object, mapped by uuid (which you should have set up as a constant when adding the EncounterType). An example can be found here. The parameters to specify are:
- defaultState: whether when opening a visit, whether this encounter should default be being expanded or unexpanded (usually unexpanded)
- shortTemplate: template to use to render the header of the Visit Template (usually the default encounter short template)
- longTemplate: the same as shortTemplate, as there is no overall expanded view, we just expand the individual sections
- icon: font-awesome icon to use for this Visit Template
- editUrl: URL used to edit the basic from (provider, date, location)... this usually is just the base standard edit url, defined earlier within encounterTypeConfig and called
hfeStandardEditUrl
. - showOnVisitList: true/false whether this encounter type will be listed (if present) in the "clinical notes" section of the expanded visit list (reached via the "Change Visit" -> "Full Details" link)
- sections: ordered list of all sections to appear within the template, referenced via the variables defined earlier in encounterTypeConfig (including those you defined in Defining the New Sections above)
TODO!