<?php

namespace Application\Service\Extension\Middleware\components;

use Application\Service\Extension\Helper\SDMHelper;
use Application\Form\item\patient\PatientFormModel;
use Application\Service\Extension\Laminas;
use Application\Service\Extension\Middleware\BaseMiddlewareComponent;

/**
 * 自动更新患者访视常规识别类表单字段完成情况
 */
class HandleNormalFormOverField extends BaseMiddlewareComponent
{
    /** @var PatientFormModel $owner */
    public $owner;
    public function __construct(array $params = [])
    {
        parent::__construct($params);

        $this->owner = &$params['owner'];
    }

    function execute()
    {
        //获取常规类识别表单完成的字段数量
        $over_num = SDMHelper::app()->patient->getShareFormOverFieldCount($this->owner->formId, $this->owner->checktimeId, $this->owner->patientId);
        Laminas::$serviceManager->patientForm->update(['complete_filed_num'=>$over_num],[
            'is_del'=>0,
            'patient_id'=>$this->owner->patientId,
            'checktime_id'=>$this->owner->checktimeId,
            'form_id'=>$this->owner->formId,
        ]);
        unset($over_num);
    }
}