|
@@ -298,16 +298,21 @@ class Client extends Model
|
|
|
|
|
|
public function currentCareMonth()
|
|
|
{
|
|
|
- $cmStartDate = strtotime(date('Y-m-d'));
|
|
|
- $month = date("n", $cmStartDate);
|
|
|
- $year = date("Y", $cmStartDate);
|
|
|
- return CareMonth
|
|
|
- ::where('client_id', $this->id)
|
|
|
- ->whereRaw('EXTRACT(MONTH FROM start_date) = ?', [$month])
|
|
|
- ->whereRaw('EXTRACT(YEAR FROM start_date) = ?', [$year])
|
|
|
+ $cmStartDate = date('Y-m-01');
|
|
|
+ return CareMonth::where('client_id', $this->id)
|
|
|
+ ->whereRaw('start_date = ?', [$cmStartDate])
|
|
|
->first();
|
|
|
}
|
|
|
|
|
|
+ // returns the current care-month, if in fact patient is awaiting mcp rm interaction
|
|
|
+ public function isAwaitingRMCommunicationFromMCP() {
|
|
|
+ // if patient is enrolled in rm AND has current care month AND $careMonth->has_mcp_interacted_with_client_about_rm IS FALSE
|
|
|
+ if($this->is_enrolled_in_rm !== 'YES') return false;
|
|
|
+ $careMonth = $this->currentCareMonth();
|
|
|
+ if(!$careMonth) return false;
|
|
|
+ return $careMonth->has_mcp_interacted_with_client_about_rm ? false : $careMonth;
|
|
|
+ }
|
|
|
+
|
|
|
public function previousCareMonth()
|
|
|
{
|
|
|
$cmStartDate = date('Y-m-d', strtotime('first day of last month'));
|