Using ChatGPT To WYSIWYG HTML Editor

Used chatgpt to edit the code files of open emr abd add WYSIWYG HTML Editor.
So far so good.
Just the save submit button link is not working. Maybe @Param_CapMinds or any developer can help fix this, we can make some good changes to Open EMR. :slight_smile:


below is the report.php file which chatgpt edited from clinical_notes.


<?php

// Include CKEditor JavaScript and CSS files

?>

<script src="https://cdn.ckeditor.com/4.16.2/standard/ckeditor.js"></script>

<link rel="stylesheet" href="https://cdn.ckeditor.com/4.16.2/standard/ckeditor.css">

<?php

// Display a textarea element for the narrative field

?>

<form method="post" action=""> <!-- Assuming save_notes.php is the file handling the save operation -->

    <textarea name="narrative" id="narrative"></textarea>

    <button type="submit">Save Note</button>

</form>

<?php

// Initialize CKEditor on the textarea element

?>

<script>

    CKEDITOR.replace('narrative');

</script>

<?php

use OpenEMR\Services\ClinicalNotesService;

require_once(__DIR__ . "/../../globals.php");

require_once($GLOBALS["srcdir"] . "/api.inc.php");

function clinical_notes_report($pid, $encounter, $cols, $id) {

    $count = 0;

    $clinicalNotesService = new ClinicalNotesService();

    $records = $clinicalNotesService->getClinicalNotesForPatientForm($id, $pid, $encounter) ?? [];

    $data = array_filter($records, function ($val) {

        return $val['activity'] == ClinicalNotesService::ACTIVITY_ACTIVE;

    });

    if (!empty($data)) { // Check if $data is not empty before proceeding

        ?>

        <table class="table w-100">

            <thead>

            <tr>

                <th class="border p-1"><?php echo xlt('Date / Note Type'); ?></th>

                <th class="border p-1"><?php echo xlt('Narrative'); ?></th>

                <th class="border p-1"><?php echo xlt('Author / Code'); ?></th>

                <th class="border p-1"><?php echo xlt('Note Category'); ?></th>

            </tr>

            </thead>

            <tbody>

            <?php

            foreach ($data as $key => $value) {

                if(isset($value['description']) && $value['description'] != ''){

                    $value['description'] = str_replace("\n", "<br>", $value['description']);

                }

                ?>

                <tr>

                    <td class="border p-1"><span class='text'><?php echo text($value['date']) . ' / ' . text($value['codetext']); ?></span></td>

                    <td class="border p-1"><span class='text'><?php echo $value['description']; ?></span></td>

                    <td class="border p-1"><span class='text'><?php echo text($value['user']) . ' / ' . text($value['code']); ?></span></td>

                    <td class="border p-1"><span class='text text-wrap'><?php echo text($value['category_title']); ?></span></td>

                </tr>

            <?php

            }

            ?>

            </tbody>

        </table>

    <?php

    }

}

?>
2 Likes

Hi, sorry to bring up an old thread, but I am brand new to openemr and was looking for a simple way to just to have rich text note fields. I’ve read and tested nationnotes, but is there a simple way I can create something like this - a basic rich text note or a simple way to just pull in a ckeditor field when creating a note? Don’t need the complexit and extra clicks of nation notes. Thanks!

In encounters any text area input can use text NN by dblclicking inside the text.
It is the text version of NN but the Rich text is there w/o templates.
I may develop a stripped down version of my secure messaging notes editor to offer app wide.
I’d be a nice addition.
We also have Office Notes that could be modified.

Thanks! I think an option like the OP would make alot of sence to pull in ckeditor or at least have the option create a basic note with rich text options. Even the quick reply to this message on the forum has a rich text option. going back to OP’s post - would that type of edit even work? I’d assume there is more backend processing required that to just plop in the rich text editor.

Column 1 Column 2 Column 3 Column 4
Tables are important
1 Like

It wouldn’t be to hard. I may look into this before next patch or just after.

1 Like

Waiting eagerly Jerry.
Pl add the ck editor for clinical notes.
Will be much appreciated. :slight_smile:

Robert,
I don’t understand. I offer an editor in Clinical Notes. I’d only need to expand the toolbar to include more options. Plus editor offers list of problems and medications ready for insert in note.
To activate just dblclick in note. Also ensure feature is turned on in Config.
Btw: This is needed for ONC

BTW Nation Notes uses CKEditor.

I’m assuming the desire is to avoid having to double click the textbox in order to get to a rich text editor entry.

Clinical notes can have rich text editing with double clicking but I’m assuming the desire is to have it all inline.

2 Likes

Exactly! Thanks for taking a look at it - the OP had a good mock up of it in the thread. Thanks!