1. 特色方模块
This commit is contained in:
@@ -0,0 +1,54 @@
|
||||
/**
|
||||
* 从 patient-item 等接口响应中解析特色方选方记录
|
||||
*/
|
||||
export function pickSpecialPrescriptionRecord(data) {
|
||||
if (!data || typeof data !== 'object') {
|
||||
return null;
|
||||
}
|
||||
return (
|
||||
data.special_prescription_patient_record
|
||||
|| data.specialPrescriptionPatientRecord
|
||||
|| null
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* 将 apply 接口返回的数据写入处方页 state
|
||||
*/
|
||||
export function applySpecialPrescriptionPayload(page, data) {
|
||||
const categoryMap = { west: 2, chinese: 1, granular: 1 };
|
||||
const prescriptionType = data.prescription_type || 'chinese';
|
||||
page.activeCategory = categoryMap[prescriptionType] || 1;
|
||||
page.loadCurrentCategoryDrugs();
|
||||
const recipes = data.recipes || [];
|
||||
page.currentDrugs.splice(0, page.currentDrugs.length);
|
||||
recipes.forEach((recipe) => {
|
||||
const drugId = recipe.drug_id || recipe.id;
|
||||
page.currentDrugs.push(page.prepareDrugForCart({
|
||||
index_id: recipe.id,
|
||||
id: drugId,
|
||||
drug_id: drugId,
|
||||
drug_name: recipe.drug_name || recipe.name,
|
||||
number: recipe.number || 1,
|
||||
price: recipe.price || 0,
|
||||
buy_price: recipe.buy_price,
|
||||
way_id: recipe.way_id || 0,
|
||||
}));
|
||||
});
|
||||
page.chineseConfig = {
|
||||
...page.chineseConfig,
|
||||
ruleType: data.rule_type ?? 1,
|
||||
dosage: data.dosage ?? data.dose_count ?? 7,
|
||||
dayDosage: data.day_dosage ?? 2,
|
||||
packageMethodId: data.package_method_id ?? 2,
|
||||
};
|
||||
if (data.clinical_diagnose) {
|
||||
page.diagnosisText = data.clinical_diagnose;
|
||||
const names = String(data.clinical_diagnose).split(',').filter(Boolean);
|
||||
page.diagnoses = names.map((name, index) => ({ id: `temp_${index}`, name }));
|
||||
}
|
||||
if (data.doctor_order) {
|
||||
page.medicalAdvice = data.doctor_order;
|
||||
}
|
||||
page.saveToLocalStorage();
|
||||
}
|
||||
Reference in New Issue
Block a user