CREATE OR REPLACE FUNCTION SF_YF_BSLXX (as_GHH000 in char,as_MZZYBZ in char default '0') return varchar2 is LS_GHH000 SF_BRXXB0.GHH000%type; ls_ZYH000 ZY_BRXXB0.ZYH000%type; LS_GHID00 SF_BRXXB0.GHID00%type; LS_result varchar2(4000); ls_GMS000 YS_BRBQB0.GMS000%type; ls_BRSG00 YS_BRBQB0.BRSG00%type; ls_BRTZ00 YS_BRBQB0.BRTZ00%type; ls_BRID00 BM_BRXXB0.BRID00%type; -- Person Date Comments -- dsm 2021.03.10 create for YFPY-20210308-001 -- dsm 2021.06.03 发药界面显示体重,身高 for YF-20210603-007 -- dsm 2025.01.02 增加入参as_mzzybz for YF-20250106-001 begin if as_MZZYBZ='0' then LS_GHH000:=trim(as_GHH000); select GHID00 into LS_GHID00 from SF_BRXXB0 where GHH000=LS_GHH000; begin select a.GMS000,a.BRSG00,a.BRTZ00 into ls_GMS000,ls_BRSG00,ls_BRTZ00 from YS_BRBQB0 a where GHID00=LS_GHID00; if ls_BRTZ00 is not null then LS_result:='体重:'||ls_BRTZ00||'kg'; end if; if ls_BRSG00 is not null then LS_result:=LS_result||' 身高:'||ls_BRSG00||'cm'; end if; if ls_GMS000 is not null then LS_result:=LS_result||' 过敏史:'||ls_GMS000; end if; exception when others then LS_result:=''; end; elsif as_MZZYBZ='1' then ls_ZYH000:=trim(as_GHH000); select ZYID00,BRID00 into LS_GHID00,ls_BRID00 from ZY_BRXXB0 where ZYH000=ls_ZYH000; --select ZYID00,BRID00 into LS_GHID00,ls_BRID00 from ZY_BRXXB0 where ZYID00=(select max(zyid00) from zy_brxxb0 where ZYH000=ls_ZYH000); begin -- select a.GMS000 into ls_GMS000 from ZS_BRBQB0 a where ZYID00=LS_GHID00; select a.BRSG00,a.BRTZ00 into ls_BRSG00,ls_BRTZ00 from BM_BRXXB0 a where BRID00=ls_BRID00; for c_gmjl in( select distinct (select YPMC00 from BM_YD0000 where YPNM00=a.YPNM00) YPMC00 from YJ_BRGMJL a where BRID00=ls_BRID00 and ZCBZ00='N' ) loop if ls_GMS000 is null then ls_GMS000:=c_gmjl.YPMC00; else ls_GMS000:=ls_GMS000||','||c_gmjl.YPMC00; end if; end loop; if ls_GMS000 is not null then ls_GMS000:=ls_GMS000||' 过敏'; end if; if ls_BRTZ00 is not null then LS_result:='体重:'||ls_BRTZ00||'kg'; end if; if ls_BRSG00 is not null then LS_result:=LS_result||' 身高:'||ls_BRSG00||'cm'; end if; if ls_GMS000 is not null then LS_result:=LS_result||' 过敏史:'||ls_GMS000; --else LS_result:=LS_result||'过敏史:无'; end if; exception when others then LS_result:=''; end; end if; return LS_result; end;