浏览代码

Pych Intake form

Samson Mutunga 3 年之前
父节点
当前提交
22cdb2a303

+ 98 - 27
resources/views/app/patient/segment-templates/psych_intake_current_mental-status/edit.blade.php

@@ -223,22 +223,44 @@ $displayColumns = [
 
 $point = App\Models\Point::getOrCreateOnlyTopLevelPointOfCategory($note, 'PSYCH_INTAKE_CURRENT_MENTAL_STATUS', $sessionKey, true);
 $contentData = [
-    
+    'orientation' => null,
+	'generalAppearance' => null,
+	'dressInput' => null,
+	'motorActivity' => null,
+	'interviewBehavior' => null,
+	'speech' => null,
+	'mood' => null,
+	'affect' => null,
+	'insight' => null,
+	'judgment' => null,
+	'memory' => null,
+	'attentionConcentration' => null,
+	'thoughtProcess' => null,
+	'thoughtContent' => null,
+	'perception' => null,
+	'functionalStatus' => null,
 ];
 if ($point->lastChildReview && $point->lastChildReview->data) {
     $point->lastChildReview->data = json_decode($point->lastChildReview->data, true);
     $contentData = $point->lastChildReview->data;
 }
+$submitFormUrl = "/api/visitPoint/upsertChildReview";
 ?>
 
-<div visit-moe no-auto-save close-on-save close-on-cancel class="d-block p-3" id="psych-intake-current-mental-status-{{$note->id}}">
-    <form show url="/api/visitPoint/upsertChildReview" class="mcp-theme-1 frm-upsert-review-typical-day-ls">
+<div visit-moe close-on-save close-on-cancel class="d-block p-3" id="psych-intake-current-mental-status-{{$note->id}}">
+    <form id="pychIntakeForm" show url="{{ $submitFormUrl }}" class="mcp-theme-1 frm-upsert-review-typical-day-ls">
         <input type="hidden" name="uid" value="<?= $point->uid ?>">
         <input type="hidden" name="noteUid" value="<?= $note->uid ?>">
         <input type="hidden" name="segmentUid" value="<?= $segment->uid ?>">
         <input type="hidden" name="data" value="{{json_encode($contentData)}}">
 
-        <p class="mb-2 font-weight-bold">Psych Intake Current Mental Status</p>
+        <div class="mb-2 d-flex align-items-center justify-content-between">
+			<p class="mb-0 font-weight-bold">Psych Intake Current Mental Status</p>
+			<div>
+				<a class="mr-2 font-weight-bold c-pointer" all-normal><i class="fas fa-thumbs-up"></i> All Normal</a>
+				<a class="font-weight-bold c-pointer" all-not-assessed><i class="fas fa-times-circle"></i> All Not assessed</a>
+			</div>
+		</div>
 
         <div>
             <div class="row">
@@ -246,15 +268,20 @@ if ($point->lastChildReview && $point->lastChildReview->data) {
                 <div class="col-md-6">
                     @foreach($keyToInputMap as  $field => $options)
                         @if(in_array($field, $displayColumns['left']))
-                            <div class="form-group">
-                                <label for="" class="control-label">{{$keyToLabelMap[$field]}}</label>
-                                <select name="{{$field}}" data-name="{{$field}}" id="" class="form-control input-sm">
-                                    <option value="">--</option>
-                                    @foreach($options as $option)
-                                        <option value="{{$option}}">{{$option}}</option>
-                                    @endforeach
-                                </select>
-                            </div>
+							<div class="row align-items-center mb-1">
+								<div class="col-md-4">
+									<label class="control-label mb-0">{{$keyToLabelMap[$field]}}:</label>
+								</div>
+								<div class="col-md-8">
+									<input type="text" list="{{$field}}s" data-name="{{$field}}" name="{{$field}}" id="{{$field}}" class="form-control" value="{{ @$contentData[$field] }}">
+									<datalist id="{{$field}}s">
+										@foreach($options as $option)
+											<option value="{{$option}}">{{$option}}</option>
+										@endforeach
+									</datalist>
+									
+								</div>
+							</div>
                         @endif
                     @endforeach
                 </div>
@@ -262,15 +289,19 @@ if ($point->lastChildReview && $point->lastChildReview->data) {
                 <div class="col-md-6">
                     @foreach($keyToInputMap as  $field => $options)
                         @if(in_array($field, $displayColumns['right']))
-                            <div class="form-group">
-                                <label for="" class="control-label">{{$keyToLabelMap[$field]}}</label>
-                                <select name="{{$field}}" data-name="{{$field}}" id="" class="form-control input-sm">
-                                    <option value="">--</option>
-                                    @foreach($options as $option)
+						<div class="row align-items-center mb-1">
+							<div class="col-md-4">
+								<label class="control-label mb-0">{{$keyToLabelMap[$field]}}:</label>
+							</div>
+							<div class="col-md-8">
+								<input type="text" list="{{$field}}s" data-name="{{$field}}" name="{{$field}}" id="{{$field}}" class="form-control" value="{{ @$contentData[$field] }}">
+								<datalist id="{{$field}}s">
+									@foreach($options as $option)
                                         <option value="{{$option}}">{{$option}}</option>
                                     @endforeach
-                                </select>
-                            </div>
+								</datalist>
+							</div>
+						</div>
                         @endif
                     @endforeach
                 </div>
@@ -289,11 +320,51 @@ if ($point->lastChildReview && $point->lastChildReview->data) {
     </form>   
 </div>
 <script>
-    (function() {
-        function init() {
-            
-        }
-        window.segmentInitializers.psych-intake-current-mental-status = init;
-        addMCInitializer('psych-intake-current-mental-status-{{$note->id}}', init, '#psych-intake-current-mental-status-{{$note->id}}');
-    }).call(window);
+    (function($){
+		var pychIntakeComponent = {
+			form: null,
+			keyLabelMap: <?= json_encode($keyToLabelMap) ?>,
+			allNormal:<?= json_encode($allNormal) ?>,
+			NotAssessedValue: "Not Assessed",
+
+			initOnSetAllNormal: function(){
+				var self = this;
+				
+				$('[all-normal]').click(function(){
+					self.resetFieldsToAllNormal();
+					return;
+				});
+				$('[all-not-assessed]').click(function(){
+					self.resetFieldsToAllNormal(true);
+					return;
+				});
+			},
+			resetFieldsToAllNormal: function(setAsNotAssessed){
+				var self = this;
+				
+				var formData = {};
+				var inputs = self.form.find('[data-name]');
+				$.each(inputs, function(i, input){
+					var key = $(input).data('name');
+					var ref = self.keyLabelMap[key];
+					var defaultValue = self.allNormal[ref];
+					if(setAsNotAssessed){
+						defaultValue = self.NotAssessedValue;
+					}
+					$(input).val(defaultValue);
+					formData[key] = defaultValue;
+				});
+				self.submitForm(formData);
+			},
+			submitForm: function(data){
+				this.form.find('input[name=data]').val(JSON.stringify(data));
+                $.post('{{ $submitFormUrl }}', this.form.serializeArray(), function(response) {}, 'json');
+			},
+			init: function(){
+				this.form = $('#pychIntakeForm');
+				this.initOnSetAllNormal();
+			}
+		};
+		pychIntakeComponent.init();
+	})(jQuery);
 </script>

+ 21 - 16
resources/views/app/patient/segment-templates/psych_intake_current_mental-status/summary.blade.php

@@ -236,25 +236,30 @@ if ($point->lastChildReview && $point->lastChildReview->data) {
         <div class="row">
             
             <div class="col-md-6">
-                @foreach($keyToInputMap as  $field => $options)
-                    @if(in_array($field, $displayColumns['left']))
-                        <div class="form-group">
-                            <label for="" class="control-label">{{$keyToLabelMap[$field]}}</label>
-                            <input type="text" readonly class="form-control input-sm" value="{{@$contentData[$field]}}">
-                        </div>
-                    @endif
-                @endforeach
+				<table class="table table-sm table-striped table-bordered">
+					@foreach($keyToInputMap as  $field => $options)
+						@if(in_array($field, $displayColumns['left']))
+							<tr>
+								<td><b>{{$keyToLabelMap[$field]}}</b></td>
+								<td>{{ @$contentData[$field] ?? '-' }}</td>
+							</tr>
+						@endif
+					@endforeach
+				</table>
+                
             </div>
                 
             <div class="col-md-6">
-                @foreach($keyToInputMap as  $field => $options)
-                    @if(in_array($field, $displayColumns['right']))
-                        <div class="form-group">
-                            <label for="" class="control-label">{{$keyToLabelMap[$field]}}</label>
-                            <input type="text" readonly class="form-control input-sm" value="{{@$contentData[$field]}}">
-                        </div>
-                    @endif
-                @endforeach
+				<table class="table table-sm table-striped table-bordered">
+					@foreach($keyToInputMap as  $field => $options)
+						@if(in_array($field, $displayColumns['right']))
+							<tr>
+								<td><b>{{$keyToLabelMap[$field]}}</b></td>
+								<td>{{ @$contentData[$field] ?? '-' }}</td>
+							</tr>
+						@endif
+					@endforeach
+				</table>
             </div>
         </div>   
     </div>