//***********************************************************************
//函數(shù)名稱:of_zy_yzfy for n_medicare_minihis
//功能說明:醫(yī)囑錄入后執(zhí)行時提交醫(yī)囑
//函數(shù)參數(shù):
// 1.S_yb_zy_yzfy astr_jyxx 醫(yī)囑費用信息
//函數(shù)返回: (BOOLEAN)
//作者:annicybc 時間:2006/03/22
//***********************************************************************
//==============================================================================
// 交易函數(shù)說明:
//------------------------------------------------------------------------------
// 入口參數(shù)(Data)
// 空~空~空~空 + 本次提交醫(yī)囑的住院號+ 該住院號的醫(yī)囑費用列表ZYMX(用%%分隔)
//醫(yī)囑費用列表ZYMX
//([]表示可以重復(fù),重復(fù)的兩條紀錄之間也以%%分隔)=
//本次提交明細條數(shù)%%[明細序號(N20)+就診類型(11門診,21住院,char(2))+
//退藥標志(1退藥,0正常,char(1))+類別標志(1藥品,2診療,char(1))+
//項目中心端編號(Varchar(20))+項目醫(yī)院端編碼(Varchar(20))+項目醫(yī)院端名稱(varchar(40))+
//項目醫(yī)院端規(guī)格(varchar(30))+項目醫(yī)院端單位(varchar(8))+醫(yī)囑日期(DATETIME)+
//醫(yī)生姓名(varchar(20))+項目單價(N(12,4))+項目數(shù)量(N(12,4),退藥時為負數(shù))+項目貼數(shù)(填1)+
//項目金額(N(10,4))+自負比例(N(5,4))+單復(fù)方標志(C1)]
//------------------------------------------------------------------------------
// 出口參數(shù)(Message)
// 交易結(jié)果~錯誤信息+空~空~空 + 無法保存的住院號列表 + 無法保存的費用流水號列表(列表間%%分隔)
//==============================================================================
String lpData[3]
String lpMessage = Space(3000),ls_data2=space(3000)
String ls_CheckData[],ls_CheckData2[]
Integer li_Rtn,i=1,j=1,k=1,h=1,li_detailsum
string ls_zyhm='',ls_wfbc_zyhlb='',ls_wfbc_yzlslb='',ls_wfbc_fylslb='',ls_yzfylb=''
string Prescription = '',Prescription2 = '',Prescription3 = ''
string Ls_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
for i = 1 to Upperbound(astr_jyxx.inzyhm)
ls_zyhm = trim(string(astr_jyxx.inzyhm[i]))
if of_get_tradeid(33) = -1 then
is_error = "申請交易號失敗!"
return false
end if
//取到該住院號對應(yīng)的醫(yī)囑執(zhí)行后產(chǎn)生的明細數(shù)據(jù)
//藥品
select count(*) into :li_detailsum from zy_sfmx where zyhm = :ls_zyhm and ybtj = '0' using sqlhis;
DECLARE SFMX CURSOR FOR
select LSXH from zy_sfmx where zyhm = :ls_zyhm and ybtj = '0' using sqlhis;
OPEN SFMX;
J = 1
DO WHILE J = li_detailsum
FETCH SFMX INTO :LS_LSXH;
// Ln_lsxh,ls_jzlx,ls_tybz,ls_lbbz,ls_xmzxbh,ls_xmyybm,"ls_xmyymc","ls_xmyygg",
//"ls_xmyydw",ldt_yzrq,ls_ysxm,ln_xmdj,ln_xmsl,ln_xmts,ln_xmje,ln_zfbl,ls_dffbz
select to_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,'99999990.0000'),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
from zy_sfmx a,gy_ypml b,gy_ysml c
where a.zyhm = :ls_zyhm and a.ybtj = '0' and a.xmlx = 1 and a.xmxh = b.ypxh and a.kzys = c.ysdm
order by lsxh
using sqlhis;
if Ls_lbbz='1' then//藥品
select nvl(ypmc,'無'),nvl(ypgg,'無'),to_char(dffbz,'0'),to_char(zydw)
into :ls_xmyymc,:ls_xmyygg,:ls_dffbz,:ls_xmyydw
from gy_ypml
where ybbh=:Ls_xmzxbh and ypxh = :Ls_xmyybm
using sqlhis;
elseif Ls_lbbz='2' then//費用
select nvl(fymc,'無')
into :ls_xmyymc
from gy_fyml
where ybbh=:Ls_xmzxbh and fyxh = :Ls_xmyybm using sqlhis;
ls_xmyygg='無'
ls_dffbz='0'
ls_xmyydw='無'
end if
CHOOSE CASE int(j/10)+1
CASE 1
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);
CASE 2
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);
CASE ELSE
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);
END CHOOSE
J++
LOOP
CLOSE SFMX;
IF J 10 THEN
lpData[1] = "$$~~~~~~" + ls_zyhm + "~~" + char(j) + "~~" + Prescription
ELSEIF J 20 THEN
lpData[2] = "$$~~~~~~" + ls_zyhm + "~~" + char(j - 10) + "~~" + Prescription2
ELSE
lpData[3] = "$$~~~~~~" + ls_zyhm + "~~" + char(j - 20) + "~~" + Prescription3
END IF
FOR K = 1 TO 3
IF ISNULL( lpData[k] ) = FALSE THEN
li_Rtn = f_UserBargaingApply(33,uniquelytradeid,lpData[k],lpMessage,ls_data2)
///////
lpMessage = of_dataunwrap(lpMessage) //數(shù)據(jù)解包
of_checkout(lpMessage,Ref ls_checkdata)
lpData[i]=lpMessage
if li_Rtn 0 then
if Upperbound(ls_checkdata) = 6 then
ls_wfbc_zyhlb = ls_checkdata[4]
ls_wfbc_yzlslb = ls_checkdata[5]
ls_wfbc_fylslb = ls_checkdata[6]
elseif Upperbound(ls_checkdata) = 1 then
is_Error = "上傳醫(yī)保數(shù)據(jù)失敗!~n~n" + lpData
return false
end if
if trim(ls_wfbc_zyhlb) > '' then
of_checkout2(ls_wfbc_zyhlb,ref ls_checkdata2)//分解無法保存的住院號
for h = 1 to Upperbound(ls_checkdata2)
astr_jyxx.outzyhm[i+h-1] = long(ls_checkdata2[h])//將住院號連續(xù)封裝,避免覆蓋
next
end if
if trim(ls_wfbc_yzlslb) > '' then
of_checkout2(ls_wfbc_yzlslb,ref ls_checkdata2)//分解無法保存的醫(yī)囑流水號列表
for h = 1 to Upperbound(ls_checkdata2)
astr_jyxx.outyzls[i+int(j/10)+1+h-1-1] = long(ls_checkdata2[h]) //將醫(yī)囑流水號連續(xù)封裝,避免覆蓋
next
end if
if trim(ls_wfbc_fylslb) > '' then
of_checkout2(ls_wfbc_fylslb,ref ls_checkdata2)//分解無法保存的費用流水號列表
for i = 1 to Upperbound(ls_checkdata2)
astr_jyxx.outfyls[i+int(j/10)+1+h-1-1] = long(ls_checkdata2[i])//將費用流水號連續(xù)封裝,避免覆蓋
next
end if
end if
choose case li_Rtn
case -1
is_Error = "上傳醫(yī)保數(shù)據(jù)失敗!~n~n" + lpData
return false
case -2
is_Error = "上傳醫(yī)保數(shù)據(jù)失敗!至少有一個住院號由于不在住院中而校驗失敗~n~n" + lpData
return false
case -3
is_Error = "上傳醫(yī)保數(shù)據(jù)失敗!至少有一條費用明細不能保存~n~n" + lpData
return false
end choose
if li_Rtn0 then
is_Error = "上傳醫(yī)保數(shù)據(jù)失敗!~n~n" + lpData
return false
end if
///////
END IF
NEXT
NEXT
RETURN True