/**
 * 药品输入剂量通过转换系数成基础剂量
 * @param medicine 药品
 * @param {number} medicine.dose 输入剂量
 * @param {number} medicine.xbzxs 转换系数
 * @returns {number} 基础剂量
 */
export function CC_Dosage2Basis({dose = 0, xbzxs = 1}) {
    console.log('log-->CC_Dosage2Basis', `dose: ${dose}, xbzxs: ${xbzxs}`);
    if (!xbzxs || xbzxs === 1) return +dose;
    return +dose * xbzxs;
}

/**
 * 药品基础剂量通过转换系数成输入剂量
 * @param medicine 药品
 * @param {number} medicine.oldDose 基础剂量
 * @param {number} medicine.xbzxs 转换系数
 * @param {((value: number, oldValue: number) => boolean) | boolean=true} keep 保留计算结果
 * @returns {number} 输入剂量
 */
export function CC_Basis2Dosage({oldDose = 0, xbzxs = 1}, keep = true) {
    console.log('log-->CC_Basis2Dosage', `basis: ${oldDose}, xbzxs: ${xbzxs}; keep=${typeof keep === 'function' ? '计算' : keep}`);
    if (!xbzxs || xbzxs === 1) return +oldDose;
    const value= +oldDose / xbzxs;
    return (typeof keep === 'function' ? keep(value, oldDose) : keep) ? value : null;
}