package org.example.util;

import org.example.entity.Patient;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.*;

public class PatientDataConverterTest {
    
    @Test
    public void testConvertNurseLevel() {
        // 测试数字代码转换
        assertEquals("特级护理", PatientDataConverter.convertNurseLevel("0"));
        assertEquals("一级护理", PatientDataConverter.convertNurseLevel("1"));
        assertEquals("二级护理", PatientDataConverter.convertNurseLevel("2"));
        assertEquals("三级护理", PatientDataConverter.convertNurseLevel("3"));
        assertEquals("未设置", PatientDataConverter.convertNurseLevel("-1"));
        
        // 测试已有的中文描述
        assertEquals("特级护理", PatientDataConverter.convertNurseLevel("特级护理"));
        assertEquals("一级护理", PatientDataConverter.convertNurseLevel("一级护理"));
        
        // 测试空值
        assertNull(PatientDataConverter.convertNurseLevel(null));
        assertEquals("", PatientDataConverter.convertNurseLevel(""));
    }
    
    @Test
    public void testConvertInpatientStatus() {
        // 测试数字代码转换
        assertEquals("入院", PatientDataConverter.convertInpatientStatus("1"));
        assertEquals("已入科", PatientDataConverter.convertInpatientStatus("2"));
        assertEquals("待入科", PatientDataConverter.convertInpatientStatus("3"));
        assertEquals("已出院", PatientDataConverter.convertInpatientStatus("4"));
        assertEquals("未设置", PatientDataConverter.convertInpatientStatus("-1"));
        
        // 测试已有的中文描述
        assertEquals("入院", PatientDataConverter.convertInpatientStatus("入院"));
        assertEquals("已入科", PatientDataConverter.convertInpatientStatus("已入科"));
        
        // 测试空值
        assertNull(PatientDataConverter.convertInpatientStatus(null));
        assertEquals("", PatientDataConverter.convertInpatientStatus(""));
    }
    
    @Test
    public void testConvertPatientData() {
        // 测试患者对象转换
        Patient patient = new Patient();
        patient.setNurseLevel("0");
        patient.setInpatientStatus("1");
        
        Patient convertedPatient = PatientDataConverter.convertPatientData(patient);
        
        assertEquals("特级护理", convertedPatient.getNurseLevel());
        assertEquals("入院", convertedPatient.getInpatientStatus());
        
        // 测试null对象
        assertNull(PatientDataConverter.convertPatientData(null));
    }
}