Kaynağa Gözat

added name and weight note templates

Josh 4 yıl önce
ebeveyn
işleme
9295db9ffd

+ 4 - 0
app/Http/Controllers/Controller.php

@@ -4,6 +4,7 @@ namespace App\Http\Controllers;
 
 use App\Models\AppSession;
 use App\Models\Note;
+use App\Models\NoteTemplate;
 use App\Models\Pro;
 use Illuminate\Foundation\Auth\Access\AuthorizesRequests;
 use Illuminate\Foundation\Bus\DispatchesJobs;
@@ -25,6 +26,9 @@ class Controller extends BaseController
         }
         view()->share('pros', Pro::all());
         view()->share('notes', Note::all());
+        
+        $noteTemplates = NoteTemplate::all();
+        view()->share('noteTemplates', $noteTemplates);
     }
 
     public function performer(){

+ 1 - 0
app/Http/Controllers/NoteController.php

@@ -78,6 +78,7 @@ class NoteController extends Controller
         $newSummaryHtml = ob_get_contents();
         ob_end_clean();
 
+       
         if($section){
             // call Java to update section
             $data = [

+ 1 - 0
app/Http/Controllers/PatientController.php

@@ -6,6 +6,7 @@ use App\Models\CareMonth;
 use App\Models\Client;
 use App\Models\ClientInfoLine;
 use App\Models\Facility;
+use App\Models\NoteTemplate;
 use App\Models\Pro;
 use App\Models\SectionTemplate;
 use Illuminate\Http\Request;

+ 10 - 0
app/Models/NoteTemplate.php

@@ -0,0 +1,10 @@
+<?php
+
+namespace App\Models;
+
+# use Illuminate\Database\Eloquent\Model;
+
+class NoteTemplate extends Model
+{
+    protected $table = 'note_template';
+}

+ 4 - 0
app/Models/Section.php

@@ -7,4 +7,8 @@ namespace App\Models;
 class Section extends Model
 {
     protected $table = 'section';
+
+    public function sectionTemplate() {
+        return $this->hasOne(SectionTemplate::class, 'id', 'section_template_id');
+    }
 }

+ 10 - 19
resources/views/app/patient/note/dashboard.blade.php

@@ -270,26 +270,17 @@
 
                 <div class="mb-3">
                     <div>
-                        <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' : '' }}>{!! $note->free_text_html !!}</div>
+                        @foreach($note->sections as $section) 
+                        <div class="p-2">
+                            <strong>{{$section->sectionTemplate->title}}</strong>
+                            <div>
+                                <h3>Summary</h3>
+                                @include('sections/'.$section->sectionTemplate->internal_name.'/summary')
+                                <h3>Edit form</h3>
+                                @include('sections/'.$section->sectionTemplate->internal_name.'/form')
+                            </div>
                         </div>
-                        {{--<div moe class="d-inline">
-                            <a show start><i class="fa fa-edit"></i></a>
-                            <form url="/api/note/putFreeTextHtml">
-                                <input type="hidden" name="uid" value="{{$note->uid}}">
-                                <div class="mb-2">
-                                    <textarea name="freeTextHtml" id="" cols="30" rows="5"
-                                              placeholder="Content"
-                                              class="memo-textarea form-control form-control-sm">{!! $note->free_text_html !!}</textarea>
-                                </div>
-                                <div class="mb-0">
-                                    <button class="btn btn-primary btn-sm" submit>Save</button>
-                                    <button class="btn btn-default border btn-sm" cancel>Cancel</button>
-                                </div>
-                            </form>
-                        </div>--}}
+                        @endforeach
                     </div>
                 </div>
 

+ 19 - 0
resources/views/layouts/patient.blade.php

@@ -330,6 +330,25 @@
                                     </div>
                                 </section>
                                 <section class=vbox>
+                                    <div moe>
+                                        <a href="" start> + note </a>
+                                        <form url="/api/note/createUsingTemplate" redir="/patients/view/{{$patient->uid}}/notes/view/[data]">
+                                            <input type="hidden" name="clientUid" value="{{$patient->uid}}">
+                                            <input type="hidden" name="hcpProUid" value="{{$pro->uid}}">
+                                            <div class="form-group">
+                                                <label for="" class="control-label">Note Template</label>
+                                                <select name="noteTemplateUid" class="form-control">
+                                                    <option value=""> --select-- </option>
+                                                    @foreach($noteTemplates as $noteTemplate)
+                                                    <option value="{{$noteTemplate->uid}}">{{$noteTemplate->title}}</option>
+                                                    @endforeach
+                                                </select>
+                                            </div>
+                                            <div class="form-group">
+                                                <button submit class="btn btn-primary btn-sm">submit</button>
+                                            </div>
+                                        </form>
+                                    </div>
                                     <button class="create-auto-note-trigger"
                                             data-patient-uid="{{ $patient->uid  }}"
                                             data-hcp-uid="{{ $pro->uid }}"

+ 34 - 0
resources/views/sections/name/form.blade.php

@@ -0,0 +1,34 @@
+<?php
+
+
+$contentData = json_decode($section->content_data, true);
+
+$firstName = isset($content_data['firstName']) ? $content_data['firstName'] : '';
+$lastName = isset($content_data['lastName']) ? $content_data['lastName'] : '';
+
+?>
+
+<div>
+
+    <div class="card">
+        <div class="card-body">
+            <form method="POST" action="/process_form_submit">
+                <input type="hidden" name="section_uid" value="<?= $section->uid ?>">
+                
+                <div class="form-group">
+                    <label for="">First Name</label>
+                    <input type="text" class="form-control" name="firstName" value="{{$firstName}}" placeholder="first name">
+                </div>
+
+                <div class="form-group">
+                    <label for="">Last Name</label>
+                    <input type="text" class="form-control" name="lastName" value="{{$lastName}}" placeholder="last name">
+                </div>
+                <div class="form-group">
+                    <button class="btn btn-primary">Submit</button>
+                </div>
+            </form>
+        </div>
+
+    </div>
+</div>

+ 12 - 0
resources/views/sections/name/summary.blade.php

@@ -0,0 +1,12 @@
+<?php 
+    $content_data = json_decode($section->content_data, true);
+
+    $firstName = isset($content_data['firstName'])?$content_data['firstName']:'';
+    $lastName = isset($content_data['lastName'])?$content_data['lastName']:'';
+
+?>
+
+<div>
+    <strong>First name: </strong> {{$firstName}} <br/>
+    <strong>Last name: </strong> {{$lastName}}
+</div>

+ 49 - 0
resources/views/sections/test2/form.blade.php

@@ -0,0 +1,49 @@
+<?php
+$contentData = [
+    'nickname'=>'',
+    'favoriteColor'=>''
+]; 
+if($section){
+    $contentData = json_decode($section->content_data, true);
+}
+
+$nickname = isset($contentData['nickname'])?$contentData['nickname']:'nickname is not set';
+$favoriteColor = isset($contentData['favoriteColor'])?$contentData['favoriteColor']:'favorite color is not set';
+?>
+
+
+
+<div>
+
+    <div class="card">
+        <div class="card-header">
+            <?php if(!$section):?>
+            <div class="alert alert-info">Create section</div>
+            <?php else: ?>
+            <div class="alert alert-info">Update section</div>
+            <?php endif; ?>
+        </div>
+        <div class="card-body">
+            <form method="POST" action="/process_form_submit" up-history="false">
+                <?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">
+                    <label for="">Nickname</label>
+                    <input type="text" class="form-control" name="nickname" value="<?= $nickname ?>" placeholder="nickname">
+                </div>
+                <div class="form-group">
+                    <label for="">Favorite color</label>
+                    <input type="text" class="form-control" name="favoriteColor" value="<?= $favoriteColor ?>" placeholder="Favorite color">
+                </div>
+                <div class="form-group">
+                    <button class="btn btn-primary">Submit</button>
+                </div>
+            </form>
+        </div>
+
+    </div>
+</div>

+ 4 - 0
resources/views/sections/test2/summary.blade.php

@@ -0,0 +1,4 @@
+<?php $content_data = json_decode($section->content_data, true) ?>
+<div  style="background-color:<?= isset($content_data['favoriteColor'])?$content_data['favoriteColor']:'not set'; ?>; ">
+    <h1>Nickname: <?= isset($content_data['nickname'])? $content_data['nickname'] : 'not set'; ?></h1>
+</div>

+ 40 - 0
resources/views/sections/weight/form.blade.php

@@ -0,0 +1,40 @@
+<?php
+
+
+$contentData = json_decode($section->content_data, true);
+
+$currentWeight = [];
+
+if(isset($contentData['currentWeight'])){
+    $currentWeight  = $contentData['currentWeight'];
+}
+
+$weight = isset($currentWeight['weight']) ? $currentWeight['weight'] : '';
+$effectiveDate = isset($currentWeight['effectiveDate']) ? $currentWeight['effectiveDate'] : '';
+
+?>
+
+<div>
+
+    <div class="card">
+        <div class="card-body">
+            <form method="POST" action="/process_form_submit">
+                <input type="hidden" name="section_uid" value="<?= $section->uid ?>">
+                
+                <div class="form-group">
+                    <label for="">Weight</label>
+                    <input type="text" class="form-control" name="weight" value="{{$weight}}" placeholder="weight">
+                </div>
+
+                <div class="form-group">
+                    <label for="">Effective Date</label>
+                    <input type="date" class="form-control" name="effectiveDate" value="{{$effectiveDate}}" placeholder="effective date">
+                </div>
+                <div class="form-group">
+                    <button class="btn btn-primary">Submit</button>
+                </div>
+            </form>
+        </div>
+
+    </div>
+</div>

+ 33 - 0
resources/views/sections/weight/summary.blade.php

@@ -0,0 +1,33 @@
+<?php
+$content_data = json_decode($section->content_data, true);
+
+$currentWeight = [];
+
+if (isset($content_data['currentWeight'])) {
+    $currentWeight  = $content_data['currentWeight'];
+}
+
+
+$weight = isset($currentWeight['weight']) ? $currentWeight['weight'] : '';
+$effectiveDate = isset($currentWeight['effectiveDate']) ? $currentWeight['effectiveDate'] : '';
+
+$weightLog = [];
+if(isset($content_data['weightLog'])){
+    $weightLog = $content_data['weightLog'];
+}
+
+?>
+
+<div>
+    <strong>Current weight: </strong> {{$weight}} <br/>
+    <strong>Effective date: </strong> {{$effectiveDate}}<br/>
+    <strong>Weight log</strong>
+    <table>
+    @foreach($weightLog as $weight)
+        <tr>
+            <td>{{$weight['effectiveDate']}}</td>
+            <td>{{$weight['weight']}}</td>
+        </tr>
+    @endforeach
+    </table>
+</div>

+ 17 - 0
storage/sections/name/processor.php

@@ -0,0 +1,17 @@
+<?php 
+
+/**
+ * Use this to generate newContentData
+ * $request 
+ * $note 
+ * $section 
+ */
+
+
+$firstName = $request->get('firstName');
+$lastName = $request->get('lastName');
+
+$newContentData = [
+    'firstName'=>$firstName,
+    'lastName'=>$lastName
+];

+ 12 - 0
storage/sections/name/summary.php

@@ -0,0 +1,12 @@
+<?php 
+    $content_data = json_decode($section->content_data, true);
+
+    $firstName = isset($content_data['firstName'])?$content_data['firstName']:'';
+    $lastName = isset($content_data['lastName'])?$content_data['lastName']:'';
+
+?>
+
+<div>
+    <strong>First name: </strong> {{$firstName}} <br/>
+    <strong>Last name: </strong> {{$lastName}}
+</div>

+ 43 - 0
storage/sections/test2/form.blade.php

@@ -0,0 +1,43 @@
+<?php
+$contentData = [
+    'nickname'=>'',
+    'favoriteColor'=>''
+]; 
+if($section){
+    $contentData = json_decode($section->content_data, true);
+}
+?>
+<div id="section_form">
+
+    <div class="card">
+        <div class="card-header">
+            <?php if(!$section):?>
+            <div class="alert alert-info">Create section</div>
+            <?php else: ?>
+            <div class="alert alert-info">Update section</div>
+            <?php endif; ?>
+        </div>
+        <div class="card-body">
+            <form method="POST" up-target="#note-container" action="/process_form_submit" up-history="false">
+                <?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">
+                    <label for="">Nickname</label>
+                    <input type="text" class="form-control" name="nickname" value="<?= $contentData['nickname'] ?>" placeholder="nickname">
+                </div>
+                <div class="form-group">
+                    <label for="">Favorite color</label>
+                    <input type="text" class="form-control" name="favoriteColor" value="<?= $contentData['favoriteColor'] ?>" placeholder="Favorite color">
+                </div>
+                <div class="form-group">
+                    <button class="btn btn-primary">Submit</button>
+                </div>
+            </form>
+        </div>
+
+    </div>
+</div>

+ 9 - 0
storage/sections/test2/processor.php

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

+ 3 - 0
storage/sections/test2/summary.php

@@ -0,0 +1,3 @@
+<div class="p-5" style="background-color:<?= $newContentData['favoriteColor']; ?>; ">
+    <h1><?= $newContentData['nickname']; ?></h1>
+</div>

+ 40 - 0
storage/sections/weight/processor.php

@@ -0,0 +1,40 @@
+<?php 
+
+/**
+ * Use this to generate newContentData
+ * $request 
+ * $note 
+ * $section 
+ */
+
+ $contentData = json_decode($section->content_data, true);
+
+ if(!isset($contentData['weights'])){
+     $contentData['weights'] = [];
+ }
+
+
+$weight = $request->get('weight');
+$effectiveDate = $request->get('effectiveDate');
+
+$currentWeight = [
+    'weight'=>$weight, 
+    'effectiveDate' => $effectiveDate
+];
+
+$weightLog = $contentData['weightLog'];
+$weightLog[] = $currentWeight;
+
+
+
+$newContentData = [
+    'currentWeight' => $currentWeight,
+    'weightLog' => $weightLog, 
+    'measurements' => [
+        [
+            'label'=> 'weight',
+            'value' => $weight, 
+            'effectiveDate' => $effectiveDate
+        ]
+    ]
+];

+ 33 - 0
storage/sections/weight/summary.php

@@ -0,0 +1,33 @@
+<?php
+$content_data = json_decode($section->content_data, true);
+
+$currentWeight = [];
+
+if (isset($content_data['currentWeight'])) {
+    $currentWeight  = $content_data['currentWeight'];
+}
+
+
+$weight = isset($currentWeight['weight']) ? $currentWeight['weight'] : '';
+$effectiveDate = isset($currentWeight['effectiveDate']) ? $currentWeight['effectiveDate'] : '';
+
+$weightLog = [];
+if(isset($content_data['weightLog'])){
+    $weightLog = $content_data['weightLog'];
+}
+
+?>
+
+<div>
+    <strong>Current weight: </strong> {{$weight}} <br/>
+    <strong>Effective date: </strong> {{$effectiveDate}}<br/>
+    <strong>Weight log</strong>
+    <table>
+    @foreach($weightLog as $weight)
+        <tr>
+            <td>{{$weight['effectiveDate']}}</td>
+            <td>{{$weight['weight']}}</td>
+        </tr>
+    @endforeach
+    </table>
+</div>