feat: add Create Rx-Group button and modal on consult page
- added '+ Rx-Group' button beside Rx Group selector in medicine panel - added rxGroupCreateModal with Name/Complaints/Diagnosis/Investigation/Finding fields - pre-fills Complaints and Diagnosis from current consult textarea values - Save: creates group and refreshes catalog (group appears in selector) - Save & Apply: creates group and immediately applies it to current session - error shown inline in modal, catalog reloads after successful create
This commit is contained in:
parent
e167704aed
commit
2ae23c0284
|
|
@ -747,6 +747,7 @@
|
|||
<div class="row g-2 mb-2">
|
||||
<div class="col-md-8 d-flex align-items-center gap-2">
|
||||
<button type="button" class="btn btn-outline-secondary btn-sm" id="btn_open_rx_group_modal">Rx Group</button>
|
||||
<button type="button" class="btn btn-outline-success btn-sm" id="btn_create_rx_group_modal" title="Create new Rx-Group">+ Rx-Group</button>
|
||||
<span class="small text-muted" id="rx_group_selected_name">No Rx-Group selected</span>
|
||||
</div>
|
||||
<div class="col-md-4 text-md-end small text-muted">
|
||||
|
|
@ -952,6 +953,46 @@
|
|||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Create Rx-Group Modal -->
|
||||
<div class="modal fade" id="rxGroupCreateModal" tabindex="-1" aria-hidden="true">
|
||||
<div class="modal-dialog modal-md">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h5 class="modal-title">Create Rx-Group</h5>
|
||||
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<div class="mb-2">
|
||||
<label class="form-label fw-semibold">Rx-Group Name <span class="text-danger">*</span></label>
|
||||
<input type="text" class="form-control form-control-sm" id="crgc_name" maxlength="150" placeholder="e.g. Fever Basic">
|
||||
</div>
|
||||
<div class="mb-2">
|
||||
<label class="form-label">Complaints</label>
|
||||
<input type="text" class="form-control form-control-sm" id="crgc_complaints" maxlength="1000">
|
||||
</div>
|
||||
<div class="mb-2">
|
||||
<label class="form-label">Diagnosis</label>
|
||||
<input type="text" class="form-control form-control-sm" id="crgc_diagnosis" maxlength="1000">
|
||||
</div>
|
||||
<div class="mb-2">
|
||||
<label class="form-label">Investigation</label>
|
||||
<input type="text" class="form-control form-control-sm" id="crgc_investigation" maxlength="1000">
|
||||
</div>
|
||||
<div class="mb-2">
|
||||
<label class="form-label">Finding Examinations</label>
|
||||
<input type="text" class="form-control form-control-sm" id="crgc_finding" maxlength="1000">
|
||||
</div>
|
||||
<div class="small text-danger" id="crgc_msg" style="display:none;"></div>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-secondary btn-sm" data-bs-dismiss="modal">Cancel</button>
|
||||
<button type="button" class="btn btn-primary btn-sm" id="btn_crgc_save">Save Rx-Group</button>
|
||||
<button type="button" class="btn btn-success btn-sm" id="btn_crgc_save_apply">Save & Apply</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<script>
|
||||
|
|
@ -4196,6 +4237,77 @@
|
|||
} catch (e) {}
|
||||
});
|
||||
|
||||
// ---- Create Rx-Group from consult page ----
|
||||
function openCreateRxGroupModal() {
|
||||
// Pre-fill from current consult fields if available
|
||||
var complaints = ($('#complaints').val() || '').trim();
|
||||
var diagnosis = ($('#diagnosis').val() || '').trim();
|
||||
$('#crgc_name').val('');
|
||||
$('#crgc_complaints').val(complaints);
|
||||
$('#crgc_diagnosis').val(diagnosis);
|
||||
$('#crgc_investigation').val('');
|
||||
$('#crgc_finding').val('');
|
||||
$('#crgc_msg').hide().text('');
|
||||
try {
|
||||
bootstrap.Modal.getOrCreateInstance(document.getElementById('rxGroupCreateModal')).show();
|
||||
} catch (e) {}
|
||||
}
|
||||
|
||||
function saveCreateRxGroup(andApply) {
|
||||
var name = ($('#crgc_name').val() || '').trim();
|
||||
if (!name) {
|
||||
$('#crgc_msg').text('Rx-Group Name is required.').show();
|
||||
return;
|
||||
}
|
||||
$('#crgc_msg').hide();
|
||||
$('#btn_crgc_save,#btn_crgc_save_apply').prop('disabled', true);
|
||||
|
||||
var payload = {
|
||||
id: 0,
|
||||
rx_group_name: name,
|
||||
complaints: ($('#crgc_complaints').val() || '').trim(),
|
||||
diagnosis: ($('#crgc_diagnosis').val() || '').trim(),
|
||||
investigation: ($('#crgc_investigation').val() || '').trim(),
|
||||
finding_examinations: ($('#crgc_finding').val() || '').trim()
|
||||
};
|
||||
|
||||
apiPost('<?= base_url('Opd_prescription/rx_group_save') ?>', payload, function(data) {
|
||||
$('#btn_crgc_save,#btn_crgc_save_apply').prop('disabled', false);
|
||||
if (parseInt(data.update || '0', 10) !== 1) {
|
||||
$('#crgc_msg').text(data.error_text || 'Unable to save Rx-Group.').show();
|
||||
return;
|
||||
}
|
||||
var newId = parseInt(data.insertid || '0', 10);
|
||||
var newName = name;
|
||||
|
||||
// Refresh catalog cache so new group appears in selector
|
||||
loadRxGroupCatalog();
|
||||
|
||||
// Close modal
|
||||
try {
|
||||
bootstrap.Modal.getInstance(document.getElementById('rxGroupCreateModal')).hide();
|
||||
} catch (e) {}
|
||||
|
||||
$('.jsError').removeClass('text-danger text-muted').addClass('text-success').text('Rx-Group "' + newName + '" created.');
|
||||
|
||||
if (andApply && newId > 0) {
|
||||
applyRxGroupToSession(newId, newName);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
$('#btn_create_rx_group_modal').on('click', function() {
|
||||
openCreateRxGroupModal();
|
||||
});
|
||||
|
||||
$('#btn_crgc_save').on('click', function() {
|
||||
saveCreateRxGroup(false);
|
||||
});
|
||||
|
||||
$('#btn_crgc_save_apply').on('click', function() {
|
||||
saveCreateRxGroup(true);
|
||||
});
|
||||
|
||||
$('#rx_group_search').on('input', function() {
|
||||
renderRxGroupModal(rxGroupCache);
|
||||
});
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user