Skip to content

Commit

Permalink
UHM-7475, display all selected relationships (#130)
Browse files Browse the repository at this point in the history
  • Loading branch information
cioan committed Oct 25, 2023
1 parent d779b28 commit 80ba211
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@

<div id="${ config.id }-container">
<div id="${ config.id }-fields-div">
<p>
<input type="hidden" id="${ config.id }-selected_persons" name="selected_persons" data-display-value=""/>
</p>
<p>
<input type="hidden" id="${ config.id }-relationship_type" name="relationship_type" class="rel_type" value="" data-display-value="-"/>
</p>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,22 @@
function RegisterPatientRelationship(patientRelationship) {

let selectedPersons = [];

function updatePersonNames() {
let confirmNames = '';
for (const [key, value] of Object.entries(selectedPersons)) {
if (value && value.length > 0) {
if (confirmNames.length > 0) {
confirmNames = confirmNames + "; " + value;
} else {
confirmNames = value;
}
}
}
if (confirmNames.length > 0 ) {
$('#' + patientRelationship.id + "-selected_persons").attr('data-display-value', confirmNames);
}
}
function getInputElementFor(fieldId) {
// this is to handle integration with HFE, when the id is set on the parent span,
// not the input element itself
Expand Down Expand Up @@ -73,13 +90,18 @@ function RegisterPatientRelationship(patientRelationship) {
+ '</p>'
+ '</div>').insertBefore('#' + patientRelationship.id + '-fields-div');

$(".removeRelationship").click(function() {
$(".removeRelationship").click(function(event) {
event.stopImmediatePropagation();
$(this).closest('div').remove();
delete selectedPersons[otherPersonUuid];
updatePersonNames();
});

setValue(patientRelationship.id + "-relationship_type", '');
setValue(patientRelationship.id + "-field", '');
setValue(patientRelationship.id + "-other_person_uuid", '');
selectedPersons[otherPersonUuid] = otherPersonName;
updatePersonNames();
}
});

Expand Down

0 comments on commit 80ba211

Please sign in to comment.