//---------------------------------------------------------------------------
// 叫号系统排队确认
//---------------------------------------------------------------------------
// String _opacsconnection; 	约定的输入变量名
// String _modalitytype; 		约定的输入变量名
// TADOQuery _qryStudy; 		外部已定义的对象
// TADOQuery _qryImage; 		外部已定义的对象
// TADOQuery _qryCustom; 		外部已定义的对象

//---------------------------------------------------------------------------
String _opacsconnection;	
String _modalitytype;

//---------------------------------------------------------------------------
// 发送网络消息，通知显示屏刷新
// msg_type=90 刷新叫号屏
// msg_type=91 清空显示屏
// msg_type=98 显示欢迎屏
//---------------------------------------------------------------------------
bool RefreshScreen()
{ 
	String sMsgParam = "";
	TStringList pMsgParam = new TStringList;
	pMsgParam.Add("msg_type=90");
	pMsgParam.Add("call_location=0");
	pMsgParam.Add("call_room=0");
	sMsgParam = pMsgParam.CommaText;
	delete pMsgParam;
	
	return SendNetMsg("NM_CALLQUEUE_ASYNC_UPDATED", sMsgParam);
}

//---------------------------------------------------------------------------
// 主程序
//---------------------------------------------------------------------------
{
	int iStudyKey = _qryStudy.FieldByName("study_key").AsInteger;
    if (iStudyKey <= 0)
    {
    	MessageBox("请先选择病人检查记录！", "排队确认", 1);
    	return;
    }
    	
    int iReportState = _qryStudy.FieldByName("report_state").AsInteger;
    if (iReportState > 0)
    {
    	MessageBox("已诊断病人不允许执行排队确认！", "排队确认", 1);
        return;    	
	}
    
    String sPatientName = _qryStudy.FieldByName("patient_name").AsString;
	if (1 == MessageBox("确认【" + sPatientName + "】开始排队检查吗？", "排队确认", 0))
	{
		_qryStudy.Edit();
		_qryStudy.FieldByName("study_dttm").Value = Now();
		_qryStudy.FieldByName("login_state").Value = 0;	// 排队中
		_qryStudy.Post();
		
		// 通知显示屏刷新
		RefreshScreen();
		////
		MessageBox("确认成功！", "排队确认", 1);
	}
}
