Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

测试不同编程语言的源码翻译 #27

Open
nobodxbodon opened this issue May 12, 2019 · 4 comments
Open

测试不同编程语言的源码翻译 #27

nobodxbodon opened this issue May 12, 2019 · 4 comments

Comments

@nobodxbodon
Copy link
Member

nobodxbodon commented May 12, 2019

只要装了语言的vsc支持插件, 应该就可以识别源码中的标识符并批量翻译。这里进行验证,并记录安装的语言插件. 主要关注翻译的覆盖程度, 如发现翻译质量问题, 在其他issue记录.
语言从支持中文命名的开始. 以业务逻辑丰富和专业术语较多的代码段优先, 最好100行左右, 热门项目优先.

已验证的:

@nobodxbodon
Copy link
Member Author

测试环境: 插件v0.0.11; ms-python.python 2019.1.0
Python
https://github.com/OCA/vertical-medical/blob/7ae22f05b55339c3faa198e6ddc766b0d91f6564/medical_disease/models/medical_patient_disease.py

# -*- coding: utf-8 -*-
###############################################################################
#
# Copyright 2008 Luis Falcon <[email protected]>
#
#    This program is free software: you can redistribute it and/or modify
#    it under the terms of the GNU Affero General Public License as
#    published by the Free Software Foundation, either version 3 of the
#    License, or (at your option) any later version.
#
#    This program is distributed in the hope that it will be useful,
#    but WITHOUT ANY WARRANTY; without even the implied warranty of
#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#    GNU Affero General Public License for more details.
#
#    You should have received a copy of the GNU Affero General Public License
#    along with this program.  If not, see <http://www.gnu.org/licenses/>.
#
###############################################################################

from openerp import models, fields, api


class MedicalPatientDisease(models.Model):
    _name = 'medical.patient.disease'
    _description = 'Medical Patient Disease'

    @api.one
    @api.depends('short_comment', 'pathology_id', 'pathology_id.name')
    def _compute_name(self):
        name = self.pathology_id.name
        if self.short_comment:
            name = '%s - %s' % (name, self.short_comment)
        self.name = name

    @api.one
    @api.depends('active')
    def _compute_expire_date(self):
        if self.active:
            self.expire_date = False
        else:
            self.expire_date = fields.Datetime.now()

    @api.one
    def action_invalidate(self):
        self.active = False

    @api.one
    def action_revalidate(self):
        self.active = True

    name = fields.Char(compute='_compute_name', store=True)
    treatment_description = fields.Char()
    expire_date = fields.Datetime(compute='_compute_expire_date', store=True)
    short_comment = fields.Char()
    pathology_id = fields.Many2one(
        comodel_name='medical.pathology', string='Pathology', index=True,
        required=True)
    physician_id = fields.Many2one(
        comodel_name='medical.physician', string='Physician', index=True)
    patient_id = fields.Many2one(
        comodel_name='medical.patient', string='Patient', required=True,
        index=True)
    disease_severity = fields.Selection([
        ('1_mi', 'Mild'),
        ('2_mo', 'Moderate'),
        ('3_sv', 'Severe')
    ], string='Severity')
    state = fields.Selection([
        ('a', 'Acute'),
        ('c', 'Chronic'),
        ('u', 'Unchanged'),
        ('h', 'Healed'),
        ('i', 'Improving'),
        ('w', 'Worsening'),
    ], string='Status of the disease')
    allergy_type = fields.Selection([
        ('da', 'Drug Allergy'),
        ('fa', 'Food Allergy'),
        ('ma', 'Misc Allergy'),
        ('mc', 'Misc Contraindication'),
    ])
    weeks_of_pregnancy = fields.Integer(
        help='Week number of pregnancy when disease contracted',
        string='Pregnancy Week#')
    age = fields.Integer(string='Age when diagnosed')
    active = fields.Boolean(default=True)
    is_infectious = fields.Boolean(string='Infectious Disease')
    is_allergy = fields.Boolean(string='Allergic Disease')
    pregnancy_warning = fields.Boolean()
    is_pregnant = fields.Boolean(string='Pregnancy warning')
    is_on_treatment = fields.Boolean(string='Currently on Treatment')
    treatment_start_date = fields.Date()
    treatment_end_date = fields.Date()
    diagnosed_date = fields.Date(string='Date of Diagnosis')
    healed_date = fields.Date(string='Date of Healing')
    notes = fields.Text()

翻译后:

# -*- coding: utf-8 -*-
###############################################################################
#
# Copyright 2008 Luis Falcon <[email protected]>
#
#    This program is free software: you can redistribute it and/or modify
#    it under the terms of the GNU Affero General Public License as
#    published by the Free Software Foundation, either version 3 of the
#    License, or (at your option) any later version.
#
#    This program is distributed in the hope that it will be useful,
#    but WITHOUT ANY WARRANTY; without even the implied warranty of
#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#    GNU Affero General Public License for more details.
#
#    You should have received a copy of the GNU Affero General Public License
#    along with this program.  If not, see <http://www.gnu.org/licenses/>.
#
###############################################################################

from openerp import 模型, , api


class 医生病人疾病(模型.Model):
    名称 = 'medical.patient.disease'
    描述 = 'Medical Patient Disease'

    @api.one
    @api.depends('短的_备注', '病理学_识别', '病理学_识别.名称')
    def _计算_名称(self):
        名称 = self.病理学_识别.名称
        if self.短的_备注:
            名称 = '%s - %s' % (名称, self.短的_备注)
        self.名称 = 名称

    @api.one
    @api.depends('活跃的')
    def _计算_期满_日期(self):
        if self.活跃的:
            self.过期日期 = False
        else:
            self.过期日期 = .Datetime.now()

    @api.one
    def 方式_使无效(self):
        self.活跃的 = False

    @api.one
    def 方式_使重新生效(self):
        self.活跃的 = True

    名称 = .Char(compute='_计算_名称', store=True)
    治疗_描述 = .Char()
    过期日期 = .Datetime(compute='_计算_期满_日期', store=True)
    短的_备注 = .Char()
    病理学_识别 = .Many2one(
        comodel名称='medical.pathology', string='Pathology', index=True,
        required=True)
    医师_识别 = .Many2one(
        comodel名称='medical.physician', string='Physician', index=True)
    忍耐的_识别 = .Many2one(
        comodel名称='medical.patient', string='Patient', required=True,
        index=True)
    疾病_严格 = .Selection([
        ('1_mi', 'Mild'),
        ('2_mo', 'Moderate'),
        ('3_sv', 'Severe')
    ], string='Severity')
    状态 = .Selection([
        ('a', 'Acute'),
        ('c', 'Chronic'),
        ('u', 'Unchanged'),
        ('h', 'Healed'),
        ('i', 'Improving'),
        ('w', 'Worsening'),
    ], string='Status of the disease')
    变应性_类型 = .Selection([
        ('da', 'Drug Allergy'),
        ('fa', 'Food Allergy'),
        ('ma', 'Misc Allergy'),
        ('mc', 'Misc Contraindication'),
    ])
    星期_of_怀孕 = .Integer(
        help='Week number of pregnancy when disease contracted',
        string='Pregnancy Week#')
    年龄 = .Integer(string='Age when diagnosed')
    活跃的 = .Boolean(default=True)
    为_有传染性的 = .Boolean(string='Infectious Disease')
    为_变应性 = .Boolean(string='Allergic Disease')
    怀孕_警告 = .Boolean()
    为_怀孕的 = .Boolean(string='Pregnancy warning')
    为_打开_治疗 = .Boolean(string='Currently on Treatment')
    治疗_起始_日期 = .Date()
    治疗_端_日期 = .Date()
    诊断_日期 = .Date(string='Date of Diagnosis')
    愈合_日期 = .Date(string='Date of Healing')
    票据 = .Text()

@nobodxbodon
Copy link
Member Author

Java vscjava.vscode-java-pack 0.6.0
https://github.com/Sunny-Nishan/HealthAnalytics/blob/ed194f08499c9cb791569dbce8eaa9c81dcea78e/src/com/spring/controller/DiseaseController.java

package com.spring.controller;

import java.util.List;

import javax.servlet.http.HttpSession;

import org.jboss.logging.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.servlet.ModelAndView;

import com.spring.DAO.DiseaseDAO;
import com.spring.VO.CountryVO;
import com.spring.VO.DiseaseVO;

@Controller
@RequestMapping("/admin")
public class DiseaseController {
	
	@Autowired
	DiseaseDAO disease;

	@RequestMapping(value="/viewDisease.html" , method=RequestMethod.GET)
	public String viewDisease(HttpSession session) throws Exception
	{
		List<Object> list=this.disease.getDisease();
		session.setAttribute("list",list);
		return("admin/viewDisease");
		
	}

	@RequestMapping(value="/addDisease.html" , method=RequestMethod.GET)
	public ModelAndView addDisease()
	{
		return new ModelAndView("admin/addDisease","insertDisease",new DiseaseVO());
		
	}
	
	@RequestMapping(value="/insertDisease" , method=RequestMethod.POST)
	public String insertDisease(@ModelAttribute DiseaseVO insertDisease)
	{
		disease.insertDisease(insertDisease);
		return("redirect:/addDisease.html");
		
	}
	
	@RequestMapping(value="/deleteDisease.html" , method=RequestMethod.GET)
	public String deleteDisease(@Param int id)
	{
		disease.deleteDisease(id);
		return("redirect:/viewDisease.html");
		
	}
	
	@RequestMapping(value="/editDisease.html" , method=RequestMethod.GET)
	public ModelAndView editCountry(@Param int id, HttpSession session)
	{
		List<Object> DiseaseList=this.disease.editDisease(id);
		session.setAttribute("list",DiseaseList);
		
			return new ModelAndView("admin/editDisease","updateDisease",new DiseaseVO()); 
		
	}
	
	@RequestMapping(value="/updateDisease.html" , method=RequestMethod.POST)
	public ModelAndView updateDisease(@ModelAttribute DiseaseVO  updateDisease)
	{
		disease.insertDisease(updateDisease);
		return new ModelAndView("redirect:/viewDisease.html");
		
	}
	
	@RequestMapping(value="/deleteDiseaseisActive.html" , method=RequestMethod.GET)
	public String updateisActive(@Param int id) throws Exception
	{
		this.disease.updateIsactive(id);
		
		return("redirect:/viewDisease.html");
		
	}
}

翻译后:

pack年龄 com.春天.控制器;

import java.util.List;

import javax.servlet.http.HttpSession;

import org.jboss.logging.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.servlet.ModelAndView;

import com.spring.DAO.DiseaseDAO;
import com.spring.VO.CountryVO;
import com.spring.VO.DiseaseVO;

@Controller
@RequestMapping("/admin")
public class 疾病控制器 {
	
	@Autowired
	DiseaseDAO 疾病;

	@RequestMapping(value="/视图疾病.html" , method=RequestMethod.GET)
	public String 视图疾病(HttpSession session) throws Exception
	{
		List<Object> list=this.疾病.getDisease();
		session.setAttribute("list",list);
		return("admin/视图疾病");
		
	}

	@RequestMapping(value="/添加疾病.html" , method=RequestMethod.GET)
	public ModelAndView 添加疾病()
	{
		return new ModelAndView("admin/添加疾病","插入疾病",new DiseaseVO());
		
	}
	
	@RequestMapping(value="/插入疾病" , method=RequestMethod.POST)
	public String 插入疾病(@ModelAttribute DiseaseVO 插入疾病)
	{
		疾病.插入疾病(插入疾病);
		return("redirect:/添加疾病.html");
		
	}
	
	@RequestMapping(value="/删除疾病.html" , method=RequestMethod.GET)
	public String 删除疾病(@Param int id)
	{
		疾病.删除疾病(id);
		return("redirect:/视图疾病.html");
		
	}
	
	@RequestMapping(value="/editDisease.html" , method=RequestMethod.GET)
	public ModelAndView 编辑DOS外部命令:用于设定国家代码(@Param int id, HttpSession session)
	{
		List<Object> DiseaseList=this.疾病.editDisease(id);
		session.setAttribute("list",DiseaseList);
		
			return new ModelAndView("admin/editDisease","更新疾病",new DiseaseVO()); 
		
	}
	
	@RequestMapping(value="/更新疾病.html" , method=RequestMethod.POST)
	public ModelAndView 更新疾病(@ModelAttribute DiseaseVO  更新疾病)
	{
		疾病.插入疾病(更新疾病);
		return new ModelAndView("redirect:/视图疾病.html");
		
	}
	
	@RequestMapping(value="/删除疾病isActive.html" , method=RequestMethod.GET)
	public String updateis活跃的(@Param int id) throws Exception
	{
		this.疾病.updateIs活跃的(id);
		
		return("redirect:/视图疾病.html");
		
	}
}

@nobodxbodon
Copy link
Member Author

PHP felixfbecker.php-pack 1.0.2

<?php
class HealthConditionsPersistence
{
    public static function getById(AcsDataBase $db, $id)
    {
        $query = "SELECT HC.WEIGHT,
                P.PREGNANT, P.DESCRIPTION AS PREGNANT_DESCRIPTION,
                D.SMOKER, D.ALCOHOL, D.DRUGS, D.DIABETES, D.AVC, D.HEART_ATTACK, D.LEPROSY, D.TUBERCULOSIS, D.CANCER, D.IN_BED,
                D.DOMICILED, D.OTHER_PRACTICES, D.MENTAL_HEALTH, D.HYPERTENSION,
                H.HEART_DISEASE, H.INSUFFICIENCY AS HEART_DISEASE_INSUFFICIENCY, H.ANOTHER AS HEART_DISEASE_ANOTHER, 
                H.DONT_KNOWN AS HEART_DISEASE_DONT_KNOWN,
                K.KIDNEY_DISEASE, K.INSUFFICIENCY AS KIDNEY_DISEASE_INSUFFICIENCY, K.ANOTHER AS KIDNEY_DISEASE_ANOTHER, 
                K.DONT_KNOWN AS KIDNEY_DISEASE_DONT_KNOWN,
                R.RESPIRATORY_DISEASE, R.ASTHMA, R.EMPHYSEMA, R.ANOTHER AS RESPIRATORY_DISEASE_ANOTHER, 
                R.DONT_KNOWN AS RESPIRATORY_DISEASE_DONT_KNOWN,
                I.INTERMENT, I.DESCRIPTION AS INTERMENT_DESCRIPTION,
                T.PLANT, T.DESCRIPTION AS PLANT_DESCRIPTION
            FROM tb_health_conditions AS HC
            INNER JOIN tb_pregnant AS P ON P.PREGNANT_ID = HC.ID_PREGNANT
            INNER JOIN tb_diseases AS D ON D.DISEASES_ID = HC.ID_DISEASES
            INNER JOIN tb_heart_disease AS H ON H.HEART_DISEASE_ID = HC.ID_HEART_DISEASE
            INNER JOIN tb_kidney_disease AS K ON K.KIDNEY_DISEASE_ID = HC.ID_KIDNEY_DISEASE
            INNER JOIN tb_respiratory_disease AS R ON R.RESPIRATORY_DISEASE_ID = HC.ID_RESPIRATORY_DISEASE
            INNER JOIN tb_interment AS I ON I.INTERMENT_ID = HC.ID_INTERMENT
            INNER JOIN tb_plant AS T ON T.PLANT_ID = HC.ID_PLANT
            WHERE HC.HEALTH_CONDITIONS_ID = :HEALTH_CONDITIONS_ID";
        return $db->select($query, array(":HEALTH_CONDITIONS_ID" => $id));
    }
    static function insert(AcsDataBase $db, HealthConditionsModel $healthConditions)
    {
        $values = $healthConditions->getValuesToDB();
        $ids[":ID_" . Pregnant::PREGNANT] = $db->insert(self::queryPregnant(), $values[Pregnant::PREGNANT]);
        $ids[":ID_" . Diseases::DISEASES] = $db->insert(self::queryDiseases(), $values[Diseases::DISEASES]);
        $ids[":ID_" . HeartDisease::HEART_DISEASE] = $db->insert(self::queryHearthDisease(), $values[HeartDisease::HEART_DISEASE]);
        $ids[":ID_" . KidneyDisease::KIDNEY_DISEASE] = $db->insert(self::queryKidneyDisease(), $values[KidneyDisease::KIDNEY_DISEASE]);
        $ids[":ID_" . RespiratoryDisease::RESPIRATORY_DISEASE] = $db->insert(self::queryRespiratoryDisease(), $values[RespiratoryDisease::RESPIRATORY_DISEASE]);
        $ids[":ID_" . Interment::INTERMENT] = $db->insert(self::queryInterment(), $values[Interment::INTERMENT]);
        $ids[":ID_" . Plant::PLANT] = $db->insert(self::queryPlant(), $values[Plant::PLANT]);
        if(in_array(false, $ids)){
            return false;
        }
        $ids[":" . HealthConditionsModel::WEIGHT] = $values[HealthConditionsModel::WEIGHT];
        return $db->insert(self::queryHealthConditions(), $ids);
    }
    private static function queryHealthConditions()
    {
        return "INSERT INTO TB_HEALTH_CONDITIONS (WEIGHT, ID_PREGNANT, ID_DISEASES, ID_HEART_DISEASE, 
                        ID_KIDNEY_DISEASE, ID_RESPIRATORY_DISEASE, ID_INTERMENT, ID_PLANT) 
                  VALUES (:WEIGHT, :ID_PREGNANT, :ID_DISEASES, :ID_HEART_DISEASE, 
                        :ID_KIDNEY_DISEASE, :ID_RESPIRATORY_DISEASE, :ID_INTERMENT, :ID_PLANT)";
    }
    private static function queryPregnant()
    {
        return "INSERT INTO TB_PREGNANT (PREGNANT, DESCRIPTION)
                  VALUES (:PREGNANT, :DESCRIPTION)";
    }
    private static function queryDiseases()
    {
        return "INSERT INTO TB_DISEASES (SMOKER, ALCOHOL, DRUGS, HYPERTENSION, DIABETES,AVC, HEART_ATTACK, LEPROSY, TUBERCULOSIS, 
                        CANCER, IN_BED, DOMICILED, OTHER_PRACTICES, MENTAL_HEALTH)
                  VALUES (:SMOKER, :ALCOHOL, :DRUGS, :HYPERTENSION, :DIABETES, :AVC, :HEART_ATTACK, :LEPROSY, :TUBERCULOSIS, 
                        :CANCER, :IN_BED, :DOMICILED, :OTHER_PRACTICES, :MENTAL_HEALTH)";
    }
    private static function queryHearthDisease()
    {
        return "INSERT INTO TB_HEART_DISEASE (HEART_DISEASE, INSUFFICIENCY, ANOTHER, DONT_KNOWN)
                  VALUES (:HEART_DISEASE, :INSUFFICIENCY, :ANOTHER, :DONT_KNOWN)";
    }
    private static function queryKidneyDisease()
    {
        return "INSERT INTO TB_KIDNEY_DISEASE (KIDNEY_DISEASE, INSUFFICIENCY, ANOTHER, DONT_KNOWN) 
                  VALUES (:KIDNEY_DISEASE, :INSUFFICIENCY, :ANOTHER, :DONT_KNOWN)";
    }
    private static function queryRespiratoryDisease()
    {
        return "INSERT INTO TB_RESPIRATORY_DISEASE (RESPIRATORY_DISEASE, ASTHMA, EMPHYSEMA, ANOTHER, DONT_KNOWN) 
                  VALUES (:RESPIRATORY_DISEASE, :ASTHMA, :EMPHYSEMA, :ANOTHER, :DONT_KNOWN)";
    }
    private static function queryInterment()
    {
        return "INSERT INTO TB_INTERMENT (INTERMENT, DESCRIPTION)
                  VALUES (:INTERMENT, :DESCRIPTION)";
    }
    private static function queryPlant()
    {
        return "INSERT INTO TB_PLANT (PLANT, DESCRIPTION)
                  VALUES (:PLANT, :DESCRIPTION)";
    }
}

翻译后:

<?php
class 健康条件固执
{
    public static function 获取被识别(AcsDataBase $db, $id)
    {
        $query = "SELECT HC.WEIGHT,
                P.PREGNANT, P.DESCRIPTION AS PREGNANT_DESCRIPTION,
                D.SMOKER, D.ALCOHOL, D.DRUGS, D.DIABETES, D.AVC, D.HEART_ATTACK, D.LEPROSY, D.TUBERCULOSIS, D.CANCER, D.IN_BED,
                D.DOMICILED, D.OTHER_PRACTICES, D.MENTAL_HEALTH, D.HYPERTENSION,
                H.HEART_DISEASE, H.INSUFFICIENCY AS HEART_DISEASE_INSUFFICIENCY, H.ANOTHER AS HEART_DISEASE_ANOTHER, 
                H.DONT_KNOWN AS HEART_DISEASE_DONT_KNOWN,
                K.KIDNEY_DISEASE, K.INSUFFICIENCY AS KIDNEY_DISEASE_INSUFFICIENCY, K.ANOTHER AS KIDNEY_DISEASE_ANOTHER, 
                K.DONT_KNOWN AS KIDNEY_DISEASE_DONT_KNOWN,
                R.RESPIRATORY_DISEASE, R.ASTHMA, R.EMPHYSEMA, R.ANOTHER AS RESPIRATORY_DISEASE_ANOTHER, 
                R.DONT_KNOWN AS RESPIRATORY_DISEASE_DONT_KNOWN,
                I.INTERMENT, I.DESCRIPTION AS INTERMENT_DESCRIPTION,
                T.PLANT, T.DESCRIPTION AS PLANT_DESCRIPTION
            FROM tb_health_conditions AS HC
            INNER JOIN tb_pregnant AS P ON P.PREGNANT_ID = HC.ID_PREGNANT
            INNER JOIN tb_疾病s AS D ON D.DISEASES_ID = HC.ID_DISEASES
            INNER JOIN tb_heart_疾病 AS H ON H.HEART_DISEASE_ID = HC.ID_HEART_DISEASE
            INNER JOIN tb_kidney_疾病 AS K ON K.KIDNEY_DISEASE_ID = HC.ID_KIDNEY_DISEASE
            INNER JOIN tb_respiratory_疾病 AS R ON R.RESPIRATORY_DISEASE_ID = HC.ID_RESPIRATORY_DISEASE
            INNER JOIN tb_interment AS I ON I.INTERMENT_ID = HC.ID_INTERMENT
            INNER JOIN tb_plant AS T ON T.PLANT_ID = HC.ID_PLANT
            WHERE HC.HEALTH_CONDITIONS_ID = :HEALTH_CONDITIONS_ID";
        return $db->select($query, array(":HEALTH_CONDITIONS_ID" => $id));
    }
    static function 插入(AcsDataBase $db, HealthConditionsModel $healthConditions)
    {
        $values = $healthConditions->getValuesToDB();
        $ids[":ID_" . Pregnant::PREGNANT] = $db->插入(self::查询怀孕的(), $values[Pregnant::PREGNANT]);
        $ids[":ID_" . Diseases::DISEASES] = $db->插入(self::查询疾病(), $values[Diseases::DISEASES]);
        $ids[":ID_" . HeartDisease::HEART_DISEASE] = $db->插入(self::查询炉床疾病(), $values[HeartDisease::HEART_DISEASE]);
        $ids[":ID_" . KidneyDisease::KIDNEY_DISEASE] = $db->插入(self::查询肾疾病(), $values[KidneyDisease::KIDNEY_DISEASE]);
        $ids[":ID_" . RespiratoryDisease::RESPIRATORY_DISEASE] = $db->插入(self::查询呼吸的疾病(), $values[RespiratoryDisease::RESPIRATORY_DISEASE]);
        $ids[":ID_" . Interment::INTERMENT] = $db->插入(self::查询埋葬(), $values[Interment::INTERMENT]);
        $ids[":ID_" . Plant::PLANT] = $db->插入(self::查询植物(), $values[Plant::PLANT]);
        if(in_array(false, $ids)){
            return false;
        }
        $ids[":" . HealthConditionsModel::WEIGHT] = $values[HealthConditionsModel::WEIGHT];
        return $db->插入(self::查询健康条件(), $ids);
    }
    private static function 查询健康条件()
    {
        return "INSERT INTO TB_HEALTH_CONDITIONS (WEIGHT, ID_PREGNANT, ID_DISEASES, ID_HEART_DISEASE, 
                        ID_KIDNEY_DISEASE, ID_RESPIRATORY_DISEASE, ID_INTERMENT, ID_PLANT) 
                  VALUES (:WEIGHT, :ID_PREGNANT, :ID_DISEASES, :ID_HEART_DISEASE, 
                        :ID_KIDNEY_DISEASE, :ID_RESPIRATORY_DISEASE, :ID_INTERMENT, :ID_PLANT)";
    }
    private static function 查询怀孕的()
    {
        return "INSERT INTO TB_PREGNANT (PREGNANT, DESCRIPTION)
                  VALUES (:PREGNANT, :DESCRIPTION)";
    }
    private static function 查询疾病()
    {
        return "INSERT INTO TB_DISEASES (SMOKER, ALCOHOL, DRUGS, HYPERTENSION, DIABETES,AVC, HEART_ATTACK, LEPROSY, TUBERCULOSIS, 
                        CANCER, IN_BED, DOMICILED, OTHER_PRACTICES, MENTAL_HEALTH)
                  VALUES (:SMOKER, :ALCOHOL, :DRUGS, :HYPERTENSION, :DIABETES, :AVC, :HEART_ATTACK, :LEPROSY, :TUBERCULOSIS, 
                        :CANCER, :IN_BED, :DOMICILED, :OTHER_PRACTICES, :MENTAL_HEALTH)";
    }
    private static function 查询炉床疾病()
    {
        return "INSERT INTO TB_HEART_DISEASE (HEART_DISEASE, INSUFFICIENCY, ANOTHER, DONT_KNOWN)
                  VALUES (:HEART_DISEASE, :INSUFFICIENCY, :ANOTHER, :DONT_KNOWN)";
    }
    private static function 查询肾疾病()
    {
        return "INSERT INTO TB_KIDNEY_DISEASE (KIDNEY_DISEASE, INSUFFICIENCY, ANOTHER, DONT_KNOWN) 
                  VALUES (:KIDNEY_DISEASE, :INSUFFICIENCY, :ANOTHER, :DONT_KNOWN)";
    }
    private static function 查询呼吸的疾病()
    {
        return "INSERT INTO TB_RESPIRATORY_DISEASE (RESPIRATORY_DISEASE, ASTHMA, EMPHYSEMA, ANOTHER, DONT_KNOWN) 
                  VALUES (:RESPIRATORY_DISEASE, :ASTHMA, :EMPHYSEMA, :ANOTHER, :DONT_KNOWN)";
    }
    private static function 查询埋葬()
    {
        return "INSERT INTO TB_INTERMENT (INTERMENT, DESCRIPTION)
                  VALUES (:INTERMENT, :DESCRIPTION)";
    }
    private static function 查询植物()
    {
        return "INSERT INTO TB_PLANT (PLANT, DESCRIPTION)
                  VALUES (:PLANT, :DESCRIPTION)";
    }
}

@nobodxbodon
Copy link
Member Author

JavaScript vsc内置语言支持
https://github.com/YouSour/dental_sengRatha/blob/d2623bb49a872a646892b54a11bb13b34b650cb7/dental/client/templates/diseaseItem/diseaseItem.js

/**
 * Index
 */
Template.dental_diseaseItem.onRendered(function() {
  // Create new  alertify
  createNewAlertify(["diseaseItem", 'diseaseCategory']);
});

Template.dental_diseaseItem.events({
  'click .insert': function(e, t) {
    alertify.diseaseItem(fa("plus", "Disease Item"), renderTemplate(
      Template.dental_diseaseItemInsert)).maximize();
  },
  'click .update': function(e, t) {
    var data = this;
    alertify.diseaseItem(fa("pencil", "Disease Item"), renderTemplate(
      Template.dental_diseaseItemUpdate, data)).maximize();
  },
  'click .remove': function(e, t) {
    var self = this;

    alertify.confirm(
      fa("remove", "Disease Item"),
      "Are you sure to delete [" + self._id + "] ?",
      function(closeEvent) {
        Dental.Collection.DiseaseItem.remove(self._id, function(error) {
          if (error) {
            alertify.error(error.message);
          } else {
            alertify.success("Success");
          }
        });
      },
      null
    );
  },
  'click .show': function(e, t) {
    var data = this;
    alertify.diseaseItem(fa("eye", "Disease Item"), renderTemplate(Template.dental_diseaseItemShow,
      data));
  }
});

/**
 * Insert
 */
Template.dental_diseaseItemInsert.onCreated(function() {
  Meteor.subscribe('dental_diseaseCategory');
});

Template.dental_diseaseItemInsert.events({
  'click .diseaseCategoryAddon': function(e, t) {
    alertify.diseaseCategory(fa("plus", "Disease Category"),
      renderTemplate(Template.dental_diseaseCategoryInsert));
  }
});

/**
 * Update
 */
Template.dental_diseaseItemUpdate.onCreated(function() {
  Meteor.subscribe('dental_diseaseCategory');
});

Template.dental_diseaseItemUpdate.events({
  'click .diseaseCategoryAddon': function(e, t) {
    alertify.diseaseCategory(fa("plus", "Disease Category"),
      renderTemplate(Template.dental_diseaseCategoryInsert));
  }
});

/**
 * Hook
 */
AutoForm.hooks({
  dental_diseaseItemInsert: {
    before: {
      insert: function(doc) {
        doc.branchId = Session.get('currentBranch');
        Meteor.call('dental');
        return doc;
      }
    },
    onSuccess: function(formType, result) {
      $('select').each(function() {
        $(this).select2("val", "");
      });

      alertify.success('Success');
    },
    onError: function(formType, error) {
      alertify.error(error.message);
    }
  },
  dental_diseaseItemUpdate: {
    onSuccess: function(formType, result) {
      alertify.diseaseItem().close();
      alertify.success('Success');
    },
    onError: function(formType, error) {
      alertify.error(error.message);
    }
  }

});

标识符大部分未识别:

/**
 * Index
 */
Template.dental_diseaseItem.onRendered(function() {
  // Create new  alertify
  createNewAlertify(["diseaseItem", 'diseaseCategory']);
});

Template.dental_diseaseItem.events({
  'click .插入': function(e, t) {
    alertify.diseaseItem(fa("plus", "Disease Item"), 回报Template(
      Template.dental_diseaseItemInsert)).maximize();
  },
  'click .update': function(e, t) {
    var data = this;
    alertify.diseaseItem(fa("pencil", "Disease Item"), 回报Template(
      Template.dental_diseaseItemUpdate, data)).maximize();
  },
  'click .remove': function(e, t) {
    var self = this;

    alertify.confirm(
      fa("remove", "Disease Item"),
      "Are you sure to delete [" + self._id + "] ?",
      function(closeEvent) {
        Dental.Collection.DiseaseItem.remove(self._id, function(error) {
          if (error) {
            alertify.error(error.message);
          } else {
            alertify.success("Success");
          }
        });
      },
      null
    );
  },
  'click .show': function(e, t) {
    var data = this;
    alertify.diseaseItem(fa("eye", "Disease Item"), 回报Template(Template.dental_diseaseItemShow,
      data));
  }
});

/**
 * Insert
 */
Template.dental_diseaseItemInsert.onCreated(function() {
  Meteor.subscribe('dental_diseaseCategory');
});

Template.dental_diseaseItemInsert.events({
  'click .diseaseCategoryAddon': function(e, t) {
    alertify.diseaseCategory(fa("plus", "Disease Category"),
      回报Template(Template.dental_diseaseCategoryInsert));
  }
});

/**
 * Update
 */
Template.dental_diseaseItemUpdate.onCreated(function() {
  Meteor.subscribe('dental_diseaseCategory');
});

Template.dental_diseaseItemUpdate.events({
  'click .diseaseCategoryAddon': function(e, t) {
    alertify.diseaseCategory(fa("plus", "Disease Category"),
      回报Template(Template.dental_diseaseCategoryInsert));
  }
});

/**
 * Hook
 */
AutoForm.hooks({
  dental_diseaseItemInsert: {
    before: {
      插入: function(doc) {
        doc.branchId = Session.get('currentBranch');
        Meteor.call('dental');
        return doc;
      }
    },
    打开成功: function(formType, result) {
      $('select').each(function() {
        $(this).select2("val", "");
      });

      alertify.success('Success');
    },
    打开错误: function(formType, error) {
      alertify.error(error.message);
    }
  },
  dental_diseaseItemUpdate: {
    打开成功: function(formType, result) {
      alertify.diseaseItem().close();
      alertify.success('Success');
    },
    打开错误: function(formType, error) {
      alertify.error(error.message);
    }
  }

});

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant