MERGE_TEST_BUG_FIXES
This commit is contained in:
commit
d950435408
@ -1677,19 +1677,55 @@ class EmployeeRestController extends AdminController
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$responseData = [
|
||||||
|
'level_1' => $level_1,
|
||||||
|
'level_2' => $level_2,
|
||||||
|
];
|
||||||
|
|
||||||
|
$tpaNetworkHospitals = $this->getTpaNetworkHospitalsByClientId($client_id);
|
||||||
|
|
||||||
|
if (! empty($tpaNetworkHospitals)) {
|
||||||
|
$responseData['tpa_network_hospitals'] = $tpaNetworkHospitals;
|
||||||
|
}
|
||||||
|
|
||||||
return $this->respond([
|
return $this->respond([
|
||||||
'status' => 'success',
|
'status' => 'success',
|
||||||
'code' => 200,
|
'code' => 200,
|
||||||
'data' => [
|
'data' => $responseData,
|
||||||
'level_1' => $level_1,
|
|
||||||
'level_2' => $level_2,
|
|
||||||
],
|
|
||||||
], 200);
|
], 200);
|
||||||
|
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
return $this->respond(['status' => 'failed', 'code' => 500, 'data' => $e->getMessage()], 500);
|
return $this->respond(['status' => 'failed', 'code' => 500, 'data' => $e->getMessage()], 500);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private function getTpaNetworkHospitalsByClientId($client_id)
|
||||||
|
{
|
||||||
|
$tpaRecords = $this->clientPolicyModel
|
||||||
|
->select('tpa.name as tpa_name, tpa.network_hospitals')
|
||||||
|
->join('tpa', 'client_policy.tpa_id = tpa.id', 'left')
|
||||||
|
->where('MD5(client_policy.client_id)', $client_id)
|
||||||
|
->where('client_policy.is_active', 1)
|
||||||
|
->where('tpa.is_active', 1)
|
||||||
|
->where('tpa.network_hospitals IS NOT NULL', null, false)
|
||||||
|
->where('tpa.network_hospitals !=', '')
|
||||||
|
->groupBy('tpa.id')
|
||||||
|
->findAll();
|
||||||
|
|
||||||
|
$tpaNetworkHospitals = [];
|
||||||
|
|
||||||
|
foreach ($tpaRecords as $tpaRecord) {
|
||||||
|
$tpaName = trim((string) ($tpaRecord['tpa_name'] ?? ''));
|
||||||
|
$networkHospitals = trim((string) ($tpaRecord['network_hospitals'] ?? ''));
|
||||||
|
|
||||||
|
if ($tpaName !== '' && $networkHospitals !== '') {
|
||||||
|
$tpaNetworkHospitals[$tpaName] = $networkHospitals;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $tpaNetworkHospitals;
|
||||||
|
}
|
||||||
|
|
||||||
public function getAddOnPolicy()
|
public function getAddOnPolicy()
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
|
|||||||
@ -499,7 +499,7 @@ SQL;
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** Metabase #197: Claims Incidence Rate */
|
/** Metabase #197: Claims Incidence Rate */
|
||||||
public function claims_incidence_rate(int $policyId): array
|
public function claims_incidence_rateOLD(int $policyId): array
|
||||||
{
|
{
|
||||||
$sql = <<<'SQL'
|
$sql = <<<'SQL'
|
||||||
SELECT
|
SELECT
|
||||||
@ -507,8 +507,10 @@ SELECT
|
|||||||
ROUND(
|
ROUND(
|
||||||
COUNT(tm.id) / NULLIF(lives.current_lives, 0) * 100
|
COUNT(tm.id) / NULLIF(lives.current_lives, 0) * 100
|
||||||
, 2)
|
, 2)
|
||||||
, '%') AS claims_incidence_rate
|
, '%') AS claims_incidence_rate,
|
||||||
|
max(cdf.created_at) as created_at
|
||||||
FROM ticket_master tm
|
FROM ticket_master tm
|
||||||
|
JOIN claim_dump_files cdf ON tm.client_policy_id = cdf.client_policy_id AND tm.tpa_id = cdf.tpa_id
|
||||||
JOIN (
|
JOIN (
|
||||||
SELECT COUNT(DISTINCT ep.employee_id) AS current_lives
|
SELECT COUNT(DISTINCT ep.employee_id) AS current_lives
|
||||||
FROM employee_polices ep
|
FROM employee_polices ep
|
||||||
@ -525,6 +527,33 @@ SQL;
|
|||||||
return $this->runKpiQuery($sql, $policyId);
|
return $this->runKpiQuery($sql, $policyId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function claims_incidence_rate(int $policyId): array
|
||||||
|
{
|
||||||
|
$sql = <<<'SQL'
|
||||||
|
SELECT
|
||||||
|
CONCAT(
|
||||||
|
ROUND(
|
||||||
|
(SELECT COUNT(tm.id) FROM ticket_master tm WHERE tm.client_policy_id = :policy_id: AND tm.is_active = 1)
|
||||||
|
/
|
||||||
|
NULLIF(lives.current_lives, 0) * 100
|
||||||
|
, 2)
|
||||||
|
, '%') AS claims_incidence_rate,
|
||||||
|
(SELECT MAX(cdf.created_at) FROM claim_dump_files cdf WHERE cdf.client_policy_id = :policy_id:) AS created_at
|
||||||
|
FROM (
|
||||||
|
SELECT COUNT(DISTINCT ep.employee_id) AS current_lives
|
||||||
|
FROM employee_polices ep
|
||||||
|
JOIN employees e ON e.id = ep.employee_id
|
||||||
|
WHERE ep.client_policy_id = :policy_id:
|
||||||
|
AND ep.status = 'active'
|
||||||
|
AND ep.is_active = 1
|
||||||
|
AND e.emp_status = 'active'
|
||||||
|
AND e.is_active = 1
|
||||||
|
) lives;
|
||||||
|
SQL;
|
||||||
|
|
||||||
|
return $this->runKpiQuery($sql, $policyId);
|
||||||
|
}
|
||||||
|
|
||||||
/** Metabase #198: Policy Start Date */
|
/** Metabase #198: Policy Start Date */
|
||||||
public function policy_start_date(int $policyId): array
|
public function policy_start_date(int $policyId): array
|
||||||
{
|
{
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user