//***********************************************************************
//函数名称:of_zy_yzfyforn_medicare_minihis
//功能说明:医嘱录入后执行时提交医嘱
//函数参数:
//1.S_yb_zy_yzfyastr_jyxx医嘱费用信息
//函数返回:(BOOLEAN)
//作者:annicybc时间:2006/03/22
//***********************************************************************
//==============================================================================
//交易函数说明:
//------------------------------------------------------------------------------
//入口参数(Data)
//空~空~空~空+本次提交医嘱的住院号+该住院号的医嘱费用列表ZYMX(用%%分隔)
//医嘱费用列表ZYMX
//([]表示可以重复,重复的两条纪录之间也以%%分隔)=
//本次提交明细条数%%[明细序号(N20)+就诊类型(11门诊,21住院,char(2))+
//退药标志(1退药,0正常,char(1))+类别标志(1药品,2诊疗,char(1))+
//项目中心端编号(Varchar(20))+项目医院端编码(Varchar(20))+项目医院端名称(varchar(40))+
//项目医院端规格(varchar(30))+项目医院端单位(varchar(8))+医嘱日期(DATETIME)+
//医生姓名(varchar(20))+项目单价(N(12,4))+项目数量(N(12,4),退药时为负数)+项目贴数(填1)+
//项目金额(N(10,4))+自负比例(N(5,4))+单复方标志(C1)]
//------------------------------------------------------------------------------
//出口参数(Message)
//交易结果~错误信息+空~空~空+无法保存的住院号列表+无法保存的费用流水号列表(列表间%%分隔)
//============================================================================== StringlpData[3]
StringlpMessage=Space(3000),ls_data2=space(3000)
Stringls_CheckData[],ls_CheckData2[]
Integerli_Rtn,i=1,j=1,k=1,h=1,li_detailsum
stringls_zyhm='',ls_wfbc_zyhlb='',ls_wfbc_yzlslb='',ls_wfbc_fylslb='',ls_yzfylb=''
stringPrescription='',Prescription2='',Prescription3=''
stringLs_lsxh,ls_jzlx,ls_tybz,ls_lbbz,ls_xmzxbh,ls_xmyybm,ls_xmyymc,ls_xmyygg,ls_xmyydw,ls_yzrq,ls_ysxm,Ls_xmdj,Ls_xmsl,Ls_xmts,Ls_xmje,Ls_zfbl,ls_dffbz
fori=1toUpperbound(astr_jyxx.inzyhm)
ls_zyhm=trim(string(astr_jyxx.inzyhm[i])) ifof_get_tradeid(33)=-1then
is_error="申请交易号失败!"
returnfalse
endif //取到该住院号对应的医嘱执行后产生的明细数据
//药品
selectcount(*)into:li_detailsumfromzy_sfmxwherezyhm=:ls_zyhmandybtj='0'usingsqlhis;
DECLARESFMXCURSORFOR
selectLSXHfromzy_sfmxwherezyhm=:ls_zyhmandybtj='0'usingsqlhis;
OPENSFMX;
J=1
DOWHILEJ<=li_detailsum
FETCHSFMXINTO:LS_LSXH;
//Ln_lsxh,"ls_xmyymc","ls_xmyygg",
//"ls_xmyydw",ldt_yzrq,ln_xmdj,ln_xmsl,ln_xmts,ln_xmje,ln_zfbl,ls_dffbz
selectto_char(a.lsxh),to_char(21),to_char(0),to_char(a.xmlx),to_char(a.YBXH),to_char(a.xmxh),
to_char(a.fyrq,'yyyy.mm.dd'),to_char(c.ysxm),to_char(a.fydj,'99999990.0000'),to_char(a.fysl,to_char(1),to_char(a.fydj*a.fysl,'999990.0000'),to_char(a.zfbl,'0.0000'),to_char(b.dffbz)
INTO:Ls_lsxh,:Ls_jzlx,:Ls_tybz,:Ls_lbbz,:Ls_xmzxbh,:Ls_xmyybm,
:Ls_yzrq,:Ls_ysxm,:Ls_xmdj,:Ls_xmsl,:Ls_xmts,:Ls_xmje,:Ls_zfbl
fromzy_sfmxa,gy_ypmlb,gy_ysmlc
wherea.zyhm=:ls_zyhmanda.ybtj='0'anda.xmlx=1anda.xmxh=b.ypxhanda.kzys=c.ysdm
orderbylsxh
usingsqlhis; ifLs_lbbz='1'then//药品
selectnvl(ypmc,'无'),nvl(ypgg,to_char(dffbz,'0'),to_char(zydw)
into:ls_xmyymc,:ls_xmyygg,:ls_dffbz,:ls_xmyydw
fromgy_ypml
whereybbh=:Ls_xmzxbhandypxh=:Ls_xmyybm
usingsqlhis;
elseifLs_lbbz='2'then//费用
selectnvl(fymc,'无')
into:ls_xmyymc
fromgy_fyml
whereybbh=:Ls_xmzxbhandfyxh=:Ls_xmyybmusingsqlhis;
ls_xmyygg='无'
ls_dffbz='0'
ls_xmyydw='无'
endif
CHOOSECASEint(j/10)+1
CASE1
Prescription=Prescription+trim(Ls_lsxh)+"%%"+trim(Ls_jzlx)+"%%"+trim(Ls_tybz)+"%%"+trim(Ls_lbbz)+"%%"+&
trim(Ls_xmzxbh)+"%%"+trim(Ls_xmyybm)+"%%"+trim(Ls_xmyymc)+"%%"+trim(Ls_xmyygg)+"%%"+trim(Ls_xmyydw)+&
"%%"+trim(Ls_yzrq)+"%%"+trim(Ls_ysxm)+"%%"+trim(Ls_xmdj)+"%%"+trim(Ls_xmsl)+"%%"+trim(Ls_xmts)+"%%"+&
trim(Ls_xmje)+"%%"+trim(Ls_zfbl)+"%%"+trim(Ls_dffbz);
CASE2
Prescription2=Prescription+trim(Ls_lsxh)+"%%"+trim(Ls_jzlx)+"%%"+trim(Ls_tybz)+"%%"+trim(Ls_lbbz)+"%%"+&
trim(Ls_xmzxbh)+"%%"+trim(Ls_xmyybm)+"%%"+trim(Ls_xmyymc)+"%%"+trim(Ls_xmyygg)+"%%"+trim(Ls_xmyydw)+&
"%%"+trim(Ls_yzrq)+"%%"+trim(Ls_ysxm)+"%%"+trim(Ls_xmdj)+"%%"+trim(Ls_xmsl)+"%%"+trim(Ls_xmts)+"%%"+&
trim(Ls_xmje)+"%%"+trim(Ls_zfbl)+"%%"+trim(Ls_dffbz);
CASEELSE
Prescription3=Prescription+trim(Ls_lsxh)+"%%"+trim(Ls_jzlx)+"%%"+trim(Ls_tybz)+"%%"+trim(Ls_lbbz)+"%%"+&
trim(Ls_xmzxbh)+"%%"+trim(Ls_xmyybm)+"%%"+trim(Ls_xmyymc)+"%%"+trim(Ls_xmyygg)+"%%"+trim(Ls_xmyydw)+&
"%%"+trim(Ls_yzrq)+"%%"+trim(Ls_ysxm)+"%%"+trim(Ls_xmdj)+"%%"+trim(Ls_xmsl)+"%%"+trim(Ls_xmts)+"%%"+&
trim(Ls_xmje)+"%%"+trim(Ls_zfbl)+"%%"+trim(Ls_dffbz);
ENDCHOOSE
J++
LOOP
CLOSESFMX; IFJ<10THEN
lpData[1]="$$~~~~~~"+ls_zyhm+"~~"+char(j)+"~~"+Prescription
ELSEIFJ<20THEN
lpData[2]="$$~~~~~~"+ls_zyhm+"~~"+char(j-10)+"~~"+Prescription2
ELSE
lpData[3]="$$~~~~~~"+ls_zyhm+"~~"+char(j-20)+"~~"+Prescription3
ENDIF
FORK=1TO3
IFISNULL(lpData[k])=FALSETHEN li_Rtn=f_UserBargaingApply(33,uniquelytradeid,lpData[k],lpMessage,ls_data2)
///////
lpMessage=of_dataunwrap(lpMessage)//数据解包
of_checkout(lpMessage,Refls_checkdata)
lpData[i]=lpMessage ifli_Rtn<0then
ifUpperbound(ls_checkdata)=6then
ls_wfbc_zyhlb=ls_checkdata[4]
ls_wfbc_yzlslb=ls_checkdata[5]
ls_wfbc_fylslb=ls_checkdata[6]
elseifUpperbound(ls_checkdata)=1then
is_Error="上传医保数据失败!~n~n"+lpData
returnfalse
endif iftrim(ls_wfbc_zyhlb)<>''then
of_checkout2(ls_wfbc_zyhlb,refls_checkdata2)//分解无法保存的住院号
forh=1toUpperbound(ls_checkdata2)
astr_jyxx.outzyhm[i+h-1]=long(ls_checkdata2[h])//将住院号连续封装,避免覆盖
next
endif
iftrim(ls_wfbc_yzlslb)<>''then
of_checkout2(ls_wfbc_yzlslb,refls_checkdata2)//分解无法保存的医嘱流水号列表
forh=1toUpperbound(ls_checkdata2)
astr_jyxx.outyzls[i+int(j/10)+1+h-1-1]=long(ls_checkdata2[h])//将医嘱流水号连续封装,避免覆盖
next
endif
iftrim(ls_wfbc_fylslb)<>''then
of_checkout2(ls_wfbc_fylslb,refls_checkdata2)//分解无法保存的费用流水号列表
fori=1toUpperbound(ls_checkdata2)
astr_jyxx.outfyls[i+int(j/10)+1+h-1-1]=long(ls_checkdata2[i])//将费用流水号连续封装,避免覆盖
next
endif endif choosecaseli_Rtn
case-1
is_Error="上传医保数据失败!~n~n"+lpData
returnfalse
case-2
is_Error="上传医保数据失败!至少有一个住院号由于不在住院中而校验失败~n~n"+lpData
returnfalse
case-3
is_Error="上传医保数据失败!至少有一条费用明细不能保存~n~n"+lpData
returnfalse
endchoose ifli_Rtn<0then
is_Error="上传医保数据失败!~n~n"+lpData
returnfalse
endif
///////
ENDIF
NEXT
NEXT RETURNTrue