Jelajahi Sumber

added claim line icd support

Josh 4 tahun lalu
induk
melakukan
f456598a77

+ 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()

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

@@ -0,0 +1,17 @@
+<?php $noteRates = $pro->noteRates(); ?>
+<span class="mx-2 text-secondary">|</span>
+<div moe wide class="">
+    <a class="" href="" show start>Create Claim</a>
+    <form url="/api/claim/createForNote">
+        <input type="hidden" name="noteUid" value="{{$note->uid}}">
+        <div class="mb-2">
+            <label for="">Are you sure you want to create a claim for this note?</label>
+        </div>
+        
+        <div class="">
+            <button class="btn btn-primary btn-sm" submit>Yes</button>
+            <button class="btn btn-default border btn-sm" cancel>Cancel</button>
+        </div>
+    </form> 
+</div>
+

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

+ 128 - 0
resources/views/app/patient/note/dashboard.blade.php

@@ -415,6 +415,134 @@
                     </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-3"></th>
+                                <th class="border-bottom-0 w-25 pl-3">Submitted?</th>
+                                <th class="border-bottom-0"></th>
+                            </tr>
+                            </thead>
+                            <tbody>
+                            @foreach ($note->claims as $claim)
+                                <tr>
+                                    <td class="pl-3">
+                                        <div>IID: {{ $claim->iid }}</div>
+                                        <div>
+                                            <div class="my-1">
+                                                @include('app.patient.note._update-claim-lines')
+                                            </div>
+                                            @if($claim->lines->count())
+                                                
+                                                <table class="table table-sm table-condensed table-striped">
+                                                    <thead>
+                                                        <tr>
+                                                            <th>CPT</th>
+                                                            <th>Date of Service</th>
+                                                            <th>ICDs</th>
+                                                        </tr>
+                                                    </thead>
+                                                    <tbody>
+                                                        @foreach($claim->lines as $line)
+                                                        <tr>
+                                                            <td>{{$line->cpt}}</td>
+                                                            <td>{{$line->date_of_service}}</td>
+                                                        
+                                                            <td>
+                                                                @include('app.patient.note._update-claim-line-icds',['line'=>$line])
+                                                                <table class="table table-sm table-condensed">
+                                                                    <thead>
+                                                                        <tr>
+                                                                            <td>Code</td>
+                                                                            <td>Description</td>
+                                                                        </tr>
+                                                                    </thead>
+                                                                    <tbody>
+                                                                        @if(count($line->claimLineIcds))
+                                                                            @foreach($line->claimLineIcds as $icd)
+                                                                            <tr>
+                                                                                <td>{{$icd->code}}</td>
+                                                                                <td>{{$icd->description}}</td>
+                                                                            </tr>
+                                                                            @endforeach
+                                                                            
+                                                                        @else 
+                                                                         <p>No icds set</p>
+                                                                        @endif
+                                                                    </tbody>
+                                                                </table>
+                                                            </td>
+                                                        </tr>
+                                                        @endforeach
+                                                    </tbody>
+                                                </table>
+                                            @else 
+                                                <p>No lines for this claim</p>
+                                            @endif
+                                            
+                                        </div>
+                                    </td>
+                                    <td>{{$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
+                                                <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">