From 4ea24afdba4eb52e3f5f1bad0bd05c40027b2c4d Mon Sep 17 00:00:00 2001 From: Cosmin Date: Fri, 31 May 2024 10:31:00 -0400 Subject: [PATCH] RA-2037: use mother's info to register a child --- .../page/controller/RegisterPatientPageController.java | 6 ++++-- .../webapp/fragments/field/registerPersonRelationship.gsp | 2 +- omod/src/main/webapp/pages/registerPatient.gsp | 8 ++++++++ 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/omod/src/main/java/org/openmrs/module/registrationapp/page/controller/RegisterPatientPageController.java b/omod/src/main/java/org/openmrs/module/registrationapp/page/controller/RegisterPatientPageController.java index 6e607caa..ed417dd0 100644 --- a/omod/src/main/java/org/openmrs/module/registrationapp/page/controller/RegisterPatientPageController.java +++ b/omod/src/main/java/org/openmrs/module/registrationapp/page/controller/RegisterPatientPageController.java @@ -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()); @@ -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 includeFragments = appFrameworkService.getExtensionsForCurrentUser("registerPatient.includeFragments"); diff --git a/omod/src/main/webapp/fragments/field/registerPersonRelationship.gsp b/omod/src/main/webapp/fragments/field/registerPersonRelationship.gsp index 2be3fff3..0e5a66b7 100644 --- a/omod/src/main/webapp/fragments/field/registerPersonRelationship.gsp +++ b/omod/src/main/webapp/fragments/field/registerPersonRelationship.gsp @@ -18,7 +18,7 @@ ${ config.label } <% if (config.classes && config.classes.join(' ').contains("required")) { %>(${ ui.message("emr.formValidation.messages.requiredField.label") })<% } %> - + <% if ( multipleValues ) { %> diff --git a/omod/src/main/webapp/pages/registerPatient.gsp b/omod/src/main/webapp/pages/registerPatient.gsp index 673058c1..0a37c9d5 100644 --- a/omod/src/main/webapp/pages/registerPatient.gsp +++ b/omod/src/main/webapp/pages/registerPatient.gsp @@ -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); + } } }); } @@ -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') {