Forráskód Böngészése

Merge branch 'dev' into dev-vj

Vijayakrishnan Krishnan 4 éve
szülő
commit
c14154a882

+ 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;

+ 1 - 1
app/Models/Note.php

@@ -30,6 +30,6 @@ class Note extends Model
 
     public function sections()
     {
-        return $this->hasMany(Section::class, 'note_id', 'id');
+        return $this->hasMany(Section::class, 'note_id', 'id')->orderBy('position_index', 'asc');
     }
 }

+ 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');
+    }
 }

+ 1 - 0
config/view.php

@@ -14,6 +14,7 @@ return [
     */
 
     'paths' => [
+        storage_path(), //TODO: research if there are security risks.
         resource_path('views'),
     ],
 

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

@@ -285,21 +285,17 @@
                                  data-shortcuts="{{ $packed }}"
                             >{!! $note->free_text_html !!}</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>--}}
+                        @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>
+                        @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
storage/sections/name/form.blade.php

@@ -0,0 +1,34 @@
+<?php
+
+
+$contentData = json_decode($section->content_data, true);
+
+$firstName = isset($contentData['firstName']) ? $contentData['firstName'] : '';
+$lastName = isset($contentData['lastName']) ? $contentData['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>

+ 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/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>

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

@@ -0,0 +1,46 @@
+<?php 
+
+/**
+ * Use this to generate newContentData
+ * $request 
+ * $note 
+ * $section 
+ */
+
+ $contentData = json_decode($section->content_data, true);
+
+ if(!isset($contentData['weights'])){
+     $contentData['weightLog'] = [];
+ }
+
+
+$weight = $request->get('weight');
+$effectiveDate = $request->get('effectiveDate');
+
+$currentWeight = [
+    'weight'=>$weight, 
+    'effectiveDate' => $effectiveDate
+];
+
+
+$weightLog = [];
+
+if(isset($contentData['weightLog'])){
+    $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>
+    <?php foreach($weightLog as $weight): ?>
+        <tr>
+            <td><?= $weight['effectiveDate'] ?></td>
+            <td><?= $weight['weight'] ?></td>
+        </tr>
+    <?php endforeach; ?>
+    </table>
+</div>