|
@@ -1,18 +1,12 @@
|
|
<?php
|
|
<?php
|
|
|
|
|
|
-use App\Models\Point;
|
|
|
|
use App\Models\Client;
|
|
use App\Models\Client;
|
|
|
|
+use App\Models\Point;
|
|
use App\Models\Note;
|
|
use App\Models\Note;
|
|
-use App\Models\Segment;
|
|
|
|
-
|
|
|
|
/** @var Client $patient */
|
|
/** @var Client $patient */
|
|
/** @var Note $note */
|
|
/** @var Note $note */
|
|
/** @var Segment $segment */
|
|
/** @var Segment $segment */
|
|
|
|
|
|
-$point = Point::getGlobalSingletonOfCategory($patient, 'SOCIAL_HISTORY',true);
|
|
|
|
-
|
|
|
|
-$socHx = $point ? $point->data : null;
|
|
|
|
-
|
|
|
|
$fields = [
|
|
$fields = [
|
|
[
|
|
[
|
|
"Tobacco" => ["Current every day smoker", "Current some day smoker", "Former smoker", "Heavy tobacco smoker", "Light tobacco smoker", "Never smoker", "Smoker, current status unknown", "Unknown if ever smoked "],
|
|
"Tobacco" => ["Current every day smoker", "Current some day smoker", "Former smoker", "Heavy tobacco smoker", "Light tobacco smoker", "Never smoker", "Smoker, current status unknown", "Unknown if ever smoked "],
|
|
@@ -31,237 +25,219 @@ $fields = [
|
|
]
|
|
]
|
|
];
|
|
];
|
|
|
|
|
|
-$customFields = [];
|
|
|
|
-/*
|
|
|
|
- // TODO
|
|
|
|
$customFields = $pro->canvasCustomItems('sochx');
|
|
$customFields = $pro->canvasCustomItems('sochx');
|
|
$customFields = array_map(function($_item) {
|
|
$customFields = array_map(function($_item) {
|
|
return $_item['label'];
|
|
return $_item['label'];
|
|
}, $customFields->toArray());
|
|
}, $customFields->toArray());
|
|
-*/
|
|
|
|
-if (!$socHx) {
|
|
|
|
- $socHx = [
|
|
|
|
|
|
+
|
|
|
|
+if(!$customFields) $customFields = [];
|
|
|
|
+
|
|
|
|
+$point = Point::getGlobalSingletonOfCategory($patient, 'SOCIAL_HISTORY',true);
|
|
|
|
+
|
|
|
|
+$contentData = $parsed = @$point && @$point->data ? $point->data : false;
|
|
|
|
+
|
|
|
|
+if(!$contentData) {
|
|
|
|
+ $contentData = [
|
|
"common" => [],
|
|
"common" => [],
|
|
"custom" => [],
|
|
"custom" => [],
|
|
"comments" => "",
|
|
"comments" => "",
|
|
];
|
|
];
|
|
}
|
|
}
|
|
|
|
|
|
-$contentData = $socHx;
|
|
|
|
?>
|
|
?>
|
|
-<div visit-moe close-on-save close-on-cancel class="d-block">
|
|
|
|
- <form show url="/api/visitPoint/upsertGlobalSingleton" class="mcp-theme-1">
|
|
|
|
- <input type="hidden" name="segmentUid" value="<?= $segment->uid ?>">
|
|
|
|
- <input type="hidden" name="category" value="SOCIAL_HISTORY">
|
|
|
|
- <input type="hidden" name="data">
|
|
|
|
- <div class="row">
|
|
|
|
- <?php for ($i = 0; $i < count($fields); $i++): ?>
|
|
|
|
- <div class="col-md-3">
|
|
|
|
- <?php foreach ($fields[$i] as $head => $values): ?>
|
|
|
|
- <div class="font-weight-bold mb-2"><?= $head ?></div>
|
|
|
|
- <div class="mb-3">
|
|
|
|
- <?php for ($k = 0; $k < count($values); $k++): ?>
|
|
|
|
- <?php $fName = $head . '_' . sanitize_field_name($values[$k]); ?>
|
|
|
|
- <label class="d-flex align-items-center mb-1">
|
|
|
|
- <input type="checkbox" class="m-0"
|
|
|
|
- data-name="common-><?= $fName ?>"
|
|
|
|
- <?= @$contentData['common'][$fName] ? 'checked' : '' ?>
|
|
|
|
- >
|
|
|
|
- <span class="mx-2"><?= $values[$k] ?></span>
|
|
|
|
- <!--<div moe>
|
|
|
|
- <a href="#" start show>
|
|
|
|
- <i v-show="common['<?= $fName ?>']" class="fa-comment"
|
|
|
|
- :class="common['<?= $fName ?>__comments'] ? 'fas' : 'far'"></i>
|
|
|
|
- </a>
|
|
|
|
- <div url="/nop">
|
|
|
|
- <div class="mb-2">
|
|
|
|
- <textarea class="form-control form-control-sm ns-custom-comment"
|
|
|
|
- data-name="common['<?= $fName ?>__comments']"></textarea>
|
|
|
|
- </div>
|
|
|
|
- <div class="">
|
|
|
|
- <button type="button" class="btn btn-sm btn-primary" cancel>Close
|
|
|
|
- </button>
|
|
|
|
|
|
+
|
|
|
|
+<div class="p-3 border-top mt-3 mcp-theme-1">
|
|
|
|
+ <div visit-moe close-on-save close-on-cancel class="d-block">
|
|
|
|
+ <form show url="/api/visitPoint/upsertGlobalSingleton" class="mcp-theme-1">
|
|
|
|
+ <input type="hidden" name="segmentUid" value="<?= $segment->uid ?>">
|
|
|
|
+ <input type="hidden" name="category" value="SOCIAL_HISTORY">
|
|
|
|
+ <input type="hidden" name="data">
|
|
|
|
+
|
|
|
|
+ <div id="edit-univ_history_social-container">
|
|
|
|
+ <div class="d-flex align-items-start flex-wrap custom-items-container">
|
|
|
|
+ @for ($i = 0; $i < count($fields); $i++)
|
|
|
|
+ <div class="w-25">
|
|
|
|
+ @foreach($fields[$i] as $head => $values)
|
|
|
|
+ <div class="font-weight-bold mb-2">{{ $head }}</div>
|
|
|
|
+ <div class="mb-3">
|
|
|
|
+ @for($k = 0; $k < count($values); $k++)
|
|
|
|
+ <?php $fName = $head . '_' . sanitize_field_name($values[$k]); ?>
|
|
|
|
+ <label class="d-flex align-items-start mb-1">
|
|
|
|
+ <input type="checkbox" name="{{ $fName }}" class="mx-0 mt-1"
|
|
|
|
+ v-model="common['{{$fName}}']">
|
|
|
|
+ <div class="ml-2">
|
|
|
|
+ <div>
|
|
|
|
+ <span class="mr-2">{{ $values[$k] }}</span>
|
|
|
|
+ <div moe relative no-mask v-show="common['{{$fName}}']" >
|
|
|
|
+ <a href="#" start show>
|
|
|
|
+ <i class="fa-comment" :class="common['{{$fName}}__comments'] ? 'fas' : 'far'"></i>
|
|
|
|
+ </a>
|
|
|
|
+ <div url="/nop" right>
|
|
|
|
+ <div class="mb-2">
|
|
|
|
+ <textarea class="form-control form-control-sm ns-custom-comment min-width-200px"
|
|
|
|
+ v-model="common['{{$fName}}__comments']"></textarea>
|
|
|
|
+ </div>
|
|
|
|
+ <div class="">
|
|
|
|
+ <button type="button" class="btn btn-sm btn-primary" cancel>Close
|
|
|
|
+ </button>
|
|
|
|
+ </div>
|
|
|
|
+ </div>
|
|
|
|
+ </div>
|
|
|
|
+ </div>
|
|
|
|
+ <span v-show="common['{{$fName}}'] && common['{{$fName}}__comments']"
|
|
|
|
+ v-html="common['{{$fName}}__comments']"
|
|
|
|
+ class="text-sm text-secondary">
|
|
|
|
+ </span>
|
|
</div>
|
|
</div>
|
|
- </div>
|
|
|
|
- </div>-->
|
|
|
|
- </label>
|
|
|
|
- <?php endfor; ?>
|
|
|
|
|
|
+ </label>
|
|
|
|
+ @endfor
|
|
|
|
+ </div>
|
|
|
|
+ @endforeach
|
|
</div>
|
|
</div>
|
|
- <?php endforeach; ?>
|
|
|
|
|
|
+ @endfor
|
|
</div>
|
|
</div>
|
|
- <?php endfor; ?>
|
|
|
|
- </div>
|
|
|
|
-
|
|
|
|
- <?php /*
|
|
|
|
- <div class="row border-top pt-3">
|
|
|
|
- <div class="col-12">
|
|
|
|
- <div class="d-flex align-items-center mb-2">
|
|
|
|
- <span class="font-weight-bold">Custom Items</span>
|
|
|
|
- <span class="mx-2 text-secondary">|</span>
|
|
|
|
- <div moe>
|
|
|
|
- <a href="#" start show>Add</a>
|
|
|
|
- <div custom-item-form url="/api/sectionTemplateCustomItem/create">
|
|
|
|
- <div class="mb-2">
|
|
|
|
- <input type="text" placeholder="Label"
|
|
|
|
- v-model="newCustomItemLabel"
|
|
|
|
- class="form-control form-control-sm label_new_custom_item">
|
|
|
|
- </div>
|
|
|
|
- <div>
|
|
|
|
- <button type="button" class="btn btn-sm btn-primary mr-1"
|
|
|
|
- v-on:click.prevent="saveCustomItem(newCustomItemLabel)">Submit</button>
|
|
|
|
- <button type="button" class="btn btn-sm btn-default border"
|
|
|
|
- v-on:click.prevent="cancelCustomItem()">Cancel</button>
|
|
|
|
|
|
+ <div class="row border-top pt-3">
|
|
|
|
+ <div class="col-12">
|
|
|
|
+ <div class="d-flex align-items-center mb-2">
|
|
|
|
+ <span class="font-weight-bold">Custom Items</span>
|
|
|
|
+ <span class="mx-2 text-secondary">|</span>
|
|
|
|
+ <div moe>
|
|
|
|
+ <a href="#" start show>Add</a>
|
|
|
|
+ <div custom-item-form url="/api/sectionTemplateCustomItem/create">
|
|
|
|
+ <div class="mb-2">
|
|
|
|
+ <input type="text" placeholder="Label"
|
|
|
|
+ v-model="newCustomItemLabel"
|
|
|
|
+ class="form-control form-control-sm label_new_custom_item">
|
|
|
|
+ </div>
|
|
|
|
+ <div>
|
|
|
|
+ <button type="button" class="btn btn-sm btn-primary mr-1"
|
|
|
|
+ v-on:click.prevent="saveCustomItem(newCustomItemLabel)">Submit</button>
|
|
|
|
+ <button type="button" class="btn btn-sm btn-default border"
|
|
|
|
+ v-on:click.prevent="cancelCustomItem()">Cancel</button>
|
|
|
|
+ </div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
- </div>
|
|
|
|
|
|
|
|
- {{-- custom items --}}
|
|
|
|
- <div class="d-flex align-items-start flex-wrap custom-items-container">
|
|
|
|
- <div class="w-25" v-for="item in customFields">
|
|
|
|
- <label class="d-flex align-items-center mb-1">
|
|
|
|
- <input type="checkbox" class="m-0"
|
|
|
|
- v-model="item.value">
|
|
|
|
- <span class="mx-2">@{{ item.label }}</span>
|
|
|
|
- <div moe>
|
|
|
|
- <a href="#" start show>
|
|
|
|
- <i v-show="item.value" class="fa-comment" :class="item.comments ? 'fas' : 'far'"></i>
|
|
|
|
- </a>
|
|
|
|
- <div url="/nop">
|
|
|
|
- <div class="mb-2">
|
|
|
|
- <textarea class="form-control form-control-sm ns-custom-comment" v-model="item.comments"></textarea>
|
|
|
|
- </div>
|
|
|
|
- <div class="">
|
|
|
|
- <button type="button" class="btn btn-sm btn-primary" cancel>Close</button>
|
|
|
|
|
|
+ {{-- custom items --}}
|
|
|
|
+ <div class="d-flex align-items-start flex-wrap custom-items-container">
|
|
|
|
+ <div class="w-25" v-for="item in customFields">
|
|
|
|
+ <label class="d-flex align-items-start mb-1">
|
|
|
|
+ <input type="checkbox" class="mx-0 mt-1"
|
|
|
|
+ v-model="item.value">
|
|
|
|
+ <div class="ml-2 pr-3">
|
|
|
|
+ <div>
|
|
|
|
+ <span class="mr-2">@{{ item.label }}</span>
|
|
|
|
+ <div moe relative no-mask v-show="item.value" >
|
|
|
|
+ <a href="#" start show>
|
|
|
|
+ <i class="fa-comment" :class="item.comments ? 'fas' : 'far'"></i>
|
|
|
|
+ </a>
|
|
|
|
+ <div url="/nop" right>
|
|
|
|
+ <div class="mb-2">
|
|
|
|
+ <textarea class="form-control form-control-sm ns-custom-comment min-width-200px" v-model="item.comments"></textarea>
|
|
|
|
+ </div>
|
|
|
|
+ <div class="">
|
|
|
|
+ <button type="button" class="btn btn-sm btn-primary" cancel>Close</button>
|
|
|
|
+ </div>
|
|
|
|
+ </div>
|
|
|
|
+ </div>
|
|
</div>
|
|
</div>
|
|
|
|
+ <span v-show="item.value && item.comments"
|
|
|
|
+ v-html="item.comments"
|
|
|
|
+ class="text-sm text-secondary">
|
|
|
|
+ </span>
|
|
</div>
|
|
</div>
|
|
- </div>
|
|
|
|
- </label>
|
|
|
|
|
|
+ </label>
|
|
|
|
+ </div>
|
|
</div>
|
|
</div>
|
|
- </div>
|
|
|
|
|
|
|
|
|
|
+ </div>
|
|
|
|
+ </div>
|
|
|
|
+ <hr class="m-neg-4">
|
|
|
|
+ <div class="mb-2">
|
|
|
|
+ <textarea class="form-control form-control-sm" name="comments">{!! $parsed && @$parsed->content ? @$parsed->content : '' !!}</textarea>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
- */ ?>
|
|
|
|
|
|
|
|
- <div class="row mb-3">
|
|
|
|
- <div class="col-12">
|
|
|
|
- <textarea type="text" class="form-control form-control-sm p-2 mt-2"
|
|
|
|
- data-name="comments"
|
|
|
|
- placeholder="Comments"><?= @$contentData['comments'] ?: '' ?></textarea>
|
|
|
|
|
|
+ <div>
|
|
|
|
+ <button submit class="btn btn-sm btn-primary mr-2">Submit</button>
|
|
|
|
+ <button cancel class="btn btn-sm btn-default border">Cancel</button>
|
|
</div>
|
|
</div>
|
|
- </div>
|
|
|
|
-
|
|
|
|
- <div>
|
|
|
|
- <button submit class="btn btn-sm btn-primary mr-2">Submit</button>
|
|
|
|
- <button cancel class="btn btn-sm btn-default border">Cancel</button>
|
|
|
|
- </div>
|
|
|
|
-
|
|
|
|
- </form>
|
|
|
|
|
|
|
|
|
|
+ </form>
|
|
|
|
+ </div>
|
|
</div>
|
|
</div>
|
|
-
|
|
|
|
<script>
|
|
<script>
|
|
- (function () {
|
|
|
|
- let model = <?= json_encode($contentData) ?>;
|
|
|
|
- model.newCustomItemLabel = '';
|
|
|
|
- let customFields = <?= json_encode($customFields) ?>;
|
|
|
|
- if (!model.customFields) {
|
|
|
|
- model.customFields = [];
|
|
|
|
- }
|
|
|
|
- for (let i = 0; i < customFields.length; i++) {
|
|
|
|
- let found = model.customFields.filter(function (_item) {
|
|
|
|
- return _item.label === customFields[i];
|
|
|
|
- }).length;
|
|
|
|
- if (!found) {
|
|
|
|
- model.customFields.push({
|
|
|
|
- label: customFields[i],
|
|
|
|
- value: '',
|
|
|
|
- comments: '',
|
|
|
|
- })
|
|
|
|
|
|
+ (function() {
|
|
|
|
+
|
|
|
|
+ window.segmentInitializers.<?= $segment->segmentTemplate->internal_name ?> = function() {
|
|
|
|
+
|
|
|
|
+ let model = <?= json_encode($contentData) ?>;
|
|
|
|
+ model.newCustomItemLabel = '';
|
|
|
|
+ let customFields = <?= json_encode($customFields) ?>;
|
|
|
|
+ if(!model.customFields) {
|
|
|
|
+ model.customFields = [];
|
|
|
|
+ }
|
|
|
|
+ for (let i = 0; i < customFields.length; i++) {
|
|
|
|
+ let found = model.customFields.filter(function(_item) {
|
|
|
|
+ return _item.label === customFields[i];
|
|
|
|
+ }).length;
|
|
|
|
+ if(!found) {
|
|
|
|
+ model.customFields.push({
|
|
|
|
+ label: customFields[i],
|
|
|
|
+ value: '',
|
|
|
|
+ comments: '',
|
|
|
|
+ })
|
|
|
|
+ }
|
|
}
|
|
}
|
|
- }
|
|
|
|
|
|
|
|
- function init() {
|
|
|
|
- window.clientSocHXApp = new Vue({
|
|
|
|
- el: '#sochxSection',
|
|
|
|
|
|
+ new Vue({
|
|
|
|
+ el: '#edit-univ_history_social-container',
|
|
data: model,
|
|
data: model,
|
|
- mounted: function () {
|
|
|
|
- $('#sochxSection [moe][initialized]').removeAttr('initialized');
|
|
|
|
|
|
+ mounted: function() {
|
|
|
|
+ $('#edit-univ_history_social-container [moe][initialized]').removeAttr('initialized');
|
|
initMoes();
|
|
initMoes();
|
|
- $('#sochxSection').find('[name="data"]').val(JSON.stringify({
|
|
|
|
- common: this.cleanObject(this.common),
|
|
|
|
- customFields: this.customFields,
|
|
|
|
- comments: this.comments,
|
|
|
|
- }));
|
|
|
|
},
|
|
},
|
|
watch: {
|
|
watch: {
|
|
$data: {
|
|
$data: {
|
|
- handler: function (val, oldVal) {
|
|
|
|
- $('#sochxSection').find('[name="data"]').val(JSON.stringify({
|
|
|
|
- common: this.cleanObject(this.common),
|
|
|
|
- customFields: this.customFields,
|
|
|
|
- comments: this.comments,
|
|
|
|
- }));
|
|
|
|
|
|
+ handler: function(val, oldVal) {
|
|
|
|
+ let parent = $('#edit-univ_history_social-container').closest('form');
|
|
|
|
+ parent.find('[name="data"]').val(JSON.stringify(this.$data));
|
|
},
|
|
},
|
|
deep: true
|
|
deep: true
|
|
}
|
|
}
|
|
},
|
|
},
|
|
methods: {
|
|
methods: {
|
|
- cleanObject: function (_source) {
|
|
|
|
- let plObject = {};
|
|
|
|
- for (let y in _source) {
|
|
|
|
- if (_source.hasOwnProperty(y)) {
|
|
|
|
- plObject[y] = _source[y];
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- return plObject;
|
|
|
|
- },
|
|
|
|
- saveCustomItem: function (_label) {
|
|
|
|
- if (!_label) return false;
|
|
|
|
|
|
+ saveCustomItem: function(_label) {
|
|
|
|
+ if(!_label) return false;
|
|
showMask();
|
|
showMask();
|
|
let self = this;
|
|
let self = this;
|
|
$.post('/api/clientCanvasCustomItem/create', {
|
|
$.post('/api/clientCanvasCustomItem/create', {
|
|
proUid: '{{ $pro->uid }}',
|
|
proUid: '{{ $pro->uid }}',
|
|
key: 'sochx',
|
|
key: 'sochx',
|
|
label: _label
|
|
label: _label
|
|
- }, function (_data) {
|
|
|
|
|
|
+ }, function(_data) {
|
|
hideMask();
|
|
hideMask();
|
|
- if (_data && _data.success) {
|
|
|
|
- self.appendCustomItem(_label);
|
|
|
|
|
|
+ if(_data && _data.success) {
|
|
hideMoeFormMask();
|
|
hideMoeFormMask();
|
|
$('[custom-item-form]').hide();
|
|
$('[custom-item-form]').hide();
|
|
- } else {
|
|
|
|
|
|
+ $('.custom-items-container').closest('.visit-segment').find('.refresh-segment').trigger('click');
|
|
|
|
+ }
|
|
|
|
+ else {
|
|
toastr.error(_data.message);
|
|
toastr.error(_data.message);
|
|
}
|
|
}
|
|
- }, 'json');
|
|
|
|
|
|
+ }, 'json')
|
|
return false;
|
|
return false;
|
|
},
|
|
},
|
|
- cancelCustomItem: function () {
|
|
|
|
|
|
+ cancelCustomItem: function() {
|
|
hideMoeFormMask();
|
|
hideMoeFormMask();
|
|
$('div[moe]').hide();
|
|
$('div[moe]').hide();
|
|
return false;
|
|
return false;
|
|
- },
|
|
|
|
- appendCustomItem: function (_name) {
|
|
|
|
- this.customFields.push({
|
|
|
|
- label: _name,
|
|
|
|
- value: '',
|
|
|
|
- comments: '',
|
|
|
|
- });
|
|
|
|
- Vue.nextTick(function () {
|
|
|
|
- $('.custom-items-container [moe][initialized]').removeAttr('initialized');
|
|
|
|
- initMoes();
|
|
|
|
- });
|
|
|
|
}
|
|
}
|
|
}
|
|
}
|
|
});
|
|
});
|
|
- }
|
|
|
|
|
|
|
|
- window.segmentInitializers.<?= $segment->segmentTemplate->internal_name ?> = function() {
|
|
|
|
- // any JS can come here
|
|
|
|
- // will be run on page-load as well as whenever this segment is refreshed
|
|
|
|
};
|
|
};
|
|
|
|
|
|
- // addMCInitializer('client-sochx', init, '#sochxSection');
|
|
|
|
- })();
|
|
|
|
|
|
+ }).call(window);
|
|
</script>
|
|
</script>
|