Skip to content

Commit

Permalink
New Document Template radio group plug ins (openemr#7837)
Browse files Browse the repository at this point in the history
add radio groups for stacked and inline
  • Loading branch information
sjpadgett authored Nov 21, 2024
1 parent ccaa709 commit 96230d2
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 1 deletion.
2 changes: 1 addition & 1 deletion portal/import_template.php
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,7 @@ function renderEditorHtml($template_id, $content)
global $authUploadTemplates;

$lists = [
'{ParseAsHTML}', '{ParseAsText}', '{styleBlockStart}', '{styleBlockEnd}', '{SignaturesRequired}', '{TextInput}', '{sizedTextInput:120px}', '{smTextInput}', '{TextBox:03x080}', '{CheckMark}', '{ynRadioGroup}', '{TrueFalseRadioGroup}', '{DatePicker}', '{DateTimePicker}', '{StandardDatePicker}', '{CurrentDate:"global"}', '{CurrentTime}', '{DOS}', '{ReferringDOC}', '{PatientID}', '{PatientName}', '{PatientSex}', '{PatientDOB}', '{PatientPhone}', '{Address}', '{City}', '{State}', '{Zip}', '{PatientSignature}', '{AdminSignature}', '{WitnessSignature}', '{AcknowledgePdf:pdf name or id:title}', '{EncounterForm:LBF}', '{Questionnaire:name or id}', '{Medications}', '{ProblemList}', '{Allergies}', '{ChiefComplaint}', '{DEM: }', '{HIS: }', '{LBF: }', '{GRP}{/GRP}'
'{ParseAsHTML}', '{ParseAsText}', '{styleBlockStart}', '{styleBlockEnd}', '{SignaturesRequired}', '{TextInput}', '{sizedTextInput:120px}', '{smTextInput}', '{TextBox:03x080}', '{CheckMark}', '{RadioGroup:option1_many...}', '{RadioGroupInline:option1_many...}', '{ynRadioGroup}', '{TrueFalseRadioGroup}', '{DatePicker}', '{DateTimePicker}', '{StandardDatePicker}', '{CurrentDate:"global"}', '{CurrentTime}', '{DOS}', '{ReferringDOC}', '{PatientID}', '{PatientName}', '{PatientSex}', '{PatientDOB}', '{PatientPhone}', '{Address}', '{City}', '{State}', '{Zip}', '{PatientSignature}', '{AdminSignature}', '{WitnessSignature}', '{AcknowledgePdf:pdf name or id:title}', '{EncounterForm:LBF}', '{Questionnaire:name or id}', '{Medications}', '{ProblemList}', '{Allergies}', '{ChiefComplaint}', '{DEM: }', '{HIS: }', '{LBF: }', '{GRP}{/GRP}'
];
?>
<!DOCTYPE html>
Expand Down
6 changes: 6 additions & 0 deletions portal/patient/templates/OnsiteDocumentListView.tpl.php
Original file line number Diff line number Diff line change
Expand Up @@ -458,6 +458,12 @@ function formReplaceRadioValues() {
let rv = $('input:radio[name="' + jsAttr(name) + '"]:checked').val();
$(this).replaceWith(rv);
});

$('.fcuGroup').each(function () {
let name = $(this).prop('id');
let rv = $('input:radio[name="' + jsAttr(name) + '"]:checked').val();
$(this).replaceWith(rv);
});
}

function formReplaceTextInputs() {
Expand Down
32 changes: 32 additions & 0 deletions src/Services/DocumentTemplates/DocumentTemplateRender.php
Original file line number Diff line number Diff line change
Expand Up @@ -305,6 +305,38 @@ private function doSubs($s, $formData): mixed
'</label>';
$sigfld .= '</span>';
$s = $this->keyReplace($s, $sigfld);
} elseif (preg_match('/^\{(RadioGroup):([\w\s]+)\}/', substr($s, $this->keyLocation), $matches)) {
// matches {RadioGroup:caption1_caption2_caption3}
$this->keyLength = 3 + strlen($matches[1]) + strlen($matches[2]);
$matchesArr = explode('_', $matches[2]);
$this->grp_cnt++;
$radioCount = -1;
$sigfld = '<div class="fcuGroup mx-1" id="group_radio' . $this->grp_cnt . '">';
foreach ($matchesArr as $buttonCaption) {
$radioCount++;
$checked = ($formData['group_radio' . $this->grp_cnt] ?? '') == attr($buttonCaption) ? "checked" : '';
$sigfld .= '<div class="form-check mb-2">' . '<label class="form-check-label" for="group_radio' . $this->grp_cnt . '_' . $radioCount . '">' .
'<input class="groupRadio form-check-input" type="radio" ' . $checked . ' name="group_radio' . $this->grp_cnt . '" value="' . attr($buttonCaption) . '" id="group_radio' . $this->grp_cnt . '_' . $radioCount . '" />' .
xlt($buttonCaption) . '</label>' . '</div>';
}
$sigfld .= '</div>';
$s = $this->keyReplace($s, $sigfld);
} elseif (preg_match('/^\{(RadioGroupInline):([\w\s]+)\}/', substr($s, $this->keyLocation), $matches)) {
// matches {RadioGroupInline:caption1_caption2_caption3}
$this->keyLength = 3 + strlen($matches[1]) + strlen($matches[2]);
$matchesArr = explode('_', $matches[2]);
$this->grp_cnt++;
$radioCount = -1;
$sigfld = '<span class="fcuGroup d-inline-flex align-items-center mx-1" id="inline_radio' . $this->grp_cnt . '">';
foreach ($matchesArr as $buttonCaption) {
$radioCount++;
$checked = ($formData['inline_radio' . $this->grp_cnt] ?? '') == attr($buttonCaption) ? "checked" : '';
$sigfld .= '<label class="mr-2 d-inline-flex align-items-center">' .
'<input class="inline_radio mr-1" type="radio" ' . $checked . ' name="inline_radio' . $this->grp_cnt . '" value="' . attr($buttonCaption) . '" />' . xlt($buttonCaption) .
'</label>';
}
$sigfld .= '</span>';
$s = $this->keyReplace($s, $sigfld);
} elseif ($this->keySearch($s, '{PatientName}')) {
$tmp = $this->ptrow['fname'];
if ($this->ptrow['mname']) {
Expand Down

0 comments on commit 96230d2

Please sign in to comment.