create or replace procedure SP_ZY_DIP_QDMXRZ(
  PYBJKID   in     varchar2                     ,--[1]输入:医保接口ID
  PJKCJBM   in     varchar2                     ,--[2]输入:接口场景编码
  PBRID00   in     number                       ,--[3]输入:BRID00
  PZYID00   in     number                       ,--[4]输入:ZYID000
  PZYH000   in     varchar2                     ,--[5]输入:ZYH000
  PCZY000   in     number                       ,--[6]输入:操作员编码
  PCZYXM0   in     varchar2                     ,--[7]输入:操作员姓名
  PCZYKS0   in     number                       ,--[8]输入:操作员科室
  PQQCSID   in     varchar2  default ''         ,--[9]输入:参数中间ID
  PINXML0   in     varchar2  default ''         ,--[10]输入:请求参数(XML)
  POTHER0   in     varchar2  default ''         ,--[11]输入:备用参数
  PCOMMIT   in     varchar2  default 'N'        ,--[12]输入:是否提交事务 Y:提交 N:不提交
  PZXZT00   out    number                       ,--[13]输出:执行状态 0:失败 1：成功
  POUTXML   out    varchar2                     ,--[14]输出:出参(XML)
  PERRMSG   out    varchar2                      --[15]输出:错误信息
)
as
-- MODIFICATION HISTORY
-- Person      Date          Comments
-- zhangyc     2022.12.13    created 住院DIP清单明细(参考:SP_ZY_GJYBRZ_JSQDSC) by ZYSF9-20221214-003
-- zhangyc     2023.01.04    改为取字典：BM_TYCJZD.CJBM00='SP_TYJK_ZY_DIP_QDFYMX' by ZYSF9-20230105-001
-- zhangyc     2023.01.10    费用明细增加节点prcunt、spec、med_chrgitm、hilist_type、selfpay_prop、ownpay_amt去掉exp_content单位组合 by  ZYSF9-20230110-002
-- linzetao    2023.02.03    手术操作信息(oprninfo列表)增加节点oper_dr_name(手术医生)、anst_dr_name(麻醉医生)、oprn_oprt_date(手术操作日期)    ZYSF9-20230203-002
-- zhangyc     2023.02.07    住院诊断信息:CUR_QUREY_diseinfo 未取到值，直接取院内HIS_QUREY_diseinfo
-- ---------   ----------    -------
  LS_COUNT0        number(12,2);
  LS_CZRQ00        char(8);
  LS_CZSJ00        char(8);
  LS_MSGSTR        varchar2(100); --错误位置信息
  LS_DateTimeStr   varchar2(20); --日期时间型:格式为：yyyy-MM-dd HH:mm:ss
  LS_DateStr       varchar2(10); --日期型:格式为：yyyy-MM-dd
  LS_TimeStr       varchar2(10); --时间型:格式为：HH:mm:ss
  LS_JKFSZ0        ZY_YBJKMX.JKFSZ0%type;--接口发送值
  LS_JKFHZ0        ZY_YBJKMX.JKFHZ0%type;--接口返回值
  LS_VALUE0        ZY_YBJKMX.VALUE0%type;--请求报文字符串
  LS_HISCS0        ZY_YBJKRZ.HISCS0%type;--HIS前台请求参数
  LS_QQDATA        ZY_YBJKRZ.QQDATA%type;--请求报文
  LS_MainJson      ZY_YBJKRZ.QQDATA%type;--主项Json
  LS_detailJson    ZY_YBJKRZ.QQDATA%type;--明细Json
  LS_inputJson     ZY_YBJKRZ.QQDATA%type;--input输入
  LS_diseinfoJson  ZY_YBJKRZ.QQDATA%type;--诊断列表Json
  LS_payinfo       ZY_YBJKRZ.QQDATA%type;--基金支付信息Json
  LS_PayinfoList   ZY_YBJKRZ.QQDATA%type;--基金支付列表Json
  LS_opspdiseinfo  ZY_YBJKRZ.QQDATA%type;--门诊慢特病诊断信息
  LS_opspdiseinfoList ZY_YBJKRZ.QQDATA%type;--门诊慢特病诊断信息列表
  LS_diseinfo      ZY_YBJKRZ.QQDATA%type;--住院诊断信息
  LS_diseinfoList  ZY_YBJKRZ.QQDATA%type;--住院诊断信息列表
  LS_iteminfo      ZY_YBJKRZ.QQDATA%type;--收费项目信息
  LS_iteminfoList  ZY_YBJKRZ.QQDATA%type;--收费项目信息列表
  LS_oprninfo      ZY_YBJKRZ.QQDATA%type;--手术操作信息
  LS_oprninfoList  ZY_YBJKRZ.QQDATA%type;--手术操作信息列表
  LS_icuinfo       ZY_YBJKRZ.QQDATA%type;--重症监护信息
  LS_icuinfoList   ZY_YBJKRZ.QQDATA%type;--重症监护信息列表
  LS_bldinfo       ZY_YBJKRZ.QQDATA%type;--输血信息
  LS_bldinfoList   ZY_YBJKRZ.QQDATA%type;--输血信息列表
  LS_ListJson      ZY_YBJKRZ.QQDATA%type;--listjson

  LS_feedetail     ZY_YBJKRZ.QQDATA%type;--费用明细Json
  LS_feedetailList ZY_YBJKRZ.QQDATA%type;--费用明细列表Json

  ROWJSD           ZY_YBJSD0%rowtype;      --医保结算单主表
  LS_JZDH00        number(10);  --结账单号

  BM_psn_no                BM_BRXXB0.psn_no%type;--psn_no:国家医保]人员编号
  BM_AAE140                BM_BRXXB0.AAE140%type;--[BM_BRXXB0]险种类型编码:310
  BM_AAE140_MC             BM_BRXXB0.AAE140_MC%type;--[BM_BRXXB0]险种类型名称
  BM_ZTQKBH                BM_BRXXB0.ZTQKBH%type;
  BM_XZQH00                BM_BRXXB0.XZQH00%type;
  ZY_psn_no                ZY_BRXXB0.psn_no%type;--psn_no:国家医保]人员编号
  ZY_AAE140                ZY_BRXXB0.AAE140%type;--[ZY_BRXXB0]险种类型编码:310
  ZY_AAE140_MC             ZY_BRXXB0.AAE140_MC%type;--[ZY_BRXXB0]险种类型名称
  ZY_ZYH000                ZY_BRXXB0.ZYH000%type;  --住院号
  ZY_RYRQ00                ZY_BRXXB0.RYRQ00%type;  --入院日期
  ZY_CYRQ00                ZY_BRXXB0.CYRQ00%type;  --出院日期
  LS_YBZYH0                ZY_BRXXB0.YBZYH0%type;  --医保住院号
  LS_DQKS00                ZY_BRXXB0.DQKS00%type;    --当前科室
  LS_DQKSMC                BM_BMBM00.BMMC00%type;    --当前科室名称
  LS_DQBQ00                ZY_BRXXB0.DQBQ00%type;    --当前病区
  LS_DQBQMC                BM_BMBM00.BMMC00%type;    --当前病区名称
  LS_YYKSBM                varchar2(50);             --医院科室编码
  LS_YBKSMC                varchar2(50);             --医保科室名称
  LS_RYLB00                ZY_BRXXB0.RYLB00%type;    --入院类别
  LS_SFXSE0                varchar2(10);             --是否新生儿
  LS_YEXM00                varchar2(50);             --婴儿姓名
  LS_PSN_NO_XSE            ZY_YBJKRZ.PSN_NO%type;    --人员编号
  LS_MDTRT_ID_XSE          ZY_YBJKRZ.MDTRT_ID%type;  --就诊id

  ZY_RYCWH0                ZY_BRXXB0.RYCWH0%type;    --病人住院床号



  LS_mdtrtsn               varchar2(50);    --住院号
  LS_wardarea_no           varchar2(50);    --当前病区编码
  LS_wardarea_name         varchar2(50);    --当前病区名称
  LS_ward_no               varchar2(50);    --当前科室编码
  LS_ward_name             varchar2(50);    --当前科室名称
  LS_bedno                 varchar2(50);    --当前病床号
  LS_rid                   varchar2(50);    --医院结算清单唯一标识
  LS_psn_no                varchar2(30);    --1.psn_no: 人员编号   字符型(30)
  LS_mdtrt_id              varchar2(30);    --2.mdtrt_id: 就诊ID   字符型(30)
  LS_setl_id               varchar2(30);    --3.setl_id: 结算ID   字符型(30)
  LS_hi_no                 varchar2(30);    --4.hi_no: 医保编号   字符型(30)
  LS_medcasno              varchar2(30);    --5.medcasno: 病案号   字符型(40)
  LS_dcla_time             varchar2(20);    --6.dcla_time: 申报时间   日期时间型()
  LS_ntly                  varchar2(6);     --7.ntly: 国籍   字符型(6)
  LS_prfs                  varchar2(6);     --8.prfs: 职业   字符型(6)
  LS_curr_addr             varchar2(200);   --9.curr_addr: 现住址   字符型(200)
  LS_emp_name              varchar2(200);   --10.emp_name: 单位名称   字符型(200)
  LS_emp_addr              varchar2(200);   --11.emp_addr: 单位地址   字符型(200)
  LS_emp_tel               varchar2(50);    --12.emp_tel: 单位电话   字符型(50)
  LS_poscode               varchar2(6);     --13.poscode: 邮编   字符型(6)
  LS_coner_name            varchar2(50);    --14.coner_name: 联系人姓名   字符型(50)
  LS_patn_rlts             varchar2(6);     --15.patn_rlts: 与患者关系   字符型(6)
  LS_coner_addr            varchar2(200);   --16.coner_addr: 联系人地址   字符型(200)
  LS_coner_tel             varchar2(50);    --17.coner_tel: 联系人电话   字符型(50)
  LS_nwb_adm_type          varchar2(3);     --18.nwb_adm_type: 新生儿入院类型   字符型(3)
  LS_nwb_bir_wt            varchar2(10);    --19.nwb_bir_wt: 新生儿出生体重   数值型(6,2)
  LS_nwb_adm_wt            varchar2(10);    --20.nwb_adm_wt: 新生儿入院体重   数值型(6,2)
  LS_mul_nwb_bir_wt        varchar2(50);    --21.mul_nwb_bir_wt: 多新生儿出生体重   字符型(50)
  LS_mul_nwb_adm_wt        varchar2(50);    --22.mul_nwb_adm_wt: 多新生儿入院体重   字符型(50)
  LS_opsp_diag_caty        varchar2(50);    --23.opsp_diag_caty: 门诊慢特病诊断科别   字符型(50)
  LS_opsp_mdtrt_date       varchar2(10);    --24.opsp_mdtrt_date: 门诊慢特病就诊日期   日期型()
  LS_adm_way               varchar2(3);     --25.adm_way: 入院途径   字符型(3)
  LS_trt_type              varchar2(3);     --26.trt_type: 治疗类别   字符型(3)
  LS_adm_time              varchar2(20);    --27.adm_time: 入院时间   日期时间型()
  LS_refldept_dept         varchar2(50);    --28.refldept_dept: 转科科别   字符型(12)
  LS_dscg_time             varchar2(20);    --29.dscg_time: 出院时间   日期时间型()
  LS_dscg_caty             varchar2(6);     --30.dscg_caty: 出院科别   字符型(6)
  LS_otp_wm_dise           varchar2(200);   --31.otp_wm_dise: 门（急）诊西医诊断   字符型(200)
  LS_wm_dise_code          varchar2(20);    --32.wm_dise_code: 西医诊断疾病代码   字符型(20)
  LS_otp_tcm_dise          varchar2(200);   --33.otp_tcm_dise: 门（急）诊中医诊断   字符型(200)
  LS_tcm_dise_code         varchar2(20);    --34.tcm_dise_code: 中医诊断代码   字符型(20)
  LS_vent_used_dura        varchar2(10);    --35.vent_used_dura: 呼吸机使用时长   字符型(10)
  LS_pwcry_bfadm_coma_dura varchar2(10);    --36.pwcry_bfadm_coma_dura: 颅脑损伤患者入院前昏迷时长   字符型(10)
  LS_pwcry_afadm_coma_dura varchar2(10);    --37.pwcry_afadm_coma_dura: 颅脑损伤患者入院后昏迷时长   字符型(10)
  LS_spga_nurscare_days    varchar2(3);     --38.spga_nurscare_days: 特级护理天数   数值型(3)
  LS_lv1_nurscare_days     varchar2(3);     --39.lv1_nurscare_days: 一级护理天数   数值型(3)
  LS_scd_nurscare_days     varchar2(3);     --40.scd_nurscare_days: 二级护理天数   数值型(3)
  LS_lv3_nurscare_days     varchar2(3);     --41.lv3_nurscare_days: 三级护理天数   数值型(3)
  LS_dscg_way              varchar2(3);     --42.dscg_way: 离院方式   字符型(3)
  LS_acp_medins_name       varchar2(100);   --43.acp_medins_name: 拟接收机构名称   字符型(100)
  LS_acp_optins_code       varchar2(30);    --44.acp_optins_code: 拟接收机构代码   字符型(30)
  LS_bill_code             varchar2(50);    --45.bill_code: 票据代码   字符型(50)
  LS_bill_no               varchar2(30);    --46.bill_no: 票据号码   字符型(30)
  LS_biz_sn                varchar2(50);    --47.biz_sn: 业务流水号   字符型(50)
  LS_days_rinp_flag_31     varchar2(3);     --48.days_rinp_flag_31: 出院31天内再住院计划标志   字符型(3)
  LS_days_rinp_pup_31      varchar2(200);   --49.days_rinp_pup_31: 出院31天内再住院目的   字符型(200)
  LS_chfpdr_code           varchar2(30);    --50.chfpdr_code: 主诊医师代码   字符型(30)
  LS_setl_begn_date        varchar2(10);    --51.setl_begn_date: 结算开始日期   日期型()
  LS_setl_end_date         varchar2(10);    --52.setl_end_date: 结算结束日期   日期型()
  LS_medins_fill_dept      varchar2(100);   --53.medins_fill_dept: 医疗机构填报部门   字符型(100)
  LS_medins_fill_psn       varchar2(50);    --54.medins_fill_psn: 医疗机构填报人   字符型(50)
  LS_resp_nurs_code        varchar2(50);    --55.resp_nurs_code: 责任护士代码   字符型(50)
  LS_stas_type             varchar2(10);    --56.stas_type: 状态分类   字符型(10)
  LS_hi_paymtd             varchar2(3);     --57.hi_paymtd: 医保支付方式   字符型(3)

  LS_adm_caty              varchar2(6);     --40.adm_caty: 入院科别   字符型(6)
  LS_fixmedins_name        varchar2(200);   --3.fixmedins_name: 定点医药机构名称   字符型(200)
  LS_fixmedins_code        varchar2(12);    --4.fixmedins_code: 定点医药机构编号   字符型(12)
  LS_hi_setl_lv            varchar2(3);     --5.hi_setl_lv: 医保结算等级   字符型(3)
  LS_psn_name              varchar2(50);    --9.psn_name: 人员姓名   字符型(50)
  LS_gend                  varchar2(6);     --10.gend: 性别   字符型(6)
  LS_brdy                  varchar2(10);    --11.brdy: 出生日期   日期型()
  LS_age                   varchar2(10);    --12.age: 年龄   数值型(4,1)
  LS_nwb_age               varchar2(3);     --14.nwb_age: （年龄不足1周岁）年龄   数值型(3)
  LS_naty                  varchar2(3);     --15.naty: 民族   字符型(3)
  LS_patn_cert_type        varchar2(6);     --16.patn_cert_type: 患者证件类别   字符型(6)
  LS_certno                varchar2(50);    --17.certno: 证件号码   字符型(50)
  LS_hi_type               varchar2(3);     --28.hi_type: 医保类型   字符型(3)
  LS_insuplc               varchar2(6);     --29.insuplc: 参保地   字符型(6)
  LS_sp_psn_type           varchar2(6);     --30.sp_psn_type: 特殊人员类型   字符型(6)
  LS_ipt_med_type          varchar2(3);     --36.ipt_med_type: 住院医疗类型   字符型(3)
  LS_act_ipt_days          varchar2(5);     --44.act_ipt_days: 实际住院天数   数值型(3)
  LS_diag_code_cnt         varchar2(3);     --49.diag_code_cnt: 诊断代码计数   数值型(3)
  LS_oprn_oprt_code_cnt    varchar2(3);     --50.oprn_oprt_code_cnt: 手术操作代码计数   数值型(3)
  LS_bld_cat               varchar2(3);     --54.bld_cat: 输血品种   字符型(3)
  LS_bld_amt               varchar2(6);     --55.bld_amt: 输血量   数值型(6)
  LS_bld_unt               varchar2(3);     --56.bld_unt: 输血计量单位   字符型(3)
  LS_chfpdr_name           varchar2(50);    --69.chfpdr_name: 主诊医师姓名   字符型(50)
  LS_psn_selfpay           varchar2(20);    --73.psn_selfpay: 个人自付   数值型(16,2)
  LS_psn_ownpay            varchar2(20);    --74.psn_ownpay: 个人自费   数值型(16,2)
  LS_acct_pay              varchar2(20);    --75.acct_pay: 个人账户支出   数值型(16,2)
  LS_psn_cashpay           varchar2(20);    --76.psn_cashpay: 个人现金支付   数值型(16,2)
  LS_hsorg                 varchar2(100);   --78.hsorg: 医保机构   字符型(100)
  LS_hsorg_opter           varchar2(50);    --79.hsorg_opter: 医保机构经办人   字符型(50)

  LS_medfee_sumamt         varchar2(20);    --73.medfee_sumamt: 总费用   数值型(16,2)
  LS_psn_type              varchar2(10);    --psn_type 人员类别
  LS_insu_admdvs           varchar2(10);    --insu_admdvs 参保所属医保区划
  LS_psn_hos_type          varchar2(20);    --psn_hos_type 结算清单类型0=住院 1=门诊
  LS_insutype              varchar2(10);    --insutype:险种类型
  LS_poolarea_no           varchar2(10);    --poolarea_no:统筹区编号
  LS_fix_blng_admdvs       varchar2(10);    --fix_blng_admdvs 定点归属医保区划

  YBXZQH_mdtrtarea_admvs   BM_YBXZQH.mdtrtarea_admvs%type;--[国家医保]就医地医保区划

  LS_med_type              varchar2(10);    --6.med_type: 医疗类别   字符型(6)
  LS_bilg_dept_codg        varchar2(30);    --13.bilg_dept_codg: 开单科室编码   字符型(30)
  LS_bilg_dept_name        varchar2(100);   --14.bilg_dept_name: 开单科室名称   字符型(100)
  LS_orders_dr_code        varchar2(30);    --19.orders_dr_code: 受单医生编码   字符型(30)
  LS_orders_dr_name        varchar2(50);    --20.orders_dr_name: 受单医生姓名   字符型(50)

  Pro_QSDJH0     number(10)                 ;--起始单据号
  Pro_ZZDJH0     number(10)                 ;--终止单据号
  Pro_JZDH00     number(10)                 ;--结帐单号
  Pro_ZYID00     number(10)                 ;--住院ID
  Pro_QSRQ00     varchar2(8)                ;--起始日期
  Pro_ZZRQ00     varchar2(8)                ;--截至日期
  Pro_FLAG00     varchar2(1)                ;--标志'5':出院病人补发送医保  调用,
  Pro_YEXM00     varchar2(20)               ;--婴儿姓名
  Pro_SFXYB0     varchar2(1)                ;--是否新医保, 0否1是, 默认0
  Pro_JSXZID     number(10)                 ;--结算选择记录ID
  Pro_INXML0     varchar2(100)              ;--xml入参
  Pro_ID0000     number(10)                 ;--输出:序列号ID
  Pro_ZXZT00     number(10)                 ;--输出:执行状态
  Pro_OUTXML     clob                       ;--输出:xml出参
  Pro_YHMSG0     varchar2(500)              ;--输出:存储过程提示的错误信息
  Pro_SYSMSG     varchar2(500)              ;--输出:系统提示的错误信息

  LS_payinfo_Num        number(12);--[数量]基金支付信息<payinfo>
  LS_opspdiseinfo_Num   number(12);--[数量]门诊慢特病诊断信息<opspdiseinfo>
  LS_diseinfo_Num       number(12);--[数量]住院诊断信息< diseinfo>
  LS_iteminfo_Num       number(12);--[数量]收费项目信息<iteminfo>
  LS_oprninfo_Num       number(12);--[数量]手术操作信息<oprninfo>
  LS_icuinfo_Num        number(12);--[数量]重症监护信息<icuinfo>
  LS_bldinfo_Num        number(12);--[数量]输血信息<bldinfo>
  LS_feedetail_Num      number(12);--[数量]费用明细<feedetail>


  --修改医保发送明细表
  cursor CUR_UPDATE_YBJKMX is
    select YBJKID,JKMXID,JDBM00,ZJDBM0,JKSXBM,JKSXMC,JKFSZ0,JKFHZ0,FSLXBZ
      from ZY_YBJKMX where YBJKID=PYBJKID and FSLXBZ in ('1','3')
        order by JKMXID;

  --查询主项数据
  cursor CUR_QUERY_Main is
    select YBJKID,JKMXID,JDBM00,ZJDBM0,JKSXBM,JKSXMC,JKFSZ0,JKFHZ0,FSLXBZ
      from ZY_YBJKMX where YBJKID=PYBJKID and FSLXBZ in ('1','3') and CJBM00 in ('AllIn')
        order by JKMXID;

  --查询明细数据
  cursor CUR_QUERY_detail is
    select YBJKID,JKMXID,JDBM00,ZJDBM0,JKSXBM,JKSXMC,JKFSZ0,JKFHZ0,FSLXBZ
     from ZY_YBJKMX where YBJKID=PYBJKID and FSLXBZ in ('1','3') and CJBM00=PJKCJBM and JDBM00='setlinfo'
       order by JKMXID;

  --基金支付信息
  cursor CUR_QUREY_payinfo is
    select fund_pay_type,to_char(fund_payamt,'9999999990.99') as fund_payamt
      from ZY_YBJSDX
        where JKJDBM='payinfo'
          and YBJKID=PYBJKID
          and fund_pay_type is not null
        ;

  --门诊慢特病诊断信息
  cursor CUR_QUREY_opspdiseinfo is
    select diag_name,diag_code,oprn_oprt_name,
           oprn_oprt_code,maindiag_flag
      from ZY_YBJSDX
        where JKJDBM='opspdiseinfo'
          and YBJKID=PYBJKID
          and diag_code is not null
            ;

  --住院诊断信息
  cursor CUR_QUREY_diseinfo is
    select diag_type,nvl(diag_code,diag_code_zy) as diag_code,nvl(diag_name,diag_name_zy) as diag_name,nvl(adm_cond_type,adm_cond_type_zy) as adm_cond_type,
           maindiag_flag
      from ZY_YBJSDX
        where JKJDBM='diseinfo'
        and YBJKID=PYBJKID
        and diag_code is not null
        ;

  --收费项目信息
  cursor CUR_QUREY_iteminfo is
    select MED_CHRGITM_TYPE as med_chrgitm,
           to_char(amt,'9999999990.99') as amt,
           to_char(claa_sumfee,'9999999990.99') as claa_sumfee,
           to_char(clab_amt,'9999999990.99') as clab_amt,
           to_char(fulamt_ownpay_amt,'9999999990.99') as fulamt_ownpay_amt,
           to_char(oth_amt,'9999999990.99') as oth_amt
      from ZY_YBJSDX
        where JKJDBM='iteminfo'
          and YBJKID=PYBJKID
          and MED_CHRGITM_TYPE is not null
        ;

  --手术操作信息
  cursor CUR_QUREY_oprninfo is
    select main_oprn_flag as oprn_oprt_type,oprn_oprt_name,oprn_oprt_code,anst_way,
           oper_dr_code,oper_dr_name,anst_dr_code,anst_dr_name,oprn_oprt_begntime,oprn_oprt_endtime,
           anst_begntime,anst_endtime,oprn_oprt_date
     from ZY_YBJSDX
       where JKJDBM='oprninfo'
         and YBJKID=PYBJKID
         and main_oprn_flag is not null
            ;

  --重症监护信息
  cursor CUR_QUREY_icuinfo is
    select scs_cutd_ward_type,scs_cutd_inpool_time,scs_cutd_exit_time,scs_cutd_sum_dura
      from ZY_YBJSDX
        where JKJDBM='icuinfo'
          and YBJKID=PYBJKID
          and scs_cutd_ward_type is not null
             ;

  --输血信息
  cursor CUR_QUREY_bldinfo is
    select bld_cat,bld_amt,bld_unt
      from ZY_YBJSDX
        where JKJDBM='bldinfo'
          and YBJKID=PYBJKID
          and bld_cat is not null and nvl(bld_amt,0)<>0 ;

--His住院诊断信息<diseinfo>开始
--diag_type:诊断类别 (1:西医诊断 2:中医主病诊断 3:中医主证诊断 4:手术操作)
--diag_type:诊断类别 (1:西医主要诊断  2:西医其他诊断  3:中医主病诊断 4:中医主证诊断)
cursor HIS_QUREY_diseinfo is
  select distinct aa.diag_type,aa.diag_code,aa.diag_name,aa.adm_cond_type,aa.maindiag_flag
    from(select decode(a.ZDLB00,'3','1','a','2','e','2','b','3','f','3','1') as diag_type,--1   diag_type   诊断类别   1:西医主要诊断  2:西医其他诊断  3:中医主病诊断 4:中医主证诊断
                substrb(nvl(nvl(a.GJBZBM,SF_XT_GETGJBZBMForICD900(a.ZDM000,'1')),a.ZDM000),1,20) as diag_code,--2   diag_code   诊断代码    varchar2(20)
                nvl(nvl(a.GJBZMC,SF_XT_GETGJBZBMForICD900(a.ZDM000,'2')),a.ZDMC00) as diag_name,--3 diag_name   诊断名称    varchar2(100)
                '4' as adm_cond_type,--4    adm_cond_type   入院病情类型    varchar2(3)     1','有' ,'3','情况不明' '2','临床未确定' '4','无'
                decode(a.ZDLB00,'3','1','0') as maindiag_flag--5    maindiag_flag   主诊断标志  varchar2(3) 0:否' '1','是'
           from BQ_BRZDXX A
             where 1=1
               and A.ZYID00=PZYID00
               and A.ZDLB00 not in ('c','d','g','h','i','j') --过滤掉:1:门诊诊断  2:入院诊断   8:初步诊断 c:入院疾病诊断 d:门诊疾病诊断 g:入院证候诊断 h:初步疾病诊断 i:初步证候诊断 j:门诊证候诊断
               and not exists(select 1 from bm_zyjb00 d where a.zdm000=d.jbbh00)
               and not exists(select 1 from bm_zyzh00 e where a.zdm000=e.zhbh00)
        ) aa order by aa.maindiag_flag desc
;

--手术操作信息<oprninfo>开始
cursor HIS_QUREY_oprninfo is
  select aa.oprn_oprt_type,        --oprn_oprt_type  手术操作类别    varchar2(3)     1:主要手术及操作' '2','其他手术及操作'
         aa.oprn_oprt_name,        --oprn_oprt_name  手术操作名称    varchar2(500)
         aa.oprn_oprt_code,        --oprn_oprt_code  手术操作代码    varchar2(30)
         aa.oprn_oprt_date,        --oprn_oprt_date  手术操作日期    number(8)
         aa.anst_way,              --anst_way    麻醉方式    varchar2(6) =xt_mzfs00
         aa.oper_dr_name,          --oper_dr_name    术者医师姓名    varchar2(50)
         aa.oper_dr_code,          --oper_dr_code    术者医师代码    varchar2(20)
         aa.anst_dr_name,          --anst_dr_name    麻醉医师姓名    varchar2(50)
         aa.anst_dr_code,          --anst_dr_name    麻醉医师姓名    varchar2(50)
         rpad(aa.oprn_oprt_begntime,14,'0') as oprn_oprt_begntime,--oprn_oprt_begntime 手术开始时间    number(14)
         rpad(aa.oprn_oprt_endtime,14,'0') as oprn_oprt_endtime,   --oprn_oprt_endtime   手术结束时间    number(14)
         rpad(aa.anst_begntime,14,'0')   as anst_begntime,     --anst_begntime  麻醉开始时间    number(14)
         rpad(aa.anst_endtime,14,'0')     as anst_endtime      --anst_endtime    麻醉结束时间    number(14)
    from (select decode(bb.SFZSS0,'0','1','2') as oprn_oprt_type,--1 oprn_oprt_type  手术操作类别    varchar2(3)     1:主要手术及操作' '2','其他手术及操作'
                 bb.SSXMJC as oprn_oprt_name,--2 oprn_oprt_name  手术操作名称    varchar2(500)
                 nvl(bb.CM3000,SSBH00) as oprn_oprt_code,--3 oprn_oprt_code  手术操作代码    varchar2(30)
                 aa.SQRQ00 as oprn_oprt_date,--4 oprn_oprt_date  手术操作日期    number(8)
                 SF_ZY_GETJSQD_JKFSZ0('anst_mtd_code',aa.MZBH00) as anst_way,--5 anst_way    麻醉方式    varchar2(6) =xt_mzfs00
                 --aa.SSYSXM as oper_dr_name,--6   oper_dr_name    术者医师姓名    varchar2(50)
                 nvl((select t2.zwxm00 from ss_yshsxx t1,bm_ygbm00 t2 where t1.yshslb='主刀医生' and t1.ssdh00=aa.ssdh00 and t1.yshsbh=t2.ygbh00),aa.SSYSXM) as oper_dr_name,--6   oper_dr_name    术者医师姓名    varchar2(50)
                 nvl((select nvl(t2.YBYGDM,t2.YSZJHM) from ss_yshsxx t1,bm_ygbm00 t2 where t1.yshslb='主刀医生' and t1.ssdh00=aa.ssdh00 and t1.yshsbh=t2.ygbh00),
                 (select nvl(t3.YBYGDM,t3.YSZJHM) from bm_ygbm00 t3 where t3.ygbh00=aa.SSYS00)  ) as oper_dr_code,--7   oper_dr_code    术者医师代码    varchar2(20)
                 --aa.MZYSXM as anst_dr_name,--8   anst_dr_name    麻醉医师姓名    varchar2(50)
                 nvl((select t2.zwxm00 from ss_yshsxx t1,bm_ygbm00 t2 where t1.yshslb='麻醉医生' and t1.ssdh00=aa.ssdh00 and t1.yshsbh=t2.ygbh00 and nvl(ZMFMBZ,'0')='0'),aa.MZYSXM) as anst_dr_name,--8   anst_dr_name    麻醉医师姓名    varchar2(50)
                 nvl((select nvl(t2.YBYGDM,t2.YSZJHM) from ss_yshsxx t1,bm_ygbm00 t2 where t1.yshslb='麻醉医生' and t1.ssdh00=aa.ssdh00 and t1.yshsbh=t2.ygbh00 and nvl(ZMFMBZ,'0')='0'),
                 (select nvl(t3.YBYGDM,t3.YSZJHM) from bm_ygbm00 t3 where t3.ygbh00=SF_XT_RETURNINDEXEH(aa.MZYS00,';',1)) ) as anst_dr_code,--9   anst_dr_code    麻醉医师代码    varchar2(20)
                 aa.SSQSRQ||substrb(aa.SSQSSJ,1,2)||substrb(aa.SSQSSJ,4,2)||substrb(aa.SSQSSJ,7,2) as oprn_oprt_begntime,--10   oprn_oprt_begntime 手术开始时间    number(14)
                 aa.SSJSRQ||substrb(aa.SSJSSJ,1,2)||substrb(aa.SSJSSJ,4,2)||substrb(aa.SSJSSJ,7,2) as oprn_oprt_endtime,--11 oprn_oprt_endtime   手术结束时间    number(14)
                 aa.MZKSRQ||substrb(aa.MZKSSJ,1,2)||substrb(aa.MZKSSJ,4,2)||substrb(aa.MZKSSJ,7,2) as anst_begntime,--12    anst_begntime  麻醉开始时间    number(14)
                 aa.MZJSRQ||substrb(aa.MZJSSJ,1,2)||substrb(aa.MZJSSJ,4,2)||substrb(aa.MZJSSJ,7,2) as anst_endtime,--13   anst_endtime    麻醉结束时间    number(14)
                 bb.ID0000
            from SS_YW0000 aa,SS_YWMX00 bb
              where aa.SSDH00=bb.SSDH00
                and aa.MZZYBZ='1'
                and aa.ZYGHID=PZYID00
                and aa.SSZT00 not in ('1','3','6')
           ) aa order by aa.oprn_oprt_type,aa.ID0000;

  --清单明细 ZY_YBJKQD
  cursor CUR_MXLIST is
    select a.MXID00  as feedetl_sn,           --1. 费用明细流水号
           a.OMXID0  as init_feedetl_sn,      --2. 原费用流水号
           LS_YBZYH0 as mdtrt_id,             --3. 就诊ID
           a.YZH000  as drord_no,             --4. 医嘱号
           LS_psn_no as psn_no,               --5. 人员编号
           LS_med_type as med_type,           --6. 医疗类别
           a.FPXMBH as  med_chrgitm,          --med_chrgitm 医疗收费项目
           --decode(a.FLAG00,'1','1','2','1','0') as hilist_type,--hilist_type三目类型 --1  药品  2 诊疗项目 3  服务设施  4 耗材
           decode(INSTRB(XMBH00,'C',1,1),1,'4',decode(a.fpxmbh,'01','1','02','1','03','1','27','4','2')) as hilist_type,--hilist_type三目类型 --1  药品  2 诊疗项目 3  服务设施  4 耗材
           substr(a.CZRQ00,1,4)||'-'||substr(a.CZRQ00,5,2)||'-'||substr(a.CZRQ00,7,2)||' '||a.CZSJ00 as fee_ocur_time,    --7. 费用发生时间
           trim(a.XMBH00) as med_list_codg,                  --8. 医疗目录编码
           a.SFXMID as medins_list_codg,                     --9. 医药机构目录编码
           a.XMJE00 as det_item_fee_sumamt,                  --10. 明细项目费用总额
           a.XMSL00 as cnt,                                  --11. 数量
           a.XMDJ00 as pric,                                 --12. 单价
           a.XMDW00 as prcunt,                               --prcunt 单位  字符型 50
           a.XMGG00 as spec,                                 --spec 规格  字符型 50
           --null as  selfpay_prop,                            --selfpay_prop 自付比例
           (select b.zfbl00 from bm_ybsfdy b where a.sfxmid=b.sfxmid and b.ybzxlb='1' and rownum=1) selfpay_prop,--selfpay_prop 自付比例
           --null as  ownpay_amt,                              --ownpay_amt 自费金额
           a.XMJE00*(select b.zfbl00 from bm_ybsfdy b where a.sfxmid=b.sfxmid and b.ybzxlb='1' and rownum=1) as  ownpay_amt,--自费金额
           LS_bilg_dept_codg as bilg_dept_codg,              --13. 开单科室编码
           LS_bilg_dept_name as bilg_dept_name,              --14. 开单科室名称
           nvl(SF_XT_TransYSToGJYBDM(a.YSYGBH),a.YSYGBH) as bilg_dr_codg, --15. 开单医生编码
           a.YSXM00 as bilg_dr_name,                         --16. 开单医师姓名
           null as acord_dept_codg,                          --17. 受单科室编码
           null as acord_dept_name,                          --18. 受单科室名称
           null as orders_dr_code,                           --19. 受单医生编码
           null as orders_dr_name,                           --20. 受单医生姓名
           decode(trim(A.SFYB00),'Y','1','2') as hosp_appr_flag,                 --21. 医院审批标志
           null as tcmdrug_used_way,                         --22. 中药使用方式
           '0'  as etip_flag,                                --23. 外检标志
           null as etip_hosp_code,                           --24. 外检医院编码
           null as dscg_tkdrug_flag,                         --25. 出院带药标志
           null as matn_fee_flag,                            --26. 生育费用标志
           null as memo,                                      --27. 备注
           null as comb_no,                                  --28. 组套编号
           --'{\"prcunt\":\"'||a.XMDW00||'\"}' as expContent,  --29. 字段扩展
           null as expContent,  --29. 字段扩展
           nvl(a.bke181,a.XMBH00) as fixmedins_hilist_id, --fixmedins_hilist_id 项目编码  字符型 50
           nvl(a.bke182,a.xmmc00) as fixmedins_hilist_name,--fixmedins_hilist_name  项目名称  字符型 100
           trim(a.XMBH00) as hilist_code,                  --hilist_code  医保项目编码  字符型 50
           trim(a.xmmc00) as hilist_name                   --hilist_name  医保项目名称  字符型 100
      from ZY_YBFSMX A
        where ID0000=Pro_ID0000 and nvl(YBFSDH,'0') = '0'
        ;

begin
  PZXZT00:=0;   --输出:执行状态 0:失败 1：成功
  POUTXML:=null;--输出:出参(XML)
  PERRMSG:=null;--输出:错误信息
  LS_QQDATA:=null;--请求报文
  LS_MainJson:=null;---主项Json
  LS_detailJson:=null;---明细Json
  LS_inputJson:=null;---input输入
  LS_ListJson:=null;--listjson
  LS_HISCS0:=substrb(PINXML0,1,2000);
  LS_CZRQ00:=to_char(sysdate,'YYYYMMDD');
  LS_CZSJ00:=to_char(sysdate,'HH24:MI:SS');
  LS_DateTimeStr:=to_char(sysdate,'YYYY-MM-DD HH24:MI:SS'); --日期时间型:格式为：yyyy-MM-dd HH:mm:ss
  LS_DateStr:=to_char(sysdate,'YYYY-MM-DD');               --日期型:格式为：yyyy-MM-dd
  LS_TimeStr:=to_char(sysdate,'HH24:MI:SS');               --时间型:格式为：HH:mm:ss
  LS_JZDH00        :=0;  --结账单号
  LS_payinfo_Num        :=0;--[数量]基金支付信息<payinfo>
  LS_opspdiseinfo_Num   :=0;--[数量]门诊慢特病诊断信息<opspdiseinfo>
  LS_diseinfo_Num       :=0;--[数量]住院诊断信息< diseinfo>
  LS_iteminfo_Num       :=0;--[数量]收费项目信息<iteminfo>
  LS_oprninfo_Num       :=0;--[数量]手术操作信息<oprninfo>
  LS_icuinfo_Num        :=0;--[数量]重症监护信息<icuinfo>
  LS_bldinfo_Num        :=0;--[数量]输血信息<bldinfo>

  LS_MSGSTR:='获取基本信息开始';
  if nvl(PZYID00,0)>0 then
    begin
      select A.ZYH000,A.psn_no,A.AAE140,A.AAE140_MC,B.psn_no,B.AAE140,B.AAE140_MC,A.RYRQ00,A.CYRQ00,
             a.YBZYH0,a.DQKS00,a.DQBQ00,a.RYLB00,A.RYCWH0,B.ZTQKBH,B.XZQH00
        into ZY_ZYH000,ZY_psn_no,ZY_AAE140,ZY_AAE140_MC,BM_psn_no,BM_AAE140,BM_AAE140_MC,ZY_RYRQ00,ZY_CYRQ00,
             LS_YBZYH0,LS_DQKS00,LS_DQBQ00,LS_RYLB00,ZY_RYCWH0,BM_ZTQKBH,BM_XZQH00
        from ZY_BRXXB0 A,BM_BRXXB0 B
          where 1=1
            and A.BRID00 = B.BRID00
            and A.BRID00=PBRID00
            and A.ZYID00=PZYID00;
    exception
      when others  then
        BM_psn_no                :=null;--psn_no:国家医保]人员编号
        BM_AAE140                :=null;--[BM_BRXXB0]险种类型编码:310
        BM_AAE140_MC             :=null;--[BM_BRXXB0]险种类型名称
        ZY_psn_no                :=null;--psn_no:国家医保]人员编号
        ZY_AAE140                :=null;--[ZY_BRXXB0]险种类型编码:310
        ZY_AAE140_MC             :=null;--[ZY_BRXXB0]险种类型名称
    end;

    LS_MSGSTR:='变量转化';

    LS_psn_no:=nvl(ZY_psn_no,BM_psn_no);
    if LS_med_type is null and LS_RYLB00 is not null then
      LS_med_type := substrb(SF_XT_GETGJYBZDByMC0000('med_type',LS_RYLB00,'1'),1,10);
    end if;
    if LS_med_type is null then
      LS_med_type := '21';
    end if;

    begin
      select  BMMC00 into LS_DQBQMC from BM_BMBM00 where BMBH00=LS_DQBQ00;
    exception
      when others then
        LS_DQBQMC := null;
    end;

    --取当前科室名称
    begin
      select BMMC00 into LS_DQKSMC from BM_BMBM00 where BMBH00=LS_DQKS00;
    exception
      when others then
        LS_DQKSMC := LS_DQBQMC;
    end;
    LS_YYKSBM :=substrb(SF_ZY_GETYYKSBM(PZYID00, 0),1,30);      --医院科室编码

    LS_bilg_dept_codg := substrb(SF_XT_TransKSBMToGJYBBM(LS_DQKS00,1),1,30);
    LS_bilg_dept_name := substrb(SF_XT_GETYBKSMC(LS_DQKS00,LS_bilg_dept_codg),1,100);
    LS_bilg_dept_codg := substrb(nvl(LS_bilg_dept_codg,LS_DQKS00),1,30);
    LS_bilg_dept_name := substrb(nvl(LS_bilg_dept_name,LS_DQKSMC),1,100);

    LS_SFXSE0 := trim(substrb(SF_XT_GETXMLSTR('SFXSE0',PINXML0),1,10));--是否新生儿
    LS_YEXM00 := trim(substrb(SF_XT_GETXMLSTR('YEXM00',PINXML0),1,50));--婴儿姓名
    if LS_SFXSE0 = '1' and nvl(LS_YEXM00,'全部') not in ('全部','母亲') then
      select max(psn_no),max(YBZYH0)
        into LS_PSN_NO_XSE,LS_mdtrt_id_XSE
        from BQ_JSXX00
          where ZYID00=PZYID00 and YEXM00=LS_YEXM00;
      LS_psn_no := nvl(LS_PSN_NO_XSE,LS_psn_no);   --人员编号
      LS_YBZYH0 := nvl(LS_mdtrt_id_XSE,LS_YBZYH0); --就诊id
      LS_med_type := '21';                         --医疗类别
    end if;
  end if;

  LS_MSGSTR:='获取基本信息结束';

  --公共输入
  --1 flag  请求是否成功  字符型 1   Y 1-成功 其他-失败
  insert into ZY_YBJKMX(YBJKID,JKMXID,JDBM00,ZJDBM0,ZDBM00,ZDMC00,JKSXBM,JKSXMC,JKFSZ0,JKFHZ0,FSLXBZ,ZDLX00,BZ0000,CJBM00)
            select PYBJKID,1,'main',null,'flag','请求是否成功(1-成功 其他-失败)','flag','请求是否成功(1-成功 其他-失败)','1',null,'1','1',null,'AllIn'
              from dual;
  --2 cause 错误信息  字符型 500   N 错误信息
  insert into ZY_YBJKMX(YBJKID,JKMXID,JDBM00,ZJDBM0,ZDBM00,ZDMC00,JKSXBM,JKSXMC,JKFSZ0,JKFHZ0,FSLXBZ,ZDLX00,BZ0000,CJBM00)
            select PYBJKID,1,'main',null,'cause','错误信息','cause','错误信息',null,null,'1','1',null,'AllIn'
              from dual;
  --2 pages 总页数 整数型     Y 总页数
  insert into ZY_YBJKMX(YBJKID,JKMXID,JDBM00,ZJDBM0,ZDBM00,ZDMC00,JKSXBM,JKSXMC,JKFSZ0,JKFHZ0,FSLXBZ,ZDLX00,BZ0000,CJBM00)
            select PYBJKID,1,'main',null,'pages','总页数','pages','总页数',null,null,'1','1',null,'AllIn'
              from dual;
  --3 total 总条数 整数型     Y 总条数
  insert into ZY_YBJKMX(YBJKID,JKMXID,JDBM00,ZJDBM0,ZDBM00,ZDMC00,JKSXBM,JKSXMC,JKFSZ0,JKFHZ0,FSLXBZ,ZDLX00,BZ0000,CJBM00)
            select PYBJKID,1,'main',null,'total','总条数','total','总条数',null,null,'1','1',null,'AllIn'
              from dual;
  --4 current 当前页数  整数型     Y 当前页数
  insert into ZY_YBJKMX(YBJKID,JKMXID,JDBM00,ZJDBM0,ZDBM00,ZDMC00,JKSXBM,JKSXMC,JKFSZ0,JKFHZ0,FSLXBZ,ZDLX00,BZ0000,CJBM00)
            select PYBJKID,1,'main',null,'current','当前页数','current','当前页数',null,null,'1','1',null,'AllIn'
              from dual;

  LS_MSGSTR:='调用过程SP_ZY_NEWYBJK_JSQDQUERY';
  --生成结算清单数据(原过程：SP_ZY_NEWYBJK_JSQDQUERY) 新过程：SP_ZY_GJYBJK_JSQDQUERY
  SP_ZY_NEWYBJK_JSQDQUERY(
    PYBJKID     ,--输入:医保接口ID：
    PJKCJBM     ,--输入:接口场景编码 YBJK_GJYBJSD_0001：医疗保障基金结算清单查询 YBJK_JSQDXXSC_001:医疗保障基金结算清单信息上传
    PZYID00     ,--输入:住院ID
    PZYH000     ,--输入:住院号
    PCZY000     ,--输入:操作员编码
    PCZYXM0     ,--输入:操作员姓名
    LS_JZDH00   ,--输入:结账单号
    8           ,--输入:数据获取类型 8:DIP获取数据
    PINXML0     ,--输入(可空):请求参数(XML格式)
    'N'         ,--输入:是否提交事务 Y:提交 N:不提交
    PZXZT00     ,--输出:执行状态 0:失败 1：成功
    POUTXML     ,--输出:返回参数(XML格式)
    PERRMSG      --输出:错误信息
  );
  if PZXZT00 = 0 then
    PZXZT00:=0;
    PERRMSG:=PERRMSG;
    return;
  end if;

  begin
    select * into RowJSD from ZY_YBJSD0 where YBJKID=PYBJKID;
  exception
    when others then
      PERRMSG := '未找到结算清单数据(ZYID00='||PZYID00||')';
      PZXZT00 := 0;   --执行状态 0:失败 1：成功
      return;
  end;

  LS_MSGSTR:='调用过程:SP_ZY_GJYBJK_FJ0000';

  Pro_QSDJH0     :=1;               --起始单据号
  Pro_ZZDJH0     :=9999999999;      --终止单据号
  Pro_JZDH00     :=0;               --结帐单号
  Pro_ZYID00     :=PZYID00;         --住院ID
  Pro_QSRQ00     :=nvl(ZY_RYRQ00,to_char(sysdate,'YYYYMMDD'));            --起始日期
  Pro_ZZRQ00     :=nvl(ZY_CYRQ00,to_char(sysdate,'YYYYMMDD'));            --截至日期
  Pro_FLAG00     :='5';             --标志'5':出院病人补发送医保  调用,
  Pro_YEXM00     :='全部';          --婴儿姓名
  Pro_SFXYB0     :='1';             --是否新医保, 0否1是, 默认0
  Pro_JSXZID     :=0;               --结算选择记录ID
  Pro_INXML0     :=null;            --xml入参
  Pro_ID0000     :=null;            --输出:序列号ID
  Pro_ZXZT00     :=null;            --输出:执行状态
  Pro_OUTXML     :=null;            --输出:xml出参
  Pro_YHMSG0     :=null;            --输出:存储过程提示的错误信息
  Pro_SYSMSG     :=null;            --输出:系统提示的错误信息


  LS_MSGSTR:='调用过程:SP_ZY_GJYBJK_FJ0000';
  --调用过程:SP_ZY_GJYBJK_FJ0000
  SP_ZY_GJYBJK_FJ0000
  (
    Pro_QSDJH0,--ad_QSDJH0     in  out  number  ,                --起始单据号
    Pro_ZZDJH0,--ad_ZZDJH0     in  out  number  ,                --终止单据号
    Pro_JZDH00,--ad_JZDH00     in       number  ,                --结帐单号
    Pro_ZYID00,--ad_ZYID00     in  out  number  ,                --住院ID
    Pro_QSRQ00,--as_QSRQ00     in       varchar2,                --起始日期
    Pro_ZZRQ00,--as_ZZRQ00     in       varchar2,                --截至日期
    Pro_FLAG00,--as_FLAG00     in       char    ,                --标志'5':出院病人补发送医保  调用,
    Pro_YEXM00,--ad_YEXM00     in       char     default '全部',  --婴儿姓名
    Pro_SFXYB0,--ad_SFXYB0     in       char     default '0',     --是否新医保, 0否1是, 默认0
    Pro_JSXZID,--ad_JSXZID     in       number   default 0,       --结算选择记录ID
    Pro_INXML0,--as_INXML0     in       varchar2 default '',      --xml入参
    Pro_ID0000,--ad_ID0000    out       number  ,                  --序列号ID
    Pro_ZXZT00,--ad_ZXZT00    out       number  ,                  --执行状态
    Pro_OUTXML,--as_OUTXML    out       clob    ,                  --xml出参
    Pro_YHMSG0,--as_YHMSG0    out       varchar2,                 --存储过程提示的错误信息
    Pro_SYSMSG--as_SYSMSG    out       varchar2                  --系统提示的错误信息
  );

  if Pro_YHMSG0 is not null then
    PZXZT00:=0;
    PERRMSG:=Pro_YHMSG0;
    return;
  end if;
  --if PZXZT00 = 0 then
  --  PZXZT00:=0;
  --  PERRMSG:=Pro_YHMSG0;
  --  return;
  --end if;


  --获取BM_YBXZQH.mdtrtarea_admvs
  if BM_XZQH00 is not null then
    begin
      select A.mdtrtarea_admvs into YBXZQH_mdtrtarea_admvs
        from BM_YBXZQH A
          where A.admdvs_code=BM_XZQH00;
    exception
      when others  then
        YBXZQH_mdtrtarea_admvs:=null;--[国家医保]就医地医保区划
    end;
  end if;
  --medfee_sumamt: 总费用   数值型(16,2)
  select sum(a.XMJE00) into LS_medfee_sumamt from  ZY_YBFSMX A where ID0000=Pro_ID0000;
  LS_mdtrtsn               :=substrb(ZY_ZYH000,1,50);    --住院号
  LS_wardarea_no           :=substrb(LS_DQBQ00,1,50);    --当前病区编码
  LS_wardarea_name         :=substrb(LS_DQBQMC,1,50);    --当前病区名称
  LS_ward_no               :=substrb(LS_DQKS00,1,50);    --当前科室编码
  LS_ward_name             :=substrb(LS_DQKSMC,1,50);    --当前科室名称
  LS_bedno                 :=substrb(ZY_RYCWH0,1,50);    --当前病床号
  LS_rid                   :=substrb(PZYID00,1,50);      --医院结算清单唯一标识
  LS_psn_no                := substrb(nvl(nvl(ZY_psn_no,BM_psn_no),RowJSD.psn_no),1,30);     --1.psn_no: 人员编号  字符型(30)
  LS_mdtrt_id              := substrb(RowJSD.mdtrt_id,1,30);                                 --2.mdtrt_id: 就诊ID   字符型(30)    varchar2(30);
  LS_setl_id               := substrb(RowJSD.setl_id,1,30);                                  --3.setl_id: 结算ID   字符型(30)    varchar2(30);
  LS_hi_no                 := substrb(RowJSD.hi_no,1,30);                                    --4.hi_no: 医保编号   字符型(30)    varchar2(30);
  LS_medcasno              := substrb(RowJSD.medcasno,1,40);                                 --5.medcasno: 病案号   字符型(40)    varchar2(40);
  LS_dcla_time             := substrb(RowJSD.dcla_time,1,20);                                --6.dcla_time: 申报时间   日期时间型()    varchar2(20);
  LS_ntly                  := substrb(RowJSD.ntly,1,6);                                      --7.ntly: 国籍   字符型(6)    varchar2(6);
  LS_prfs                  := substrb(RowJSD.prfs,1,6);                                      --8.prfs: 职业   字符型(6)    varchar2(6);
  LS_curr_addr             := substrb(RowJSD.curr_addr,1,200);                               --9.curr_addr: 现住址   字符型(200)    varchar2(200);
  LS_emp_name              := substrb(RowJSD.emp_name,1,200);                                --10.emp_name: 单位名称   字符型(200)    varchar2(200);
  LS_emp_addr              := substrb(RowJSD.emp_addr,1,200);                                --11.emp_addr: 单位地址   字符型(200)    varchar2(200);
  LS_emp_tel               := substrb(RowJSD.emp_tel,1,50);                                  --12.emp_tel: 单位电话   字符型(50)    varchar2(50);
  LS_poscode               := substrb(RowJSD.poscode,1,6);                                   --13.poscode: 邮编   字符型(6)    varchar2(6);
  LS_coner_name            := substrb(RowJSD.coner_name,1,50);                               --14.coner_name: 联系人姓名   字符型(50)    varchar2(50);
  LS_patn_rlts             := substrb(RowJSD.patn_rlts,1,6);                                 --15.patn_rlts: 与患者关系   字符型(6)    varchar2(6);
  LS_coner_addr            := substrb(RowJSD.coner_addr,1,200);                              --16.coner_addr: 联系人地址   字符型(200)    varchar2(200);
  LS_coner_tel             := substrb(RowJSD.coner_tel,1,50);                                --17.coner_tel: 联系人电话   字符型(50)    varchar2(50);
  LS_nwb_adm_type          := substrb(RowJSD.nwb_adm_type,1,3);                              --18.nwb_adm_type: 新生儿入院类型   字符型(3)    varchar2(3);
  LS_nwb_bir_wt            := substrb(RowJSD.NWBBIRWT,1,10);                                 --19.nwb_bir_wt: 新生儿出生体重   数值型(6,2)    varchar2(10);
  LS_nwb_adm_wt            := substrb(RowJSD.NWBADMWT,1,10);                                 --20.nwb_adm_wt: 新生儿入院体重   数值型(6,2)    varchar2(10);
  LS_mul_nwb_bir_wt        := substrb(RowJSD.MUL_NWB_BIR_WT,1,50);                           --21.mul_nwb_bir_wt: 多新生儿出生体重   字符型(50) varchar2(50);
  LS_mul_nwb_adm_wt        := substrb(RowJSD.MUL_NWB_ADM_WT,1,50);                           --22.mul_nwb_adm_wt: 多新生儿入院体重   字符型(50) varchar2(50);
  LS_opsp_diag_caty        := substrb(RowJSD.opsp_diag_caty,1,50);                           --23.opsp_diag_caty: 门诊慢特病诊断科别   字符型(50)    varchar2(50);
  LS_opsp_mdtrt_date       := substrb(RowJSD.opsp_mdtrt_date,1,10);                          --24.opsp_mdtrt_date: 门诊慢特病就诊日期   日期型()    varchar2(10);
  LS_adm_way               := substrb(RowJSD.adm_way,1,3);                                   --25.adm_way: 入院途径   字符型(3)    varchar2(3);
  LS_trt_type              := substrb(RowJSD.trt_type,1,3);                                  --26.trt_type: 治疗类别   字符型(3)    varchar2(3);
  LS_adm_time              := substrb(RowJSD.adm_time,1,20);                                 --27.adm_time: 入院时间   日期时间型()    varchar2(20);
  LS_refldept_dept         := substrb(RowJSD.refldept_dept,1,50);                            --28.refldept_dept: 转科科别   字符型(12)    varchar2(12);
  LS_dscg_time             := substrb(RowJSD.dscg_time,1,20);                                --29.dscg_time: 出院时间   日期时间型()    varchar2(20);
  LS_dscg_caty             := substrb(RowJSD.dscg_caty,1,6);                                 --30.dscg_caty: 出院科别   字符型(6)    varchar2(6);
  LS_otp_wm_dise           := substrb(RowJSD.otp_wm_dise,1,200);                             --31.otp_wm_dise: 门（急）诊西医诊断   字符型(200)    varchar2(200);
  LS_wm_dise_code          := substrb(RowJSD.wm_dise_code,1,20);                             --32.wm_dise_code: 西医诊断疾病代码   字符型(20)    varchar2(20);
  LS_otp_tcm_dise          := substrb(RowJSD.otp_tcm_dise,1,200);                            --33.otp_tcm_dise: 门（急）诊中医诊断   字符型(200)    varchar2(200);
  LS_tcm_dise_code         := substrb(RowJSD.tcm_dise_code,1,20);                            --34.tcm_dise_code: 中医诊断代码   字符型(20)    varchar2(20);
  LS_vent_used_dura        := substrb(RowJSD.vent_used_dura,1,10);                           --35.vent_used_dura: 呼吸机使用时长   字符型(10)    varchar2(10);
  LS_pwcry_bfadm_coma_dura := substrb(RowJSD.pwcry_bfadm_coma_dura,1,10);                    --36.pwcry_bfadm_coma_dura: 颅脑损伤患者入院前昏迷时长   字符型(10)    varchar2(10);
  LS_pwcry_afadm_coma_dura := substrb(RowJSD.pwcry_afadm_coma_dura,1,10);                    --37.pwcry_afadm_coma_dura: 颅脑损伤患者入院后昏迷时长   字符型(10)    varchar2(10);
  LS_spga_nurscare_days    := substrb(RowJSD.spga_nurscare_days,1,3);                        --38.spga_nurscare_days: 特级护理天数   数值型(3)    varchar2(3);
  LS_lv1_nurscare_days     := substrb(RowJSD.lv1_nurscare_days,1,3);                         --39.lv1_nurscare_days: 一级护理天数   数值型(3)    varchar2(3);
  LS_scd_nurscare_days     := substrb(RowJSD.scd_nurscare_days,1,3);                         --40.scd_nurscare_days: 二级护理天数   数值型(3)    varchar2(3);
  LS_lv3_nurscare_days     := substrb(RowJSD.lv3_nurscare_days,1,3);                         --41.lv3_nurscare_days: 三级护理天数   数值型(3)    varchar2(3);
  LS_dscg_way              := substrb(RowJSD.dscg_way,1,3);                                  --42.dscg_way: 离院方式   字符型(3)    varchar2(3);
  LS_acp_medins_name       := substrb(RowJSD.acp_medins_name,1,100);                         --43.acp_medins_name: 拟接收机构名称   字符型(100)    varchar2(100);
  LS_acp_optins_code       := substrb(RowJSD.acp_optins_code,1,30);                          --44.acp_optins_code: 拟接收机构代码   字符型(30)    varchar2(30);
  LS_bill_code             := substrb(RowJSD.bill_code,1,50);                                --45.bill_code: 票据代码   字符型(50)    varchar2(50);
  LS_bill_no               := substrb(RowJSD.bill_no,1,30);                                  --46.bill_no: 票据号码   字符型(30)    varchar2(30);
  LS_biz_sn                := substrb(RowJSD.biz_sn,1,50);                                   --47.biz_sn: 业务流水号   字符型(50)    varchar2(50);
  LS_days_rinp_flag_31     := substrb(RowJSD.days_rinp_flag_31,1,3);                         --48.days_rinp_flag_31: 出院31天内再住院计划标志   字符型(3)    varchar2(3);
  LS_days_rinp_pup_31      := substrb(RowJSD.days_rinp_pup_31,1,200);                        --49.days_rinp_pup_31: 出院31天内再住院目的   字符型(200)    varchar2(200);
  LS_chfpdr_code           := substrb(RowJSD.chfpdr_code,1,30);                              --50.chfpdr_code: 主诊医师代码   字符型(30)    varchar2(30);
  LS_setl_begn_date        := substrb(RowJSD.setl_begn_date,1,10);                           --51.setl_begn_date: 结算开始日期   日期型()    varchar2(10);
  LS_setl_end_date         := substrb(RowJSD.setl_end_date,1,10);                            --52.setl_end_date: 结算结束日期   日期型()    varchar2(10);
  LS_medins_fill_dept      := substrb(RowJSD.medins_fill_dept,1,100);                        --53.medins_fill_dept: 医疗机构填报部门   字符型(100)    varchar2(100);
  LS_medins_fill_psn       := substrb(RowJSD.medins_fill_psn,1,50);                          --54.medins_fill_psn: 医疗机构填报人   字符型(50)    varchar2(50);
  LS_resp_nurs_code        := substrb(RowJSD.resp_nurs_code,1,50);                           --55.resp_nurs_code: 责任护士代码   字符型(50)    varchar2(50);
  LS_stas_type             := substrb(RowJSD.stas_type,1,10);                                --56.stas_type: 状态分类   字符型(10)    varchar2(10);
  LS_hi_paymtd             := substrb(RowJSD.hi_paymtd,1,3);                                 --57.hi_paymtd: 医保支付方式   字符型(3)    varchar2(3);

  LS_fixmedins_name        := substrb(RowJSD.fixmedins_name,1,200);                          --3.fixmedins_name: 定点医药机构名称   字符型(200)    varchar2(200);
  LS_fixmedins_code        := substrb(RowJSD.fixmedins_code,1,12);                           --4.fixmedins_code: 定点医药机构编号   字符型(12)    varchar2(12);
  LS_hi_setl_lv            := substrb(RowJSD.hi_setl_lv,1,3);                                --5.hi_setl_lv: 医保结算等级   字符型(3)    varchar2(3);
  LS_psn_name              := substrb(RowJSD.psn_name,1,50);                                 --9.psn_name: 人员姓名   字符型(50)    varchar2(50);
  LS_gend                  := substrb(RowJSD.gend,1,6);                                      --10.gend: 性别   字符型(6)    varchar2(6);
  LS_brdy                  := substrb(RowJSD.brdy,1,10);                                     --11.brdy: 出生日期   日期型()    varchar2(10);
  LS_age                   := substrb(RowJSD.age,1,10);                                      --12.age: 年龄   数值型(4,1)    varchar2(10);
  LS_nwb_age               := substrb(RowJSD.nwb_age,1,3);                                   --14.nwb_age: （年龄不足1周岁）年龄   数值型(3)    varchar2(3);
  LS_naty                  := substrb(RowJSD.naty,1,3);                                      --15.naty: 民族   字符型(3)    varchar2(3);
  LS_patn_cert_type        := substrb(RowJSD.patn_cert_type,1,6);                            --16.patn_cert_type: 患者证件类别   字符型(6)    varchar2(6);
  LS_certno                := substrb(RowJSD.certno,1,50);                                   --17.certno: 证件号码   字符型(50)    varchar2(50);
  LS_hi_type               := substrb(RowJSD.hi_type,1,3);                                   --28.hi_type: 医保类型   字符型(3)    varchar2(3);
  LS_insuplc               := substrb(RowJSD.INSU_ADMDVS,1,6);                               --29.insuplc: 参保地   字符型(6)    varchar2(6);
  LS_sp_psn_type           := substrb(RowJSD.sp_psn_type,1,6);                               --30.sp_psn_type: 特殊人员类型   字符型(6)    varchar2(6);
  LS_ipt_med_type          := substrb(RowJSD.ipt_med_type,1,3);                              --36.ipt_med_type: 住院医疗类型   字符型(3)    varchar2(3);
  LS_adm_caty              := substrb(RowJSD.adm_caty,1,6);                                  --40.adm_caty: 入院科别   字符型(6)    varchar2(6);
  LS_act_ipt_days          := substrb(RowJSD.act_ipt_days,1,5);                              --44.act_ipt_days: 实际住院天数   数值型(3)    varchar2(5);
  LS_diag_code_cnt         := substrb(RowJSD.diag_code_cnt,1,3);                             --49.diag_code_cnt: 诊断代码计数   数值型(3)    varchar2(3);
  LS_oprn_oprt_code_cnt    := substrb(RowJSD.oprn_oprt_code_cnt,1,3);                        --50.oprn_oprt_code_cnt: 手术操作代码计数   数值型(3)    varchar2(3);
  LS_bld_cat               := substrb(RowJSD.bld_cat,1,3);                                   --54.bld_cat: 输血品种   字符型(3)    varchar2(3);
  LS_bld_amt               := substrb(RowJSD.bld_amt,1,6);                                   --55.bld_amt: 输血量   数值型(6)    varchar2(6);
  LS_bld_unt               := substrb(RowJSD.bld_unt,1,3);                                   --56.bld_unt: 输血计量单位   字符型(3)    varchar2(3);
  LS_chfpdr_name           := substrb(RowJSD.chfpdr_name,1,50);                              --69.chfpdr_name: 主诊医师姓名   字符型(50)    varchar2(50);
  LS_psn_selfpay           := substrb(RowJSD.psn_selfpay,1,20);                              --73.psn_selfpay: 个人自付   数值型(16,2)    varchar2(20);
  LS_psn_ownpay            := substrb(RowJSD.psn_ownpay,1,20);                               --74.psn_ownpay: 个人自费   数值型(16,2)    varchar2(20);
  LS_acct_pay              := substrb(RowJSD.acct_pay,1,20);                                 --75.acct_pay: 个人账户支出   数值型(16,2)    varchar2(20);
  LS_psn_cashpay           := substrb(RowJSD.psn_cashpay,1,20);                              --76.psn_cashpay: 个人现金支付   数值型(16,2)    varchar2(20);
  LS_hsorg                 := substrb(RowJSD.HSORG_NAME,1,100);                              --78.hsorg: 医保机构   字符型(100)    varchar2(100);
  LS_hsorg_opter           := substrb(RowJSD.HSORG_OPTER,1,50);                              --79.hsorg_opter: 医保机构经办人   字符型(50)    varchar2(50);
  LS_psn_hos_type          := '0';                                                           --psn_hos_type 结算清单类型0=住院 1=门诊
  LS_insu_admdvs           :=nvl(substrb(RowJSD.INSU_ADMDVS,1,6),BM_XZQH00);                 --insu_admdvs 参保所属医保区划
  LS_insutype              :=nvl(ZY_AAE140,BM_AAE140);                                       --insutype:险种类型
  LS_poolarea_no           :=null;                                                           --poolarea_no:统筹区编号
  LS_fix_blng_admdvs       :=null;                                                           --fix_blng_admdvs 定点归属医保区划
  LS_psn_type              :=BM_ZTQKBH;                                                      --psn_type 人员类别

  if YBXZQH_mdtrtarea_admvs is not null then
    LS_poolarea_no         :=YBXZQH_mdtrtarea_admvs;                                         --poolarea_no:统筹区编号
    LS_fix_blng_admdvs     :=YBXZQH_mdtrtarea_admvs;                                         --fix_blng_admdvs 定点归属医保区划
  end if;

  --插入表ZY_YBJKMX
  insert into ZY_YBJKMX(YBJKID,JKMXID,JDBM00,ZJDBM0,ZDBM00,ZDMC00,
                        JKSXBM,JKSXMC,JKFSZ0,JKFHZ0,FSLXBZ,ZDLX00,BZ0000,CJBM00)
                 select PYBJKID,A.ZDNBID,A.JDBM00,null,substrb(nvl(A.JKDZBM,A.JKSXBM),1,50),substrb(nvl(A.JKDZMC,JKSXMC),1,100),
                        A.JKSXBM,A.JKSXMC,null,null,substrb(a.JKFSLX,1,1),substrb(a.ZDTYPE,1,1),a.BZ0000,PJKCJBM
                   from BM_TYCJZD A
                   where A.CJBM00='SP_TYJK_ZY_DIP_QDFYMX' and A.JDBM00 in ('setlinfo')
                     and nvl(A.SFYX00,'1')='1' and A.JKFSLX in ('1','2','3')
                     ORDER BY ZDNBID;

  --修改:医保发送变量赋值
  for C_YBFS in CUR_UPDATE_YBJKMX loop
    LS_JKFSZ0:=null;--接口发送值
    LS_JKFHZ0:=null;--接口返回值
    LS_VALUE0:=null;--
    if C_YBFS.JKSXBM='mdtrtsn' then--mdtrtsn  住院号
      LS_JKFSZ0:=substrb(LS_mdtrtsn,1,250);
      update ZY_YBJKMX set JKFSZ0=LS_JKFSZ0,JKFHZ0=LS_JKFHZ0,VALUE0=LS_VALUE0 where YBJKID=PYBJKID and JKSXBM=C_YBFS.JKSXBM and JKMXID=C_YBFS.JKMXID;
    elsif C_YBFS.JKSXBM='wardarea_no' then--wardarea_no 当前病区编码
      LS_JKFSZ0:=substrb(LS_wardarea_no,1,250);
      update ZY_YBJKMX set JKFSZ0=LS_JKFSZ0,JKFHZ0=LS_JKFHZ0,VALUE0=LS_VALUE0 where YBJKID=PYBJKID and JKSXBM=C_YBFS.JKSXBM and JKMXID=C_YBFS.JKMXID;
    elsif C_YBFS.JKSXBM='wardarea_name' then--wardarea_name 当前病区名称
      LS_JKFSZ0:=substrb(LS_wardarea_name,1,250);
      update ZY_YBJKMX set JKFSZ0=LS_JKFSZ0,JKFHZ0=LS_JKFHZ0,VALUE0=LS_VALUE0 where YBJKID=PYBJKID and JKSXBM=C_YBFS.JKSXBM and JKMXID=C_YBFS.JKMXID;
    elsif C_YBFS.JKSXBM='ward_no' then--ward_no 当前科室编码
      LS_JKFSZ0:=substrb(LS_ward_no,1,250);
      update ZY_YBJKMX set JKFSZ0=LS_JKFSZ0,JKFHZ0=LS_JKFHZ0,VALUE0=LS_VALUE0 where YBJKID=PYBJKID and JKSXBM=C_YBFS.JKSXBM and JKMXID=C_YBFS.JKMXID;
    elsif C_YBFS.JKSXBM='ward_name' then--ward_name 当前科室名称
      LS_JKFSZ0:=substrb(LS_ward_name,1,250);
      update ZY_YBJKMX set JKFSZ0=LS_JKFSZ0,JKFHZ0=LS_JKFHZ0,VALUE0=LS_VALUE0 where YBJKID=PYBJKID and JKSXBM=C_YBFS.JKSXBM and JKMXID=C_YBFS.JKMXID;
    elsif C_YBFS.JKSXBM='bedno' then--bedno 当前病床号
      LS_JKFSZ0:=substrb(LS_bedno,1,250);
      update ZY_YBJKMX set JKFSZ0=LS_JKFSZ0,JKFHZ0=LS_JKFHZ0,VALUE0=LS_VALUE0 where YBJKID=PYBJKID and JKSXBM=C_YBFS.JKSXBM and JKMXID=C_YBFS.JKMXID;
    elsif C_YBFS.JKSXBM='rid' then--rid 医院结算清单唯一标识
      LS_JKFSZ0:=substrb(LS_rid,1,250);
      update ZY_YBJKMX set JKFSZ0=LS_JKFSZ0,JKFHZ0=LS_JKFHZ0,VALUE0=LS_VALUE0 where YBJKID=PYBJKID and JKSXBM=C_YBFS.JKSXBM and JKMXID=C_YBFS.JKMXID;
    elsif C_YBFS.JKSXBM='mdtrt_id' then--mdtrt_id 就诊ID
      LS_JKFSZ0:=substrb(LS_mdtrt_id,1,250);
      update ZY_YBJKMX set JKFSZ0=LS_JKFSZ0,JKFHZ0=LS_JKFHZ0,VALUE0=LS_VALUE0 where YBJKID=PYBJKID and JKSXBM=C_YBFS.JKSXBM and JKMXID=C_YBFS.JKMXID;
    elsif C_YBFS.JKSXBM='setl_id' then--setl_id 结算ID
      LS_JKFSZ0:=substrb(LS_setl_id,1,250);
      update ZY_YBJKMX set JKFSZ0=LS_JKFSZ0,JKFHZ0=LS_JKFHZ0,VALUE0=LS_VALUE0 where YBJKID=PYBJKID and JKSXBM=C_YBFS.JKSXBM and JKMXID=C_YBFS.JKMXID;
    elsif C_YBFS.JKSXBM='fixmedins_name' then--fixmedins_name 定点医药机构名称
      LS_JKFSZ0:=substrb(LS_fixmedins_name,1,250);
      update ZY_YBJKMX set JKFSZ0=LS_JKFSZ0,JKFHZ0=LS_JKFHZ0,VALUE0=LS_VALUE0 where YBJKID=PYBJKID and JKSXBM=C_YBFS.JKSXBM and JKMXID=C_YBFS.JKMXID;
    elsif C_YBFS.JKSXBM='fixmedins_code' then--fixmedins_code 定点医药机构编号
      LS_JKFSZ0:=substrb(LS_fixmedins_code,1,250);
      update ZY_YBJKMX set JKFSZ0=LS_JKFSZ0,JKFHZ0=LS_JKFHZ0,VALUE0=LS_VALUE0 where YBJKID=PYBJKID and JKSXBM=C_YBFS.JKSXBM and JKMXID=C_YBFS.JKMXID;
    elsif C_YBFS.JKSXBM='hi_setl_lv' then--hi_setl_lv 医保结算等级
      LS_JKFSZ0:=substrb(LS_hi_setl_lv,1,250);
      update ZY_YBJKMX set JKFSZ0=LS_JKFSZ0,JKFHZ0=LS_JKFHZ0,VALUE0=LS_VALUE0 where YBJKID=PYBJKID and JKSXBM=C_YBFS.JKSXBM and JKMXID=C_YBFS.JKMXID;
    elsif C_YBFS.JKSXBM='hi_no' then--hi_no 医保编号
      LS_JKFSZ0:=substrb(LS_hi_no,1,250);
      update ZY_YBJKMX set JKFSZ0=LS_JKFSZ0,JKFHZ0=LS_JKFHZ0,VALUE0=LS_VALUE0 where YBJKID=PYBJKID and JKSXBM=C_YBFS.JKSXBM and JKMXID=C_YBFS.JKMXID;
    elsif C_YBFS.JKSXBM='medcasno' then--medcasno 病案号
      LS_JKFSZ0:=substrb(LS_medcasno,1,250);
      update ZY_YBJKMX set JKFSZ0=LS_JKFSZ0,JKFHZ0=LS_JKFHZ0,VALUE0=LS_VALUE0 where YBJKID=PYBJKID and JKSXBM=C_YBFS.JKSXBM and JKMXID=C_YBFS.JKMXID;
    elsif C_YBFS.JKSXBM='dcla_time' then--dcla_time 申报时间
      LS_JKFSZ0:=substrb(LS_dcla_time,1,250);
      update ZY_YBJKMX set JKFSZ0=LS_JKFSZ0,JKFHZ0=LS_JKFHZ0,VALUE0=LS_VALUE0 where YBJKID=PYBJKID and JKSXBM=C_YBFS.JKSXBM and JKMXID=C_YBFS.JKMXID;
    elsif C_YBFS.JKSXBM='psn_name' then--psn_name 人员姓名
      LS_JKFSZ0:=substrb(LS_psn_name,1,250);
      update ZY_YBJKMX set JKFSZ0=LS_JKFSZ0,JKFHZ0=LS_JKFHZ0,VALUE0=LS_VALUE0 where YBJKID=PYBJKID and JKSXBM=C_YBFS.JKSXBM and JKMXID=C_YBFS.JKMXID;
    elsif C_YBFS.JKSXBM='gend' then--gend 性别
      LS_JKFSZ0:=substrb(LS_gend,1,250);
      update ZY_YBJKMX set JKFSZ0=LS_JKFSZ0,JKFHZ0=LS_JKFHZ0,VALUE0=LS_VALUE0 where YBJKID=PYBJKID and JKSXBM=C_YBFS.JKSXBM and JKMXID=C_YBFS.JKMXID;
    elsif C_YBFS.JKSXBM='brdy' then--brdy 出生日期
      LS_JKFSZ0:=substrb(LS_brdy,1,250);
      update ZY_YBJKMX set JKFSZ0=LS_JKFSZ0,JKFHZ0=LS_JKFHZ0,VALUE0=LS_VALUE0 where YBJKID=PYBJKID and JKSXBM=C_YBFS.JKSXBM and JKMXID=C_YBFS.JKMXID;
    elsif C_YBFS.JKSXBM='age' then--age 年龄
      LS_JKFSZ0:=substrb(LS_age,1,250);
      update ZY_YBJKMX set JKFSZ0=LS_JKFSZ0,JKFHZ0=LS_JKFHZ0,VALUE0=LS_VALUE0 where YBJKID=PYBJKID and JKSXBM=C_YBFS.JKSXBM and JKMXID=C_YBFS.JKMXID;
    elsif C_YBFS.JKSXBM='ntly' then--ntly 国籍
      LS_JKFSZ0:=substrb(LS_ntly,1,250);
      update ZY_YBJKMX set JKFSZ0=LS_JKFSZ0,JKFHZ0=LS_JKFHZ0,VALUE0=LS_VALUE0 where YBJKID=PYBJKID and JKSXBM=C_YBFS.JKSXBM and JKMXID=C_YBFS.JKMXID;
    elsif C_YBFS.JKSXBM='nwb_age' then--nwb_age （年龄不足1周岁）年龄
      LS_JKFSZ0:=substrb(LS_nwb_age,1,250);
      update ZY_YBJKMX set JKFSZ0=LS_JKFSZ0,JKFHZ0=LS_JKFHZ0,VALUE0=LS_VALUE0 where YBJKID=PYBJKID and JKSXBM=C_YBFS.JKSXBM and JKMXID=C_YBFS.JKMXID;
    elsif C_YBFS.JKSXBM='naty' then--naty 民族
      LS_JKFSZ0:=substrb(LS_naty,1,250);
      update ZY_YBJKMX set JKFSZ0=LS_JKFSZ0,JKFHZ0=LS_JKFHZ0,VALUE0=LS_VALUE0 where YBJKID=PYBJKID and JKSXBM=C_YBFS.JKSXBM and JKMXID=C_YBFS.JKMXID;
    elsif C_YBFS.JKSXBM='patn_cert_type' then--patn_cert_type 患者证件类别
      LS_JKFSZ0:=substrb(LS_patn_cert_type,1,250);
      update ZY_YBJKMX set JKFSZ0=LS_JKFSZ0,JKFHZ0=LS_JKFHZ0,VALUE0=LS_VALUE0 where YBJKID=PYBJKID and JKSXBM=C_YBFS.JKSXBM and JKMXID=C_YBFS.JKMXID;
    elsif C_YBFS.JKSXBM='certno' then--certno 证件号码
      LS_JKFSZ0:=substrb(LS_certno,1,250);
      update ZY_YBJKMX set JKFSZ0=LS_JKFSZ0,JKFHZ0=LS_JKFHZ0,VALUE0=LS_VALUE0 where YBJKID=PYBJKID and JKSXBM=C_YBFS.JKSXBM and JKMXID=C_YBFS.JKMXID;
    elsif C_YBFS.JKSXBM='prfs' then--prfs 职业
      LS_JKFSZ0:=substrb(LS_prfs,1,250);
      update ZY_YBJKMX set JKFSZ0=LS_JKFSZ0,JKFHZ0=LS_JKFHZ0,VALUE0=LS_VALUE0 where YBJKID=PYBJKID and JKSXBM=C_YBFS.JKSXBM and JKMXID=C_YBFS.JKMXID;
    elsif C_YBFS.JKSXBM='curr_addr' then--curr_addr 现住址
      LS_JKFSZ0:=substrb(LS_curr_addr,1,250);
      update ZY_YBJKMX set JKFSZ0=LS_JKFSZ0,JKFHZ0=LS_JKFHZ0,VALUE0=LS_VALUE0 where YBJKID=PYBJKID and JKSXBM=C_YBFS.JKSXBM and JKMXID=C_YBFS.JKMXID;
    elsif C_YBFS.JKSXBM='emp_name' then--emp_name 单位名称
      LS_JKFSZ0:=substrb(LS_emp_name,1,250);
      update ZY_YBJKMX set JKFSZ0=LS_JKFSZ0,JKFHZ0=LS_JKFHZ0,VALUE0=LS_VALUE0 where YBJKID=PYBJKID and JKSXBM=C_YBFS.JKSXBM and JKMXID=C_YBFS.JKMXID;
    elsif C_YBFS.JKSXBM='emp_addr' then--emp_addr 单位地址
      LS_JKFSZ0:=substrb(LS_emp_addr,1,250);
      update ZY_YBJKMX set JKFSZ0=LS_JKFSZ0,JKFHZ0=LS_JKFHZ0,VALUE0=LS_VALUE0 where YBJKID=PYBJKID and JKSXBM=C_YBFS.JKSXBM and JKMXID=C_YBFS.JKMXID;
    elsif C_YBFS.JKSXBM='emp_tel' then--emp_tel 单位电话
      LS_JKFSZ0:=substrb(LS_emp_tel,1,250);
      update ZY_YBJKMX set JKFSZ0=LS_JKFSZ0,JKFHZ0=LS_JKFHZ0,VALUE0=LS_VALUE0 where YBJKID=PYBJKID and JKSXBM=C_YBFS.JKSXBM and JKMXID=C_YBFS.JKMXID;
    elsif C_YBFS.JKSXBM='poscode' then--poscode 邮编
      LS_JKFSZ0:=substrb(LS_poscode,1,250);
      update ZY_YBJKMX set JKFSZ0=LS_JKFSZ0,JKFHZ0=LS_JKFHZ0,VALUE0=LS_VALUE0 where YBJKID=PYBJKID and JKSXBM=C_YBFS.JKSXBM and JKMXID=C_YBFS.JKMXID;
    elsif C_YBFS.JKSXBM='coner_name' then--coner_name 联系人姓名
      LS_JKFSZ0:=substrb(LS_coner_name,1,250);
      update ZY_YBJKMX set JKFSZ0=LS_JKFSZ0,JKFHZ0=LS_JKFHZ0,VALUE0=LS_VALUE0 where YBJKID=PYBJKID and JKSXBM=C_YBFS.JKSXBM and JKMXID=C_YBFS.JKMXID;
    elsif C_YBFS.JKSXBM='patn_rlts' then--patn_rlts 与患者关系
      LS_JKFSZ0:=substrb(LS_patn_rlts,1,250);
      update ZY_YBJKMX set JKFSZ0=LS_JKFSZ0,JKFHZ0=LS_JKFHZ0,VALUE0=LS_VALUE0 where YBJKID=PYBJKID and JKSXBM=C_YBFS.JKSXBM and JKMXID=C_YBFS.JKMXID;
    elsif C_YBFS.JKSXBM='coner_addr' then--coner_addr 联系人地址
      LS_JKFSZ0:=substrb(LS_coner_addr,1,250);
      update ZY_YBJKMX set JKFSZ0=LS_JKFSZ0,JKFHZ0=LS_JKFHZ0,VALUE0=LS_VALUE0 where YBJKID=PYBJKID and JKSXBM=C_YBFS.JKSXBM and JKMXID=C_YBFS.JKMXID;
    elsif C_YBFS.JKSXBM='coner_tel' then--coner_tel 联系人电话
      LS_JKFSZ0:=substrb(LS_coner_tel,1,250);
      update ZY_YBJKMX set JKFSZ0=LS_JKFSZ0,JKFHZ0=LS_JKFHZ0,VALUE0=LS_VALUE0 where YBJKID=PYBJKID and JKSXBM=C_YBFS.JKSXBM and JKMXID=C_YBFS.JKMXID;
    elsif C_YBFS.JKSXBM='hi_type' then--hi_type 医保类型
      LS_JKFSZ0:=substrb(LS_hi_type,1,250);
      update ZY_YBJKMX set JKFSZ0=LS_JKFSZ0,JKFHZ0=LS_JKFHZ0,VALUE0=LS_VALUE0 where YBJKID=PYBJKID and JKSXBM=C_YBFS.JKSXBM and JKMXID=C_YBFS.JKMXID;
    elsif C_YBFS.JKSXBM='insuplc' then--insuplc 参保地
      LS_JKFSZ0:=substrb(LS_insuplc,1,250);
      update ZY_YBJKMX set JKFSZ0=LS_JKFSZ0,JKFHZ0=LS_JKFHZ0,VALUE0=LS_VALUE0 where YBJKID=PYBJKID and JKSXBM=C_YBFS.JKSXBM and JKMXID=C_YBFS.JKMXID;
    elsif C_YBFS.JKSXBM='sp_psn_type' then--sp_psn_type 特殊人员类型
      LS_JKFSZ0:=substrb(LS_sp_psn_type,1,250);
      update ZY_YBJKMX set JKFSZ0=LS_JKFSZ0,JKFHZ0=LS_JKFHZ0,VALUE0=LS_VALUE0 where YBJKID=PYBJKID and JKSXBM=C_YBFS.JKSXBM and JKMXID=C_YBFS.JKMXID;
    elsif C_YBFS.JKSXBM='nwb_adm_type' then--nwb_adm_type 新生儿入院类型
      LS_JKFSZ0:=substrb(LS_nwb_adm_type,1,250);
      update ZY_YBJKMX set JKFSZ0=LS_JKFSZ0,JKFHZ0=LS_JKFHZ0,VALUE0=LS_VALUE0 where YBJKID=PYBJKID and JKSXBM=C_YBFS.JKSXBM and JKMXID=C_YBFS.JKMXID;
    elsif C_YBFS.JKSXBM='nwb_bir_wt' then--nwb_bir_wt 新生儿出生体重
      LS_JKFSZ0:=substrb(LS_nwb_bir_wt,1,250);
      update ZY_YBJKMX set JKFSZ0=LS_JKFSZ0,JKFHZ0=LS_JKFHZ0,VALUE0=LS_VALUE0 where YBJKID=PYBJKID and JKSXBM=C_YBFS.JKSXBM and JKMXID=C_YBFS.JKMXID;
    elsif C_YBFS.JKSXBM='nwb_adm_wt' then--nwb_adm_wt 新生儿入院体重
      LS_JKFSZ0:=substrb(LS_nwb_adm_wt,1,250);
      update ZY_YBJKMX set JKFSZ0=LS_JKFSZ0,JKFHZ0=LS_JKFHZ0,VALUE0=LS_VALUE0 where YBJKID=PYBJKID and JKSXBM=C_YBFS.JKSXBM and JKMXID=C_YBFS.JKMXID;
    elsif C_YBFS.JKSXBM='opsp_diag_caty' then--opsp_diag_caty 门诊慢特病诊断科别
      LS_JKFSZ0:=substrb(LS_opsp_diag_caty,1,250);
      update ZY_YBJKMX set JKFSZ0=LS_JKFSZ0,JKFHZ0=LS_JKFHZ0,VALUE0=LS_VALUE0 where YBJKID=PYBJKID and JKSXBM=C_YBFS.JKSXBM and JKMXID=C_YBFS.JKMXID;
    elsif C_YBFS.JKSXBM='opsp_mdtrt_date' then--opsp_mdtrt_date 门诊慢特病就诊日期
      LS_JKFSZ0:=substrb(LS_opsp_mdtrt_date,1,250);
      update ZY_YBJKMX set JKFSZ0=LS_JKFSZ0,JKFHZ0=LS_JKFHZ0,VALUE0=LS_VALUE0 where YBJKID=PYBJKID and JKSXBM=C_YBFS.JKSXBM and JKMXID=C_YBFS.JKMXID;
    elsif C_YBFS.JKSXBM='ipt_med_type' then--ipt_med_type 住院医疗类型
      LS_JKFSZ0:=substrb(LS_ipt_med_type,1,250);
      update ZY_YBJKMX set JKFSZ0=LS_JKFSZ0,JKFHZ0=LS_JKFHZ0,VALUE0=LS_VALUE0 where YBJKID=PYBJKID and JKSXBM=C_YBFS.JKSXBM and JKMXID=C_YBFS.JKMXID;
    elsif C_YBFS.JKSXBM='adm_way' then--adm_way 入院途径
      LS_JKFSZ0:=substrb(LS_adm_way,1,250);
      update ZY_YBJKMX set JKFSZ0=LS_JKFSZ0,JKFHZ0=LS_JKFHZ0,VALUE0=LS_VALUE0 where YBJKID=PYBJKID and JKSXBM=C_YBFS.JKSXBM and JKMXID=C_YBFS.JKMXID;
    elsif C_YBFS.JKSXBM='trt_type' then--trt_type 治疗类别
      LS_JKFSZ0:=substrb(LS_trt_type,1,250);
      update ZY_YBJKMX set JKFSZ0=LS_JKFSZ0,JKFHZ0=LS_JKFHZ0,VALUE0=LS_VALUE0 where YBJKID=PYBJKID and JKSXBM=C_YBFS.JKSXBM and JKMXID=C_YBFS.JKMXID;
    elsif C_YBFS.JKSXBM='adm_time' then--adm_time 入院时间
      LS_JKFSZ0:=substrb(LS_adm_time,1,250);
      update ZY_YBJKMX set JKFSZ0=LS_JKFSZ0,JKFHZ0=LS_JKFHZ0,VALUE0=LS_VALUE0 where YBJKID=PYBJKID and JKSXBM=C_YBFS.JKSXBM and JKMXID=C_YBFS.JKMXID;
    elsif C_YBFS.JKSXBM='adm_caty' then--adm_caty 入院科别
      LS_JKFSZ0:=substrb(LS_adm_caty,1,250);
      update ZY_YBJKMX set JKFSZ0=LS_JKFSZ0,JKFHZ0=LS_JKFHZ0,VALUE0=LS_VALUE0 where YBJKID=PYBJKID and JKSXBM=C_YBFS.JKSXBM and JKMXID=C_YBFS.JKMXID;
    elsif C_YBFS.JKSXBM='refldept_dept' then--refldept_dept 转科科别
      LS_JKFSZ0:=substrb(LS_refldept_dept,1,250);
      update ZY_YBJKMX set JKFSZ0=LS_JKFSZ0,JKFHZ0=LS_JKFHZ0,VALUE0=LS_VALUE0 where YBJKID=PYBJKID and JKSXBM=C_YBFS.JKSXBM and JKMXID=C_YBFS.JKMXID;
    elsif C_YBFS.JKSXBM='dscg_time' then--dscg_time 出院时间
      LS_JKFSZ0:=substrb(LS_dscg_time,1,250);
      update ZY_YBJKMX set JKFSZ0=LS_JKFSZ0,JKFHZ0=LS_JKFHZ0,VALUE0=LS_VALUE0 where YBJKID=PYBJKID and JKSXBM=C_YBFS.JKSXBM and JKMXID=C_YBFS.JKMXID;
    elsif C_YBFS.JKSXBM='dscg_caty' then--dscg_caty 出院科别
      LS_JKFSZ0:=substrb(LS_dscg_caty,1,250);
      update ZY_YBJKMX set JKFSZ0=LS_JKFSZ0,JKFHZ0=LS_JKFHZ0,VALUE0=LS_VALUE0 where YBJKID=PYBJKID and JKSXBM=C_YBFS.JKSXBM and JKMXID=C_YBFS.JKMXID;
    elsif C_YBFS.JKSXBM='act_ipt_days' then--act_ipt_days 实际住院天数
      LS_JKFSZ0:=substrb(LS_act_ipt_days,1,250);
      update ZY_YBJKMX set JKFSZ0=LS_JKFSZ0,JKFHZ0=LS_JKFHZ0,VALUE0=LS_VALUE0 where YBJKID=PYBJKID and JKSXBM=C_YBFS.JKSXBM and JKMXID=C_YBFS.JKMXID;
    elsif C_YBFS.JKSXBM='otp_wm_dia' then--otp_wm_dia 门（急）诊西医诊断
      LS_JKFSZ0:=substrb(LS_otp_wm_dise,1,250);
      update ZY_YBJKMX set JKFSZ0=LS_JKFSZ0,JKFHZ0=LS_JKFHZ0,VALUE0=LS_VALUE0 where YBJKID=PYBJKID and JKSXBM=C_YBFS.JKSXBM and JKMXID=C_YBFS.JKMXID;
    elsif C_YBFS.JKSXBM='otp_wm_diag_dise_code' then--otp_wm_diag_dise_code 西医诊断疾病代码
      LS_JKFSZ0:=substrb(LS_otp_tcm_dise,1,250);
      update ZY_YBJKMX set JKFSZ0=LS_JKFSZ0,JKFHZ0=LS_JKFHZ0,VALUE0=LS_VALUE0 where YBJKID=PYBJKID and JKSXBM=C_YBFS.JKSXBM and JKMXID=C_YBFS.JKMXID;
    elsif C_YBFS.JKSXBM='otp_tcm_diag' then--otp_tcm_diag 门（急）诊中医诊断
      LS_JKFSZ0:=substrb(LS_otp_tcm_dise,1,250);
      update ZY_YBJKMX set JKFSZ0=LS_JKFSZ0,JKFHZ0=LS_JKFHZ0,VALUE0=LS_VALUE0 where YBJKID=PYBJKID and JKSXBM=C_YBFS.JKSXBM and JKMXID=C_YBFS.JKMXID;
    elsif C_YBFS.JKSXBM='otp_tcm_diag_dise_code' then--otp_tcm_diag_dise_code 中医诊断代码
      LS_JKFSZ0:=substrb(LS_tcm_dise_code,1,250);
      update ZY_YBJKMX set JKFSZ0=LS_JKFSZ0,JKFHZ0=LS_JKFHZ0,VALUE0=LS_VALUE0 where YBJKID=PYBJKID and JKSXBM=C_YBFS.JKSXBM and JKMXID=C_YBFS.JKMXID;
    elsif C_YBFS.JKSXBM='diag_code_cnt' then--diag_code_cnt 诊断代码计数
      LS_JKFSZ0:=substrb(LS_diag_code_cnt,1,250);
      update ZY_YBJKMX set JKFSZ0=LS_JKFSZ0,JKFHZ0=LS_JKFHZ0,VALUE0=LS_VALUE0 where YBJKID=PYBJKID and JKSXBM=C_YBFS.JKSXBM and JKMXID=C_YBFS.JKMXID;
    elsif C_YBFS.JKSXBM='oprn_oprt_code_cnt' then--oprn_oprt_code_cnt 手术操作代码计数
      LS_JKFSZ0:=substrb(LS_oprn_oprt_code_cnt,1,250);
      update ZY_YBJKMX set JKFSZ0=LS_JKFSZ0,JKFHZ0=LS_JKFHZ0,VALUE0=LS_VALUE0 where YBJKID=PYBJKID and JKSXBM=C_YBFS.JKSXBM and JKMXID=C_YBFS.JKMXID;
    elsif C_YBFS.JKSXBM='vent_used_dura' then--vent_used_dura 呼吸机使用时长
      LS_JKFSZ0:=substrb(LS_vent_used_dura,1,250);
      update ZY_YBJKMX set JKFSZ0=LS_JKFSZ0,JKFHZ0=LS_JKFHZ0,VALUE0=LS_VALUE0 where YBJKID=PYBJKID and JKSXBM=C_YBFS.JKSXBM and JKMXID=C_YBFS.JKMXID;
    elsif C_YBFS.JKSXBM='pwcry_bfadm_coma_dura' then--pwcry_bfadm_coma_dura 颅脑损伤患者入院前昏迷时长
      LS_JKFSZ0:=substrb(LS_pwcry_bfadm_coma_dura,1,250);
      update ZY_YBJKMX set JKFSZ0=LS_JKFSZ0,JKFHZ0=LS_JKFHZ0,VALUE0=LS_VALUE0 where YBJKID=PYBJKID and JKSXBM=C_YBFS.JKSXBM and JKMXID=C_YBFS.JKMXID;
    elsif C_YBFS.JKSXBM='pwcry_afadm_coma_dura' then--pwcry_afadm_coma_dura 颅脑损伤患者入院后昏迷时长
      LS_JKFSZ0:=substrb(LS_pwcry_afadm_coma_dura,1,250);
      update ZY_YBJKMX set JKFSZ0=LS_JKFSZ0,JKFHZ0=LS_JKFHZ0,VALUE0=LS_VALUE0 where YBJKID=PYBJKID and JKSXBM=C_YBFS.JKSXBM and JKMXID=C_YBFS.JKMXID;
    elsif C_YBFS.JKSXBM='bld_cat' then--bld_cat 输血品种
      LS_JKFSZ0:=substrb(LS_bld_cat,1,250);
      update ZY_YBJKMX set JKFSZ0=LS_JKFSZ0,JKFHZ0=LS_JKFHZ0,VALUE0=LS_VALUE0 where YBJKID=PYBJKID and JKSXBM=C_YBFS.JKSXBM and JKMXID=C_YBFS.JKMXID;
    elsif C_YBFS.JKSXBM='bld_amt' then--bld_amt 输血量
      LS_JKFSZ0:=substrb(LS_bld_amt,1,250);
      update ZY_YBJKMX set JKFSZ0=LS_JKFSZ0,JKFHZ0=LS_JKFHZ0,VALUE0=LS_VALUE0 where YBJKID=PYBJKID and JKSXBM=C_YBFS.JKSXBM and JKMXID=C_YBFS.JKMXID;
    elsif C_YBFS.JKSXBM='bld_unt' then--bld_unt 输血计量单位
      LS_JKFSZ0:=substrb(LS_bld_unt,1,250);
      update ZY_YBJKMX set JKFSZ0=LS_JKFSZ0,JKFHZ0=LS_JKFHZ0,VALUE0=LS_VALUE0 where YBJKID=PYBJKID and JKSXBM=C_YBFS.JKSXBM and JKMXID=C_YBFS.JKMXID;
    elsif C_YBFS.JKSXBM='spga_nurscare_days' then--spga_nurscare_days 特级护理天数
      LS_JKFSZ0:=substrb(LS_spga_nurscare_days,1,250);
      update ZY_YBJKMX set JKFSZ0=LS_JKFSZ0,JKFHZ0=LS_JKFHZ0,VALUE0=LS_VALUE0 where YBJKID=PYBJKID and JKSXBM=C_YBFS.JKSXBM and JKMXID=C_YBFS.JKMXID;
    elsif C_YBFS.JKSXBM='lv1_nurscare_days' then--lv1_nurscare_days 一级护理天数
      LS_JKFSZ0:=substrb(LS_lv1_nurscare_days,1,250);
      update ZY_YBJKMX set JKFSZ0=LS_JKFSZ0,JKFHZ0=LS_JKFHZ0,VALUE0=LS_VALUE0 where YBJKID=PYBJKID and JKSXBM=C_YBFS.JKSXBM and JKMXID=C_YBFS.JKMXID;
    elsif C_YBFS.JKSXBM='scd_nurscare_days' then--scd_nurscare_days 二级护理天数
      LS_JKFSZ0:=substrb(LS_scd_nurscare_days,1,250);
      update ZY_YBJKMX set JKFSZ0=LS_JKFSZ0,JKFHZ0=LS_JKFHZ0,VALUE0=LS_VALUE0 where YBJKID=PYBJKID and JKSXBM=C_YBFS.JKSXBM and JKMXID=C_YBFS.JKMXID;
    elsif C_YBFS.JKSXBM='lv3_nurscare_days' then--lv3_nurscare_days 三级护理天数
      LS_JKFSZ0:=substrb(LS_lv3_nurscare_days,1,250);
      update ZY_YBJKMX set JKFSZ0=LS_JKFSZ0,JKFHZ0=LS_JKFHZ0,VALUE0=LS_VALUE0 where YBJKID=PYBJKID and JKSXBM=C_YBFS.JKSXBM and JKMXID=C_YBFS.JKMXID;
    elsif C_YBFS.JKSXBM='dscg_way' then--dscg_way 离院方式
      LS_JKFSZ0:=substrb(LS_dscg_way,1,250);
      update ZY_YBJKMX set JKFSZ0=LS_JKFSZ0,JKFHZ0=LS_JKFHZ0,VALUE0=LS_VALUE0 where YBJKID=PYBJKID and JKSXBM=C_YBFS.JKSXBM and JKMXID=C_YBFS.JKMXID;
    elsif C_YBFS.JKSXBM='acp_medins_name' then--acp_medins_name 拟接收机构名称
      LS_JKFSZ0:=substrb(LS_acp_medins_name,1,250);
      update ZY_YBJKMX set JKFSZ0=LS_JKFSZ0,JKFHZ0=LS_JKFHZ0,VALUE0=LS_VALUE0 where YBJKID=PYBJKID and JKSXBM=C_YBFS.JKSXBM and JKMXID=C_YBFS.JKMXID;
    elsif C_YBFS.JKSXBM='acp_optins_code' then--acp_optins_code 拟接收机构代码
      LS_JKFSZ0:=substrb(LS_acp_optins_code,1,250);
      update ZY_YBJKMX set JKFSZ0=LS_JKFSZ0,JKFHZ0=LS_JKFHZ0,VALUE0=LS_VALUE0 where YBJKID=PYBJKID and JKSXBM=C_YBFS.JKSXBM and JKMXID=C_YBFS.JKMXID;
    elsif C_YBFS.JKSXBM='bill_code' then--bill_code 票据代码
      LS_JKFSZ0:=substrb(LS_bill_code,1,250);
      update ZY_YBJKMX set JKFSZ0=LS_JKFSZ0,JKFHZ0=LS_JKFHZ0,VALUE0=LS_VALUE0 where YBJKID=PYBJKID and JKSXBM=C_YBFS.JKSXBM and JKMXID=C_YBFS.JKMXID;
    elsif C_YBFS.JKSXBM='bill_no' then--bill_no 票据号码
      LS_JKFSZ0:=substrb(LS_bill_no,1,250);
      update ZY_YBJKMX set JKFSZ0=LS_JKFSZ0,JKFHZ0=LS_JKFHZ0,VALUE0=LS_VALUE0 where YBJKID=PYBJKID and JKSXBM=C_YBFS.JKSXBM and JKMXID=C_YBFS.JKMXID;
    elsif C_YBFS.JKSXBM='biz_sn' then--biz_sn 业务流水号
      LS_JKFSZ0:=substrb(LS_biz_sn,1,250);
      update ZY_YBJKMX set JKFSZ0=LS_JKFSZ0,JKFHZ0=LS_JKFHZ0,VALUE0=LS_VALUE0 where YBJKID=PYBJKID and JKSXBM=C_YBFS.JKSXBM and JKMXID=C_YBFS.JKMXID;
    elsif C_YBFS.JKSXBM='days_rinp_flag_31' then--days_rinp_flag_31 出院31天内再住院计划标志
      LS_JKFSZ0:=substrb(LS_days_rinp_flag_31,1,250);
      update ZY_YBJKMX set JKFSZ0=LS_JKFSZ0,JKFHZ0=LS_JKFHZ0,VALUE0=LS_VALUE0 where YBJKID=PYBJKID and JKSXBM=C_YBFS.JKSXBM and JKMXID=C_YBFS.JKMXID;
    elsif C_YBFS.JKSXBM='rinp_pup' then--rinp_pup 出院31天内再住院目的
      LS_JKFSZ0:=substrb(LS_days_rinp_pup_31,1,250);
      update ZY_YBJKMX set JKFSZ0=LS_JKFSZ0,JKFHZ0=LS_JKFHZ0,VALUE0=LS_VALUE0 where YBJKID=PYBJKID and JKSXBM=C_YBFS.JKSXBM and JKMXID=C_YBFS.JKMXID;
    elsif C_YBFS.JKSXBM='chfpdr_name' then--chfpdr_name 主诊医师姓名
      LS_JKFSZ0:=substrb(LS_chfpdr_name,1,250);
      update ZY_YBJKMX set JKFSZ0=LS_JKFSZ0,JKFHZ0=LS_JKFHZ0,VALUE0=LS_VALUE0 where YBJKID=PYBJKID and JKSXBM=C_YBFS.JKSXBM and JKMXID=C_YBFS.JKMXID;
    elsif C_YBFS.JKSXBM='chfpdr_code' then--chfpdr_code 主诊医师代码
      LS_JKFSZ0:=substrb(LS_chfpdr_code,1,250);
      update ZY_YBJKMX set JKFSZ0=LS_JKFSZ0,JKFHZ0=LS_JKFHZ0,VALUE0=LS_VALUE0 where YBJKID=PYBJKID and JKSXBM=C_YBFS.JKSXBM and JKMXID=C_YBFS.JKMXID;
    elsif C_YBFS.JKSXBM='setl_begn_date' then--setl_begn_date 结算开始日期
      LS_JKFSZ0:=substrb(LS_setl_begn_date,1,250);
      update ZY_YBJKMX set JKFSZ0=LS_JKFSZ0,JKFHZ0=LS_JKFHZ0,VALUE0=LS_VALUE0 where YBJKID=PYBJKID and JKSXBM=C_YBFS.JKSXBM and JKMXID=C_YBFS.JKMXID;
    elsif C_YBFS.JKSXBM='setl_end_date' then--setl_end_date 结算结束日期
      LS_JKFSZ0:=substrb(LS_setl_end_date,1,250);
      update ZY_YBJKMX set JKFSZ0=LS_JKFSZ0,JKFHZ0=LS_JKFHZ0,VALUE0=LS_VALUE0 where YBJKID=PYBJKID and JKSXBM=C_YBFS.JKSXBM and JKMXID=C_YBFS.JKMXID;
    elsif C_YBFS.JKSXBM='psn_selfpay' then--psn_selfpay 个人自付
      LS_JKFSZ0:=substrb(LS_psn_selfpay,1,250);
      update ZY_YBJKMX set JKFSZ0=LS_JKFSZ0,JKFHZ0=LS_JKFHZ0,VALUE0=LS_VALUE0 where YBJKID=PYBJKID and JKSXBM=C_YBFS.JKSXBM and JKMXID=C_YBFS.JKMXID;
    elsif C_YBFS.JKSXBM='psn_ownpay' then--psn_ownpay 个人自费
      LS_JKFSZ0:=substrb(LS_psn_ownpay,1,250);
      update ZY_YBJKMX set JKFSZ0=LS_JKFSZ0,JKFHZ0=LS_JKFHZ0,VALUE0=LS_VALUE0 where YBJKID=PYBJKID and JKSXBM=C_YBFS.JKSXBM and JKMXID=C_YBFS.JKMXID;
    elsif C_YBFS.JKSXBM='acct_pay' then--acct_pay 个人账户支出
      LS_JKFSZ0:=substrb(LS_acct_pay,1,250);
      update ZY_YBJKMX set JKFSZ0=LS_JKFSZ0,JKFHZ0=LS_JKFHZ0,VALUE0=LS_VALUE0 where YBJKID=PYBJKID and JKSXBM=C_YBFS.JKSXBM and JKMXID=C_YBFS.JKMXID;
    elsif C_YBFS.JKSXBM='psn_cashpay' then--psn_cashpay 个人现金支付
      LS_JKFSZ0:=substrb(LS_psn_cashpay,1,250);
      update ZY_YBJKMX set JKFSZ0=LS_JKFSZ0,JKFHZ0=LS_JKFHZ0,VALUE0=LS_VALUE0 where YBJKID=PYBJKID and JKSXBM=C_YBFS.JKSXBM and JKMXID=C_YBFS.JKMXID;
    elsif C_YBFS.JKSXBM='hi_paymtd' then--hi_paymtd 医保支付方式
      LS_JKFSZ0:=substrb(LS_hi_paymtd,1,250);
      update ZY_YBJKMX set JKFSZ0=LS_JKFSZ0,JKFHZ0=LS_JKFHZ0,VALUE0=LS_VALUE0 where YBJKID=PYBJKID and JKSXBM=C_YBFS.JKSXBM and JKMXID=C_YBFS.JKMXID;
    elsif C_YBFS.JKSXBM='hsorg' then--hsorg 医保机构
      LS_JKFSZ0:=substrb(LS_hsorg,1,250);
      update ZY_YBJKMX set JKFSZ0=LS_JKFSZ0,JKFHZ0=LS_JKFHZ0,VALUE0=LS_VALUE0 where YBJKID=PYBJKID and JKSXBM=C_YBFS.JKSXBM and JKMXID=C_YBFS.JKMXID;
    elsif C_YBFS.JKSXBM='hsorg_opter' then--hsorg_opter 医保机构经办人
      LS_JKFSZ0:=substrb(LS_hsorg_opter,1,250);
      update ZY_YBJKMX set JKFSZ0=LS_JKFSZ0,JKFHZ0=LS_JKFHZ0,VALUE0=LS_VALUE0 where YBJKID=PYBJKID and JKSXBM=C_YBFS.JKSXBM and JKMXID=C_YBFS.JKMXID;
    elsif C_YBFS.JKSXBM='medins_fill_dept' then--medins_fill_dept 医疗机构填报部门
      LS_JKFSZ0:=substrb(LS_medins_fill_dept,1,250);
      update ZY_YBJKMX set JKFSZ0=LS_JKFSZ0,JKFHZ0=LS_JKFHZ0,VALUE0=LS_VALUE0 where YBJKID=PYBJKID and JKSXBM=C_YBFS.JKSXBM and JKMXID=C_YBFS.JKMXID;
    elsif C_YBFS.JKSXBM='medins_fill_psn' then--medins_fill_psn 医疗机构填报人
      LS_JKFSZ0:=substrb(LS_medins_fill_psn,1,250);
      update ZY_YBJKMX set JKFSZ0=LS_JKFSZ0,JKFHZ0=LS_JKFHZ0,VALUE0=LS_VALUE0 where YBJKID=PYBJKID and JKSXBM=C_YBFS.JKSXBM and JKMXID=C_YBFS.JKMXID;
    elsif C_YBFS.JKSXBM='psn_hos_type' then--psn_hos_type 结算清单类型0=住院 1=门诊
      LS_JKFSZ0:=substrb(LS_psn_hos_type,1,250);
      update ZY_YBJKMX set JKFSZ0=LS_JKFSZ0,JKFHZ0=LS_JKFHZ0,VALUE0=LS_VALUE0 where YBJKID=PYBJKID and JKSXBM=C_YBFS.JKSXBM and JKMXID=C_YBFS.JKMXID;
    elsif C_YBFS.JKSXBM='medfee_sumamt' then--medfee_sumamt 总费用
      LS_JKFSZ0:=substrb(LS_medfee_sumamt,1,250);
      update ZY_YBJKMX set JKFSZ0=LS_JKFSZ0,JKFHZ0=LS_JKFHZ0,VALUE0=LS_VALUE0 where YBJKID=PYBJKID and JKSXBM=C_YBFS.JKSXBM and JKMXID=C_YBFS.JKMXID;
    elsif C_YBFS.JKSXBM='insu_admdvs' then--insu_admdvs 参保所属医保区划
      LS_JKFSZ0:=substrb(LS_insu_admdvs,1,250);
      update ZY_YBJKMX set JKFSZ0=LS_JKFSZ0,JKFHZ0=LS_JKFHZ0,VALUE0=LS_VALUE0 where YBJKID=PYBJKID and JKSXBM=C_YBFS.JKSXBM and JKMXID=C_YBFS.JKMXID;
    elsif C_YBFS.JKSXBM='psn_type' then--psn_type 人员类别
      LS_JKFSZ0:=substrb(LS_psn_type,1,250);
      update ZY_YBJKMX set JKFSZ0=LS_JKFSZ0,JKFHZ0=LS_JKFHZ0,VALUE0=LS_VALUE0 where YBJKID=PYBJKID and JKSXBM=C_YBFS.JKSXBM and JKMXID=C_YBFS.JKMXID;
    elsif C_YBFS.JKSXBM='fix_blng_admdvs' then--fix_blng_admdvs 定点归属医保区划
      LS_JKFSZ0:=substrb(LS_fix_blng_admdvs,1,250);
      update ZY_YBJKMX set JKFSZ0=LS_JKFSZ0,JKFHZ0=LS_JKFHZ0,VALUE0=LS_VALUE0 where YBJKID=PYBJKID and JKSXBM=C_YBFS.JKSXBM and JKMXID=C_YBFS.JKMXID;
    elsif C_YBFS.JKSXBM='poolarea_no' then--poolarea_no 统筹区编号
      LS_JKFSZ0:=substrb(LS_poolarea_no,1,250);
      update ZY_YBJKMX set JKFSZ0=LS_JKFSZ0,JKFHZ0=LS_JKFHZ0,VALUE0=LS_VALUE0 where YBJKID=PYBJKID and JKSXBM=C_YBFS.JKSXBM and JKMXID=C_YBFS.JKMXID;
    elsif C_YBFS.JKSXBM='insutype' then--insutype 险种类型
      LS_JKFSZ0:=substrb(LS_insutype,1,250);
      update ZY_YBJKMX set JKFSZ0=LS_JKFSZ0,JKFHZ0=LS_JKFHZ0,VALUE0=LS_VALUE0 where YBJKID=PYBJKID and JKSXBM=C_YBFS.JKSXBM and JKMXID=C_YBFS.JKMXID;
    end if;
  end loop;

  --查询主项数据
  for C_Main in CUR_QUERY_Main loop
    LS_MainJson := SF_XT_GETJSONSTR(LS_MainJson,C_Main.JKSXBM,C_Main.JKFSZ0,'0');
  end loop;

  if LS_MainJson is null then
    PZXZT00:=0;
    PERRMSG:='主项报文不能为空!';
    return;
  end if;

  --查询明细数据
  for C_detail in CUR_QUERY_detail loop
    LS_detailJson := SF_XT_GETJSONSTR(LS_detailJson,C_detail.JKSXBM,C_detail.JKFSZ0,'0');
  end loop;

  if LS_detailJson is null then
    PZXZT00:=0;
    PERRMSG:='明细报文不能为空!';
    return;
  end if;

  LS_MSGSTR:='基金支付信息';
  --基金支付信息
  LS_PayinfoList := null;
  for C_payinfo in CUR_QUREY_payinfo loop
    LS_payinfo := null;
    LS_payinfo := SF_XT_GETJSONSTR(LS_payinfo,'fund_pay_type',C_payinfo.fund_pay_type,'0');
    LS_payinfo := SF_XT_GETJSONSTR(LS_payinfo,'fund_payamt',C_payinfo.fund_payamt,'0');
    LS_PayinfoList := SF_XT_GETJSONSTR(LS_PayinfoList,null,LS_payinfo,'1');
    LS_payinfo_Num:=nvl(LS_payinfo_Num,0)+1;--[数量]基金支付信息<payinfo>
  end loop;
  LS_PayinfoList := SF_XT_GETJSONSTR(null,'payinfo',LS_PayinfoList,'2');

  LS_MSGSTR:='门诊慢特病诊断信息';
  --门诊慢特病诊断信息
  LS_opspdiseinfoList := null;
  for C_opspdiseinfo in CUR_QUREY_opspdiseinfo loop
    LS_opspdiseinfo := null;
    LS_opspdiseinfo := SF_XT_GETJSONSTR(LS_opspdiseinfo,'diag_name',C_opspdiseinfo.diag_name,'0');
    LS_opspdiseinfo := SF_XT_GETJSONSTR(LS_opspdiseinfo,'diag_code',C_opspdiseinfo.diag_code,'0');
    LS_opspdiseinfo := SF_XT_GETJSONSTR(LS_opspdiseinfo,'oprn_oprt_name',C_opspdiseinfo.oprn_oprt_name,'0');
    LS_opspdiseinfo := SF_XT_GETJSONSTR(LS_opspdiseinfo,'oprn_oprt_code',C_opspdiseinfo.oprn_oprt_code,'0');
    LS_opspdiseinfoList := SF_XT_GETJSONSTR(LS_opspdiseinfoList,null,LS_opspdiseinfo,'1');
    LS_opspdiseinfo_Num:=nvl(LS_opspdiseinfo_Num,0)+1;--[数量]门诊慢特病诊断信息<opspdiseinfo>
  end loop;
  LS_opspdiseinfoList := SF_XT_GETJSONSTR(null,'opspdiseinfo',LS_opspdiseinfoList,'2');

  LS_MSGSTR:='住院诊断信息';
  --住院诊断信息
  LS_diseinfoList := null;
  for C_diseinfo in CUR_QUREY_diseinfo loop
    LS_diseinfo := null;
    LS_diseinfo := SF_XT_GETJSONSTR(LS_diseinfo,'diag_type',C_diseinfo.diag_type,'0');
    LS_diseinfo := SF_XT_GETJSONSTR(LS_diseinfo,'diag_code',C_diseinfo.diag_code,'0');
    LS_diseinfo := SF_XT_GETJSONSTR(LS_diseinfo,'diag_name',C_diseinfo.diag_name,'0');
    LS_diseinfo := SF_XT_GETJSONSTR(LS_diseinfo,'adm_cond_type',C_diseinfo.adm_cond_type,'0');
    LS_diseinfo := SF_XT_GETJSONSTR(LS_diseinfo,'maindiag_flag',C_diseinfo.maindiag_flag,'0');
    LS_diseinfoList := SF_XT_GETJSONSTR(LS_diseinfoList,null,LS_diseinfo,'1');
    LS_diseinfo_Num:=nvl(LS_diseinfo_Num,0)+1;--[数量]住院诊断信息< diseinfo>
  end loop;
if nvl(LS_diseinfo_Num,0)=0 then
  for C_diseinfo in HIS_QUREY_diseinfo loop
    LS_diseinfo := null;
    LS_diseinfo := SF_XT_GETJSONSTR(LS_diseinfo,'diag_type',C_diseinfo.diag_type,'0');
    LS_diseinfo := SF_XT_GETJSONSTR(LS_diseinfo,'diag_code',C_diseinfo.diag_code,'0');
    LS_diseinfo := SF_XT_GETJSONSTR(LS_diseinfo,'diag_name',C_diseinfo.diag_name,'0');
    LS_diseinfo := SF_XT_GETJSONSTR(LS_diseinfo,'adm_cond_type',C_diseinfo.adm_cond_type,'0');
    LS_diseinfo := SF_XT_GETJSONSTR(LS_diseinfo,'maindiag_flag',C_diseinfo.maindiag_flag,'0');
    LS_diseinfoList := SF_XT_GETJSONSTR(LS_diseinfoList,null,LS_diseinfo,'1');
    LS_diseinfo_Num:=nvl(LS_diseinfo_Num,0)+1;--[数量]住院诊断信息< diseinfo>
  end loop;
end if;
  LS_diseinfoList := SF_XT_GETJSONSTR(null,'diseinfo',LS_diseinfoList,'2');

  LS_MSGSTR:='收费项目信息';
  --收费项目信息
  LS_iteminfoList := null;
  for C_iteminfo in CUR_QUREY_iteminfo loop
    LS_iteminfo := null;
    LS_iteminfo := SF_XT_GETJSONSTR(LS_iteminfo,'med_chrgitm',C_iteminfo.med_chrgitm,'0');
    LS_iteminfo := SF_XT_GETJSONSTR(LS_iteminfo,'amt',C_iteminfo.amt,'0');
    LS_iteminfo := SF_XT_GETJSONSTR(LS_iteminfo,'claa_sumfee',C_iteminfo.claa_sumfee,'0');
    LS_iteminfo := SF_XT_GETJSONSTR(LS_iteminfo,'clab_amt',C_iteminfo.clab_amt,'0');
    LS_iteminfo := SF_XT_GETJSONSTR(LS_iteminfo,'fulamt_ownpay_amt',C_iteminfo.fulamt_ownpay_amt,'0');
    LS_iteminfo := SF_XT_GETJSONSTR(LS_iteminfo,'oth_amt',C_iteminfo.oth_amt,'0');
    LS_iteminfoList := SF_XT_GETJSONSTR(LS_iteminfoList,null,LS_iteminfo,'1');
    LS_iteminfo_Num:=nvl(LS_iteminfo_Num,0)+1;--[数量]收费项目信息<iteminfo>
  end loop;
  LS_iteminfoList := SF_XT_GETJSONSTR(null,'iteminfo',LS_iteminfoList,'2');

  LS_MSGSTR:='手术操作信息';
  --手术操作信息
  LS_oprninfoList := null;
  for C_oprninfo in CUR_QUREY_oprninfo loop
    LS_oprninfo := null;
    LS_oprninfo := SF_XT_GETJSONSTR(LS_oprninfo,'oprn_oprt_type',C_oprninfo.oprn_oprt_type,'0');
    LS_oprninfo := SF_XT_GETJSONSTR(LS_oprninfo,'oprn_oprt_name',C_oprninfo.oprn_oprt_name,'0');
    LS_oprninfo := SF_XT_GETJSONSTR(LS_oprninfo,'oprn_oprt_code',C_oprninfo.oprn_oprt_code,'0');
    LS_oprninfo := SF_XT_GETJSONSTR(LS_oprninfo,'anst_way',C_oprninfo.anst_way,'0');
    LS_oprninfo := SF_XT_GETJSONSTR(LS_oprninfo,'oper_dr_code',C_oprninfo.oper_dr_code,'0');
    LS_oprninfo := SF_XT_GETJSONSTR(LS_oprninfo,'oprn_oprt_date',C_oprninfo.oprn_oprt_date,'0');
    LS_oprninfo := SF_XT_GETJSONSTR(LS_oprninfo,'oper_dr_name',C_oprninfo.oper_dr_name,'0');
    LS_oprninfo := SF_XT_GETJSONSTR(LS_oprninfo,'anst_dr_code',C_oprninfo.anst_dr_code,'0');
    LS_oprninfo := SF_XT_GETJSONSTR(LS_oprninfo,'anst_dr_name',C_oprninfo.anst_dr_name,'0');
    LS_oprninfo := SF_XT_GETJSONSTR(LS_oprninfo,'oprn_oprt_begntime',C_oprninfo.oprn_oprt_begntime,'0');
    LS_oprninfo := SF_XT_GETJSONSTR(LS_oprninfo,'oprn_oprt_endtime',C_oprninfo.oprn_oprt_endtime,'0');
    LS_oprninfo := SF_XT_GETJSONSTR(LS_oprninfo,'anst_begntime',C_oprninfo.anst_begntime,'0');
    LS_oprninfo := SF_XT_GETJSONSTR(LS_oprninfo,'anst_endtime',C_oprninfo.anst_endtime,'0');
    LS_oprninfoList := SF_XT_GETJSONSTR(LS_oprninfoList,null,LS_oprninfo,'1');
    LS_oprninfo_Num:=nvl(LS_oprninfo_Num,0)+1;--[数量]手术操作信息<oprninfo>
  end loop;
  if nvl(LS_oprninfo_Num,0)=0 then
  for C_oprninfo in HIS_QUREY_oprninfo loop
    LS_oprninfo := null;
    LS_oprninfo := SF_XT_GETJSONSTR(LS_oprninfo,'oprn_oprt_type',C_oprninfo.oprn_oprt_type,'0');
    LS_oprninfo := SF_XT_GETJSONSTR(LS_oprninfo,'oprn_oprt_name',C_oprninfo.oprn_oprt_name,'0');
    LS_oprninfo := SF_XT_GETJSONSTR(LS_oprninfo,'oprn_oprt_code',C_oprninfo.oprn_oprt_code,'0');
    LS_oprninfo := SF_XT_GETJSONSTR(LS_oprninfo,'anst_way',C_oprninfo.anst_way,'0');
    LS_oprninfo := SF_XT_GETJSONSTR(LS_oprninfo,'oper_dr_code',C_oprninfo.oper_dr_code,'0');
    LS_oprninfo := SF_XT_GETJSONSTR(LS_oprninfo,'oprn_oprt_date',C_oprninfo.oprn_oprt_date,'0');
    LS_oprninfo := SF_XT_GETJSONSTR(LS_oprninfo,'oper_dr_name',C_oprninfo.oper_dr_name,'0');
    LS_oprninfo := SF_XT_GETJSONSTR(LS_oprninfo,'anst_dr_code',C_oprninfo.anst_dr_code,'0');
    LS_oprninfo := SF_XT_GETJSONSTR(LS_oprninfo,'anst_dr_name',C_oprninfo.anst_dr_name,'0');
    LS_oprninfo := SF_XT_GETJSONSTR(LS_oprninfo,'oprn_oprt_begntime',C_oprninfo.oprn_oprt_begntime,'0');
    LS_oprninfo := SF_XT_GETJSONSTR(LS_oprninfo,'oprn_oprt_endtime',C_oprninfo.oprn_oprt_endtime,'0');
    LS_oprninfo := SF_XT_GETJSONSTR(LS_oprninfo,'anst_begntime',C_oprninfo.anst_begntime,'0');
    LS_oprninfo := SF_XT_GETJSONSTR(LS_oprninfo,'anst_endtime',C_oprninfo.anst_endtime,'0');
    LS_oprninfoList := SF_XT_GETJSONSTR(LS_oprninfoList,null,LS_oprninfo,'1');
    LS_oprninfo_Num:=nvl(LS_oprninfo_Num,0)+1;--[数量]手术操作信息<oprninfo>
  end loop;
  end if;

  LS_oprninfoList := SF_XT_GETJSONSTR(null,'oprninfo',LS_oprninfoList,'2');

  LS_MSGSTR:='重症监护信息';
  --重症监护信息
  LS_icuinfoList := null;
  for C_icuinfo in CUR_QUREY_icuinfo loop
    LS_icuinfo := null;
    LS_icuinfo := SF_XT_GETJSONSTR(LS_icuinfo,'scs_cutd_ward_type',C_icuinfo.scs_cutd_ward_type,'0');
    LS_icuinfo := SF_XT_GETJSONSTR(LS_icuinfo,'scs_cutd_inpool_time',C_icuinfo.scs_cutd_inpool_time,'0');
    LS_icuinfo := SF_XT_GETJSONSTR(LS_icuinfo,'scs_cutd_exit_time',C_icuinfo.scs_cutd_exit_time,'0');
    LS_icuinfo := SF_XT_GETJSONSTR(LS_icuinfo,'scs_cutd_sum_dura',C_icuinfo.scs_cutd_sum_dura,'0');
    LS_icuinfoList := SF_XT_GETJSONSTR(LS_icuinfoList,null,LS_icuinfo,'1');
    LS_icuinfo_Num:=nvl(LS_icuinfo_Num,0)+1;--[数量]重症监护信息<icuinfo>
  end loop;
  LS_icuinfoList := SF_XT_GETJSONSTR(null,'icuinfo',LS_icuinfoList,'2');

  LS_MSGSTR:='输血信息';
  --输血信息
  LS_bldinfoList := null;
  for C_icuinfo in CUR_QUREY_bldinfo loop
    LS_bldinfo := null;
    LS_bldinfo := SF_XT_GETJSONSTR(LS_bldinfo,'bld_cat',C_icuinfo.bld_cat,'0');
    LS_bldinfo := SF_XT_GETJSONSTR(LS_bldinfo,'bld_amt',to_char(C_icuinfo.bld_amt,'99999999990.99'),'0');
    LS_bldinfo := SF_XT_GETJSONSTR(LS_bldinfo,'bld_unt',C_icuinfo.bld_unt,'0');
    --insert into ZY_YBJKMX(YBJKID,JKMXID,JDBM00,ZJDBM0,JKSXBM,ZDMC00,JKFSZ0,JKFHZ0,FSLXBZ,BZ0000,VALUE0)
    --select PYBJKID,SQ_ZY_YBJKMX_JKMXID.nextval,'bldinfo','setlinfo','bldinfo','输血信息',null,null,'1',null,'{'||LS_bldinfo||'}' from dual;
    LS_bldinfoList := SF_XT_GETJSONSTR(LS_bldinfoList,null,LS_bldinfo,'1');
    LS_bldinfo_Num:=nvl(LS_bldinfo_Num,0)+1;--[数量]输血信息<bldinfo>
  end loop;
  LS_bldinfoList := SF_XT_GETJSONSTR(null,'bldinfo',LS_bldinfoList,'2');

  LS_MSGSTR:='费用明细';
  --费用明细
  LS_feedetail      :=null;--费用明细Json
  LS_feedetailList  :=null;--费用明细列表Json
  for C_CFMX in CUR_MXLIST loop
    LS_feedetail := '';
    LS_feedetail := SF_XT_GETJSONSTR(LS_feedetail,'feedetl_sn',substrb(C_CFMX.feedetl_sn,1,250),'0');          --1.feedetl_sn: 费用明细流水号
    LS_feedetail := SF_XT_GETJSONSTR(LS_feedetail,'init_feedetl_sn',substrb(C_CFMX.init_feedetl_sn,1,250),'0');--2.init_feedetl_sn: 原费用明细流水号
    LS_feedetail := SF_XT_GETJSONSTR(LS_feedetail,'mdtrt_id',substrb(C_CFMX.mdtrt_id,1,250),'0');--3.mdtrt_id: 就诊ID
    LS_feedetail := SF_XT_GETJSONSTR(LS_feedetail,'drord_no',substrb(C_CFMX.drord_no,1,250),'0');--4.chrg_bchno: 收费批次号
    LS_feedetail := SF_XT_GETJSONSTR(LS_feedetail,'psn_no',substrb(C_CFMX.psn_no,1,250),'0');--5.psn_no: 人员编号
    LS_feedetail := SF_XT_GETJSONSTR(LS_feedetail,'med_type',substrb(C_CFMX.med_type,1,250),'0');--6.med_type: 医疗类别
    LS_feedetail := SF_XT_GETJSONSTR(LS_feedetail,'fee_ocur_time',substrb(C_CFMX.fee_ocur_time,1,250),'0');--7.fee_ocur_time: 费用发生时间
    LS_feedetail := SF_XT_GETJSONSTR(LS_feedetail,'med_chrgitm',substrb(C_CFMX.med_chrgitm,1,250),'0');--med_chrgitm  医疗收费项目
    LS_feedetail := SF_XT_GETJSONSTR(LS_feedetail,'hilist_type',substrb(C_CFMX.hilist_type,1,250),'0');--hilist_type 三目类型 --1 药品  2 诊疗项目 3  服务设施  4 耗材
    LS_feedetail := SF_XT_GETJSONSTR(LS_feedetail,'med_list_codg',substrb(C_CFMX.med_list_codg,1,250),'0');--8.med_list_codg: 医疗目录编码
    LS_feedetail := SF_XT_GETJSONSTR(LS_feedetail,'medins_list_codg',substrb(C_CFMX.medins_list_codg,1,250),'0');--9.medins_list_codg: 医药机构目录编码
    LS_feedetail := SF_XT_GETJSONSTR(LS_feedetail,'det_item_fee_sumamt',substrb(trim(to_char(C_CFMX.det_item_fee_sumamt,'fm99999999999999990.09')),1,16),'0');--10.det_item_fee_sumamt: 明细项目费用总额
    LS_feedetail := SF_XT_GETJSONSTR(LS_feedetail,'cnt',substrb(trim(to_char(C_CFMX.cnt,'fm999999999999990.0999')),1,16),'0');--11.cnt: 数量
    LS_feedetail := SF_XT_GETJSONSTR(LS_feedetail,'pric',substrb(trim(to_char(C_CFMX.pric,'fm9999999999999990.099999')),1,16),'0');--12.pric: 单价
    LS_feedetail := SF_XT_GETJSONSTR(LS_feedetail,'prcunt',substrb(C_CFMX.prcunt,1,50),'0');--prcunt  单位  字符型 50
    LS_feedetail := SF_XT_GETJSONSTR(LS_feedetail,'spec',substrb(C_CFMX.spec,1,50),'0');--spec  规格  字符型 50
    LS_feedetail := SF_XT_GETJSONSTR(LS_feedetail,'selfpay_prop',substrb(C_CFMX.selfpay_prop,1,50),'0');--selfpay_prop  自付比例
    LS_feedetail := SF_XT_GETJSONSTR(LS_feedetail,'ownpay_amt',substrb(C_CFMX.ownpay_amt,1,50),'0');--ownpay_amt  自费金额
    LS_feedetail := SF_XT_GETJSONSTR(LS_feedetail,'bilg_dept_codg',substrb(C_CFMX.bilg_dept_codg,1,250),'0');--13.bilg_dept_codg: 开单科室编码
    LS_feedetail := SF_XT_GETJSONSTR(LS_feedetail,'bilg_dept_name',substrb(C_CFMX.bilg_dept_name,1,250),'0');--14.bilg_dept_name: 开单科室名称
    LS_feedetail := SF_XT_GETJSONSTR(LS_feedetail,'bilg_dr_codg',substrb(C_CFMX.bilg_dr_codg,1,250),'0');--15.bilg_dr_codg: 开单医生编码
    LS_feedetail := SF_XT_GETJSONSTR(LS_feedetail,'bilg_dr_name',substrb(C_CFMX.bilg_dr_name,1,250),'0');--16.bilg_dr_name: 开单医师姓名
    LS_feedetail := SF_XT_GETJSONSTR(LS_feedetail,'acord_dept_codg',substrb(C_CFMX.acord_dept_codg,1,250),'0');--17.acord_dept_codg: 受单科室编码
    LS_feedetail := SF_XT_GETJSONSTR(LS_feedetail,'acord_dept_name',substrb(C_CFMX.acord_dept_name,1,250),'0');--18.acord_dept_name: 受单科室名称
    LS_feedetail := SF_XT_GETJSONSTR(LS_feedetail,'orders_dr_code',substrb(C_CFMX.orders_dr_code,1,250),'0');--19.orders_dr_code: 受单医生编码
    LS_feedetail := SF_XT_GETJSONSTR(LS_feedetail,'orders_dr_name',substrb(C_CFMX.orders_dr_name,1,250),'0');--20.orders_dr_name: 受单医生姓名
    LS_feedetail := SF_XT_GETJSONSTR(LS_feedetail,'hosp_appr_flag',substrb(C_CFMX.hosp_appr_flag,1,250),'0');--21.hosp_appr_flag: 医院审批标志
    LS_feedetail := SF_XT_GETJSONSTR(LS_feedetail,'tcmdrug_used_way',substrb(C_CFMX.tcmdrug_used_way,1,250),'0');--22.tcmdrug_used_way: 中药使用方式
    LS_feedetail := SF_XT_GETJSONSTR(LS_feedetail,'etip_flag',substrb(C_CFMX.etip_flag,1,250),'0');--23.etip_flag: 外检标志
    LS_feedetail := SF_XT_GETJSONSTR(LS_feedetail,'etip_hosp_code',substrb(C_CFMX.etip_hosp_code,1,250),'0');--24.etip_hosp_code: 外检医院编码
    LS_feedetail := SF_XT_GETJSONSTR(LS_feedetail,'dscg_tkdrug_flag',substrb(C_CFMX.dscg_tkdrug_flag,1,250),'0');--25.dscg_tkdrug_flag: 出院带药标志
    LS_feedetail := SF_XT_GETJSONSTR(LS_feedetail,'matn_fee_flag',substrb(C_CFMX.matn_fee_flag,1,250),'0');--26.matn_fee_flag: 生育费用标志
    LS_feedetail := SF_XT_GETJSONSTR(LS_feedetail,'memo',substrb(C_CFMX.memo,1,250),'0');--27.memo: 备注
    LS_feedetail := SF_XT_GETJSONSTR(LS_feedetail,'comb_no',substrb(C_CFMX.comb_no,1,250),'0');--28.comb_no: 组套编号
    LS_feedetail := SF_XT_GETJSONSTR(LS_feedetail,'exp_content',substrb(C_CFMX.expContent,1,1000),'0');--29.expContent: 字段扩展
    LS_feedetail := SF_XT_GETJSONSTR(LS_feedetail,'fixmedins_hilist_id',substrb(C_CFMX.fixmedins_hilist_id,1,50),'0');--fixmedins_hilist_id 项目编码  字符型 50
    LS_feedetail := SF_XT_GETJSONSTR(LS_feedetail,'fixmedins_hilist_name',substrb(C_CFMX.fixmedins_hilist_name,1,100),'0');--fixmedins_hilist_name  项目名称  字符型 100
    LS_feedetail := SF_XT_GETJSONSTR(LS_feedetail,'hilist_code',substrb(C_CFMX.hilist_code,1,50),'0');--hilist_code 医保项目编码  字符型 50
    LS_feedetail := SF_XT_GETJSONSTR(LS_feedetail,'hilist_name',substrb(C_CFMX.hilist_name,1,100),'0');--hilist_name  医保项目名称  字符型 100

    LS_feedetailList := SF_XT_GETJSONSTR(LS_feedetailList,null,LS_feedetail,'1');
    LS_feedetail_Num:=nvl(LS_feedetail_Num,0)+1;--[数量]费用明细<feedetail>
  end loop;
  LS_feedetailList := SF_XT_GETJSONSTR(null,'feedetail',LS_feedetailList,'2');

  --明细项加标题
  LS_detailJson := SF_XT_GETJSONSTR(null,'setlinfo',LS_detailJson,'1');

  --基金支付信息<payinfo>开始
  if LS_ListJson is not null then
    LS_ListJson:=LS_ListJson||','||LS_PayinfoList;
  else
    LS_ListJson:=LS_PayinfoList;
  end if;

  --门诊慢特病诊断信息<opspdiseinfo>开始
  if LS_ListJson is not null then
    LS_ListJson:=LS_ListJson||','||LS_opspdiseinfoList;
  else
    LS_ListJson:=LS_opspdiseinfoList;
  end if;
  --住院诊断信息< diseinfo>开始
  if LS_ListJson is not null then
    LS_ListJson:=LS_ListJson||','||LS_diseinfoList;
  else
    LS_ListJson:=LS_diseinfoList;
  end if;
  --收费项目信息<iteminfo>开始
  if LS_ListJson is not null then
    LS_ListJson:=LS_ListJson||','||LS_iteminfoList;
  else
    LS_ListJson:=LS_iteminfoList;
  end if;

  --手术操作信息<oprninfo>开始
  if LS_ListJson is not null then
    LS_ListJson:=LS_ListJson||','||LS_oprninfoList;
  else
    LS_ListJson:=LS_oprninfoList;
  end if;

  --重症监护信息<icuinfo>开始
  if LS_ListJson is not null then
    LS_ListJson:=LS_ListJson||','||LS_icuinfoList;
  else
    LS_ListJson:=LS_icuinfoList;
  end if;

  --输血信息<bldinfo>
  if LS_ListJson is not null then
    LS_ListJson:=LS_ListJson||','||LS_bldinfoList;
  else
    LS_ListJson:=LS_bldinfoList;
  end if;

  --费用明细<feedetail>
  if LS_ListJson is not null then
    LS_ListJson:=LS_ListJson||','||LS_feedetailList;
  else
    LS_ListJson:=LS_feedetailList;
  end if;
  if LS_ListJson is not null then
    LS_detailJson:=LS_detailJson||','||LS_ListJson;
  end if;

  --input输入
  LS_inputJson := SF_XT_GETJSONSTR(LS_inputJson,'data',LS_detailJson,'1');

  --拼接整个报文
  LS_QQDATA := LS_MainJson||','||LS_inputJson;
  LS_QQDATA:='{'||LS_QQDATA||'}';

  --修改请求报文
  update ZY_YBJKRZ set QQDATA=LS_QQDATA where YBJKID=PYBJKID;--请求报文

  if PCOMMIT='Y' then
    commit;
  end if;

  PZXZT00:=1;        --输出:执行状态 0:失败 1：成功
  PERRMSG:=null;     --输出:错误信息
exception
  when no_data_found then
    PZXZT00:=0;
    PERRMSG:=substrb('住院DIP清单明细生成失败,'||'错误位置:['||LS_MSGSTR||']原因:'||sqlerrm,1,200);
    rollback;
  when others   then
    PZXZT00:=0;
    PERRMSG:=substrb('住院DIP清单明细生成失败,'||'错误位置:['||LS_MSGSTR||']原因:'||sqlerrm,1,200);
    rollback;
end;
