//---------------------------------------------------------------------------
// String _opacsconnection; 约定的输入变量名
// String _hisconnection; 	约定的输入变量名 
// String _modalitytype; 	约定的输入变量名
// String _requestid; 		约定的输入变量名
// String _patientname; 	约定的输入变量名
// String _examclass; 		约定的输入变量名
// String _examsubclass; 	约定的输入变量名
// TDateTime _startdate; 	约定的输入变量名
// TDateTime _enddate; 	    约定的输入变量名
// TADOQuery _qryStudy		外部已定义的对象
// TADOQuery _qryCustom		外部已定义的对象
// TADOQuery _qryHisStudy   外部已定义的对象
// TADOQuery _qryHisCustom  外部已定义的对象
// TADOQuery _qryHisCommon  外部已定义的对象
//
// 脚本必须实现的函数 int _QueryHisTable();
// 脚本必须实现的函数 int _ConfirmHisLogin(); 	
// 脚本必须实现的函数 int _CancelHisLogin(); 	
// 脚本必须实现的函数 int _PatientValidate();
//---------------------------------------------------------------------------

#include "..\\Common\\HisCommon.cpp"

String      _opacsconnection;
String      _hisconnection;
String 		_modalitytype;
String      _requestid;
String      _patientname;
String      _examclass;
String      _examsubclass;
TDateTime   _startdate;
TDateTime   _enddate;

//---------------------------------------------------------------------------

// 下列函数被 ExecSQL() 调用
int ExecSQL_OLD()
{
	ShowMessage( "此模式仅用于浏览HIS数据，请用输入住院号方式登记！");
	String sHisQuery = "";
	////
    int iFieldCount = 0;
    String sFieldPairs[2][100];
	//SetArrayItem(sFieldPairs, iFieldCount, "patient_guid", 	"zyhm");//自动编号
	//SetArrayItem(sFieldPairs, iFieldCount, "study_guid", 		"ROWID");
    SetArrayItem(sFieldPairs, iFieldCount, "patient_name", 		"BRXM");
    SetArrayItem(sFieldPairs, iFieldCount, "patient_sex", 		"BRXB");
    SetArrayItem(sFieldPairs, iFieldCount, "patient_birthday", 	"CSNY");
    SetArrayItem(sFieldPairs, iFieldCount, "patient_address", 	"HKDZ");
    SetArrayItem(sFieldPairs, iFieldCount, "patient_telephone", "JTDH");
    SetArrayItem(sFieldPairs, iFieldCount, "study_sickregion", 	"BQ");
    SetArrayItem(sFieldPairs, iFieldCount, "study_sickroom", 	"BRCH");
    SetArrayItem(sFieldPairs, iFieldCount, "study_number2", 	"zyhm");
    SetArrayItem(sFieldPairs, iFieldCount, "study_dttm", 		"FYRQ"); // !!!
    SetArrayItem(sFieldPairs, iFieldCount, "study_examkind", 	"EXAM_CLASS");
    SetArrayItem(sFieldPairs, iFieldCount, "study_examname", 	"FYMC");
    SetArrayItem(sFieldPairs, iFieldCount, "study_number0", 	"ROWID"); // 用于回传报告时定位记录
    ////
	if (!IsConnetSQLServer(_hisconnection))
		return 0;//数据源不对

        sHisQuery = "select top 100 zyhm,zyhm,ROWID,brxm,brxb,csny,FYrq, exam_class=case " + 
		"when charindex('(CT)',fymc)>0 then 'CT' "+
		"when charindex('(DR)',fymc)>0 then 'DX' "+ 
		"when charindex('(CR)',fymc)>0 then 'DX' "+
		"else '' end, "+
		"fymc,hkdz,jtdh,C.KSMC as BQ,BRCH "+
		"from zy_fymx a,zy_brry b,gy_ksdm c "+
		"where fyxm in (7,45) and fyxh in (289,329,330,332,30313) and b.zyh=a.zyh and c.ksdm=b.brbq";
    ////
    if (_requestid != "")
        sHisQuery = InsertWhereCondition(sHisQuery, "zyhm = '" + _requestid + "'");
    if (_patientname != "")
        sHisQuery = AddWhereCondition(sHisQuery, "brxm = '" + _patientname + "'");    
	////
    if (_examclass != "")
        sHisQuery = AddWhereCondition(sHisQuery, "charindex('" + _examclass + "',fymc)>0");
//    if (_examsubclass != "")
//        sHisQuery = AddWhereCondition(sHisQuery, "a.EXAM_SUB_CLASS = '" + _examsubclass + "'");
	////
	String sStartDate = FormatDateTime("yyyy-mm-dd 0:0:0", _startdate);
	if ( sStartDate >= "2000-01-01" )
		sHisQuery = AddWhereCondition(sHisQuery, "fyrq >= '" + sStartDate + "'" );
    String sEndDate = FormatDateTime("yyyy-mm-dd 23:59:59", _enddate);
	if ( sEndDate >= "2000-01-01" )
		sHisQuery = AddWhereCondition(sHisQuery, "fyrq <= '" + sEndDate + "'" );
    ////
    _qryHisCustom.Close();
    _qryHisCustom.SQL.Text = sHisQuery;
    try
    {
        _qryHisCustom.Open();
    }
    except
    {
    	ShowMessage( sHisQuery);
        ShowMessage("查询失败！请检查输入条件！");
    }
    ////
    if (!_qryHisCustom.IsEmpty())
    {
        _qryHisCustom.First();
        while (!_qryHisCustom.Eof)
        {
            _qryHisStudy.Append();
			_qryHisStudy.FieldByName("study_source").Value = "住院";
            for (int i = 0; i < iFieldCount; i++)
            {
                if (!_qryHisCustom.FieldByName(sFieldPairs[1][i]).IsNull)
                {
                    if (sFieldPairs[0][i] == "patient_sex")
                    {
                        String sPatientSex = _qryHisCustom.FieldByName(sFieldPairs[1][i]).Value;
                        if ((sPatientSex == "男") || (sPatientSex == "1"))
                            _qryHisStudy.FieldByName(sFieldPairs[0][i]).Value = "男";
                        else if ((sPatientSex == "女") || (sPatientSex == "2"))
                            _qryHisStudy.FieldByName(sFieldPairs[0][i]).Value = "女";
                    }
					else if (sFieldPairs[0][i] == "patient_birthday")
					{
						TDateTime dtStudy = Now(); // 此处值得斟酌！by boost
						_qryHisStudy.FieldByName("patient_studyage").Value =
							CalcStudyAge(_qryHisCustom.FieldByName(sFieldPairs[1][i]).Value, dtStudy);
						_qryHisStudy.FieldByName(sFieldPairs[0][i]).Value =
							_qryHisCustom.FieldByName(sFieldPairs[1][i]).Value;
					}
                    else
                    {
                        _qryHisStudy.FieldByName(sFieldPairs[0][i]).Value =
                            _qryHisCustom.FieldByName(sFieldPairs[1][i]).Value;
                    }
                }
            }
            _qryHisStudy.Post();
            _qryHisCustom.Next();
        }
    }

    return 1;
}
//---------------------------------------------------------------------------

int ExecSQL()
{
	String sHisQuery = "";
	////
	if (!IsConnetSQLServer(_hisconnection))
		return 0;//数据源不对
		
    ////
    String sBRXM = "";
    String sBRXB = "0";	//numeric
    String sCSNY = "";	//date
    String sAge = "";
    String sHKDZ = "";
    String sJTDH = "";
    String sID = "0";	//numeric
    String sKDRQ = "";	//date
    String sFPHM = "";
    String sYGXM = "";
    String sKSMC = "";
    String sMZHM = "";
    String sBRBQ = "";
    String sBRCH = "";
	    
    int iProgStep = 10;
    if (_requestid != "")
    {
       	sHisQuery = "SELECT top 1 ZYH,BRXM,BRXB,CSNY,HKDZ,JTDH,datediff(yy,CSNY,getdate()) as Age," +
       	"b.KSMC as BQ,BRCH FROM ZY_BRRY a, GY_KSDM b WHERE ZYHM='" + _requestid +"' and cypb in (0,1) AND b.KSDM=a.BRBQ";
    }
    else
    {
	    if (_patientname != "")
	    {
	    	return ExecSQL_OLD();
	    }
	    else    
	       	sHisQuery = "SELECT top 1 ZYH,BRXM,BRXB,CSNY,HKDZ,JTDH,datediff(yy,CSNY,getdate()) as Age," +
	       	"b.KSMC as BQ,BRCH FROM ZY_BRRY WHERE ZYH in (" +
	       	"select top 1 zyh from zy_fymx where fyxh in (289,290,329,330,332,30313) " +
	       	" and fyxm in(7,45) and getdate()- jfrq <1) AND b.KSDM=a.BRBQ";
    }
	////
	if ( iProgStep == 10 )
	{
	    _qryHisCustom.Close();
	    _qryHisCustom.SQL.Text = sHisQuery;
	    try
	    {
	        _qryHisCustom.Open();
	    }
	    except
	    {
	        ShowMessage("查询失败！请检查输入条件！");
	        return 0;
	    }
	    if (_qryHisCustom.IsEmpty())
	    {
	        ShowMessage("无此住院病人，请检查住院号是否正确？");
	    	return 0;
	    }
        else
        {
	       _qryHisCustom.First();
	        if (!_qryHisCustom.FieldByName("ZYH").IsNull)
	        	sID = _qryHisCustom.FieldByName("ZYH").Value;
	        if (!_qryHisCustom.FieldByName("BRXM").IsNull)
	        	sBRXM = _qryHisCustom.FieldByName("BRXM").Value;
	        if (!_qryHisCustom.FieldByName("BRXB").IsNull)
	        	sBRXB = _qryHisCustom.FieldByName("BRXB").Value;
	        if (!_qryHisCustom.FieldByName("CSNY").IsNull)
	        	sCSNY = _qryHisCustom.FieldByName("CSNY").Value;
	        if (!_qryHisCustom.FieldByName("HKDZ").IsNull)
	        	sHKDZ = _qryHisCustom.FieldByName("HKDZ").Value;
	        if (!_qryHisCustom.FieldByName("JTDH").IsNull)
	        	sJTDH = _qryHisCustom.FieldByName("JTDH").Value;
	        sAge = _qryHisCustom.FieldByName("Age").Value;
	        sBRBQ = _qryHisCustom.FieldByName("BQ").Value;
	        sBRCH = _qryHisCustom.FieldByName("BRCH").Value;
	        sMZHM = _requestid;
	        iProgStep = 20;
	    }
	}

	// iProgStep = 20
	sHisQuery = "SELECT ROWID,convert(varchar(8),FYRQ,12)+YSGH as YJXH,FYXH as YLXH,ZJJE AS JE " +
	"FROM ZY_FYMX WHERE ZYH=" + sID + " and fyxh in (289,290,329,330,332,30313,30177) and fyxm in(7,45)";
	if (_examclass != "")
	{
		if ( _examclass == "DR" )
        	sHisQuery = AddWhereCondition(sHisQuery, "FYXH in (30313,290)");
		else if ( _examclass == "CT" )
        	sHisQuery = AddWhereCondition(sHisQuery, "FYXH in (320,329,332,30177)");
		else if ( _examclass == "CR" )
        	sHisQuery = AddWhereCondition(sHisQuery, "FYXH in (289,290)");
    }
	////
	String sStartDate = FormatDateTime("yyyy-mm-dd 0:0:0", _startdate);
	if ( sStartDate >= "2000-01-01" )
		sHisQuery = AddWhereCondition(sHisQuery, "JFRQ >= '" + sStartDate + "'" );
    String sEndDate = FormatDateTime("yyyy-mm-dd 23:59:59", _enddate);
	if ( sEndDate >= "2000-01-01" )
		sHisQuery = AddWhereCondition(sHisQuery, "JFRQ <= '" + sEndDate + "'" );
    ////
    _qryHisCustom.Close();
    _qryHisCustom.SQL.Text = sHisQuery;
    //fDR_SUM
    try
    {
        _qryHisCustom.Open();
    }
    except
    {
        ShowMessage("查询失败！请检查输入条件！");
        return 0;
    }
    ////
    if (_qryHisCustom.IsEmpty())
    	return 0;

    _qryHisCustom.First();
    int iYLXH = 0;
    String sYJXH_ini = _qryHisCustom.FieldByName("YJXH").Value;//以此判定一组费用并不准确,但HIS太烂没办法,默认有日期过滤
    String sYJXH_cur = "";
    float fJE = 0.0;
	float fCT_SUM = 0.0;//numeric
	float fDR_SUM = 0.0;//numeric
	float fCR_SUM = 0.0;//numeric
	String sPatientSex = "";
	int iRowId = 0;

    while (!_qryHisCustom.Eof)
    {
    	iRowId = _qryHisCustom.FieldByName("ROWID").Value;
    	sYJXH_cur = _qryHisCustom.FieldByName("YJXH").Value;
    	if ( sYJXH_cur != sYJXH_ini )
    	{
    		//输出
			// iProgStep = 40
			sHisQuery = "SELECT top 1 CONVERT(VARCHAR(18),ZYH)+'_'+YSGH as FPHM," +
			"JFRQ as KDRQ,b.KSMC,c.YGXM FROM ZY_FYMX a, GY_KSDM b, GY_YGDM c WHERE ROWID="
				+ IntToStr(iRowId) + " and b.KSDM=a.FYKS and c.YGDM=a.YSGH";
		    _qryHisCommon.Close();
		    _qryHisCommon.SQL.Text = sHisQuery;
		    _qryHisCommon.Open();
		    if (!_qryHisCommon.IsEmpty())
		    {
			    _qryHisCommon.First();
				sFPHM = _qryHisCommon.FieldByName("FPHM").Value;
	        	//sBRXM = _qryHisCommon.FieldByName("BRXM").Value;
				sKDRQ = _qryHisCommon.FieldByName("KDRQ").Value;
				sKSMC = _qryHisCommon.FieldByName("KSMC").Value;
				sYGXM = _qryHisCommon.FieldByName("YGXM").Value;
			}
			////
			if ( sBRXB == "1" )
				sPatientSex = "男";
			else if ( sBRXB == "2" )
				sPatientSex = "女";
				
		    if ( fDR_SUM > 0.0 )
		    {
		        _qryHisStudy.Append();
				_qryHisStudy.FieldByName("study_examkind").Value = "DX";
				_qryHisStudy.FieldByName("study_examname").Value = "数字化摄影(DR)";
				_qryHisStudy.FieldByName("study_charge").Value = fDR_SUM;
				////
				_qryHisStudy.FieldByName("study_source").Value = "住院";
				//_qryHisStudy.FieldByName("patient_guid").Value = sID;//自动编号
				_qryHisStudy.FieldByName("patient_name").Value = sBRXM;
				_qryHisStudy.FieldByName("patient_sex").Value = sPatientSex;
				if (sCSNY != "")
				_qryHisStudy.FieldByName("patient_birthday").Value = sCSNY;
				_qryHisStudy.FieldByName("patient_studyage").Value = sAge;
				_qryHisStudy.FieldByName("patient_telephone").Value = sJTDH;
				_qryHisStudy.FieldByName("patient_address").Value = sHKDZ;
				_qryHisStudy.FieldByName("study_number0").Value = sFPHM;
				_qryHisStudy.FieldByName("study_number2").Value = sMZHM;
				_qryHisStudy.FieldByName("study_number3").Value = sBRCH;
				_qryHisStudy.FieldByName("study_sickregion").Value = sBRBQ;
				_qryHisStudy.FieldByName("study_dttm").Value = sKDRQ;
				_qryHisStudy.FieldByName("study_department").Value = sKSMC;
				_qryHisStudy.FieldByName("study_applicant").Value = sYGXM;
			   _qryHisStudy.Post();
		   	}
		
		    if ( fCT_SUM > 0.0 )
		    {

		        _qryHisStudy.Append();
				_qryHisStudy.FieldByName("study_examkind").Value = "CT";
				_qryHisStudy.FieldByName("study_examname").Value = "X线计算机体层(CT)螺旋扫描";
				_qryHisStudy.FieldByName("study_charge").Value = fCT_SUM;
				////
				_qryHisStudy.FieldByName("study_source").Value = "住院";
				//_qryHisStudy.FieldByName("patient_guid").Value = sID;//自动编号
				_qryHisStudy.FieldByName("patient_name").Value = sBRXM;
				_qryHisStudy.FieldByName("patient_sex").Value = sPatientSex;
				if (sCSNY != "")
				_qryHisStudy.FieldByName("patient_birthday").Value = sCSNY;
				_qryHisStudy.FieldByName("patient_studyage").Value = sAge;
				_qryHisStudy.FieldByName("patient_telephone").Value = sJTDH;
				_qryHisStudy.FieldByName("patient_address").Value = sHKDZ;
				_qryHisStudy.FieldByName("study_number0").Value = sFPHM;
				_qryHisStudy.FieldByName("study_number2").Value = sMZHM;
				_qryHisStudy.FieldByName("study_number3").Value = sBRCH;
				_qryHisStudy.FieldByName("study_sickregion").Value = sBRBQ;
				_qryHisStudy.FieldByName("study_dttm").Value = sKDRQ;
				_qryHisStudy.FieldByName("study_department").Value = sKSMC;
				_qryHisStudy.FieldByName("study_applicant").Value = sYGXM;
			   _qryHisStudy.Post();
		   	}
		
		    if ( fCR_SUM > 0.0 )
		    {
		        _qryHisStudy.Append();
				_qryHisStudy.FieldByName("study_examkind").Value = "DX";
				_qryHisStudy.FieldByName("study_examname").Value = "数字化摄影(CR)";
				_qryHisStudy.FieldByName("study_charge").Value = fCR_SUM;
				////
				_qryHisStudy.FieldByName("study_source").Value = "住院";
				//_qryHisStudy.FieldByName("patient_guid").Value = sID;//自动编号
				_qryHisStudy.FieldByName("patient_name").Value = sBRXM;
				_qryHisStudy.FieldByName("patient_sex").Value = sPatientSex;
				if (sCSNY != "")
				_qryHisStudy.FieldByName("patient_birthday").Value = sCSNY;
				_qryHisStudy.FieldByName("patient_studyage").Value = sAge;
				_qryHisStudy.FieldByName("patient_telephone").Value = sJTDH;
				_qryHisStudy.FieldByName("patient_address").Value = sHKDZ;
				_qryHisStudy.FieldByName("study_number0").Value = sFPHM;
				_qryHisStudy.FieldByName("study_number2").Value = sMZHM;
				_qryHisStudy.FieldByName("study_number3").Value = sBRCH;
				_qryHisStudy.FieldByName("study_sickregion").Value = sBRBQ;
				_qryHisStudy.FieldByName("study_dttm").Value = sKDRQ;
				_qryHisStudy.FieldByName("study_department").Value = sKSMC;
				_qryHisStudy.FieldByName("study_applicant").Value = sYGXM;
			   _qryHisStudy.Post();
		   	}
    		
    		//初始化
    		fDR_SUM = 0.0;
    		fCT_SUM = 0.0;
    		fCR_SUM = 0.0;
    		sPatientSex="";
    		sYJXH_ini = sYJXH_cur;
    	}
    		
    	fJE = _qryHisCustom.FieldByName("JE").Value;
    	iYLXH = _qryHisCustom.FieldByName("YLXH").Value;
    	if ( iYLXH == 289 )
    		fCR_SUM += fJE;
    	else if ( iYLXH == 30313 )
    		fDR_SUM += fJE;
    	else if ( iYLXH == 290 )
    	{
    		if ( fCR_SUM > 0.0 )
    			fCR_SUM += fJE;
    		else
	    		fDR_SUM += fJE;
    	}
    	else if ( (iYLXH == 330) || (iYLXH == 329) || (iYLXH == 332) || (iYLXH == 30177) )
    		fCT_SUM += fJE;
    	
        _qryHisCustom.Next();
    }

	//输出
	// iProgStep = 40
	sHisQuery = "SELECT top 1 CONVERT(VARCHAR(18),ZYH)+'_'+YSGH as FPHM," +
	"JFRQ as KDRQ,b.KSMC,c.YGXM FROM ZY_FYMX a, GY_KSDM b, GY_YGDM c WHERE ROWID="
		+ IntToStr(iRowId) + " and b.KSDM=a.FYKS and c.YGDM=a.YSGH";
    _qryHisCommon.Close();
    _qryHisCommon.SQL.Text = sHisQuery;
    _qryHisCommon.Open();
    if (!_qryHisCommon.IsEmpty())
    {
	    _qryHisCommon.First();
		sFPHM = _qryHisCommon.FieldByName("FPHM").Value;
    	//sBRXM = _qryHisCommon.FieldByName("BRXM").Value;
		sKDRQ = _qryHisCommon.FieldByName("KDRQ").Value;
		sKSMC = _qryHisCommon.FieldByName("KSMC").Value;
		sYGXM = _qryHisCommon.FieldByName("YGXM").Value;
	}
	////
	if ( sBRXB == "1" )
		sPatientSex = "男";
	else if ( sBRXB == "2" )
		sPatientSex = "女";
		
    if ( fDR_SUM > 0.0 )
    {
        _qryHisStudy.Append();
		_qryHisStudy.FieldByName("study_examkind").Value = "DX";
		_qryHisStudy.FieldByName("study_examname").Value = "数字化摄影(DR)";
		_qryHisStudy.FieldByName("study_charge").Value = fDR_SUM;
		////
		_qryHisStudy.FieldByName("study_source").Value = "住院";
		//_qryHisStudy.FieldByName("patient_guid").Value = sID;//自动编号
		_qryHisStudy.FieldByName("patient_name").Value = sBRXM;
		_qryHisStudy.FieldByName("patient_sex").Value = sPatientSex;
		if (sCSNY != "")
		_qryHisStudy.FieldByName("patient_birthday").Value = sCSNY;
		_qryHisStudy.FieldByName("patient_studyage").Value = sAge;
		_qryHisStudy.FieldByName("patient_telephone").Value = sJTDH;
		_qryHisStudy.FieldByName("patient_address").Value = sHKDZ;
		_qryHisStudy.FieldByName("study_number0").Value = sFPHM;
		_qryHisStudy.FieldByName("study_number2").Value = sMZHM;
		_qryHisStudy.FieldByName("study_number3").Value = sBRCH;
		_qryHisStudy.FieldByName("study_sickregion").Value = sBRBQ;
		_qryHisStudy.FieldByName("study_dttm").Value = sKDRQ;
		_qryHisStudy.FieldByName("study_department").Value = sKSMC;
		_qryHisStudy.FieldByName("study_applicant").Value = sYGXM;
	   _qryHisStudy.Post();
   	}

    if ( fCT_SUM > 0.0 )
    {
        _qryHisStudy.Append();
		_qryHisStudy.FieldByName("study_examkind").Value = "CT";
		_qryHisStudy.FieldByName("study_examname").Value = "X线计算机体层(CT)螺旋扫描";
		_qryHisStudy.FieldByName("study_charge").Value = fCT_SUM;
		////
		_qryHisStudy.FieldByName("study_source").Value = "住院";
		//_qryHisStudy.FieldByName("patient_guid").Value = sID;//自动编号
		_qryHisStudy.FieldByName("patient_name").Value = sBRXM;
		_qryHisStudy.FieldByName("patient_sex").Value = sPatientSex;
		if (sCSNY != "")
		_qryHisStudy.FieldByName("patient_birthday").Value = sCSNY;
		_qryHisStudy.FieldByName("patient_studyage").Value = sAge;
		_qryHisStudy.FieldByName("patient_telephone").Value = sJTDH;
		_qryHisStudy.FieldByName("patient_address").Value = sHKDZ;
		_qryHisStudy.FieldByName("study_number0").Value = sFPHM;
		_qryHisStudy.FieldByName("study_number2").Value = sMZHM;
		_qryHisStudy.FieldByName("study_number3").Value = sBRCH;
		_qryHisStudy.FieldByName("study_sickregion").Value = sBRBQ;
		_qryHisStudy.FieldByName("study_dttm").Value = sKDRQ;
		_qryHisStudy.FieldByName("study_department").Value = sKSMC;
		_qryHisStudy.FieldByName("study_applicant").Value = sYGXM;
	   _qryHisStudy.Post();
   	}

    if ( fCR_SUM > 0.0 )
    {
        _qryHisStudy.Append();
		_qryHisStudy.FieldByName("study_examkind").Value = "DX";
		_qryHisStudy.FieldByName("study_examname").Value = "数字化摄影(CR)";
		_qryHisStudy.FieldByName("study_charge").Value = fCR_SUM;
		////
		_qryHisStudy.FieldByName("study_source").Value = "住院";
		//_qryHisStudy.FieldByName("patient_guid").Value = sID;//自动编号
		_qryHisStudy.FieldByName("patient_name").Value = sBRXM;
		_qryHisStudy.FieldByName("patient_sex").Value = sPatientSex;
		if (sCSNY != "")
		_qryHisStudy.FieldByName("patient_birthday").Value = sCSNY;
		_qryHisStudy.FieldByName("patient_studyage").Value = sAge;
		_qryHisStudy.FieldByName("patient_telephone").Value = sJTDH;
		_qryHisStudy.FieldByName("patient_address").Value = sHKDZ;
		_qryHisStudy.FieldByName("study_number0").Value = sFPHM;
		_qryHisStudy.FieldByName("study_number2").Value = sMZHM;
		_qryHisStudy.FieldByName("study_number3").Value = sBRCH;
		_qryHisStudy.FieldByName("study_sickregion").Value = sBRBQ;
		_qryHisStudy.FieldByName("study_dttm").Value = sKDRQ;
		_qryHisStudy.FieldByName("study_department").Value = sKSMC;
		_qryHisStudy.FieldByName("study_applicant").Value = sYGXM;
	   _qryHisStudy.Post();
   	}

    return 1;
}
//---------------------------------------------------------------------------

int _QueryHisTable()
{
    // 查询脚本
    return ExecSQL();
}
//---------------------------------------------------------------------------

int _ConfirmHisLogin()
{
    // 登记检查
	MessageBox("没有配置确认登记功能！", "电子申请单", 1);
    return 0;
}
//---------------------------------------------------------------------------

int _CancelHisLogin()
{
    // 撤销登记
	MessageBox("没有配置撤销登记功能！", "电子申请单", 1);
    return 0;
}
//---------------------------------------------------------------------------

int _PatientValidate()
{
	return 0;	
}
//---------------------------------------------------------------------------

// 主程序
{
    // Nothing need to do.
}
//---------------------------------------------------------------------------
