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

Merge branch 'dev-vj' of rav.triplestart.com:jmudaka/stagfe2 into dev

Josh 4 éve
szülő
commit
ed6c20cf62

+ 4 - 1
app/Models/Claim.php

@@ -8,5 +8,8 @@ class Claim extends Model
 {
 
     protected $table = 'claim';
-    //
+
+    public function lines(){
+        return $this->hasMany(ClaimLine::class, 'claim_id', 'id');
+    }
 }

+ 16 - 0
app/Models/ClaimLine.php

@@ -0,0 +1,16 @@
+<?php
+
+namespace App\Models;
+
+use Illuminate\Database\Eloquent\Model;
+
+class ClaimLine extends Model
+{
+
+    protected $table = 'claim_line';
+
+    public function claimLineIcds(){
+        return $this->hasMany(ClaimLineIcd::class, 'claim_line_id', 'id');
+    }
+
+}

+ 12 - 0
app/Models/ClaimLineIcd.php

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

+ 1 - 1
app/Models/Note.php

@@ -57,7 +57,7 @@ class Note extends Model
 
     public function claims()
     {
-        return $this->hasMany(Claim::class, 'id', 'note_id');
+        return $this->hasMany(Claim::class, 'note_id', 'id');
     }
 
     public function summary()

+ 3 - 0
public/css/style.css

@@ -1184,3 +1184,6 @@ button.note-templates-trigger-assessment {
 .appt-calendar-col.click-through .fc-timegrid-event-harness {
     pointer-events: none !important;
 }
+.claim-line:last-child td {
+    padding-bottom: 1.3rem;
+}

+ 7 - 0
public/css/yemi.css

@@ -14,6 +14,13 @@
     padding: 10px;
     border: 1px solid gray;
 }
+[moe][fixed-center] [url]:not([show]) {
+    position: fixed !important;
+    top: 50% !important;
+    left: 50% !important;
+    width: 600px;
+    transform: translate(-50%, -50%) !important;
+}
 [moe] [url][right] {
     right: 0;
     min-width: 200px;

+ 172 - 0
resources/views/app/patient/note/_create-claim.blade.php

@@ -0,0 +1,172 @@
+<span class="mx-2 text-secondary">|</span>
+<a href="#" onclick="return showStagPopup('create-claim')">Create Claim</a>
+<div class="stag-popup stag-popup-md mcp-theme-1" stag-popup-key="create-claim">
+    <form action="/api/claim/createForNote" id="createClaimApp">
+        <h3 class="stag-popup-title border-bottom-0 mb-0">
+            <span>Create Claim</span>
+            <span class="mx-2 text-secondary">|</span>
+            <a href="#" v-on:click.prevent="addLine()">Add Line</a>
+            <a href="#" class="ml-auto text-secondary"
+               onclick="return closeStagPopup()"><i class="fa fa-times-circle"></i></a>
+        </h3>
+        <input type="hidden" name="noteUid" value="{{$note->uid}}">
+        <table class="table table-sm table-condensed mb-3 border-left border-right border-bottom">
+            <thead>
+            <tr class="bg-light">
+                <th class="width-100px border-bottom-0">CPT Code</th>
+                <th class="width-100px border-bottom-0">Date of Service</th>
+                <th class="border-bottom-0">ICDs</th>
+                <th class="border-bottom-0">&nbsp;</th>
+            </tr>
+            </thead>
+            <tbody>
+            <tr v-for="(line, lineIndex) in payload.lines">
+                <td class="py-2">
+                    <input required type="text" class="min-width-unset form-control form-control-sm" v-model="line.cpt">
+                </td>
+                <td class="py-2">
+                    <input required type="date" class="min-width-unset form-control form-control-sm" v-model="line.dateOfService">
+                </td>
+                <td class="p-2 bg-light">
+                    <div class="d-flex align-items-baseline">
+                        <a href="#" class="text-nowrap text-primary mr-2"
+                           v-on:click.prevent="addICD(lineIndex)" title="Add ICD">
+                            <i class="fa fa-plus-square text-primary"></i>
+                        </a>
+                        <div class="flex-grow-1">
+                            <div v-for="(icd, icdIndex) in line.icds" class="d-flex align-items-center" :class="icdIndex > 0 ? 'mt-1' : ''">
+                                <input required type="text" class="form-control form-control-sm width-100px"
+                                       data-field="icd"
+                                       :data-line-index="lineIndex"
+                                       :data-icd-index="icdIndex"
+                                       v-model="icd.code">
+                                <input required type="text" class="form-control form-control-sm flex-grow-1 ml-2"
+                                       v-model="icd.description">
+                                <a href="#" class="text-nowrap text-danger ml-2"
+                                   v-on:click.prevent="removeICD(lineIndex, icdIndex)"
+                                   v-if="line.icds.length > 1" title="Remove ICD">
+                                    <i class="fa fa-trash-alt text-danger"></i>
+                                </a>
+                            </div>
+                        </div>
+                    </div>
+                </td>
+                <td class="text-center pt-2">
+                    <a href="#" class="text-nowrap text-danger d-block mt-1"
+                       :class="payload.lines.length <= 1 ? 'opacity-60' : ''"
+                       v-on:click.prevent="removeLine(lineIndex)">
+                        <i class="fa fa-trash-alt text-danger"></i>
+                        Remove Line
+                    </a>
+                </td>
+            </tr>
+            </tbody>
+        </table>
+
+        <div class="mt-2">
+            <button type="button" class="btn btn-primary btn-sm font-weight-bold" v-on:click.prevent="saveClaim()">Create</button>
+            <button type="button" class="btn btn-default border btn-sm font-weight-bold ml-2" onclick="return closeStagPopup()">Cancel</button>
+        </div>
+    </form>
+</div>
+<script>
+    window.createClaimApp = new Vue({
+        el: '#createClaimApp',
+        delimiters: ['@{{', '}}'],
+        data: {
+            payload: {
+                lines: [
+                    {
+                        cpt: '',
+                        dateOfService: '{{date('Y-m-d')}}',
+                        icds: window.noteReasons
+                    }
+                ]
+            }
+        },
+        methods: {
+            addLine: function () {
+                this.payload.lines.push({
+                    cpt: '',
+                    dateOfService: '{{date('Y-m-d')}}',
+                    icds: window.noteReasons
+                });
+                Vue.nextTick(() => {
+                    this.initICDAutoSuggest();
+                });
+            },
+            removeLine: function (_index) {
+                if(this.payload.lines.length > 1) {
+                    this.payload.lines.splice(_index, 1);
+                }
+            },
+            addICD: function(_lineIndex) {
+                this.payload.lines[_lineIndex].icds.push({
+                    code: '',
+                    description: '',
+                });
+                Vue.nextTick(() => {
+                    this.initICDAutoSuggest();
+                });
+            },
+            removeICD: function(_lineIndex, _icdIndex) {
+                if(this.payload.lines[_lineIndex].icds.length > 1) {
+                    this.payload.lines[_lineIndex].icds.splice(_icdIndex, 1);
+                }
+            },
+            initICDAutoSuggest: function () {
+                let self = this;
+                $('#createClaimApp input[type="text"][data-field="icd"]:not([ac-initialized])').each(function () {
+                    var elem = this,
+                        dynID = 'icd-' + Math.ceil(Math.random() * 1000000),
+                        lineIndex = $(this).attr('data-line-index'),
+                        icdIndex = $(this).attr('data-icd-index');
+                    $(elem).attr('id', dynID);
+                    new window.Def.Autocompleter.Search(dynID,
+                        'https://clinicaltables.nlm.nih.gov/api/icd10cm/v3/search?sf=code,name&ef=name', {
+                            tableFormat: true,
+                            valueCols: [0],
+                            colHeaders: ['Code', 'Name'],
+                        }
+                    );
+                    window.Def.Autocompleter.Event.observeListSelections(dynID, function () {
+                        let acData = elem.autocomp.getSelectedItemData();
+                        self.payload.lines[lineIndex].icds[icdIndex].code = acData[0].code;
+                        self.payload.lines[lineIndex].icds[icdIndex].description = acData[0].data.name;
+                        return false;
+                    });
+                    $(elem).attr('ac-initialized', 1);
+                });
+            },
+            saveClaim: function() {
+                let form = $('form#createClaimApp').first();
+                if(!form[0].checkValidity()) {
+                    form[0].reportValidity();
+                    return false;
+                }
+
+                $.post('/api/claim/create', {
+                    noteUid: '{{$note->uid}}',
+                    data: JSON.stringify(this.payload)
+                }, function(_data) {
+                    if (!_data.success) {
+                        if (_data.message) {
+                            toastr.error(_data.message);
+                        }
+                        else {
+                            toastr.error('Unable to save the claim!');
+                        }
+                    }
+                    else {
+                        toastr.success('Claim saved!');
+                        closeStagPopup();
+                        fastReload();
+                    }
+                }, 'json')
+            }
+        },
+        mounted: function () {
+            this.initICDAutoSuggest();
+        }
+    })
+</script>

+ 12 - 1
resources/views/app/patient/note/_create-note-reason.blade.php

@@ -1,3 +1,14 @@
+<script>
+    window.noteReasons = [];
+    @if(count($note->reasons))
+        @foreach($note->reasons as $reason)
+        window.noteReasons.push({
+            code: '{{$reason->code}}',
+            description: '{{$reason->description}}'
+        });
+        @endforeach
+    @endif
+</script>
 <div moe wide class="">
     <a class="" href="" show start><i class="fa fa-edit"></i></a>
     <form url="/api/note/update-note-reasons">
@@ -101,4 +112,4 @@
         }
 
     })();
-</script>
+</script>

+ 106 - 0
resources/views/app/patient/note/_update-claim-line-icds.blade.php

@@ -0,0 +1,106 @@
+<div moe wide class="">
+    <a class="" href="" show start><i class="fa fa-edit"></i></a>
+    <form url="/api/claimLine/update-claim-line-icds">
+        <input type="hidden" name="uid" value="{{$line->uid}}">
+        <table class="table table-sm table-condensed" id="claim-line-icds-table-{{$line->uid}}">
+            <thead>
+                <tr>
+                    <td>Code</td>
+                    <td>Description</td>
+                    <td></td>
+                </tr>
+            </thead>
+            <tbody>
+            <?php var_dump($line->icds); ?>
+                @if($line->icds && $line->icds->count()))
+               
+                @foreach($line->icds as $icd)
+                <tr class="data-row">
+                    <td><input type="text" class="form-control claim-line-icd" data-index="{{$loop->index}}" id="{{$line->uid}}-cl_icd_{{$loop->index}}" name="claimLineIcdDTOs[{{$loop->index}}].code" value="{{$icd->code}}"></td>
+                    <td><input type="text" class="form-control claim-line-description" data-index="{{$loop->index}}" id="{{$line->uid}}-cl_description_{{$loop->index}}" name="claimLineIcdDTOs[{{$loop->index}}].description" value="{{$icd->description}}"></td>
+                    <td>
+                        <button class="btn btn-sm btn-info cli-btn-remove-row">-</button>
+                    </td>
+                </tr>
+                @endforeach
+                @else
+                <tr class="data-row">
+                    <td><input type="text" class="form-control claim-line-icd"  data-index="0" id="{{$line->uid}}-cl_icd_0" name="claimLineIcdDTOs[0].code"></td>
+                    <td><input type="text" class="form-control claim-line-description" data-index="0" id="{{$line->uid}}-cl_description_0" name="claimLineIcdDTOs[0].description"></td>
+                    <td>
+                        <button class="btn btn-sm btn-info cli-btn-remove-row">-</button>
+                    </td>
+                </tr>
+                <tr class="data-row">
+                    <td><input type="text" class="form-control claim-line-icd" data-index="1" id="{{$line->uid}}-cl_icd_1" name="claimLineIcdDTOs[1].code"></td>
+                    <td><input type="text" class="form-control claim-line-description" data-index="1" id="{{$line->uid}}-cl_description_1" name="claimLineIcdDTOs[1].description"></td>
+                    <td>
+                        <button class="btn btn-sm btn-info cli-btn-remove-row">-</button>
+                    </td>
+                </tr>
+                <tr class="data-row">
+                    <td><input type="text" class="form-control claim-line-icd" data-index="2" id="{{$line->uid}}-cl_icd_2" name="claimLineIcdDTOs[2].code"></td>
+                    <td><input type="text" class="form-control claim-line-description" data-index="2" id="{{$line->uid}}-cl_description_2" name="claimLineIcdDTOs[2].description"></td>
+                    <td>
+                        <button class="btn btn-sm btn-info cli-btn-remove-row">-</button>
+                    </td>
+                </tr>
+                @endif
+            </tbody>
+        </table>
+        <div class="form-group">
+            <button class="btn btn-outline-primary btn-sm " id="btn-add-row-{{$line->uid}}">Add row</button>
+        </div>
+        <div class="form-group">
+            <button class="btn btn-primary btn-sm" submit>Submit</button>
+            <button class="btn btn-default border btn-sm" cancel>Cancel</button>
+        </div>
+    </form>
+</div>
+<script>
+    (function() {
+        $("#btn-add-row-{{$line->uid}}").click(function() {
+            var rowCount = $('#claim-line-icds-table-{{$line->uid}}').find('tr').length;
+            var nextIndex = rowCount -1;
+            var clone = $('#claim-line-icds-table-{{$line->uid}} tr.data-row:first').clone();
+            clone.find('input').attr('data-index', nextIndex);
+            clone.find('input.claim-line-icd').attr('name','claimLineIcdDTOs['+nextIndex+'].code').val('');
+            clone.find('input.claim-line-icd').attr('id','cl_icd_'+nextIndex);
+            clone.find('input.claim-line-description').attr('name','claimLineIcdDTOs['+nextIndex+'].description').val('');
+            clone.find('input.claim-line-description').attr('id','cl_description_'+nextIndex);
+            $('#claim-line-icds-table-{{$line->uid}}').append(clone);
+            attachAutocompleterToField(nextIndex);
+
+            return false;
+        });
+
+        $('#claim-line-icds-table-{{$line->uid}}').on('click', '.cli-btn-remove-row', function() {
+            $(this).closest('tr').remove();
+            return false;
+        });
+
+        $('#claim-line-icds-table-{{$line->uid}} .claim-line-icd').each(function(i,e) {
+            var fieldIndex = $(e).attr('data-index');
+            attachAutocompleterToField(fieldIndex);
+        });
+
+        function attachAutocompleterToField(fieldIndex){
+            var e = $('#{{$line->uid}}-cl_icd_'+fieldIndex)[0];
+            new Def.Autocompleter.Search('{{$line->uid}}-cl_icd_'+fieldIndex, 'https://clinicaltables.nlm.nih.gov/api/icd10cm/v3/search?sf=code,name', {
+                tableFormat: true,
+                valueCols: [1],
+                colHeaders: ['Code', 'Name']
+            });
+            Def.Autocompleter.Event.observeListSelections('{{$line->uid}}-cl_icd_'+fieldIndex, function(data) {
+                console.log("DATA:", data);
+                var descriptionInput = $(e).closest('tr').find('.claim-line-description')[0];
+                console.log("Setting value of e to : ", data.item_code);
+                $('#{{$line->uid}}-cl_icd_'+fieldIndex).val(data.item_code);
+                $('#{{$line->uid}}-cl_description_'+fieldIndex).val(data.final_val);
+                $('#{{$line->uid}}-cl_icd_'+fieldIndex).focus();
+                return false;
+            });
+        }
+
+    })();
+</script>

+ 79 - 0
resources/views/app/patient/note/_update-claim-lines.blade.php

@@ -0,0 +1,79 @@
+<div moe wide class="">
+    <a class="" href="" show start>Update lines</a>
+    <form url="/api/claim/update-claim-lines">
+        <input type="hidden" name="uid" value="{{$claim->uid}}">
+        <table class="table table-sm table-condensed" id="claim-lines-table-{{$claim->uid}}">
+            <thead>
+                <tr>
+                    <td>CPT</td>
+                    <td>Date of Service</td>
+                    <td></td>
+                </tr>
+            </thead>
+            <tbody>
+                @if(count($claim->lines))
+                @foreach($claim->lines as $line)
+                <tr class="data-row">
+                    <td><input type="text" class="form-control claim-line-cpt" data-index="{{$loop->index}}" id="cpt_{{$loop->index}}" name="claimLineDTOs[{{$loop->index}}].cpt" value="{{$line->cpt}}"></td>
+                    <td><input type="date" class="form-control claim-line-date_of_service" data-index="{{$loop->index}}" id="date_of_service_{{$loop->index}}" name="claimLineDTOs[{{$loop->index}}].dateOfService" value="{{$line->date_of_service}}"></td>
+                    <td>
+                        <button class="btn btn-sm btn-info cl-btn-remove-row">-</button>
+                    </td>
+                </tr>
+                @endforeach
+                @else
+                <tr class="data-row">
+                    <td><input type="text" class="form-control claim-line-cpt"  data-index="0" id="cpt_0" name="claimLineDTOs[0].cpt"></td>
+                    <td><input type="date" class="form-control claim-line-date_of_service" data-index="0" id="date_of_service_0" name="claimLineDTOs[0].date_of_service"></td>
+                    <td>
+                        <button class="btn btn-sm btn-info cl-btn-remove-row">-</button>
+                    </td>
+                </tr>
+                <tr class="data-row">
+                    <td><input type="text" class="form-control claim-line-cpt" data-index="1" id="cpt_1" name="claimLineDTOs[1].cpt"></td>
+                    <td><input type="date" class="form-control claim-line-date_of_service" data-index="1" id="date_of_service_1" name="claimLineDTOs[1].date_of_service"></td>
+                    <td>
+                        <button class="btn btn-sm btn-info cl-btn-remove-row">-</button>
+                    </td>
+                </tr>
+                <tr class="data-row">
+                    <td><input type="text" class="form-control claim-line-cpt" data-index="2" id="cpt_2" name="claimLineDTOs[2].cpt"></td>
+                    <td><input type="date" class="form-control claim-line-date_of_service" data-index="2" id="date_of_service_2" name="claimLineDTOs[2].date_of_service"></td>
+                    <td>
+                        <button class="btn btn-sm btn-info cl-btn-remove-row">-</button>
+                    </td>
+                </tr>
+                @endif
+            </tbody>
+        </table>
+        <div class="form-group">
+            <button class="btn btn-outline-primary btn-sm" id="cl-btn-add-row-{{$claim->uid}}">Add row</button>
+        </div>
+        <div class="form-group">
+            <button class="btn btn-primary btn-sm" submit>Submit</button>
+            <button class="btn btn-default border btn-sm" cancel>Cancel</button>
+        </div>
+    </form>
+</div>
+<script>
+    (function() {
+        $('#cl-btn-add-row-{{$claim->uid}}').click(function() {
+            var rowCount = $('#claim-lines-table-{{$claim->uid}}').find('tr').length;
+            var nextIndex = rowCount -1;
+            var clone = $('#claim-lines-table-{{$claim->uid}} tr.data-row:first').clone();
+            clone.find('input').attr('data-index', nextIndex);
+            clone.find('input.claim-line-cpt').attr('name','claimLineDTOs['+nextIndex+'].cpt').val('');
+            clone.find('input.claim-line-cpt').attr('id','cpt_'+nextIndex);
+            clone.find('input.claim-line-date_of_service').attr('name','claimLineDTOs['+nextIndex+'].date_of_service').val('');
+            clone.find('input.claim-line-date_of_service').attr('id','date_of_service_'+nextIndex);
+            $('#claim-lines-table-{{$claim->uid}}').append(clone);
+            return false;
+        });
+
+        $('#claim-lines-table-{{$claim->uid}}').on('click', '.cl-btn-remove-row', function() {
+            $(this).closest('tr').remove();
+            return false;
+        });
+
+    })();
+</script>

+ 187 - 0
resources/views/app/patient/note/_update-claim.blade.php

@@ -0,0 +1,187 @@
+<?php $componentID = rand(10001, 99999); ?>
+<a href="#" onclick="return showStagPopup('update-claim-{{$componentID}}')">Edit</a>
+<div class="stag-popup stag-popup-md mcp-theme-1" stag-popup-key="update-claim-{{$componentID}}">
+    <form action="/api/claim/createForNote" id="updateClaimApp{{$componentID}}">
+        <h3 class="stag-popup-title border-bottom-0 mb-0">
+            <span>Update Claim</span>
+            <span class="mx-2 text-secondary">|</span>
+            <a href="#" v-on:click.prevent="addLine()">Add Line</a>
+            <a href="#" class="ml-auto text-secondary"
+               onclick="return closeStagPopup()"><i class="fa fa-times-circle"></i></a>
+        </h3>
+        <input type="hidden" name="uid" value="{{$claim->uid}}">
+        <table class="table table-sm table-condensed mb-3 border-left border-right border-bottom">
+            <thead>
+            <tr class="bg-light">
+                <th class="width-100px border-bottom-0">CPT Code</th>
+                <th class="width-100px border-bottom-0">Date of Service</th>
+                <th class="border-bottom-0">ICDs</th>
+                <th class="border-bottom-0">&nbsp;</th>
+            </tr>
+            </thead>
+            <tbody>
+            <tr v-for="(line, lineIndex) in payload.lines">
+                <td class="py-2">
+                    <input required type="text" class="min-width-unset form-control form-control-sm" v-model="line.cpt">
+                </td>
+                <td class="py-2">
+                    <input required type="date" class="min-width-unset form-control form-control-sm" v-model="line.dateOfService">
+                </td>
+                <td class="p-2 bg-light">
+                    <div class="d-flex align-items-baseline">
+                        <a href="#" class="text-nowrap text-primary mr-2"
+                           v-on:click.prevent="addICD(lineIndex)" title="Add ICD">
+                            <i class="fa fa-plus-square text-primary"></i>
+                        </a>
+                        <div class="flex-grow-1">
+                            <div v-for="(icd, icdIndex) in line.icds" class="d-flex align-items-center" :class="icdIndex > 0 ? 'mt-1' : ''">
+                                <input required type="text" class="form-control form-control-sm width-100px"
+                                       data-field="icd"
+                                       :data-line-index="lineIndex"
+                                       :data-icd-index="icdIndex"
+                                       v-model="icd.code">
+                                <input required type="text" class="form-control form-control-sm flex-grow-1 ml-2"
+                                       v-model="icd.description">
+                                <a href="#" class="text-nowrap text-danger ml-2"
+                                   v-on:click.prevent="removeICD(lineIndex, icdIndex)"
+                                   v-if="line.icds.length > 1" title="Remove ICD">
+                                    <i class="fa fa-trash-alt text-danger"></i>
+                                </a>
+                            </div>
+                        </div>
+                    </div>
+                </td>
+                <td class="text-center pt-2">
+                    <a href="#" class="text-nowrap text-danger d-block mt-1"
+                       :class="payload.lines.length <= 1 ? 'opacity-60' : ''"
+                       v-on:click.prevent="removeLine(lineIndex)">
+                        <i class="fa fa-trash-alt text-danger"></i>
+                        Remove Line
+                    </a>
+                </td>
+            </tr>
+            </tbody>
+        </table>
+
+        <div class="mt-2">
+            <button type="button" class="btn btn-primary btn-sm font-weight-bold" v-on:click.prevent="saveClaim()">Update</button>
+            <button type="button" class="btn btn-default border btn-sm font-weight-bold ml-2" onclick="return closeStagPopup()">Cancel</button>
+        </div>
+    </form>
+</div>
+<script>
+    <?php
+        $loadedLines = [];
+        foreach ($claim->lines as $line) {
+            $newLine = (object)[];
+            $newLine->cpt = $line->cpt;
+            $newLine->dateOfService = $line->date_of_service;
+            $newLine->icds = [];
+            foreach ($line->claimLineIcds as $icd) {
+                $newICD = (object)[];
+                $newICD->code = $icd->code;
+                $newICD->description = $icd->description;
+                $newLine->icds[] = $newICD;
+            }
+            $loadedLines[] = $newLine;
+        }
+    ?>
+    window.updateClaimApp{{$componentID}} = new Vue({
+        el: '#updateClaimApp{{$componentID}}',
+        delimiters: ['@{{', '}}'],
+        data: {
+            payload: {
+                lines: <?= json_encode($loadedLines) ?>
+            }
+        },
+        methods: {
+            addLine: function () {
+                this.payload.lines.push({
+                    cpt: '',
+                    dateOfService: '{{date('Y-m-d')}}',
+                    icds: [
+                        {
+                            code: '',
+                            description: '',
+                        }
+                    ]
+                });
+                Vue.nextTick(() => {
+                    this.initICDAutoSuggest();
+                });
+            },
+            removeLine: function (_index) {
+                if(this.payload.lines.length > 1) {
+                    this.payload.lines.splice(_index, 1);
+                }
+            },
+            addICD: function(_lineIndex) {
+                this.payload.lines[_lineIndex].icds.push({
+                    code: '',
+                    description: '',
+                });
+                Vue.nextTick(() => {
+                    this.initICDAutoSuggest();
+                });
+            },
+            removeICD: function(_lineIndex, _icdIndex) {
+                if(this.payload.lines[_lineIndex].icds.length > 1) {
+                    this.payload.lines[_lineIndex].icds.splice(_icdIndex, 1);
+                }
+            },
+            initICDAutoSuggest: function () {
+                let self = this;
+                $('#updateClaimApp{{$componentID}} input[type="text"][data-field="icd"]:not([ac-initialized])').each(function () {
+                    var elem = this,
+                        dynID = 'icd-' + Math.ceil(Math.random() * 1000000),
+                        lineIndex = $(this).attr('data-line-index'),
+                        icdIndex = $(this).attr('data-icd-index');
+                    $(elem).attr('id', dynID);
+                    new window.Def.Autocompleter.Search(dynID,
+                        'https://clinicaltables.nlm.nih.gov/api/icd10cm/v3/search?sf=code,name&ef=name', {
+                            tableFormat: true,
+                            valueCols: [0],
+                            colHeaders: ['Code', 'Name'],
+                        }
+                    );
+                    window.Def.Autocompleter.Event.observeListSelections(dynID, function () {
+                        let acData = elem.autocomp.getSelectedItemData();
+                        self.payload.lines[lineIndex].icds[icdIndex].code = acData[0].code;
+                        self.payload.lines[lineIndex].icds[icdIndex].description = acData[0].data.name;
+                        return false;
+                    });
+                    $(elem).attr('ac-initialized', 1);
+                });
+            },
+            saveClaim: function() {
+                let form = $('form#updateClaimApp{{$componentID}}').first();
+                if(!form[0].checkValidity()) {
+                    form[0].reportValidity();
+                    return false;
+                }
+
+                $.post('/api/claim/update', {
+                    uid: '{{$claim->uid}}',
+                    data: JSON.stringify(this.payload)
+                }, function(_data) {
+                    if (!_data.success) {
+                        if (_data.message) {
+                            toastr.error(_data.message);
+                        }
+                        else {
+                            toastr.error('Unable to save the claim!');
+                        }
+                    }
+                    else {
+                        toastr.success('Claim saved!');
+                        closeStagPopup();
+                        fastReload();
+                    }
+                }, 'json')
+            }
+        },
+        mounted: function () {
+            this.initICDAutoSuggest();
+        }
+    })
+</script>

+ 113 - 3
resources/views/app/patient/note/dashboard.blade.php

@@ -285,7 +285,7 @@
                 <div class="border-top p-3">
                     <div class="">
                         <div class="d-flex align-items-center mb-2">
-                            <p class="font-weight-bold text-secondary m-0 mr-2">Assessments</p>
+                            <p class="font-weight-bold text-secondary m-0 mr-2">ICDs</p>
                             @include('app/patient/note/_create-note-reason')
                         </div>
                         <div>
@@ -295,7 +295,7 @@
                                     {{ $reason->description}} ({{ $reason->code }})
                                 </span>
                             @endforeach
-                        @else 
+                        @else
                             <div class="alert alert-info">No note reasons</div>
                         @endif
                         </div>
@@ -415,7 +415,117 @@
                     </div>
                 @endif
 
-                
+                @if($note->claims->count())
+                    <div class="mt-2 px-3">
+                        <div class="d-flex align-items-center mb-2">
+                            <p class="font-weight-bold text-secondary m-0">Claims</p>
+                            @include('app/patient/note/_create-claim')
+                        </div>
+
+                        <table class="table table-sm tabe-striped mb-3 border-left border-right border-bottom">
+                            <thead class="bg-light">
+                            <tr>
+                                <th class="border-bottom-0 pl-2">IID</th>
+                                <th class="border-bottom-0 w-50">Details</th>
+                                <th class="border-bottom-0 text-center">Submitted?</th>
+                                <th class="border-bottom-0">Actions</th>
+                            </tr>
+                            </thead>
+                            <tbody>
+                            @foreach ($note->claims as $claim)
+                                <tr>
+                                    <td class="pl-2">{{ $claim->iid }}</td>
+                                    <td class="p-0">
+                                        @if($claim->lines->count())
+                                            <table class="table table-sm table-condensed border-left border-right mb-0">
+                                                <thead>
+                                                    <tr class="bg-light">
+                                                        <th class="border-0">CPT</th>
+                                                        <th class="border-0">Date of Service</th>
+                                                        <th class="border-0">ICDs</th>
+                                                    </tr>
+                                                </thead>
+                                                <tbody class="pb-3">
+                                                    @foreach($claim->lines as $line)
+                                                    <tr class="claim-line">
+                                                        <td>{{$line->cpt}}</td>
+                                                        <td>{{$line->date_of_service}}</td>
+                                                        <td>
+                                                            @if(count($line->claimLineIcds))
+                                                                @foreach($line->claimLineIcds as $icd)
+                                                                    <div>
+                                                                        <b>{{$icd->code}}</b> <span class="text-secondary">({{$icd->description}})</span>
+                                                                    </div>
+                                                                @endforeach
+                                                            @else
+                                                                <p>No ICDs set</p>
+                                                            @endif
+                                                        </td>
+                                                    </tr>
+                                                    @endforeach
+                                                </tbody>
+                                            </table>
+                                        @else
+                                            <p>No lines for this claim</p>
+                                        @endif
+                                    </td>
+                                    <td class="text-center">{{$claim->was_submitted? 'Yes':'No'}}</td>
+
+                                    <td>
+                                        <div class="d-flex align-items-center">
+                                            @if($claim->was_submitted)
+                                                <span class="d-block text-secondary">
+                                                    Submitted
+                                                </span>
+                                            @else
+                                                @include('app/patient/note/_update-claim')
+                                                <span class="mx-2 text-secondary">|</span>
+                                                <span moe class="d-block" title="Submit Claim">
+                                                    <a class="" href="" show start>Submit</a>
+                                                    <form url="/api/claim/submit">
+                                                        <input type="hidden" name="uid" value="{{$claim->uid}}">
+                                                        <p>Submit claim?</p>
+                                                        <div class="mb-0">
+                                                            <button class="btn btn-success btn-sm" submit>Sign</button>
+                                                            <button class="btn btn-default border btn-sm" cancel>Cancel</button>
+                                                        </div>
+                                                    </form>
+                                                </span>
+                                            @endif
+                                            @if($claim->is_cancelled)
+                                                <span class="mx-2 text-secondary">|</span>
+                                                <span class="d-block text-secondary">
+                                                    Cancelled
+                                                </span>
+                                            @else
+                                                <span class="mx-2 text-secondary">|</span>
+                                                <span class="d-block" moe>
+                                                    <a class="text-danger" href="" show start>Cancel</a>
+                                                    <form url="/api/claim/cancel">
+                                                        <input type="hidden" name="uid" value="{{$claim->uid}}">
+                                                        <p>Cancel this claim?</p>
+                                                        <div class="mb-0">
+                                                            <button class="btn btn-danger btn-sm" submit>Yes</button>
+                                                            <button class="btn btn-default border btn-sm" cancel>No</button>
+                                                        </div>
+                                                    </form>
+                                                </span>
+                                            @endif
+                                        </div>
+                                    </td>
+                                </tr>
+                            @endforeach
+                            </tbody>
+                        </table>
+                    </div>
+                @else
+                    <div class="my-3 px-3 d-flex">
+                        <p class="font-weight-bold mb-0 text-secondary">No claims in this note</p>
+                        @include('app/patient/note/_create-claim')
+                    </div>
+                @endif
+
+
 
                 <div class="border-top p-3">
                     @if($note->addendums->count())

+ 37 - 0
spec/claim-data-strucure-spec.txt

@@ -0,0 +1,37 @@
+
+api/claim/create
+
+=====================================
+
+{
+	note_uid: STRING,
+	lines: [
+		{
+			cpt: STRING,
+			date_of_service: DATE,
+			icds: [
+				{
+				code:
+				description:
+				}...
+			]
+		}....
+	]
+}
+
+=====================================
+
+CPT | DOS | ICD(s)
+code | desc (+)
+(+)
+
+[SUBMIT]
+
+-------------------------------------
+
+api/claim/update
+
+note_uid -> uid (claim->uid)
+
+=====================================
+...