فهرست منبع

Rich notes [WIP]

Vijayakrishnan Krishnan 4 سال پیش
والد
کامیت
ebe77f7b1f

+ 4 - 4
app/Helpers/helpers.php

@@ -15,8 +15,8 @@ if(!function_exists('get_current_session')) {
 }
 
 if(!function_exists('friendly_date_time')) {
-    function friendly_date_time($value, $includeTime = true) {
-        if(!$value || empty($value)) return "-";
+    function friendly_date_time($value, $includeTime = true, $default = '-') {
+        if(!$value || empty($value)) return $default;
         try {
             $result = strtotime($value);
             $result = date("jS M o" . ($includeTime ? ", H:i" : ""), $result);
@@ -29,8 +29,8 @@ if(!function_exists('friendly_date_time')) {
 }
 
 if(!function_exists('friendly_time')) {
-    function friendly_time($value) {
-        if(!$value || empty($value)) return "-";
+    function friendly_time($value, $default = '-') {
+        if(!$value || empty($value)) return $default;
         try {
             $result = strtotime($value);
             $result = date("H:i", $result);

+ 9 - 2
app/Http/Controllers/NoteController.php

@@ -4,6 +4,7 @@ namespace App\Http\Controllers;
 
 use App\Models\Pro;
 use Illuminate\Http\Request;
+use Illuminate\Support\Collection;
 use Illuminate\Support\Facades\Http;
 
 use App\Models\Note;
@@ -16,7 +17,13 @@ class NoteController extends Controller
     public function dashboard(Request $request, Client $patient, Note $note )
     {
         $pros = Pro::all();
-        return view('app.patient.note.dashboard', compact('patient', 'note', 'pros'));
+        $noteSections = $note->sections;
+        $noteSectionTemplateIDs = [];
+        foreach ($noteSections as $noteSection) {
+            $noteSectionTemplateIDs[] = $noteSection->sectionTemplate->id;
+        }
+        $sections = SectionTemplate::whereNotIn('id', $noteSectionTemplateIDs)->get();
+        return view('app.patient.note.dashboard', compact('patient', 'note', 'pros', 'sections'));
     }
 
     public function renderNote($noteUid, Request $request)
@@ -78,7 +85,7 @@ class NoteController extends Controller
         $newSummaryHtml = ob_get_contents();
         ob_end_clean();
 
-       
+
         if($section){
             // call Java to update section
             $data = [

+ 10 - 0
public/css/style.css

@@ -244,3 +244,13 @@ body>nav.navbar {
     margin-left: -1.25rem;
     margin-right: -1.25rem;
 }
+
+.note-section:not(.edit) .if-not-edit {
+    display: block !important;
+}
+.note-section.edit .if-edit {
+    display: block !important;
+}
+.c-pointer {
+    cursor: pointer;
+}

+ 37 - 15
resources/views/app/patient/note/dashboard.blade.php

@@ -1,5 +1,6 @@
 <?php
 /** @var App\Models\Note $note */
+/** @var App\Models\Pro $pro */
 ?>
 @extends ('layouts.patient')
 
@@ -50,7 +51,7 @@
     </div>
 
     <div class="card mb-0 {{ $note->is_cancelled ? 'cancelled-item' : '' }}">
-        <div class="card-header d-flex align-items-start px-3 border-bottom-0">
+        <div class="card-header d-flex align-items-start px-3 py-2 border-bottom">
             <div class="pr-2">
                 {{$note->title}}
                 @if(!$note->is_signed_by_hcp)
@@ -72,7 +73,7 @@
             </div>
             <div class="px-2 border-left border-right">
                 <div class="d-flex">
-                    <span class="mr-2">{{friendly_date_time($note->effective_dateest, false)}}</span>
+                    <span class="mr-2">{{friendly_date_time($note->effective_dateest, false, '')}}</span>
                     @if(!$note->is_signed_by_hcp)
                     <span moe class="ml-auto">
                         <a href="" show start><i class="fa fa-calendar"></i></a>
@@ -91,7 +92,7 @@
                     @endif
                 </div>
                 <div class="d-flex">
-                    <span class="mr-2">{{friendly_time($note->effective_time)}}</span>
+                    <span class="mr-2">{{friendly_time($note->effective_time, '')}}</span>
                     @if(!$note->is_signed_by_hcp)
                     <span moe class="ml-auto">
                         <a href="" show start><i class="fa fa-clock"></i></a>
@@ -135,6 +136,28 @@
                     </div>
                     @endif
                 </div>
+                <div class="d-flex">
+                    <div moe>
+                        <a href="" show start>+ Add Section</a>
+                        <form url="/api/section/create">
+                            <input type="hidden" name="noteUid" value="{{$note->uid}}">
+                            <input type="hidden" name="summaryHtml" value="">
+                            <input type="hidden" name="contentData" value="">
+                            <div class="mb-2">
+                                <select name="sectionTemplateUid" class="form-control form-control-sm">
+                                    <option value="">-- Select Section --</option>
+                                    @foreach ($sections as $section)
+                                        <option value="{{$section->uid}}">{{$section->title}}</option>
+                                    @endforeach
+                                </select>
+                            </div>
+                            <div class="mb-0">
+                                <button class="btn btn-primary btn-sm" submit>Submit</button>
+                                <button class="btn btn-default border btn-sm" cancel>Cancel</button>
+                            </div>
+                        </form>
+                    </div>
+                </div>
             </div>
             <div class="ml-auto d-flex align-items-start">
                 <div class="pr-2">
@@ -173,7 +196,7 @@
                                     <input type="date" name="effectiveDate" class="form-control form-control-sm" value="{{date('Y-m-d')}}" required>
                                 </div>
                                 <div class="mb-2">
-                                    <select autofocus class="form-control" name="code" value="">
+                                    <select autofocus class="form-control" name="code">
                                         <option value="">-- Select Code --</option>
                                         <?php $noteRates = $pro->noteRates(); ?>
                                         @if($noteRates && count($noteRates))
@@ -235,22 +258,21 @@
                         }
                         $packed = implode("^^^", $packed);
                         ?>
-                        <div class="primary-form">
+                        {{--<div class="primary-form">
                             <div class="note-content {{ $note->is_cancelled ? 'cancelled' : '' }} {{ $note->is_signed_by_hcp ? 'readonly' : '' }}"
                                  data-note-uid="{{ $note->uid  }}"
                                  {{ !$note->is_cancelled && empty($note->free_text_html) ? 'auto-edit' : '' }}
                                  data-shortcuts="{{ $packed }}"
                             >{!! $note->free_text_html !!}</div>
-                        </div>
+                        </div>--}}
                         @foreach($note->sections as $section)
-                        <div class="p-2">
-                            <strong>{{$section->sectionTemplate->title}}</strong>
-                            <div>
-                                <h3>Summary</h3>
-                                {!! $section->summary_html !!}
-                                <h3>Edit form</h3>
-                                @include('sections/'.$section->sectionTemplate->internal_name.'/form')
-                            </div>
+                        <div class="p-3 border-bottom note-section">
+                            <a class="font-weight-bold text-primary mb-2 d-flex align-items-center c-pointer" onclick="return $(this).parent().toggleClass('edit')">
+                                {{$section->sectionTemplate->title}}
+                                <span class="d-none if-not-edit"><i class="fa fa-edit ml-2"></i></span>
+                            </a>
+                            <div class="d-none if-not-edit bg-light p-2 border">{!! !empty($section->summary_html) ? $section->summary_html : '-' !!}</div>
+                            <div class="d-none if-edit">@include('sections/'.$section->sectionTemplate->internal_name.'/form')</div>
                         </div>
                         @endforeach
                     </div>
@@ -345,7 +367,7 @@
                                     <input type="date" name="effectiveDate" class="form-control form-control-sm" value="{{date('Y-m-d')}}" required>
                                 </div>
                                 <div class="mb-2">
-                                    <select autofocus class="form-control" name="code" value="">
+                                    <select autofocus class="form-control" name="code">
                                         <option value="">-- Select Code --</option>
                                         <?php $noteRates = $pro->noteRates(); ?>
                                         @if($noteRates && count($noteRates))

+ 39 - 0
storage/sections/current-goals/form.blade.php

@@ -0,0 +1,39 @@
+<?php
+$contentData = false;
+if($section){
+    $contentData = json_decode($section->content_data, true);
+}
+if(!$contentData || !isset($contentData['value'])) {
+    $contentData = [
+        'value'=>''
+    ];
+}
+$formID = rand(0, 100000);
+?>
+<form method="POST" action="/process_form_submit" onsubmit="return submitForm_NoteSection_{{ $formID }}(this);">
+    <?php if($section): ?>
+        <input type="hidden" name="section_uid" value="<?= $section->uid?>">
+    <?php else: ?>
+        <input type="hidden" name="note_uid" value="<?= $note->uid?>">
+        <input type="hidden" name="section_template_uid" value="<?= $sectionTemplate->uid ?>">
+    <?php endif; ?>
+    <div class="form-group mb-2">
+        <textarea type="text" class="form-control form-control-sm p-2" name="value" placeholder="Value"><?= $contentData['value'] ?></textarea>
+    </div>
+    <div class="form-group m-0 d-flex">
+        <button class="btn btn-sm btn-primary mr-2">Submit</button>
+        <button class="btn btn-sm btn-default border" onclick="return cancelForm_NoteSection_{{ $formID }}(this)">Cancel</button>
+    </div>
+</form>
+<script>
+    function submitForm_NoteSection_{{ $formID }}(_form) {
+        $.post(_form.action, $(_form).serialize(), function(_data) {
+            fastReload();
+        });
+        return false;
+    }
+    function cancelForm_NoteSection_{{ $formID }}(_trigger) {
+        $(_trigger).closest('.note-section').toggleClass('edit');
+        return false;
+    }
+</script>

+ 4 - 0
storage/sections/current-goals/processor.php

@@ -0,0 +1,4 @@
+<?php
+$newContentData = [
+    'value' => $request->get('value')
+];

+ 1 - 0
storage/sections/current-goals/summary.php

@@ -0,0 +1 @@
+<div><?= $newContentData['value']; ?></div>

+ 39 - 0
storage/sections/psychhx/form.blade.php

@@ -0,0 +1,39 @@
+<?php
+$contentData = false;
+if($section){
+    $contentData = json_decode($section->content_data, true);
+}
+if(!$contentData || !isset($contentData['value'])) {
+    $contentData = [
+        'value'=>''
+    ];
+}
+$formID = rand(0, 100000);
+?>
+<form method="POST" action="/process_form_submit" onsubmit="return submitForm_NoteSection_{{ $formID }}(this);">
+    <?php if($section): ?>
+        <input type="hidden" name="section_uid" value="<?= $section->uid?>">
+    <?php else: ?>
+        <input type="hidden" name="note_uid" value="<?= $note->uid?>">
+        <input type="hidden" name="section_template_uid" value="<?= $sectionTemplate->uid ?>">
+    <?php endif; ?>
+    <div class="form-group mb-2">
+        <textarea type="text" class="form-control form-control-sm p-2" name="value" placeholder="Value"><?= $contentData['value'] ?></textarea>
+    </div>
+    <div class="form-group m-0 d-flex">
+        <button class="btn btn-sm btn-primary mr-2">Submit</button>
+        <button class="btn btn-sm btn-default border" onclick="return cancelForm_NoteSection_{{ $formID }}(this)">Cancel</button>
+    </div>
+</form>
+<script>
+    function submitForm_NoteSection_{{ $formID }}(_form) {
+        $.post(_form.action, $(_form).serialize(), function(_data) {
+            fastReload();
+        });
+        return false;
+    }
+    function cancelForm_NoteSection_{{ $formID }}(_trigger) {
+        $(_trigger).closest('.note-section').toggleClass('edit');
+        return false;
+    }
+</script>

+ 4 - 0
storage/sections/psychhx/processor.php

@@ -0,0 +1,4 @@
+<?php
+$newContentData = [
+    'value' => $request->get('value')
+];

+ 1 - 0
storage/sections/psychhx/summary.php

@@ -0,0 +1 @@
+<div><?= $newContentData['value']; ?></div>

+ 39 - 0
storage/sections/subjective/form.blade.php

@@ -0,0 +1,39 @@
+<?php
+$contentData = false;
+if($section){
+    $contentData = json_decode($section->content_data, true);
+}
+if(!$contentData || !isset($contentData['value'])) {
+    $contentData = [
+        'value'=>''
+    ];
+}
+$formID = rand(0, 100000);
+?>
+<form method="POST" action="/process_form_submit" onsubmit="return submitForm_NoteSection_{{ $formID }}(this);">
+    <?php if($section): ?>
+        <input type="hidden" name="section_uid" value="<?= $section->uid?>">
+    <?php else: ?>
+        <input type="hidden" name="note_uid" value="<?= $note->uid?>">
+        <input type="hidden" name="section_template_uid" value="<?= $sectionTemplate->uid ?>">
+    <?php endif; ?>
+    <div class="form-group mb-2">
+        <textarea type="text" class="form-control form-control-sm p-2" name="value" placeholder="Value"><?= $contentData['value'] ?></textarea>
+    </div>
+    <div class="form-group m-0 d-flex">
+        <button class="btn btn-sm btn-primary mr-2">Submit</button>
+        <button class="btn btn-sm btn-default border" onclick="return cancelForm_NoteSection_{{ $formID }}(this)">Cancel</button>
+    </div>
+</form>
+<script>
+    function submitForm_NoteSection_{{ $formID }}(_form) {
+        $.post(_form.action, $(_form).serialize(), function(_data) {
+            fastReload();
+        });
+        return false;
+    }
+    function cancelForm_NoteSection_{{ $formID }}(_trigger) {
+        $(_trigger).closest('.note-section').toggleClass('edit');
+        return false;
+    }
+</script>

+ 4 - 0
storage/sections/subjective/processor.php

@@ -0,0 +1,4 @@
+<?php
+$newContentData = [
+    'value' => $request->get('value')
+];

+ 1 - 0
storage/sections/subjective/summary.php

@@ -0,0 +1 @@
+<div><?= $newContentData['value']; ?></div>