浏览代码

Merge branch 'dev' into dev-vj-probs-ui

Vijayakrishnan 3 年之前
父节点
当前提交
806867e083

+ 19 - 0
app/Helpers/helpers.php

@@ -176,6 +176,25 @@ if(!function_exists('friendly_date_time')) {
     }
 }
 
+if(!function_exists('friendly_date_month_year')) {
+    function friendly_date_month_year($value, $default = '-', $long_year=true) {
+        if(!$value || empty($value)) return $default;
+        try {
+            $result = strtotime($value);
+                if($long_year){
+                    $result = date("m/Y", $result);
+                }else{
+                    $result = date("m/y", $result);
+                }
+                return $result;
+        }
+        catch (Exception $e) {
+            return $value;
+        }
+    }
+}
+
+
 if(!function_exists('friendlier_date_time')) {
     function friendlier_date_time($value, $includeTime = true, $default = '-') {
         return friendly_date_time($value, $includeTime, $default);

+ 13 - 1
app/Http/Controllers/PracticeManagementController.php

@@ -2822,11 +2822,16 @@ ORDER BY c.name_last, c.name_first
         $filters = $request->all();
     
         $careMonthStartDate = $request->get('care_month_start_date');
+        $careMonthYear = $request->get('care_month_year');
         
         if(!$careMonthStartDate){
             $careMonthStartDate = '2022-01-01';
         }
 
+        if($careMonthYear){
+            $careMonthStartDate = $careMonthYear . "-01";
+        }
+
         $lastDateOfMonth = new DateTime(date("Y-m-t", strtotime(get_current_date())));
         $today = new DateTime(get_current_date());
         $diff = $lastDateOfMonth->diff($today);
@@ -2880,7 +2885,14 @@ ORDER BY c.name_last, c.name_first
            
         }
 
-        $rows = $cmQuery->paginate(50);
+        $claimingClosed = $request->get('claiming_closed');
+        if($claimingClosed){
+            if($claimingClosed === 'YES') $cmQuery = $cmQuery->where('is_claim_closed', true);
+            if($claimingClosed === 'NO') $cmQuery = $cmQuery->where('is_claim_closed', false);
+        }
+
+        $cmQuery = $cmQuery->orderBy('start_date', 'DESC')->orderBy('client_id', 'ASC');
+        $rows =$cmQuery->paginate(15);
 
         return view('app.practice-management.rm-action-report', compact('rows', 'filters', 'minRequiredMeasurements'));
 

+ 4 - 0
app/Models/Bill.php

@@ -25,6 +25,10 @@ class Bill extends Model
         return $this->hasOne(Pro::class, 'id', 'hcp_pro_id');
     }
 
+    public function rmmPro() {
+        return $this->hasOne(Pro::class, 'id', 'rmm_pro_id');
+    }
+
     public function ally() {
         return $this->hasOne(Pro::class, 'id', 'na_pro_id');
     }

+ 9 - 0
app/Models/CareMonth.php

@@ -114,4 +114,13 @@ class CareMonth extends Model
         return $this->hasOne(Note::class, 'id', 'note_id');
     }
 
+    public function mcpRmGenericBill()
+    {
+        return $this->hasOne(Bill::class, 'id', 'mcp_rm_generic_bill_id');
+    }
+    public function rmmRmGenericBill()
+    {
+        return $this->hasOne(Bill::class, 'id', 'rmm_rm_generic_bill_id');
+    }
+
 }

+ 240 - 0
resources/views/app/patient/care-month/_create-claim-table-action.blade.php

@@ -0,0 +1,240 @@
+@if($careMonth->is_claim_closed)
+    <b class="ml-2 text-info">[CLAIMING CLOSED]</b>
+@elseif($pro->pro_type === 'ADMIN' && $careMonth->was_rm_setup_performed && !$careMonth->rm_setup_claim_id)
+    <span class="text-warning-mellow font-weight-bold">
+        <i class="fa fa-exclamation-triangle"></i>
+        RM setup was performed, but RM setup claim is missing
+    </span>
+@else
+    <a href="#" onclick="return showStagPopup('create-claim{{ $careMonth->uid }}')">Create Claim</a>
+@endif
+@if($pro->pro_type === 'ADMIN')
+    @if(!$careMonth->is_claim_closed)
+        <span class="d-block" moe relative>
+            <a class="text-danger" href="" show start>Close Claiming</a>
+            <form url="/api/careMonth/closeClaiming" right>
+                <input type="hidden" name="uid" value="{{$careMonth->uid}}">
+                <p>Close claiming?</p>
+                <div class="mb-0">
+                    <button class="btn btn-success btn-sm" submit>Submit</button>
+                    <button class="btn btn-default border btn-sm" cancel>Cancel</button>
+                </div>
+            </form>
+        </span>
+    @elseif($careMonth->is_claim_closed)
+        <span class="d-block" moe relative>
+            <a class="text-danger" href="" show start>Reopen Claiming</a>
+            <form url="/api/careMonth/reopenClaiming" right>
+                <input type="hidden" name="uid" value="{{$careMonth->uid}}">
+                <p>Reopen claiming?</p>
+                <div class="mb-0">
+                    <button class="btn btn-success btn-sm" submit>Submit</button>
+                    <button class="btn btn-default border btn-sm" cancel>Cancel</button>
+                </div>
+            </form>
+        </span>
+        <span class="d-block" moe relative>
+            <a class="text-danger" href="" show start>Update Claim Total Paid</a>
+            <form url="/api/careMonth/updateClaimTotalPaid" right>
+                <input type="hidden" name="uid" value="{{$careMonth->uid}}">
+                <div class="form-group">
+                    <input type="number" class="form-control" name="claimTotalPaid">
+                </div>
+                <div class="mb-0">
+                    <button class="btn btn-success btn-sm" submit>Submit</button>
+                    <button class="btn btn-default border btn-sm" cancel>Cancel</button>
+                </div>
+            </form>
+        </span>
+    @endif
+@endif
+<div class="stag-popup stag-popup-md mcp-theme-1" style="width:100%" stag-popup-key="create-claim{{ $careMonth->uid }}">
+    <form action="/api/claim/createForCareMonth" id="createCareMonthClaimApp{{$careMonth->uid}}">
+        <h3 class="stag-popup-title border-bottom-0 mb-0">
+            <span class="mr-2">Create Claim</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="careMonthUid" value="{{$careMonth->uid}}">
+        <table class="table table-sm table-condensed mb-3 border-left border-right border-bottom">
+            <thead>
+            <tr class="bg-light">
+                <th style="min-width: 100px;" class="border-bottom-0">CPT Code</th>
+                <th style="min-width: 100px;" class="border-bottom-0">DOS</th>
+                <th class="border-bottom-0">Units</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="py-2">
+                    <input required type="number" class="min-width-unset form-control form-control-sm" v-model="line.numberOfUnits">
+                </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.rmReasons = [];
+    var careMonthClaimSuggestionJson = <?= $careMonth->claim_suggestion_json ?? 0 ?>;
+   
+    new Vue({
+        el: '#createCareMonthClaimApp{{$careMonth->uid}}',
+        delimiters: ['@{{', '}}'],
+        data: {
+            payload: {
+                lines: [
+                    {
+                        cpt: '',
+                        dateOfService: '{{date_format($careMonth->created_at, "Y-m-d")}}',
+                        icds: JSON.parse(JSON.stringify(window.rmReasons)),
+                        numberOfUnits: 1
+                    }
+                ]
+            }
+        },
+        methods: {
+            addLine: function () {
+                this.payload.lines.push({
+                    cpt: '',
+                    dateOfService: '{{date("Y-m-d")}}',
+                    icds: JSON.parse(JSON.stringify(window.rmReasons)),
+                    numberOfUnits: 1
+                });
+                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;
+                $('#createCareMonthClaimApp{{$careMonth->uid}} 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();
+                        console.log('ALIX', lineIndex, icdIndex);
+                        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#createCareMonthClaimApp{{$careMonth->uid}}').first();
+                if(!form[0].checkValidity()) {
+                    form[0].reportValidity();
+                    return false;
+                }
+
+                $.post('/api/claim/createForCareMonth', {
+                    careMonthUid: '{{$careMonth->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')
+            },
+            getPrefillValues: function() {
+                if(careMonthClaimSuggestionJson){
+                    let csj = careMonthClaimSuggestionJson;
+                    if(csj && csj.lines && csj.lines.length) {
+                        this.payload.lines.splice(0, 1);
+                        this.payload.lines = csj.lines;
+                    }
+                }
+            }
+        },
+        mounted: function () {
+            this.initICDAutoSuggest();
+            this.getPrefillValues();
+        }
+    });
+</script>

+ 27 - 0
resources/views/app/patient/care-month/update-claim-status.blade.php

@@ -0,0 +1,27 @@
+<span moe relative title="Submit Claim">
+	<a class="" href="" show start><i class="fa fa-pencil-alt"></i></a>
+	<form url="/api/claim/updateStatus" right>
+		<input type="hidden" name="uid" value="{{$claim->uid}}">
+		<div class="mb-2">
+			<label for="" class="control-label">Status</label>
+			<select name="status" class="form-control form-control-sm" required>
+				<option value="">-- select --</option>
+				<option value="NEW" {{$claim->status === 'NEW' ? 'selected' : ''}}>New</option>
+				<option value="PICKED_UP" {{$claim->status === 'PICKED_UP' ? 'selected' : ''}}>Picked Up</option>
+				<option value="SUBMITTED" {{$claim->status === 'SUBMITTED' ? 'selected' : ''}}>Submitted</option>
+				<option value="IN_PROCESS" {{$claim->status === 'IN_PROCESS' ? 'selected' : ''}}>In Process</option>
+				<option value="ACCEPTED" {{$claim->status === 'ACCEPTED' ? 'selected' : ''}}>Accepted</option>
+				<option value="REJECTED" {{$claim->status === 'REJECTED' ? 'selected' : ''}}>Rejected</option>
+				<option value="ABANDONED" {{$claim->status === 'ABANDONED' ? 'selected' : ''}}>Abandoned</option>
+			</select>
+		</div>
+		<div class="mb-2">
+			<label for="" class="control-label">Status Memo</label>
+			<textarea name="memo" class="form-control"><?= $claim->status_memo ?></textarea>
+		</div>
+		<div class="mb-0">
+			<button class="btn btn-primary btn-sm" submit>Submit</button>
+			<button class="btn btn-default border btn-sm" cancel>Cancel</button>
+		</div>
+	</form>
+</span>

+ 150 - 11
resources/views/app/practice-management/rm-action-report.blade.php

@@ -21,8 +21,11 @@
 		margin-right: 15px;
 	}
 	.sm-section {
-		width: 200px !important;
+		width: 250px !important;
 	}
+    thead.border-bottom-0 tr th {
+        border-bottom: none;
+    }
 </style>
 <div id="rm-action-report" class="p-3 mcp-theme-1">
     <div class="card">
@@ -37,11 +40,28 @@
             <div class="m-2">
                 <form id="rm-action-report-filters" method="GET" action="{{ route('practice-management.rmActionReport') }}" class="filter-container" v-cloak>
                     <div class="sm-section">
+                        <div class="form-group">
+                            <label>Month/Year</label>
+                            <input name="care_month_year" type="month" class="form-control input-sm" v-model="filters.care_month_year">
+                        </div>
+                    </div>
+                    <!-- <div class="sm-section">
                         <div class="form-group">
                             <label>Care Month Start Date:</label>
                             <input name="care_month_start_date" type="date" class="form-control input-sm" v-model="filters.care_month_start_date">
                         </div>
+                    </div> -->
+                    <div class="sm-section">
+                        <div class="form-group">
+                            <label>Claiming Closed:</label>
+                            <select name="claiming_closed" class="form-control input-sm" v-model="filters.claiming_closed">
+                                <option value="">All</option>
+                                <option value="YES">Yes</option>
+                                <option value="NO">No</option>
+                            </select>
+                        </div>
                     </div>
+
                     <div class="sm-section">
                         <div class="form-group">
                             <label>Number Of Measurement Days:</label>
@@ -81,19 +101,36 @@
                             <label>&nbsp;</label>
                             <div class=" d-flex">
                                 <button type="button" v-on:click.prevent="doSubmit()" class="btn btn-primary btn-sm mr-2"><i class="fas fa-filter"></i> Filter</button>
-                                <a href="#" v-on:click.prevent="fastLoad('{{route('mcp.patients')}}')" class="btn btn-link btn-sm text-danger">Clear Filters</a>
+                                <a href="#" v-on:click.prevent="fastLoad('{{ route('practice-management.rmActionReport') }}')" class="btn btn-link btn-sm text-danger">Clear Filters</a>
                             </div>
                         </div>
                     </div>
                 </form>
             </div> 
-            <table class="table table-sm table-striped border-0 p-0 m-0 text-nowrap">
-                <thead class="bg-light">
+            <table class="table table-sm table-striped table-bordered border-0 p-0 m-0 text-nowrap">
+                <thead class="bg-light border-bottom-0">
                     <tr>
-                        <th>Patient</th>
                         <th>Care Month</th>
+                        <th>Patient</th>                        
                         <th>MCP</th>
+                        <th>RMM</th>
                         <th>Number of Measurement Days</th>
+                        <th>Most Recent Visit</th>
+                        <th>Most Recent Visit Days Before EOM</th>
+                        <th># Minutes Billed by MCP</th>
+                        <th># Minutes Billed by RMM</th>
+                        <th># Minutes Billed Total</th>
+                        <th>Has Admin interacted?</th>
+                        <th>Has MCP interacted?</th>
+                        <th>Is Payable to MCP?</th>
+                        <th>MCP Bill</th>
+                        <th>Is Payable to RMM?</th>
+                        <th>RMM Bill</th>
+                        <th>Guidance</th>
+                        <th>Claiming Closed?</th>
+                        <th>Claim</th>
+                        <th>Claim Status</th>
+
                         <th>Has Been Spoken To This Month</th>
                         <th>Days Since Last Visit</th>
                         <th>Last Visit Date</th>
@@ -103,18 +140,25 @@
                     @foreach ($rows as $row)
                     <tr class="{{false ? 'bg-light' : ''}}">
                         <td class="text-nowrap border-left-0">
-                            <a href="/patients/view/{{$row->client->uid}}">
-                                {{$row->client->name_first}} {{$row->client->name_last}}
+                            <a href="/patients/view/{{$row->client->uid}}/care-months/view/{{$row->uid}}">
+                                {{friendly_date_month_year($row->start_date)}}
                             </a>
                         </td>
                         <td class="text-nowrap border-left-0">
-                            <a href="/patients/view/{{$row->client->uid}}/care-months/view/{{$row->uid}}">
-                                {{friendly_date($row->start_date)}}
+                            <a href="/patients/view/{{$row->client->uid}}">
+                                {{$row->client->name_first}} {{$row->client->name_last}}
                             </a>
+                        </td>                        
+                        <td>
+                            @if($row->mcp)
+                                {{$row->mcp->name_first}} {{$row->mcp->name_last}}
+                            @else 
+                                --
+                            @endif
                         </td>
                         <td>
-                            @if($row->client->mcp)
-                                {{$row->client->mcp->name_first}} {{$row->client->mcp->name_last}}
+                            @if($row->rmmPro)
+                                {{$row->rmmPro->name_first}} {{$row->rmmPro->name_last}}
                             @else 
                                 --
                             @endif
@@ -122,6 +166,99 @@
                         <td>
                             {{$row->number_of_days_with_remote_measurements}}
                         </td>
+                        <td>
+                            <!-- Most Recent Visit -->
+                            @if($row->client->mostRecentCompletedMcpNote)
+                            <a href="/patients/view/{{ $row->patient->uid }}/notes/view/{{ $row->client->mostRecentCompletedMcpNote->uid }}">{{ friendly_date($row->client->most_recent_completed_mcp_note_date) }}</a>
+                            @else
+                                -
+                            @endif
+                        </td>
+                        <td>
+                            <!-- Most Recent Visit Days Before EOM -->
+                            {{ $row->days_between_most_recent_mcp_note_date_and_end_of_care_month ?? '-' }}
+                        </td>
+                        <td>
+                            <!-- # Minutes Billed by MCP -->
+                            {{ $row->rm_total_time_in_seconds_by_mcp / 60 }}
+                        </td>
+                        <td>
+                            <!-- # Minutes Billed by RMM -->
+                            {{ $row->rm_total_time_in_seconds_by_rmm / 60 }}
+                        </td>
+                        <td>
+                            <!-- # Minutes Billed Total -->
+                            {{ $row->rmTotalTimeInSeconds / 60 }}
+                        </td>
+                        <td>
+                            <!-- Has Admin interacted? -->
+                            {{ $row->has_admin_interacted_with_client_about_rm }}
+                        </td>
+                        <td>
+                            <!-- Has MCP interacted? -->
+                            {{ $row->has_mcp_interacted_with_client_about_rm }}
+                        </td>
+                        <td>
+                            <!-- Is Payable to MCP? -->
+                            {{ $row->mcpRmGenericBill ? 'YES':'NO' }}
+                        </td>
+                        <td>
+                            <!-- MCP Bill -->
+                            @if($row->mcpRmGenericBill)
+                                {{ $row->rmmRmGenericBill->code }}
+                            @else
+                                -
+                            @endif
+                        </td>
+                        <td>
+                            <!-- Is Payable to RMM? -->
+                            {{ $row->rmmRmGenericBill ? 'YES':'NO' }}
+                        </td>
+                        <td>
+                            <!-- RMM Bill -->
+                            @if($row->rmmRmGenericBill)
+                                {{ $row->rmmRmGenericBill->code }}
+                            @else
+                                -
+                            @endif
+                        </td>
+                        <td>
+                            <?php
+                                $careMonthClaimSuggestion = json_decode($row->claim_suggestion_json);
+                            ?>
+                            @if($careMonthClaimSuggestion)
+                            <div class="d-flex flex-column">
+                                @foreach($careMonthClaimSuggestion->lines as $line)
+                                <span><i class="fas fa-circle" style="color: #00bcd4;"></i> {{ $line->cpt }}</span>
+                                @endforeach
+                            </div>
+                            @endif
+                        </td>
+                        <td>
+                            {{ $row->is_claim_closed ? 'YES':'NO' }}
+                        </td>
+                        <td>
+                            <div class="d-flex justify-content-between">
+                                <div>
+                                    @foreach($row->claims as $claim)
+                                        <div class="d-flex flex-column">
+                                            @foreach($claim->lines as $claimLine)
+                                            <span><i class="fas fa-check-circle" style="color: #8bc34a;"></i> {{$claimLine->cpt}}</span>
+                                            @endforeach
+                                        </div>                                
+                                    @endforeach
+                                </div>
+                                
+                            </div>
+                            @include('app.patient.care-month._create-claim-table-action', ['careMonth' => $row])
+                        </td>
+                        <td>
+                            <?php $rowFirstClaim = $row->claims->first(); ?>
+                            @if($rowFirstClaim)
+                                <span class="mr-2"><b>{{$rowFirstClaim->status}}</b></span>
+                                @include('app.patient.care-month.update-claim-status', ['claim' => $rowFirstClaim])
+                            @endif
+                        </td>
                         <td>
                             {{$row->has_anyone_interacted_with_client_about_rm_outside_note? 'YES': 'NO'}}
                         </td>
@@ -162,6 +299,8 @@
 $loadedFilters = $filters;
 $allFilterKeys = [
 	'care_month_start_date',
+    'care_month_year',
+    'claiming_closed',
     'num_of_measurements',
     'has_recent_visit',
     'has_been_spoken_to',