Skip to content

Commit

Permalink
RA-2037: use mother's info to register a child
Browse files Browse the repository at this point in the history
  • Loading branch information
cioan committed May 31, 2024
1 parent 83855c1 commit 4ea24af
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,16 +30,17 @@ public void get(UiSessionContext sessionContext, PageModel model,
@RequestParam("appId") AppDescriptor app,
@RequestParam(value = "breadcrumbOverride", required = false) String breadcrumbOverride,
@RequestParam(value = "initialValues", required = false) String initialValues,
@RequestParam(value = "mother", required = false) Patient mother,
@ModelAttribute("patient") @BindParams Patient patient,
@SpringBean("emrApiProperties") EmrApiProperties emrApiProperties,
@SpringBean("appFrameworkService") AppFrameworkService appFrameworkService,
UiUtils ui) throws Exception {

sessionContext.requireAuthentication();
addModelAttributes(model, patient, app, emrApiProperties.getPrimaryIdentifierType(), breadcrumbOverride, initialValues, appFrameworkService, sessionContext);
addModelAttributes(model, patient, app, emrApiProperties.getPrimaryIdentifierType(), breadcrumbOverride, initialValues, mother,appFrameworkService, sessionContext);
}

public void addModelAttributes(PageModel model, Patient patient, AppDescriptor app, PatientIdentifierType primaryIdentifierType, String breadcrumbOverride, String initialValues, AppFrameworkService appFrameworkService, UiSessionContext sessionContext) throws Exception {
public void addModelAttributes(PageModel model, Patient patient, AppDescriptor app, PatientIdentifierType primaryIdentifierType, String breadcrumbOverride, String initialValues, Patient mother, AppFrameworkService appFrameworkService, UiSessionContext sessionContext) throws Exception {
NavigableFormStructure formStructure = RegisterPatientFormBuilder.buildFormStructure(app, app.getConfig().get("combineSections") != null ? app.getConfig().get("combineSections").getBooleanValue() : false,
appFrameworkService, sessionContext.generateAppContextModel());

Expand Down Expand Up @@ -69,6 +70,7 @@ public void addModelAttributes(PageModel model, Patient patient, AppDescriptor a
Context.getAdministrationService().getGlobalProperty("addresshierarchy.enableOverrideOfAddressPortlet", "false"));
model.addAttribute("breadcrumbOverride", breadcrumbOverride);
model.addAttribute("initialFieldValues", initialValues);
model.addAttribute("mother", mother);
model.addAttribute("relationshipTypes", Context.getPersonService().getAllRelationshipTypes());

List<Extension> includeFragments = appFrameworkService.getExtensionsForCurrentUser("registerPatient.includeFragments");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
${ config.label } <% if (config.classes && config.classes.join(' ').contains("required")) { %><span>(${ ui.message("emr.formValidation.messages.requiredField.label") })</span><% } %>
</label>

<input type="text" id="${ config.id }-field" class="searchablePerson" size="40" placeholder="${ui.message(ui.encodeHtmlAttribute('registrationapp.person.name'))}"/>
<input type="text" id="${ config.id }-field" name="${ config.id }-field" class="searchablePerson" size="40" placeholder="${ui.message(ui.encodeHtmlAttribute('registrationapp.person.name'))}"/>
<input type="hidden" name="other_person_uuid" id="${ config.id }-other_person_uuid"/>
<input type="hidden" name="other_person_name" id="${ config.id }-other_person_name"/>
<% if ( multipleValues ) { %>
Expand Down
8 changes: 8 additions & 0 deletions omod/src/main/webapp/pages/registerPatient.gsp
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,10 @@ fieldset[id\$="-fieldset"] div > div {
if (NavigatorController.getQuestionById(questionName) != undefined) {
NavigatorController.getQuestionById(questionName).questionLi.addClass("done");
}
if (fieldName == 'mother-field') {
// otherwise the field's change() event that gets trigger automatically would clear the initial values which we just set above
jq('#mother-field').autocomplete("option", "disabled", true);
}
}
});
}
Expand Down Expand Up @@ -385,6 +389,10 @@ fieldset[id\$="-fieldset"] div > div {
if (field.type == 'personAddress') {
configOptions.addressTemplate = addressTemplate
// if a mother has been specified for this patient, then use the mother's address
if ( question.id == 'personAddressQuestion' && mother) {
configOptions.initialValue = mother.personAddress
}
}
if (field.type == 'personRelationships') {
Expand Down

0 comments on commit 4ea24af

Please sign in to comment.