12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017 |
- using Newtonsoft.Json;
- using Newtonsoft.Json.Linq;
- using PTMedicalInsurance.Business;
- using PTMedicalInsurance.Helper;
- using PTMedicalInsurance.Variables;
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Drawing;
- using System.IO;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.Windows.Forms;
- using PTMedicalInsurance.FormSetter;
- using PTMedicalInsurance.Common;
- using OfficeOpenXml;
- namespace PTMedicalInsurance.Forms
- {
- public partial class BasicData : Form
- {
- //设置实例
- CenterBusiness cBus = new CenterBusiness();
- HisMainBusiness hBus = new HisMainBusiness();
- HisIrisServices hIS = new HisIrisServices();
- MIIrisServices mIS = new MIIrisServices();
- InvokeHelper invoker = new InvokeHelper();
- InsuServices Iis = new InsuServices();
- //1.声明自适应类实例
- AutoResizeForm asc = new AutoResizeForm();
- public JObject joSelectedInsuInfo;
- public int insuInfoIndex = 0;
- public int idInfoIndex = 0;
- int iTotalCount = 0;
- int currentPageIndex = 0;
- private Func<JObject, OutParamWrapper, int> action;
- private DataTable dtAllMapped;
- DataTable dtExport;
- public BasicData()
- {
- InitializeComponent();
- rbgDirecType.SelectedIndex = 0;
- rbgDirecType_C.SelectedIndex = 0;
- rbSingleDown.Checked = true;
- rbOnlyName.Checked = true;
- this.rbgDirecType.ValueChanged += new Sunny.UI.UIRadioButtonGroup.OnValueChanged(this.rbgDirecType_ValueChanged);
- this.pgDownload.PageChanged += new Sunny.UI.UIPagination.OnPageChangeEventHandler(this.pgDownload_PageChanged);
- this.pgCenterDirect.PageChanged += new Sunny.UI.UIPagination.OnPageChangeEventHandler(this.pgCenterDirect_PageChanged);
- Font rowFont = new Font("UTF-8", 8);
- Font columnFont = new Font("UTF-8", 9);
- rbgDirecType.SelectedIndex = 8;
- rbAll.Checked = true;
- //tabControl1.SelectedIndex = 1;
- //this.StartPosition = FormStartPosition.CenterParent;
- asc.controllInitializeSize(this);
- asc.controlAutoSize(this);
- TextCbd.Text = Global.inf.areaCode;
- //查询区域通用目录
- MIIrisServices mIS = new MIIrisServices();
- JObject joRtnTY = mIS.getInterface_TY(Global.inf.interfaceDr.ToString(), "");
- Global.inf.InsuCurrencyCataLogue = JsonHelper.getDestValue(joRtnTY, "InsuCurrencyCataLogue"); //通用目录编码 6
- Global.inf.hospitalDr_TY = JsonHelper.getDestValue(joRtnTY, "HospitalDr_TY"); //通用目录所属医院ID
- }
- #region 函数封装
- private void queryInsuDirectory(int currentPage, int pageSize, int directoryType, int interfaceDr, string code)
- {
- try
- {
- string dirCode = "";
- string dirName = "";
- string approvalNO = "";
- string DosageForm = "";
- string Specifications = "";
- string manufacturers = "";
- Sunny.UI.UIDataGridView dgv;
- Sunny.UI.UIPagination pg;
- if (tabControl1.SelectedIndex == 0)
- {
- dirCode = tbDirectoryCode.Text;
- dirName = tbDircetoryName.Text;
- approvalNO = "";
- dgv = dgvDirectoy;
- pg = pgDownload;
- }
- else
- {
- dirName = tbCenterDirectoryFilter.Text;
- dirCode = tbInsuCode.Text;
- dgv = dgvCenterDirectory;
- approvalNO = tbApprovalNO.Text;
- pg = pgCenterDirect;
- manufacturers = tbManufacturer.Text;
- DosageForm = tbDosageForm.Text;
- Specifications = tbSpecifications.Text;
- }
- JObject joInput = new JObject {
- { "currentPage" , currentPage },
- { "pageSize" , pageSize },
- { "serviceCode" , code },
- { "directoryType" , directoryType },
- { "directoryCode" , dirCode },
- { "directoryName" , dirName },
- { "approvalNO" , approvalNO },
- { "dosageForm" , DosageForm },
- { "specifications" , Specifications },
- { "manufacturers" , manufacturers },
- { "directoryDr" , interfaceDr }
- };
- JObject joRtn = mIS.getMIDirectoryByPagination(joInput);
- if (joRtn["errorCode"].ToString() != "0")
- {
- MessageBox.Show("IRIS数据返回错误:" + joRtn["errorMessage"].ToString());
- return;
- }
- if (joRtn["result"]["rows"] == null)
- {
- MessageBox.Show("该节点不存在");
- return;
- }
- if (joRtn["result"]["total"].ToString() == "0")
- {
- MessageBox.Show("未查询到数据");
- dgv.DataSource = null;
- return;
- }
- DataTable dt = (DataTable)joRtn["result"]["rows"].ToObject(typeof(DataTable));
- int totalCount = int.Parse(joRtn["result"]["total"].ToString());
- pg.TotalCount = totalCount;
- pg.PageSize = pageSize;
- dgv.DataSource = dt;
- dgv.Columns[0].ReadOnly = true;
- }
- catch (Exception ex)
- {
- MessageBox.Show("查询异常:" + ex.Message);
- }
- }
- private void setHeaderTxt(int directoryType, Sunny.UI.UIDataGridView dgv)
- {
- GridViewSetter gvdSetter = new GridViewSetter();
- switch (directoryType)
- {
- case 0://药品
- {
- gvdSetter.SetHeaderTextOfDrug(dgv);
- break;
- }
- case 1://诊疗
- {
- gvdSetter.SetHeaderTextOfMedicalService(dgv);
- break;
- }
- case 2://材料
- {
- gvdSetter.SetHeaderTextOfMaterials(dgv);
- break;
- }
- case 3://疾病诊断
- {
- gvdSetter.SetHeaderTextOfDiagnose(dgv);
- break;
- }
- case 4://手术
- {
- gvdSetter.SetHeaderTextOfDiagnose(dgv);
- break;
- }
- case 5://慢性病
- {
- gvdSetter.SetHeaderTextOfDiagnose(dgv);
- break;
- }
- case 6://DRGs
- {
- gvdSetter.SetHeaderTextOfDiagnose(dgv);
- break; ;
- }
- case 7://日间手术
- {
- gvdSetter.SetHeaderTextOfDiagnose(dgv);
- break; ;
- }
- case 8://字典表
- {
- gvdSetter.SetHeaderTextOfDictionary(dgv);
- break;
- }
- case 9://中药饮片下载
- {
- gvdSetter.SetHeaderTextOfChineseMedicine(dgv);
- break;
- }
- case 10://医药机构制剂目录下载
- {
- gvdSetter.SetHeaderTextOfPreparation(dgv);
- break;
- }
- case 11://肿瘤形态学下载
- {
- gvdSetter.SetHeaderTextOfTumorMorphology(dgv);
- break;
- }
- case 12:
- {
- //中医疾病下载
- gvdSetter.GetChineseDiagnoseJsonByTxt(dgv);
- // ICPC3
- //gvdSetter.SetICPCAdmReasonHeader(dgv);
- break;
- }
- case 13:
- {
- //中医证候下载
- gvdSetter.GetTCMSyndromeJsonByTxt(dgv);
- // ICPC3
- //gvdSetter.SetICPCTreatmentHeader(dgv);
- break;
- }
- case 14://民族药品
- {
- gvdSetter.GetEthnicMedicineJsonByTxt(dgv);
- break;
- }
- case 15://目录信息查询
- {
- gvdSetter.GetMedInsuCatalogJsonByTxt(dgv);
- break;
- }
- case 16://医疗与医保目录匹配关系查询
- {
- gvdSetter.GetMedInsuCorrespondencJsonByTxt(dgv);
- break;
- }
- case 17://医药机构目录匹配查询
- {
- gvdSetter.GetMedInstCorrespondencJsonByTxt(dgv);
- break;
- }
- case 18://医保目录限价查询
- {
- gvdSetter.GetMedInsuFixedPriceJsonByTxt(dgv);
- break;
- }
- case 19://医保目录先自付比例下载
- {
- gvdSetter.GetMedInsuFirstPayProportionJsonByTxt(dgv);
- break;
- }
- case 20://医药机构信息
- {
- gvdSetter.GetMedicalInstitutionJsonByTxt(dgv);
- break;
- }
- }
- gvdSetter.DatagridviewColumnWidthAdaptation(dgv);
- }
- private void queryHISInsuDirectory(int directoryType, int pageIndex, int count, Sunny.UI.UIDataGridView dgv, int interfaceDr)
- {
- string code = "09010042";
- if (tabControl1.SelectedIndex == 0)
- {
- if (rbgDirecType.SelectedIndex == 20)
- {
- code = "090100XX";
- }
- else if (rbgDirecType.SelectedIndex == 8)
- {
- code = "09010043";
- }
- else
- {
- code = "09010042";
- }
- if (rbgDirecType.SelectedIndex <= 13)
- {
- queryInsuDirectory(pageIndex, count, directoryType + 1, interfaceDr, code);
- setHeaderTxt(directoryType, dgv);
- }
- else //几个医保查询该部分数据不存数据库只是临时查询(除医疗机构信息查询外)
- {
- //生成DataView列
- //setHeaderTxt(directoryType, dgv);
- string pages, recordCounts, errorMessage, sOutpar;
- dynamic joData = GetInput(rbgDirecType.SelectedIndex, out TradeEnum trade);
- JObject joRtn = cBus.InvokeMedicalInsuranceInquiry(trade, joData);
- if (joRtn["infcode"].ToString() == "0")
- {
- try
- {
- Sunny.UI.UIPagination pg;
- dgv = dgvDirectoy;
- pg = pgDownload;
- DataTable dt;
- if (rbgDirecType.SelectedIndex == 20)
- {
- dt = (DataTable)joRtn["output"]["medinsinfo"].ToObject(typeof(DataTable));
- if (joRtn["output"]["medinsinfo"].ToString() == "")
- {
- MessageBox.Show("查询成功,但返回结果集为空!");
- //return;
- }
- pg.TotalCount = 50;
- pg.PageSize = 50;
- }
- else
- {
- pages = joRtn["output"]["pages"].ToString(); //页数
- recordCounts = joRtn["output"]["recordCounts"].ToString(); //总记录条数
- dt = (DataTable)joRtn["output"]["data"].ToObject(typeof(DataTable));
- if (recordCounts == "0")
- {
- MessageBox.Show("查询成功,但返回结果集为空!");
- //return;
- }
- pg.TotalCount = int.Parse(recordCounts);
- pg.PageSize = int.Parse(TexBYSJL.Text); //int.Parse(pages);
- }
- dgv.DataSource = dt;
- dgv.Columns[0].ReadOnly = true;
- }
- catch (Exception ex)
- {
- MessageBox.Show("查询异常:" + ex.Message);
- }
- }
- else
- {
- errorMessage = "调用交易" + trade.GetCode() + "出现错误,请查看日志!"; //joImportRtn["errorMessage"].ToString();
- MessageBox.Show(errorMessage);
- return;
- }
- }
- }
- else
- {
- queryInsuDirectory(pageIndex, count, directoryType + 1, interfaceDr, code);
- setHeaderTxt(directoryType, dgv);
- }
- GridViewSetter gridSetter = new GridViewSetter();
- gridSetter.DatagridviewColumnWidthAdaptation(dgvCenterDirectory);
- }
- private int queryHISDirectory(int currentPage, int pageSize, out string errMsg)
- {
- errMsg = "";
- string directoryType = string.Empty;
- switch (rbgDirecType_C.SelectedIndex)
- {
- case 0:
- {
- directoryType = "drugs";
- break;
- }
- case 1:
- {
- directoryType = "diagnosi";
- break;
- }
- case 2:
- {
- directoryType = "consumables";
- break;
- }
- }
- JObject joHISRtn = new JObject();
- JObject joRtn = new JObject();
- InvokeHelper invoker = new InvokeHelper();
- string flag = "";
- //全部是先调HIS,然后再匹配医保平台的对照关系
- if (rbAll.Checked)
- {
- JArray jaPagination = new JArray();
- JArray jaParams = new JArray();
- flag = "All";
- dynamic joParam = new JObject();
- joParam.code = "";
- joParam.descripts = "";
- joParam.FindType = new JArray();
- joParam.TypeID = "";
- joParam.alias = tbHISDirectoryFilter.Text;
- joParam.include = "Hosp";
- joParam.groupID = "324";
- joParam.hospID = Global.inf.hisHospitalDr;
- joParam.interfaceDr = Global.inf.interfaceDr;
- joParam.type = directoryType;
- joParam.flag = flag;
- joParam.specInput = txtSpecFilter.Text.Trim();
- jaParams.Add(joParam);
- dynamic joPagination = new JObject();
- joPagination.pageSize = pageSize;
- //joPagination.pageSize = 2;
- joPagination.currentPage = currentPage;
- joPagination.sortColumn = "Code";
- joPagination.sortOrder = "asc";
- jaPagination.Add(joPagination);
- //该服务需要改写,需要跟(CloudMedicalInsurancePlatform.Tables.MapRelation)进行关联
- //joInParams.code = "09010038";
- if (hIS.getHISDir(jaPagination, jaParams, out joHISRtn, out errMsg) != 0)
- {
- return -1;
- }
- joRtn = mIS.ConvertHISDir(joHISRtn);
- if (JsonHelper.parseIrisRtnValue(joRtn, out errMsg) != 0)
- {
- return -1;
- }
- }
- //已对照是先调云医保,然后再匹配HIS
- if (rbMaped.Checked)
- {
- JArray jaPagination = new JArray();
- JArray jaParams = new JArray();
- flag = "Maped";
- dynamic joParam = new JObject();
- joParam.alias = tbHISDirectoryFilter.Text;
- joParam.HospitalDr = Global.inf.hospitalDr;
- joParam.InterfaceDr = Global.inf.interfaceDr;
- joParam.hisType = directoryType;
- jaParams.Add(joParam);
- dynamic joPagination = new JObject();
- joPagination.pageSize = pageSize;
- joPagination.currentPage = currentPage;
- joPagination.sortColumn = "HisCode";
- joPagination.sortOrder = "asc";
- jaPagination.Add(joPagination);
- JObject joMIRtn = mIS.GetMappedHISDir(jaPagination, jaParams);
- if (JsonHelper.parseIrisRtnValue(joMIRtn, out errMsg) != 0)
- {
- return -1;
- }
- //传给HIS,进行匹配
- joParam = new JObject();
- joParam.TotalCount = joMIRtn["result"]["TotalCount"];
- joParam.type = directoryType;
- joParam.flag = flag;
- joParam.hospID = Global.inf.hisHospitalDr;
- joParam.interfaceDr = Global.inf.interfaceDr;
- joParam.alias = tbHISDirectoryFilter.Text;
- joParam.include = "Hosp";
- joParam.groupID = "324";
- joParam.compareArr = joMIRtn["result"]["Data"];
- jaParams = new JArray();
- jaParams.Add(joParam);
- if (hIS.getHISDir(jaPagination, jaParams, out joRtn, out errMsg) != 0)
- {
- return -1;
- }
- }
- //if (rbNoMaped.Checked) { flag = "NoMaped"; }
- if (rbNoMaped.Checked)
- {
- JArray jaPagination = new JArray();
- JArray jaParams = new JArray();
- flag = "All";
- dynamic joParam = new JObject();
- joParam.code = "";
- joParam.descripts = "";
- joParam.FindType = new JArray();
- joParam.TypeID = "";
- joParam.alias = tbHISDirectoryFilter.Text;
- joParam.include = "Hosp";
- joParam.groupID = "324";
- joParam.hospID = Global.inf.hisHospitalDr;
- joParam.interfaceDr = Global.inf.interfaceDr;
- joParam.type = directoryType;
- joParam.flag = flag;
- joParam.specInput = "";
- jaParams.Add(joParam);
- dynamic joPagination = new JObject();
- joPagination.pageSize = pageSize;
- //joPagination.pageSize = 2;
- joPagination.currentPage = currentPage;
- joPagination.sortColumn = "Code";
- joPagination.sortOrder = "asc";
- jaPagination.Add(joPagination);
-
- //1.获取全部HIS目录
- if (hIS.getHISDir(jaPagination, jaParams, out joHISRtn, out errMsg) != 0)
- {
- return -1;
- }
- joRtn = mIS.GetNoMappHISDir(joHISRtn);
- if (JsonHelper.parseIrisRtnValue(joRtn, out errMsg) != 0)
- {
- return -1;
- }
- }
- DataTable dt = (DataTable)joRtn["result"]["Data"].ToObject(typeof(DataTable));
- dtExport = dt;
- int totalCount = int.Parse(joRtn["result"]["TotalCount"].ToString());
- pgHISDirect.TotalCount = totalCount;
- //if (rbNoMaped.Checked)
- // pgHISDirect.PageSize = pageSize;
- //else
- // pgHISDirect.PageSize = 50;
- pgHISDirect.PageSize = pageSize;
- dgvHISDirectory.DataSource = null;
- dgvHISDirectory.DataSource = dt;
- dgvHISDirectory.Columns[0].ReadOnly = true;
- GridViewSetter gridSetter = new GridViewSetter();
- gridSetter.SetHeaderTextOfMapping_HisDirectory(dgvHISDirectory);
- gridSetter.DatagridviewColumnWidthAdaptation(dgvHISDirectory);
- return 0;
- }
- private void queryCenterDirectory_09010012(int currentPage, int pageSize)
- {
- string directoryType = string.Empty;
- switch (rbgDirecType_C.SelectedIndex)
- {
- case 0:
- {
- directoryType = "drugs";
- break;
- }
- case 1:
- {
- directoryType = "diagnosi";
- break;
- }
- case 2:
- {
- directoryType = "consumables";
- break;
- }
- }
- dynamic joInParams = new JObject();
- joInParams.pagination = new JArray() as dynamic;
- joInParams.session = new JArray() as dynamic;
- JArray jaParams = new JArray();
- dynamic joParams = new JObject();
- joParams.code = "";
- joParams.descripts = "";
- joParams.FindType = new JArray();
- joParams.TypeID = "";
- joParams.alias = "";
- joParams.include = "Hosp";
- joParams.groupID = "324";
- joParams.hospID = "25";
- joParams.type = directoryType;
- joParams.specInput = "";
- jaParams.Add(joParams);
- joInParams.Add("params", JArray.FromObject(jaParams));
- dynamic joSession = new JObject();
- joSession.userID = "";
- joSession.locID = "";
- joSession.groupID = "";
- joSession.hospID = "";
- joSession.sessionID = "";
- joSession.hospCode = "";
- joSession.language = "";
- joSession.hostName = "";
- joSession.ipv4 = "";
- joSession.ipv6 = "";
- joSession.mac = "";
- joInParams.session.Add(joSession);
- dynamic joPagination = new JObject();
- joPagination.pageSize = pageSize;
- joPagination.currentPage = currentPage;
- joPagination.sortColumn = "Code";
- joPagination.sortOrder = "asc";
- joInParams.pagination.Add(joPagination);
- joInParams.code = "09010012";
- string sInput = joInParams.ToString();
- string sRtn = invoker.invokeInsuService(joInParams, "");
- JObject jsonRtn = JObject.Parse(sRtn);
- if (jsonRtn["result"]["Data"] == null)
- {
- MessageBox.Show("该节点不存在");
- return;
- }
- JObject joRtn = JObject.Parse(sRtn);
- DataTable dt = (DataTable)joRtn["result"]["Data"].ToObject(typeof(DataTable));
- int totalCount = int.Parse(joRtn["result"]["TotalCount"].ToString());
- pgCenterDirect.TotalCount = totalCount;
- pgCenterDirect.PageSize = 50;
- dgvCenterDirectory.DataSource = dt;
- }
- private void Mapping()
- {
- int iHis = dgvHISDirectory.CurrentRow.Index;
- if (dgvCenterDirectory.CurrentRow == null)
- {
- MessageBox.Show("请查询中心目录");
- return;
- }
- int iCenter = dgvCenterDirectory.CurrentRow.Index;
- DataTable dtHis = (DataTable)dgvHISDirectory.DataSource;
- DataTable dtCenter = (DataTable)dgvCenterDirectory.DataSource;
- dgvHISDirectory.Rows[iHis].Cells["insuCode"].Value = dgvCenterDirectory.Rows[iCenter].Cells["Code"].Value.ToString();
- dgvHISDirectory.Rows[iHis].Cells["insuName"].Value = dgvCenterDirectory.Rows[iCenter].Cells["Name"].Value.ToString();
- int hisType = rbgDirecType_C.SelectedIndex + 1;
- string hisTypeName = rbgDirecType_C.Items[hisType - 1].ToString(); ;
- JArray jaParams = new JArray();
- dynamic jsonTemp = new JObject();
- jsonTemp.ID = dtHis.Rows[iHis]["MapID"];
- jsonTemp.HospitalDr = Global.inf.hospitalDr;
- jsonTemp.updateUserID = Global.user.ID;
- jsonTemp.InterfaceDr = Global.inf.interfaceDr;
- jsonTemp.HISCode = dgvHISDirectory.Rows[iHis].Cells["itemCode"].Value;
- jsonTemp.HISName = dgvHISDirectory.Rows[iHis].Cells["itemDesc"].Value;
- jsonTemp.ChargeItemDr = dtHis.Rows[iHis]["ID"];
- jsonTemp.DiretoryDr = dtCenter.Rows[iCenter]["medInsuDirectoryID"];
- //1.已对照 2.已对照但未上传 3 已对照且已上传
- jsonTemp.State = 1;
- jsonTemp.HisType = hisType;
- jsonTemp.HisTypeName = hisTypeName;
- jsonTemp.InsuCode = dgvCenterDirectory.Rows[dgvCenterDirectory.CurrentRow.Index].Cells["Code"].Value;
- jsonTemp.InsuName = dgvCenterDirectory.Rows[dgvCenterDirectory.CurrentRow.Index].Cells["Name"].Value;
- jsonTemp.UpdateDate = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
- jaParams.Add(jsonTemp);
- JObject joIn = new JObject();
- joIn.Add(new JProperty("params", jaParams));
- joIn.Add("code", "09010040");
- InvokeHelper invoker = new InvokeHelper();
- JObject joRtn = invoker.invokeInsuService(joIn.ToString(), "插入对照信息");
- //JObject joRtn = JObject.Parse(irisRtn);
- if ((int)joRtn["errorCode"] == 0)
- {
- dgvHISDirectory.Rows[iHis].Cells["flag"].Value = "已对照";
- }
- else
- {
- dgvHISDirectory.Rows[iHis].Cells["flag"].Value = "对照失败";
- }
- }
- private void CancleMapping()
- {
- int iHis = dgvHISDirectory.CurrentRow.Index;
- DataTable dtHis = (DataTable)dgvHISDirectory.DataSource;
- JArray jaParams = new JArray();
- dynamic jsonTemp = new JObject();
- jsonTemp.ID = dtHis.Rows[iHis]["MapID"];
- jsonTemp.HospitalDr = Global.inf.hospitalDr;
- jsonTemp.updateUserID = Global.user.ID;
- jsonTemp.InterfaceDr = Global.inf.interfaceDr;
- jsonTemp.HISCode = dgvHISDirectory.Rows[iHis].Cells["itemCode"].Value;
- jsonTemp.UpdateDate = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
- jaParams.Add(jsonTemp);
- JObject joIn = new JObject();
- joIn.Add(new JProperty("params", jaParams));
- joIn.Add("code", "09010041");
- InvokeHelper invoker = new InvokeHelper();
- JObject joRtn = invoker.invokeInsuService(joIn.ToString(), "取消对照");
- if ((int)joRtn["errorCode"] == 0)
- {
- dgvHISDirectory.Rows[iHis].Cells["insuCode"].Value = "";
- dgvHISDirectory.Rows[iHis].Cells["insuName"].Value = "";
- dgvHISDirectory.Rows[iHis].Cells["flag"].Value = "";
- }
- else
- {
- dgvHISDirectory.Rows[iHis].Cells["flag"].Value = "取消失败";
- }
- }
- public void loadTextDebug()
- {
- DataImoport bus = new DataImoport();
- string txtPath = @"E:\insu\Demo\bin\Debug\20230101535395327567680436.txt";
- JObject joImportRtn = bus.importDataToIrisByTxt(txtPath, 50, 2, uiProcessBar1);
- }
- /// <summary>
- /// 医保目录单个版本号的下载
- /// </summary>
- /// <param name="ver"></param>
- /// <param name="directoryType"></param>
- /// <param name="uiProcessBar"></param>
- /// <param name="errorMessage"></param>
- /// <returns></returns>
- public int downloadDicionary(JObject joData, Sunny.UI.UIProcessBar uiProcessBar, string dictCode,out string errorMessage)
- {
- errorMessage = "";
- int iResult = -1;
- try
- {
- JObject joRtn = cBus.DownDictionay(joData);
- if (JsonHelper.parseCenterRtnValue(joRtn, out errorMessage) == 0)
- {
- DataImoport DI = new DataImoport();
- JArray jaList = JArray.Parse(JsonHelper.getDestValue(joRtn, "output.list"));
- JObject joImportRtn = DI.importDictionary(uiProcessBar, jaList, dictCode);
- if (JsonHelper.parseIrisRtnValue(joImportRtn, out errorMessage) == 0)
- {
- iResult = 0;
- }
- else
- {
- errorMessage = "导入数据出现错误,请查看日志!" + errorMessage;
- }
- }
- return iResult;
- }
- catch (Exception ex)
- {
- errorMessage = "downloadDicionary提示:" + ex.Message;
- return -1;
- }
- }
- #endregion
- private void Form1_Load(object sender, EventArgs e)
- {
- this.WindowState = FormWindowState.Maximized;
- rbgDirecType.ValueChanged += new Sunny.UI.UIRadioButtonGroup.OnValueChanged(rbgDirecType_ValueChanged);
- LabExplain.Visible = false;
- }
- private void btnDownload_Click(object sender, EventArgs e)
- {
- string errorMessage = string.Empty;
- string ver = tbVer.Text;
- JObject input = new JObject();
- input["ver"] = ver;
- // 目录查询
- switch(rbgDirecType.SelectedIndex)
- {
- case 15:
- break;
- case 8: //字典
- {
- if (tbDicDate.Text == "")
- {
- MessageBox.Show("请输入查询日期!");
- return;
- }
- // 支持批量
- string[] dictText = tbDicType.Text.Trim().Split(",".ToCharArray());
- dictText.ToList().ForEach((dict) =>
- {
- this.downloadDict(dict);
- });
- break;
- }
- //case 12:
- // {
- // downloadMedData(TradeEnum.ICPC3AdmReason, ver, uiProcessBar1);
- // break;
- // }
- //case 13:
- // {
- // downloadMedData(TradeEnum.ICPC3Treatment, ver, uiProcessBar1);
- // break;
- // }
- default:
- {
- MedDirDownloadProcess mp = new MedDirDownloadProcess();
- if (rbSingleDown.Checked)
- {
- if (mp.SingleDownload(ver, rbgDirecType.SelectedIndex, uiProcessBar1, out errorMessage) != 0)
- {
- MessageBox.Show("医保目录下载失败:" + errorMessage);
- return;
- }
- }
- if (rbAutoDown.Checked)
- {
- mp.VerChangeEvent += Mp_VerChangeEvent;
- if (mp.AutoDownload(rbgDirecType.SelectedIndex, uiProcessBar1, out errorMessage) != 0)
- {
- MessageBox.Show("医保目录下载失败:" + errorMessage);
- return;
- }
- }
- break;
- }
- }
- btnQuery_Click(sender, e);
- }
- private void Mp_VerChangeEvent(object sender, string ver)
- {
- tbVer.Text = ver;
- }
- private void downloadDict(string dictCode)
- {
- try
- {
- string errorMessage = "";
- dynamic joData = new JObject();
- joData.type = dictCode; //字典类型
- joData.parentValue = ""; //父字典键值
- joData.admdvs = Global.inf.areaCode; //行政区划 就医地
- joData.date = tbDicDate.Text; //查询日期
- joData.vali_flag = "1"; //有效标志
- if (downloadDicionary(joData, uiProcessBar1,dictCode, out errorMessage) != 0)
- {
- MessageBox.Show("医保字典下载失败:" + errorMessage);
- }
- }
- catch (Exception e)
- {
-
- }
- }
- private int downloadMedData(TradeEnum trade,string version,Sunny.UI.UIProcessBar uiProcessBar)
- {
- string errorMessage = "";
- if (rbAutoDown.Checked)
- {
- JObject joMaxVerNO = mIS.getDirectoryMaxVersionNO(rbgDirecType.SelectedIndex);
- string ver = joMaxVerNO["result"]["MaxVersionNO"].ToString();
- if (!string.IsNullOrEmpty(ver))
- {
- version = ver;
- tbVer.Text = ver;
- }
- }
- JObject joRtn = cBus.DownDirecotry(trade, version);
- if (JsonHelper.parseCenterRtnValue(joRtn, out errorMessage) == 0)
- {
- //解析
- DataImoport DI = new DataImoport();
- JObject joImportRtn = DI.importMedDataToIris(trade,joRtn,uiProcessBar);
- if (JsonHelper.parseIrisRtnValue(joImportRtn, out errorMessage) == 0)
- {
- //递归调用
- if (rbAutoDown.Checked)
- {
- downloadMedData(trade, version, uiProcessBar);
- }
- }
- return 0;
- }
- MessageBox.Show(errorMessage);
- return -1;
- }
- private void btnQuery_Click(object sender, EventArgs e)
- {
- #region 校验查询条件
- if ((rbgDirecType.SelectedIndex < 0) || (rbgDirecType.SelectedIndex > 20))
- {
- MessageBox.Show("请先选择查询类型!");
- return;
- }
- if (rbgDirecType.SelectedIndex > 13)
- {
- if (rbgDirecType.SelectedIndex != 20)
- {
- if ((TexDate.Text == "") || (TexDate.Text == "输入日期 2021-01-01"))
- {
- MessageBox.Show("查询条件-请输入查询日期!");
- return;
- }
- if ((TexDQYS.Text == "") || (TexDQYS.Text == "当前页数"))
- {
- MessageBox.Show("查询条件-请输入当前页数!");
- return;
- }
- if ((TexBYSJL.Text == "") || (TexBYSJL.Text == "本页数据量"))
- {
- MessageBox.Show("查询条件-请输入本页数据量!");
- return;
- }
- }
- else
- {
- if ((TexYYMC.Text == "") || (TexYYMC.Text == "输入医院名称模糊查找"))
- {
- MessageBox.Show("查询条件-请输入医院名称模糊查找!");
- return;
- }
- }
- }
- #endregion
- queryHISInsuDirectory(rbgDirecType.SelectedIndex, 1, 20, dgvDirectoy, Global.inf.interfaceDr);
- }
- private void btnQueryHISDirectory_Click(object sender, EventArgs e)
- {
- this.dgvHISDirectory.SelectionChanged -= this.dgvHISDirectory_SelectionChanged;
- int iCount = 50;
- if (rbNoMaped.Checked)
- {
- iCount = 300;
- }
- string errMsg;
- if (queryHISDirectory(1, iCount, out errMsg) != 0)
- {
- MessageBox.Show(errMsg);
- return;
- }
- this.dgvHISDirectory.SelectionChanged += this.dgvHISDirectory_SelectionChanged;
- }
- private void btnQueryCenterDirectory_Click(object sender, EventArgs e)
- {
- if ((tbCenterDirectoryFilter.Text == "") && (tbInsuCode.Text == "") && (tbApprovalNO.Text == "") &&
- (tbManufacturer.Text == "") && (tbSpecifications.Text == "") && (tbDosageForm.Text == ""))
- {
- return;
- }
- //查询区域通用目录
- JObject joRtn = mIS.getInterface_TY(Global.inf.interfaceDr.ToString(),"");
- string InsuCurrencyCataLogue = JsonHelper.getDestValue(joRtn, "InsuCurrencyCataLogue"); //通用目录编码 6
- string InterfaceName_TY = JsonHelper.getDestValue(joRtn, "InterfaceName_TY"); //通用目录名称
- string HospName_TY = JsonHelper.getDestValue(joRtn, "HospitalName"); //目录名称
- string HospitalDr_TY = JsonHelper.getDestValue(joRtn, "HospitalDr_TY"); //区域通用目录医院ID
- if (InsuCurrencyCataLogue != "")
- {
- queryHISInsuDirectory(rbgDirecType_C.SelectedIndex, 1, 50, dgvCenterDirectory, int.Parse(InsuCurrencyCataLogue));
- LabExplain.Visible = true;
- LabExplain.Text = "当前接口已设置区域通用目录,数据源:" + HospName_TY + " ,如果确认没有所查目录请联系数据源医院新增维护!";
- }
- else
- {
- queryHISInsuDirectory(rbgDirecType_C.SelectedIndex, 1, 50, dgvCenterDirectory, Global.inf.interfaceDr);
- LabExplain.Visible = true;
- LabExplain.Text = "当前接口未设置区域通用目录,数据源:" + HospName_TY;
- }
- }
- private void pgDownload_PageChanged(object sender, object pagingSource, int pageIndex, int count)
- {
- queryHISInsuDirectory(rbgDirecType.SelectedIndex, pageIndex, count, dgvDirectoy, Global.inf.interfaceDr);
- }
- private void pgHISDirect_PageChanged(object sender, object pagingSource, int pageIndex, int count)
- {
- string errMsg;
- int iCount = 50;
- if (rbNoMaped.Checked) iCount = 300;
-
- if (queryHISDirectory(pageIndex, iCount, out errMsg) != 0)
- {
- MessageBox.Show(errMsg);
- return;
- }
- }
- private void pgCenterDirect_PageChanged(object sender, object pagingSource, int pageIndex, int count)
- {
- queryHISInsuDirectory(rbgDirecType_C.SelectedIndex, pageIndex, count, dgvCenterDirectory, Global.inf.interfaceDr);
- }
- private void rbgDirecType_ValueChanged(object sender, int index, string text)
- {
- //选定项不同调用的接口也不相同,Index值大于
- if (rbgDirecType.SelectedIndex > 13)
- {
- uiGroupBox1.Visible = false;
- uiGroupBox5.Visible = false;
- uiGroupBox2.Visible = true;
- //uiGroupBox3.Visible = true;
- uiProcessBar1.Visible = false;
- uiGroupBox2.Left = rbgDirecType.Width + rbgDirecType.Left + 5;
- uiGroupBox3.Left = uiGroupBox2.Width+rbgDirecType.Width + rbgDirecType.Left + 10;
- dgvDirectoy.DataSource = null;
- }
- else
- {
- uiGroupBox1.Visible = true;
- uiGroupBox5.Visible = true;
- uiGroupBox2.Visible = true;
- //uiGroupBox3.Visible = false;
- uiProcessBar1.Visible = true;
- uiGroupBox1.Left = rbgDirecType.Width + rbgDirecType.Left + 5;
- uiGroupBox5.Left = uiGroupBox1.Width + rbgDirecType.Width + rbgDirecType.Left + 10;
- uiGroupBox2.Left = uiGroupBox5.Width + uiGroupBox1.Width + rbgDirecType.Width + rbgDirecType.Left + 15;
- uiGroupBox3.Left = uiGroupBox2.Width + uiGroupBox5.Width + uiGroupBox1.Width + rbgDirecType.Width + rbgDirecType.Left + 20;
- uiProcessBar1.Left = rbgDirecType.Width + rbgDirecType.Left + 5;
- uiProcessBar1.Width = uiGroupBox1.Width + uiGroupBox5.Width + uiGroupBox2.Width + 10;
- }
- setHeaderTxt(rbgDirecType.SelectedIndex, dgvDirectoy);
- }
- private void toolStripMenuItem2_Click(object sender, EventArgs e)
- {
- CancleMapping();
- }
- private void tsmiMapping_Click(object sender, EventArgs e)
- {
- Mapping();
- }
- private void dgvHISDirectory_DoubleClick(object sender, EventArgs e)
- {
- int currentPage = pgHISDirect.ActivePage;
- string flag = dgvHISDirectory.Rows[dgvHISDirectory.CurrentRow.Index].Cells["flag"].Value.ToString();
- if (flag == "未对照")
- {
- Mapping();
- }
- else
- if (flag == "已对照")
- {
- CancleMapping();
- }
- if (rbAll.Checked)
- {
- string errMsg;
- if (queryHISDirectory(1, 50, out errMsg) != 0)
- {
- MessageBox.Show(errMsg);
- return;
- }
- }
- }
- private void dgvDirectoy_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
- {
- }
- private void dgvDirectoy_CellContentClick(object sender, DataGridViewCellEventArgs e)
- {
- }
- private void uiRadioButton1_CheckedChanged(object sender, EventArgs e)
- {
- }
- private void dgvDirectoy_RowPostPaint(object sender, DataGridViewRowPostPaintEventArgs e)
- {
- //自动编号,与数据无关
- Rectangle rectangle = new Rectangle(e.RowBounds.Location.X,
- e.RowBounds.Location.Y,
- dgvDirectoy.RowHeadersWidth - 4,
- e.RowBounds.Height);
- TextRenderer.DrawText(e.Graphics,
- (e.RowIndex + 1).ToString(),
- dgvDirectoy.RowHeadersDefaultCellStyle.Font,
- rectangle,
- dgvDirectoy.RowHeadersDefaultCellStyle.ForeColor,
- TextFormatFlags.VerticalCenter | TextFormatFlags.Right);
- }
- private void rbAll_ValueChanged(object sender, bool value)
- {
- //if (rbAll.Checked)
- //{
- // btnQueryHISDirectory_Click(null, new EventArgs());
- //}
- }
- private void rbMaped_CheckedChanged(object sender, EventArgs e)
- {
- //if (rbMaped.Checked)
- //{
- // string errMsg;
- // if (queryHISDirectory(1, 50, out errMsg) != 0)
- // {
- // MessageBox.Show(errMsg);
- // return;
- // }
- //}
- }
- private void btAddDir_Click(object sender, EventArgs e)
- {
- if (rbgDirecType.SelectedIndex == 8)
- {
- string errMsg = "";
- AddSingleDictionary addDictionary = new AddSingleDictionary();
- if (addDictionary.ShowDialog() == DialogResult.OK)
- {
- if (UpdateDictionaryBySelf(addDictionary, out errMsg) != 0)
- {
- MessageBox.Show(errMsg);
- }
- else
- {
- MessageBox.Show("新增成功!");
- }
- }
- }
- else
- {
- AddSingleDirectory addDirectory = new AddSingleDirectory(rbgDirecType.SelectedIndex);
- if (addDirectory.ShowDialog() == DialogResult.OK)
- {
- JObject joRtn = mIS.UpdateDirectoryBySelf(addDirectory.joPamam);
- string error = "";
- if (JsonHelper.parseIrisRtnValue(joRtn, out error) != 0)
- {
- MessageBox.Show("新增失败:" + error);
- }
- else
- {
- MessageBox.Show("新增成功");
- }
- }
- }
- }
- private void btEditDir_Click(object sender, EventArgs e)
- {
- DataTable dt = (DataTable)dgvDirectoy.DataSource;
- if ((dt == null) || (dt.Rows.Count < 1))
- {
- MessageBox.Show("表中无数据,请检查!");
- return;
- }
- DataRow dr = dt.Rows[dgvDirectoy.CurrentRow.Index];
- AddSingleDirectory addDirectory = new AddSingleDirectory(rbgDirecType.SelectedIndex, dr);
- if (addDirectory.ShowDialog() == DialogResult.OK)
- {
- JObject joRtn = mIS.UpdateDirectoryBySelf(addDirectory.joPamam);
- string error = "";
- if (JsonHelper.parseIrisRtnValue(joRtn, out error) != 0)
- {
- MessageBox.Show("修改失败:" + error);
- }
- else
- {
- MessageBox.Show("修改成功");
- }
- }
- }
- private void btnExit_Click(object sender, EventArgs e)
- {
- Close();
- }
- /// <summary>
- /// 几个医保查询的交易组织入参
- /// </summary>
- /// <param name="Index"></param>
- /// <param name="funNo"></param>
- /// <returns></returns>
- private JObject GetInput(int Index, out TradeEnum trade)
- {
- trade = TradeEnum.MedicalServiceDirectory;
- dynamic joData = new JObject();
- switch (Index)
- {
- case 14://民族药品目
- {
- trade = TradeEnum.NationalityDrug;
- joData.med_list_codg = tbDirectoryCode.Text; //医疗目录编码
- joData.genname_codg = ""; //通用名编号
- joData.drug_genname = ""; //药品通用名
- joData.drug_prodname = tbDircetoryName.Text; //药品商品名
- joData.reg_name = ""; //注册名称
- joData.tcmherb_name = ""; //中草药名称
- joData.mlms_name = ""; //药材名称
- joData.vali_flag = ""; //有效标志
- joData.rid = ""; //唯一记录号
- joData.ver = ""; //版本号
- joData.ver_name = ""; //版本名称
- joData.opt_begn_time = ""; //经办开始时间
- joData.opt_end_time = ""; //经办结束时间
- joData.updt_time = TexDate.Text; //更新时间
- joData.page_num = TexDQYS.Text; //当前页数
- joData.page_size = TexBYSJL.Text; //本页数据量
- break;
- }
- case 15://目录信息查询
- {
- trade = TradeEnum.InsuDirectory;
- joData.query_date = ""; //查询时间点
- joData.hilist_code = tbDirectoryCode.Text; //医保目录编码
- joData.insu_admdvs = TextCbd.Text; //参保机构医保区划
- joData.begndate = ""; //开始日期
- joData.hilist_name = tbDircetoryName.Text; //医保目录名称
- joData.wubi = ""; //五笔助记码
- joData.pinyin = ""; //拼音助记码
- joData.med_chrgitm_type = ""; //医疗收费项目类别
- joData.chrgitm_lv = ""; //收费项目等级
- joData.lmt_used_flag = ""; //限制使用标志
- joData.list_type = ""; //目录类别
- joData.med_use_flag = ""; //医疗使用标志
- joData.matn_used_flag = ""; //生育使用标志
- joData.hilist_use_type = ""; //医保目录使用类别
- joData.lmt_cpnd_type = ""; //限复方使用类型
- joData.vali_flag = ""; //有效标志
- joData.updt_time = TexDate.Text; //更新时间
- joData.page_num = TexDQYS.Text; //当前页数
- joData.page_size = TexBYSJL.Text; //本页数据量
- break;
- }
- case 16://医疗与医保目录匹配
- {
- trade = TradeEnum.MedicalAndInsuDirectory;
- joData.query_date = ""; //查询时间点
- joData.medins_list_codg = ""; //定点医药机构目录编号
- joData.hilist_code = tbDirectoryCode.Text; //医保目录编码
- joData.list_type = ""; //目录类别
- joData.insu_admdvs = TextCbd.Text; //参保机构医保区划
- joData.begndate = ""; //开始日期
- joData.vali_flag = ""; //有效标志
- joData.updt_time = TexDate.Text; //更新时间
- joData.page_num = TexDQYS.Text; //当前页数
- joData.page_size = TexBYSJL.Text; //本页数据量
- break;
- }
- case 17://医药机构目录匹配
- {
- trade = TradeEnum.MedcineOrgDirectory;
- joData.query_date = ""; //查询时间点
- joData.fixmedins_code = ""; //定点医药机构编号
- joData.medins_list_codg = ""; //定点医药机构目录编号
- joData.medins_list_name = ""; //定点医药机构目录名称
- joData.insu_admdvs = TextCbd.Text; //参保机构医保区划
- joData.list_type = ""; //目录类别
- joData.med_list_codg = tbDirectoryCode.Text; //医疗目录编码
- joData.begndate = ""; //开始日期
- joData.vali_flag = ""; //有效标志
- joData.updt_time = TexDate.Text; //更新时间
- joData.page_num = TexDQYS.Text; //当前页数
- joData.page_size = TexBYSJL.Text; //本页数据量
- break;
- }
- case 18://医保目录限价
- {
- trade = TradeEnum.InsuPriceLimitDirectory;
- joData.query_date = ""; //查询时间点
- joData.hilist_code = tbDirectoryCode.Text; //医保目录编码
- joData.hilist_lmtpric_type = ""; //医保目录限价类型
- joData.overlmt_dspo_way = ""; //医保目录超限处理方式
- joData.insu_admdvs = TextCbd.Text; //参保机构医保区划
- joData.begndate = ""; //开始日期
- joData.enddate = ""; //结束日期
- joData.vali_flag = ""; //有效标志
- joData.rid = ""; //唯一记录号
- joData.tabname = ""; //表名
- joData.poolarea_no = ""; //统筹区
- joData.updt_time = TexDate.Text; //更新时间
- joData.page_num = TexDQYS.Text; //当前页数
- joData.page_size = TexBYSJL.Text; //本页数据量
- break;
- }
- case 19://医保目录先自付比例
- {
- trade = TradeEnum.PrepayPercentDirectory;
- joData.query_date = ""; //查询时间点
- joData.hilist_code = tbDirectoryCode.Text; //医保目录编码
- joData.selfpay_prop_psn_type = "";//医保目录自付比例人员类别
- joData.selfpay_prop_type = ""; //目录自付比例类别
- joData.insu_admdvs = TextCbd.Text; //参保机构医保区划
- joData.begndate = ""; //开始日期
- joData.enddate = ""; //结束日期
- joData.vali_flag = ""; //有效标志
- joData.rid = ""; //唯一记录号
- joData.tabname = ""; //表名
- joData.poolarea_no = ""; //统筹区
- joData.updt_time = TexDate.Text; //更新时间
- joData.page_num = TexDQYS.Text; //当前页数
- joData.page_size = TexBYSJL.Text; //本页数据量
- break;
- }
- case 20://医药机构信息
- {
- trade = TradeEnum.MedicalOrgination;
- joData.fixmedins_type = "1"; //定点医疗服务机构类型 1定点医疗机构,2定点零售药店,3工伤定点康复机构,4辅助器具配置机构,5计划生育服务机构
- joData.fixmedins_name = TexYYMC.Text; //定点医药机构名称
- joData.fixmedins_code = ""; //定点医药机构编号
- break;
- }
- }
- return joData;
- }
- private void uiButton1_Click(object sender, EventArgs e)
- {
- Close();
- }
- /// <summary>
- /// 单条上传目录对照关系
- /// </summary>
- private void SingleUpload()
- {
- if ((dgvHISDirectory.CurrentRow == null))
- {
- MessageBox.Show("请查询HIS目录对照关系");
- return;
- }
- string errorMsg = "", sMLLX = "";
- //单条目录对照关系上传
- int iHis = dgvHISDirectory.CurrentRow.Index;
- DataTable dtHis = (DataTable)dgvHISDirectory.DataSource;
- int hisType = rbgDirecType_C.SelectedIndex + 1; //1药品 2诊疗 3材料
- //string hisTypeName = rbgDirecType_C.Items[hisType - 1].ToString();
- if (hisType == 1)
- {
- sMLLX = "101"; //101西药中成药 102中药饮片 103自制剂 104民族药 201医疗服务项目 301医用耗材 501长护服务项目 105其他
- }
- else if (hisType == 2)
- {
- sMLLX = "201";
- }
- else if (hisType == 3)
- {
- sMLLX = "301";
- }
- string InsuCode = dtHis.Rows[iHis]["InsuCode"].ToString();
- string InsuName = dtHis.Rows[iHis]["InsuName"].ToString();
- string HisCode = dtHis.Rows[iHis]["itemCode"].ToString();
- string HisName = dtHis.Rows[iHis]["itemDesc"].ToString();
- string UpdateDate = DateTime.Now.ToString("yyyy-MM-dd");
- string MapId = dtHis.Rows[iHis]["MapID"].ToString();
- JArray dataArray = new JArray();
- //调用3301目录对照上传
- JObject joData = new JObject();
- joData.Add("fixmedins_hilist_id", HisCode);
- joData.Add("fixmedins_hilist_name", HisName);
- joData.Add("list_type", sMLLX); //目录类别
- joData.Add("med_list_codg", InsuCode); //医疗目录编码
- joData.Add("begndate", "2023-10-01"); //开始日期
- joData.Add("enddate", UpdateDate); //结束日期
- joData.Add("aprvno", "");
- joData.Add("dosform", "");
- joData.Add("exct_cont", "");
- joData.Add("item_cont", "");
- joData.Add("prcunt", "");
- joData.Add("spec", "");
- joData.Add("pacspec", "");
- joData.Add("memo", "");
- dataArray.Add(joData);
- // 单条与多条保持一致
- JObject joInput = new JObject();
- joInput.Add("data", dataArray);
- InvokeHelper invoker = new InvokeHelper();
- Global.pat.insuplc_admdvs = Global.inf.areaCode;
- JObject joRtn = invoker.invokeCenterService(TradeEnum.DirectoryContrastUpload, joInput);
- if (JsonHelper.parseCenterRtnValue(joRtn, out errorMsg) != 0)
- {
- MessageBox.Show("目录对照关系上传失败:" + errorMsg);
- }
- else
- {
- UpdateUploadStatus(MapId, 3);
- MessageBox.Show("目录对照关系上传成功!");
- }
- }
- /// <summary>
- /// 单条撤销目录对照关系上传
- /// </summary>
- private void SingleCancelUpload()
- {
- if ((dgvHISDirectory.CurrentRow == null) || (rbMaped.Checked != true))
- {
- MessageBox.Show("请查询HIS目录对照关系");
- return;
- }
- string errorMsg = "", sMLLX = "";
- //撤销目录对照关系
- DataTable dtHis = (DataTable)dgvHISDirectory.DataSource;
- int iHis = dgvHISDirectory.CurrentRow.Index;
- string InsuCode = dtHis.Rows[iHis]["InsuCode"].ToString();
- string HisCode = dtHis.Rows[iHis]["HisCode"].ToString();
- string MapId = dtHis.Rows[iHis]["MapID"].ToString();
- int hisType = rbgDirecType_C.SelectedIndex + 1; //1药品 2诊疗 3材料
- //string hisTypeName = rbgDirecType_C.Items[hisType - 1].ToString();
- if (hisType == 1)
- {
- sMLLX = "101"; //101西药中成药 102中药饮片 103自制剂 104民族药 201医疗服务项目 301医用耗材 501长护服务项目 105其他
- }
- else if (hisType == 2)
- {
- sMLLX = "201";
- }
- else if (hisType == 3)
- {
- sMLLX = "301";
- }
- //调用3302目录对照撤销
- JObject joData = new JObject();
- joData.Add("fixmedins_code", Global.inf.hospitalNO);
- joData.Add("fixmedins_hilist_id", HisCode);
- joData.Add("list_type", sMLLX); //目录类别
- joData.Add("med_list_codg", InsuCode); //医疗目录编码
- JObject joInput = new JObject();
- joInput.Add("data", joData);
- InvokeHelper invoker = new InvokeHelper();
- Global.pat.insuplc_admdvs = Global.inf.areaCode;
- JObject joRtn = invoker.invokeCenterService(TradeEnum.DirectoryContrastCancel, joInput);
- if (JsonHelper.parseCenterRtnValue(joRtn, out errorMsg) != 0)
- {
- MessageBox.Show("目录对照撤销失败:" + errorMsg);
- }
- else
- {
- UpdateUploadStatus(MapId, 2);
- MessageBox.Show("目录对照撤销成功!");
- }
- }
- /// <summary>
- /// 全部上传目录对照关系
- /// </summary>
- private void AllUpLoad()
- {
- if ((dgvHISDirectory.CurrentRow == null))
- {
- MessageBox.Show("请查询HIS目录对照关系");
- return;
- }
- string sInputStr = "", sMLLX = "", errorMsg = "", Msg = "";
- Boolean bOk = true;
- JObject InputjoRtn = new JObject();
- string UpdateDate = DateTime.Now.ToString("yyyy-MM-dd");
- int hisType = rbgDirecType_C.SelectedIndex + 1; //1药品 2诊疗 3材料
- if (hisType == 1)
- {
- sMLLX = "101"; //101西药中成药 102中药饮片 103自制剂 104民族药 201医疗服务项目 301医用耗材 501长护服务项目 105其他
- }
- else if (hisType == 2)
- {
- sMLLX = "201";
- }
- else if (hisType == 3)
- {
- sMLLX = "301";
- }
- List<String> mapIdList = new List<string>();
- DataTable dtHis = (DataTable)dgvHISDirectory.DataSource;
- JArray dataArray = new JArray();
- for (int i = 0; i < dtHis.Rows.Count; i++)
- {
- string InsuCode = dtHis.Rows[i]["InsuCode"].ToString(); //医保目录编码
- string InsuName = dtHis.Rows[i]["InsuName"].ToString(); //医保目录名称
- string HisCode = dtHis.Rows[i]["itemCode"].ToString(); //HIS目录编码
- string HisName = dtHis.Rows[i]["itemDesc"].ToString(); //HIS目录名称
- mapIdList.Add(dtHis.Rows[i]["MapID"].ToString()); //ID
- //调用3301目录对照上传
- JObject joData = new JObject();
- joData.Add("fixmedins_hilist_id", HisCode);
- joData.Add("fixmedins_hilist_name", HisName);
- joData.Add("list_type", sMLLX); //目录类别
- joData.Add("med_list_codg", InsuCode); //医疗目录编码
- joData.Add("begndate", "2023-10-01"); //开始日期
- joData.Add("enddate", UpdateDate); //结束日期
- joData.Add("aprvno", "");
- joData.Add("dosform", "");
- joData.Add("exct_cont", "");
- joData.Add("item_cont", "");
- joData.Add("prcunt", "");
- joData.Add("spec", "");
- joData.Add("pacspec", "");
- joData.Add("memo", "");
- dataArray.Add(joData);
- }
- JObject joInput = new JObject();
- joInput.Add("data", dataArray);
- Global.pat.insuplc_admdvs = Global.inf.areaCode;
- InvokeHelper invoker = new InvokeHelper();
- JObject joRtn = invoker.invokeCenterService(TradeEnum.DirectoryContrastUpload, joInput);
- if (JsonHelper.parseCenterRtnValue(joRtn, out errorMsg) != 0)
- {
- bOk = false;
- Msg = Msg + "<" + joInput.ToString() + ":" + errorMsg + ">";
- }
- if (bOk == false)
- {
- MessageBox.Show("全部目录对照关系上传成功,部分上传异常:" + Msg);
- }
- else
- {
- UpdateUploadStatus(string.Join(",",mapIdList.ToArray()),3);
- MessageBox.Show("全部目录对照关系上传成功!");
- }
- }
- private void UpdateUploadStatus(string ids, int state)
- {
- if (string.IsNullOrEmpty(ids)) return;
- dynamic joInput = new JObject();
- joInput.HospitalDr = Global.inf.hospitalDr;
- joInput.InterfaceDr = Global.inf.interfaceDr;
- joInput.ID = ids;
- joInput.state = state;
- JObject joRtn = invoker.invokeInsuService(JsonHelper.setIrisInpar("09010103", joInput).ToString(), "更新上传状态");
- if (joRtn["errorCode"].Text() != "0")
- {
- Global.writeLog("更新状态失败!" + joRtn["errorMessage"].ToString());
- }
- }
- /// <summary>
- /// 全部撤销目录对照关系上传
- /// </summary>
- private void AllCancelUpload()
- {
- if ((dgvHISDirectory.CurrentRow == null) || (rbMaped.Checked != true))
- {
- MessageBox.Show("请查询HIS目录对照关系");
- return;
- }
- string sMLLX = "", errorMsg = "", Msg = "";
- Boolean bOk = true;
- string UpdateDate = DateTime.Now.ToString("yyyy-MM-dd");
- int hisType = rbgDirecType_C.SelectedIndex + 1; //1药品 2诊疗 3材料
- if (hisType == 1)
- {
- sMLLX = "101"; //101西药中成药 102中药饮片 103自制剂 104民族药 201医疗服务项目 301医用耗材 501长护服务项目 105其他
- }
- else if (hisType == 2)
- {
- sMLLX = "201";
- }
- else if (hisType == 3)
- {
- sMLLX = "301";
- }
- DataTable dtHis = (DataTable)dgvHISDirectory.DataSource;
- List<String> mapIdList = new List<string>();
- for (int i = 0; i < dtHis.Rows.Count; i++)
- {
- string InsuCode = dtHis.Rows[i]["InsuCode"].ToString();
- string HisCode = dtHis.Rows[i]["HisCode"].ToString();
- mapIdList.Add(dtHis.Rows[i]["MapID"].ToString()); //ID
- //调用3302目录对照撤销
- JObject joData = new JObject();
- joData.Add("fixmedins_code", Global.inf.hospitalNO);
- joData.Add("fixmedins_hilist_id", HisCode);
- joData.Add("list_type", sMLLX); //目录类别
- joData.Add("med_list_codg", InsuCode); //医疗目录编码
- JObject joInput = new JObject();
- joInput.Add("data", joData);
- InvokeHelper invoker = new InvokeHelper();
- JObject joRtn = invoker.invokeCenterService(TradeEnum.DirectoryContrastCancel, joInput);
- if (JsonHelper.parseCenterRtnValue(joRtn, out errorMsg) != 0)
- {
- bOk = false;
- Msg = Msg + "<" + joInput.ToString()+":" + errorMsg + ">";
- }
- }
- if (bOk == false)
- {
- MessageBox.Show("全部撤销目录对照关系上传成功,部分撤销异常:" + Msg);
- }
- else
- {
- UpdateUploadStatus(string.Join(",", mapIdList.ToArray()), 2);
- MessageBox.Show("全部撤销目录对照关系上传成功!");
- }
- }
- private void ToolStripMenuItem_Upload_Click(object sender, EventArgs e)
- {
- SingleUpload();
- }
- private void ToolStripMenuItem_CancelUpload_Click(object sender, EventArgs e)
- {
- SingleCancelUpload();
- }
- private void rbgDirecType_C_ValueChanged(object sender, int index, string text)
- {
- tbHISDirectoryFilter.Text = "";
- uiTextBox1.Text = "";
- rbAll.Checked = true;
- rbMaped.Checked = false;
- rbNoMaped.Checked = false;
- tbCenterDirectoryFilter.Text = "";
- tbInsuCode.Text = "";
- tbApprovalNO.Text = "";
- dgvCenterDirectory.DataSource = null;
- btnQueryHISDirectory_Click(null, new EventArgs());
- }
- private void rbNoMaped_CheckedChanged(object sender, EventArgs e)
- {
- //if (rbNoMaped.Checked)
- //{
- // string errMsg;
- // if (queryHISDirectory(1, 300, out errMsg) != 0)
- // {
- // MessageBox.Show(errMsg);
- // return;
- // }
- //}
- }
- private void dgvHISDirectory_RowStateChanged(object sender, DataGridViewRowStateChangedEventArgs e)
- {
- e.Row.HeaderCell.Value = string.Format("{0}", e.Row.Index + 1);
- }
- private void dgvCenterDirectory_RowStateChanged(object sender, DataGridViewRowStateChangedEventArgs e)
- {
- e.Row.HeaderCell.Value = string.Format("{0}", e.Row.Index + 1);
- }
- private void updateLimitPrice()
- {
- SelfpayPercentForm selfpay = new SelfpayPercentForm();
- selfpay.CenterCode = dgvDirectoy.Rows[dgvDirectoy.SelectedIndex].Cells["Code"].Value + "";
- selfpay.ShowDialog();
- }
-
- private void btSignIn_Click(object sender, EventArgs e)
- {
- if (mIS.isSigned(ref Global.curEvt.signno) != true)
- {
- JObject joRtn = new JObject();
- CallResult callResult = new SignInProcess().Process(joRtn);
- string error = "";
- if (JsonHelper.parseIrisRtnValue(JObject.FromObject(callResult.PureData), out error) != 0)
- {
- MessageBox.Show($"签到失败!{error}");
- }
- else
- {
- MessageBox.Show("签到成功!");
- }
- }
- else
- {
- MessageBox.Show("今日已签到!");
- }
- }
- private void tsmiSingleUpdateAuxInfo_Click(object sender, EventArgs e)
- {
- string error;
- int iDir = dgvDirectoy.CurrentRow.Index;
- if (dgvDirectoy.CurrentRow == null)
- {
- MessageBox.Show("请查询中心目录");
- return;
- }
- JObject jo = new JObject();
- jo.Add("code", dgvDirectoy.Rows[iDir].Cells["code"].Value.ToString());
- jo.Add("HisType", rbgDirecType.SelectedIndex + 1);
- if (updateAuxInfo(jo,out error) != 0)
- {
- MessageBox.Show(error);
- }
- else
- {
- MessageBox.Show(error);
- }
- }
- public string getDataRowValue(DataRow dr, string columnName)
- {
- if (!dr.Table.Columns.Contains(columnName))
- {
- return "";
- }
- else
- {
- return dr[columnName].ToString();
- }
- }
- //更新目录信息(附属信息)
- private int updateAuxInfo(JObject jo,out string err)
- {
- err = "";
- tbDirectoryCode.Text = JsonHelper.getDestValue(jo,"code");
- dynamic joData = GetInput(15, out TradeEnum trade);
- JObject joRtn = cBus.InvokeMedicalInsuranceInquiry(trade, joData);
- if (joRtn["infcode"].ToString() == "0")
- {
- DataTable dtAuxInfo = (DataTable)joRtn["output"]["data"].ToObject(typeof(DataTable));
- DateTime dtToday = DateTime.Today;
- string chrgitm_lv = "";
- string begndate = "";
- string enddate = "";
- string list_type = "";
- string med_chrgitm_type = "";
-
- int iAdpater = 0;
- foreach (DataRow dr in dtAuxInfo.Rows)
- {
- DateTime dtBegin = getDataRowValue(dr, "begndate") == "" ? Convert.ToDateTime("2000-01-01 00:00:00") : Convert.ToDateTime(getDataRowValue(dr, "begndate"));
- DateTime dtEnd = getDataRowValue(dr, "enddate") == "" ? Convert.ToDateTime("2099-01-01 00:00:00") : Convert.ToDateTime(getDataRowValue(dr, "enddate"));
- if ((dtBegin < dtToday) && (dtToday < dtEnd))
- {
- iAdpater++;
- chrgitm_lv = dr["chrgitm_lv"].ToString();
- begndate = dr["begndate"].ToString();
- enddate = dr["enddate"].ToString();
- list_type = dr["list_type"].ToString();
- med_chrgitm_type = dr["med_chrgitm_type"].ToString();
- }
- }
- //有且只能有一条数据符合
- if (iAdpater == 1)
- {
- JObject joPamam = new JObject();
- joPamam.Add("Code", JsonHelper.getDestValue(jo, "code"));
- joPamam.Add("HisType", JsonHelper.getDestValue(jo, "HisType"));
- joPamam.Add("StartDate", begndate);
- joPamam.Add("EndDate", enddate);
- joPamam.Add("ChargeItemLevel", chrgitm_lv);
- joPamam.Add("ListType", list_type);
- joPamam.Add("ChargeItemType", med_chrgitm_type);
- JObject joUpdateRtn = mIS.UpdateDirectoryBySelf(joPamam);
- string error = "";
- if (JsonHelper.parseIrisRtnValue(joUpdateRtn, out error) != 0)
- {
- err = "修改失败:" + error;
- return -1;
- }
- else
- {
- err = "修改成功";
- return 0;
- }
- }
- else
- {
- err = "中心返回符合条数的记录不唯一或者为空,请检查!";
- return -1;
- }
- }
- else
- {
- err = "查询中心数据出错,请检查!";
- return -1;
- }
- }
- //更新目录信息(附属信息)
- private int updateCellingPrice(JObject jo, out string err)
- {
- err = "";
- tbDirectoryCode.Text = JsonHelper.getDestValue(jo, "code");
- dynamic joData = GetInput(18, out TradeEnum trade);
- JObject joRtn = cBus.InvokeMedicalInsuranceInquiry(trade, joData);
- if (joRtn["infcode"].ToString() == "0")
- {
- DataTable dtAuxInfo = (DataTable)joRtn["output"]["data"].ToObject(typeof(DataTable));
- DateTime dtToday = DateTime.Today;
- string cellingPrice = "";
- string begndate = "";
- string enddate = "";
- int iAdpater = 0;
- foreach (DataRow dr in dtAuxInfo.Rows)
- {
- DateTime dtBegin = getDataRowValue(dr, "begndate") == "" ? Convert.ToDateTime("2000-01-01 00:00:00") : Convert.ToDateTime(getDataRowValue(dr, "begndate"));
- DateTime dtEnd = getDataRowValue(dr, "enddate") == "" ? Convert.ToDateTime("2099-01-01 00:00:00") : Convert.ToDateTime(getDataRowValue(dr, "enddate"));
- if ((dtBegin < dtToday) && (dtToday < dtEnd))
- {
- iAdpater++;
- cellingPrice = dr["hilist_pric_uplmt_amt"].ToString();
- begndate = dr["begndate"].ToString();
- enddate = dr["enddate"].ToString();
- }
- }
- //有且只能有一条数据符合
- if (iAdpater == 1)
- {
- JObject joPamam = new JObject();
- joPamam.Add("Code", JsonHelper.getDestValue(jo, "code"));
- joPamam.Add("HisType", JsonHelper.getDestValue(jo, "HisType"));
- joPamam.Add("StartDate", begndate);
- joPamam.Add("EndDate", enddate);
- joPamam.Add("CeilingPrice", cellingPrice);
- JObject joUpdateRtn = mIS.UpdateDirectoryBySelf(joPamam);
- string error = "";
- if (JsonHelper.parseIrisRtnValue(joUpdateRtn, out error) != 0)
- {
- err = "修改失败:" + error;
- return -1;
- }
- else
- {
- err = "修改成功";
- return 0;
- }
- }
- else
- {
- err = "中心返回符合条数的记录不唯一或者为空,请检查!";
- return -1;
- }
- }
- else
- {
- err = "查询中心数据出错,请检查!";
- return -1;
- }
- }
- private int updateSelfRatioInfo(JObject jo, out string err)
- {
- err = "";
- tbDirectoryCode.Text = JsonHelper.getDestValue(jo, "code");
- dynamic joData = GetInput(19, out TradeEnum trade);
- JObject joRtn = cBus.InvokeMedicalInsuranceInquiry(trade, joData);
- if (joRtn["infcode"].ToString() == "0")
- {
- DataTable dtRatioInfo = (DataTable)joRtn["output"]["data"].ToObject(typeof(DataTable));
- DateTime dtToday = DateTime.Today;
- string cellingPrice = "";
- string begndate = "";
- string enddate = "";
- int iAdpater = 0;
- var dataArray = JArray.FromObject(joRtn["output"]["data"]);
- DateTime today = DateTime.Today;
- var groupedResult = dataArray
- .Where(item =>
- {
- if (DateTime.TryParse(item["enddate"]?.ToString(), out var endDate))
- {
- return endDate.Date >= today.Date;
- }
- return false;
- })
- .GroupBy(item => item["selfpay_prop_psn_type"]?.ToString());
- JArray joArray = new JArray();
- foreach (var group in groupedResult)
- {
- foreach (var item in group)
- {
- // 将 JsonNode 转换为 JObject
- JObject jObj = JObject.Parse(item.ToString());
- dynamic joTmp = new JObject();
- joTmp.HospitalDr = Global.inf.hospitalDr;
- joTmp.InterfaceDr = Global.inf.interfaceDr;
- joTmp.updateUserID = Global.user.ID;
- joTmp.Code = jObj["hilist_code"];
- joTmp.PersonnelType = jObj["selfpay_prop_psn_type"];
- joTmp.ProportionType = jObj["selfpay_prop_type"];
- joTmp.Proportion = jObj["selfpay_prop"];
- joTmp.BeginDate = jObj["begndate"];
- joTmp.EndDate = jObj["enddate"];
- joTmp.InsuranceAreaCode = jObj["insu_admdvs"];
- joTmp.PoolAreaNO = jObj["poolarea_no"];
- joTmp.ValidFlag = jObj["vali_flag"];
- joTmp.RequiredID = jObj["rid"];
- joArray.Add(joTmp);
- }
- }
- string errMsg = "";
- InvokeHelper invoker = new InvokeHelper();
- joRtn = invoker.invokeInsuService(JsonHelper.setIrisInpar("09010085", joArray).ToString(), "设置自费比例");
- if (JsonHelper.parseIrisRtnValue(joRtn, out errMsg) != 0)
- {
- err = errMsg;
- return -1;
- }
- else {
- err = ("更新成功!");
- return 0;
- }
- }
- else
- {
- err = "查询中心数据出错,请检查!";
- return -1;
- }
- }
- private void tsmiUpdateCellingPrice_Click(object sender, EventArgs e)
- {
- string error;
- int iDir = dgvDirectoy.CurrentRow.Index;
- if (dgvDirectoy.CurrentRow == null)
- {
- MessageBox.Show("请查询中心目录");
- return;
- }
- JObject jo = new JObject();
- jo.Add("code", dgvDirectoy.Rows[iDir].Cells["code"].Value.ToString());
- jo.Add("HisType", rbgDirecType.SelectedIndex + 1);
- if (updateCellingPrice(jo,out error) != 0)
- {
- MessageBox.Show(error);
- }
- else
- {
- MessageBox.Show(error);
- }
- }
- private void btTripMenu_Click(object sender, EventArgs e)
- {
- uiContextMenuStrip1.Show(((Sunny.UI.UIButton)sender), new Point(0, btTripMenu.Height));
- }
- private void tsmExportAllMappedData_Click(object sender, EventArgs e)
- {
- // 创建 DataLoader 并传递 queryExportData 方法
- DataLoader _dataLoader;
- _dataLoader = new DataLoader(queryExportData_CallBack, this);
- _dataLoader.Start(new object[] { 0 }, (result, errMsg) =>
- {
- // 在这里处理结果和错误信息
- if (result == 0)
- {
- MessageBox.Show(errMsg);
- }
- else
- {
- MessageBox.Show(errMsg);
- }
- });
- }
- private int queryExportData(out string errMsg)
- {
- errMsg = "";
- int currentPage = 1; int pageSize = 50;
- string directoryType = string.Empty;
- switch (rbgDirecType_C.SelectedIndex)
- {
- case 0:
- {
- directoryType = "drugs";
- break;
- }
- case 1:
- {
- directoryType = "diagnosi";
- break;
- }
- case 2:
- {
- directoryType = "consumables";
- break;
- }
- }
- JObject joHISRtn = new JObject();
- JObject joRtn = new JObject();
- string flag = "";
- //全部是先调HIS,然后再匹配医保平台的对照关系
- if (rbAll.Checked)
- {
- JArray jaPagination = new JArray();
- JArray jaParams = new JArray();
- flag = "All";
- dynamic joParam = new JObject();
- joParam.code = "";
- joParam.descripts = "";
- joParam.FindType = new JArray();
- joParam.TypeID = "";
- joParam.alias = tbHISDirectoryFilter.Text;
- joParam.include = "Hosp";
- joParam.groupID = "324";
- joParam.hospID = Global.inf.hisHospitalDr;
- joParam.interfaceDr = Global.inf.interfaceDr;
- joParam.type = directoryType;
- joParam.flag = flag;
- joParam.specInput = txtSpecFilter.Text.Trim();
- jaParams.Add(joParam);
- dynamic joPagination = new JObject();
- joPagination.pageSize = pageSize;
- //joPagination.pageSize = 2;
- joPagination.currentPage = currentPage;
- joPagination.sortColumn = "Code";
- joPagination.sortOrder = "asc";
- jaPagination.Add(joPagination);
- //该服务需要改写,需要跟(CloudMedicalInsurancePlatform.Tables.MapRelation)进行关联
- //joInParams.code = "09010038";
- if (hIS.getHISDir(jaPagination, jaParams, out joHISRtn, out errMsg) != 0)
- {
- return -1;
- }
- int count = int.Parse(JsonHelper.getDestValue(joHISRtn, "result.TotalCount"));
- if (count > pageSize)
- {
- joPagination["pageSize"] = count;
- jaPagination = new JArray();
- jaPagination.Add(joPagination);
- if (hIS.getHISDir(jaPagination, jaParams, out joHISRtn, out errMsg) != 0)
- {
- return -1;
- }
- }
- int defaultCount = 200;
- dtExport = null;
- if (count > defaultCount)
- {
- JArray jaHisDir = JArray.Parse(JsonHelper.getDestValue(joHISRtn, "result.Data"));
- JArray jaTmp = new JArray();
- for (int i = 0; i < count; i++)
- {
- JObject joTmp = (JObject)jaHisDir[i];
- foreach (var property in joTmp.Properties())
- {
- if (property.Value.Type == JTokenType.Integer || property.Value.Type == JTokenType.Float)
- {
- property.Value = new JValue(property.Value.ToString());
- }
- }
- jaTmp.Add(joTmp);
- if ((((i + 1) % defaultCount) == 0) || (i + 1 == count))
- {
- JObject joConvert = new JObject();
- joConvert.Add("errorCode", 0);
- joConvert.Add("errorMessage", "查询成功");
- JObject joResult = new JObject();
- if ((i % defaultCount) == 0)
- {
- joResult.Add("TotalCount", defaultCount);
- }
- else
- {
- joResult.Add("TotalCount", (i + 1) % defaultCount);
- }
- joResult.Add("Data", jaTmp);
- joConvert.Add("result", joResult);
- joRtn = mIS.ConvertHISDir(joConvert);
- if (JsonHelper.parseIrisRtnValue(joRtn, out errMsg) != 0)
- {
- return -1;
- }
- else
- {
- DataTable dtTmp = (DataTable)joRtn["result"]["Data"].ToObject(typeof(DataTable));
- if (dtExport == null)
- {
- dtExport = dtTmp.Clone();
- dtExport.Merge(dtTmp);
- }
- else
- {
- dtExport.Merge(dtTmp);
- }
- jaTmp = new JArray();
- }
- }
- }
- }
- else
- {
- joRtn = mIS.ConvertHISDir(joHISRtn);
- if (JsonHelper.parseIrisRtnValue(joRtn, out errMsg) != 0)
- {
- return -1;
- }
- dtExport = (DataTable)joRtn["result"]["Data"].ToObject(typeof(DataTable));
- }
- }
- //已对照是先调云医保,然后再匹配HIS
- if (rbMaped.Checked)
- {
- JArray jaPagination = new JArray();
- JArray jaParams = new JArray();
- flag = "Maped";
- dynamic joParam = new JObject();
- joParam.alias = tbHISDirectoryFilter.Text;
- joParam.HospitalDr = Global.inf.hospitalDr;
- joParam.InterfaceDr = Global.inf.interfaceDr;
- joParam.hisType = directoryType;
- jaParams.Add(joParam);
- dynamic joPagination = new JObject();
- joPagination.pageSize = pageSize;
- joPagination.currentPage = currentPage;
- joPagination.sortColumn = "HisCode";
- joPagination.sortOrder = "asc";
- jaPagination.Add(joPagination);
- JObject joMIRtn = mIS.GetMappedHISDir(jaPagination, jaParams);
- if (JsonHelper.parseIrisRtnValue(joMIRtn, out errMsg) != 0)
- {
- return -1;
- }
- //传给HIS,进行匹配
- joParam = new JObject();
- joParam.TotalCount = joMIRtn["result"]["TotalCount"];
- joParam.type = directoryType;
- joParam.flag = flag;
- joParam.hospID = Global.inf.hisHospitalDr;
- joParam.interfaceDr = Global.inf.interfaceDr;
- joParam.alias = tbHISDirectoryFilter.Text;
- joParam.include = "Hosp";
- joParam.groupID = "324";
- joParam.compareArr = joMIRtn["result"]["Data"];
- jaParams = new JArray();
- jaParams.Add(joParam);
- if (hIS.getHISDir(jaPagination, jaParams, out joRtn, out errMsg) != 0)
- {
- return -1;
- }
- }
- //if (rbNoMaped.Checked) { flag = "NoMaped"; }
- if (rbNoMaped.Checked)
- {
- JArray jaPagination = new JArray();
- JArray jaParams = new JArray();
- flag = "All";
- dynamic joParam = new JObject();
- joParam.code = "";
- joParam.descripts = "";
- joParam.FindType = new JArray();
- joParam.TypeID = "";
- joParam.alias = tbHISDirectoryFilter.Text;
- joParam.include = "Hosp";
- joParam.groupID = "324";
- joParam.hospID = Global.inf.hisHospitalDr;
- joParam.interfaceDr = Global.inf.interfaceDr;
- joParam.type = directoryType;
- joParam.flag = flag;
- joParam.specInput = "";
- jaParams.Add(joParam);
- dynamic joPagination = new JObject();
- joPagination.pageSize = pageSize;
- //joPagination.pageSize = 2;
- joPagination.currentPage = currentPage;
- joPagination.sortColumn = "Code";
- joPagination.sortOrder = "asc";
- jaPagination.Add(joPagination);
- //1.获取全部HIS目录
- if (hIS.getHISDir(jaPagination, jaParams, out joHISRtn, out errMsg) != 0)
- {
- return -1;
- }
- joRtn = mIS.GetNoMappHISDir(joHISRtn);
- if (JsonHelper.parseIrisRtnValue(joRtn, out errMsg) != 0)
- {
- return -1;
- }
- }
- return 0;
- }
- private int queryExportData_CallBack(object[] o,out string errMsg, DataLoader.ProgressCallback callback, DataLoader.ProgressMaxCallback maxCallback, BackgroundWorker worker)
- {
- if (queryExportData(out errMsg) != 0)
- {
- return -1;
- }
- //test.Stop();
- this.pgHISDirect.PageChanged += new Sunny.UI.UIPagination.OnPageChangeEventHandler(this.pgHISDirect_PageChanged);
- if (dtExport.Rows.Count > 0)
- {
- string directoryType = string.Empty;
- string sBZ = "";
- switch (rbgDirecType_C.SelectedIndex)
- {
- case 0:
- {
- directoryType = "药品";
- break;
- }
- case 1:
- {
- directoryType = "诊疗";
- break;
- }
- case 2:
- {
- directoryType = "材料";
- break;
- }
- }
- if (rbAll.Checked) sBZ = "全部";
- else
- if (rbMaped.Checked) sBZ = "已对照";
- else
- if (rbNoMaped.Checked) sBZ = "未对照";
- string LSH = DateTime.Now.ToString("yyyy-MM-dd"); //DateTime.Now.ToString("MMddHHmmssffff");
- string filename = LSH + "(" + directoryType + ")医保目录" + sBZ + "信息.xls";
- string sFliePathName = Global.curEvt.path + "\\MapRelation\\" + filename;
- //string sFliePathName = @"D:\" + LSH + "(" + directoryType + ")医保目录" + sBZ + "信息.xls";
- //如果不存在目录,则创建目录
- if (!Directory.Exists(Global.curEvt.path + "\\MapRelation"))
- {
- //创建文件夹
- DirectoryInfo dirInfo = Directory.CreateDirectory(Global.curEvt.path + "\\MapRelation");
- }
-
- //如存在同名文件不询问直接删除
- if (File.Exists(sFliePathName))
- {
- File.Delete(sFliePathName);
- }
-
- //新版方法,用的EPPLUS,方便
- ExportToExcel.ExportDataTableToExcel(dtExport, sFliePathName);
- if (true)
- {
- errMsg = ($"导出成功,文件保存路径:{sFliePathName}");
- return 0;
- }
- else
- {
- errMsg = ("导出失败!");
- return -1;
- }
- }
- else
- {
- errMsg = "查询数据集为空!";
- return -1;
- }
- }
- private void tsmUploadAllMappedData_Click(object sender, EventArgs e)
- {
- AllUpLoad();
- }
- private void tsmCancelAllUploadedData_Click(object sender, EventArgs e)
- {
- AllCancelUpload();
- }
- private void tsmUpdateCellPriceOfAllMapped_Click(object sender, EventArgs e)
- {
- batchUpdateMappedInsuInfo(updateCellPriceWrapper);
- }
- private void tsmUpdateAllMapped_Click(object sender, EventArgs e)
- {
- batchUpdateMappedInsuInfo(updateAuxAndCellPriceWrapper);
- }
-
- private void batchUpdateMappedInsuInfo( Func<JObject, OutParamWrapper, int> _action)
- {
- action = _action;
- string sqlStr = $"select * from HB_MedInsuMapRelation where Interface_Dr='{Global.inf.interfaceDr}' and Hospital_Dr ='{Global.inf.hospitalDr}'";
- JObject joSqlstr = new JObject();
- joSqlstr.Add("sqlStr", sqlStr);
- JObject joRtn = mIS.QueryMappedData(joSqlstr, "查询所有已对照数据");
- iTotalCount = int.Parse(joRtn["result"]["total"].ToString());
- dtAllMapped = (DataTable)joRtn["result"]["data"].ToObject(typeof(DataTable));
- DataLoader _dataLoader;
- _dataLoader = new DataLoader(updateMappedInsuInfo,this);
- _dataLoader.SetProgressBar(ProgressBarStyle.Continuous,"正在更新...",50);
- _dataLoader.Start(new object[] { iTotalCount }, (result, errMsg) =>
- {
- // 在这里处理结果和错误信息
- if (result == 0)
- {
- MessageBox.Show(errMsg);
- }
- else
- {
- MessageBox.Show(errMsg);
- }
- });
- }
- private int updateMappedInsuInfo(object[] o,out string errMsg, DataLoader.ProgressCallback callback, DataLoader.ProgressMaxCallback maxCallback, BackgroundWorker worker)
- {
- int iFalse = 0;
- int iCount = 0;
- List<string> errList = new List<string>();
- if (maxCallback != null)
- {
- maxCallback(iTotalCount);
- }
- foreach (DataRow dr in dtAllMapped.Rows)
- {
- JObject jo = new JObject();
- jo.Add("code", dr["InsuCode"].ToString());
- jo.Add("HisType", dr["HisType"].ToString());
- OutParamWrapper outParWarp = new OutParamWrapper();
- if (action(jo, outParWarp) != 0)
- {
- iFalse++;
- errList.Add(outParWarp.Value);
- Global.writeLog(outParWarp.Value);
- }
- iCount++;
- // 检查是否应取消操作
- if (worker.CancellationPending)
- {
- errMsg = "操作取消!";
- return -1; // 或者其他表示取消的返回值
- }
- if (callback != null)
- {
- callback(iCount);
- }
- }
- if (iFalse != 0)
- {
- errMsg = ($"总共{iCount}条数据更新完成,但有{iFalse}条更新发生错误!");
- Global.writeLog($"{errMsg}\r\n{errList}");
- }
- else
- {
- errMsg = ($"全部数据({iCount}条)更新完成");
- }
- return iFalse;
- }
- private int updateAuxAndCellPriceWrapper(JObject jo, OutParamWrapper outParamWrapper)
- {
- string err;
- int iresult = updateAuxAndCellPrice(jo, out err);
- outParamWrapper.Value = err;
- return iresult;
- }
- private int updateCellPriceWrapper(JObject jo, OutParamWrapper outParamWrapper)
- {
- string err;
- int iresult = updateCellingPrice(jo, out err);
- outParamWrapper.Value = err;
- return iresult;
- }
- private int updateSelfRatioWrapper(JObject jo, OutParamWrapper outParamWrapper)
- {
- string err;
- int iresult = updateSelfRatioInfo(jo, out err);
- outParamWrapper.Value = err;
- return iresult;
- }
- private int updateAuxInfoWrapper(JObject jo, OutParamWrapper outParamWrapper)
- {
- string err;
- int iresult = updateAuxInfo(jo, out err);
- outParamWrapper.Value = err;
- return iresult;
- }
- private int updateAuxAndCellPrice(JObject jo, out string error)
- {
- string err ="";
- int iResult=0;
- error = "";
- if (updateAuxInfo(jo, out err) != 0)
- {
- error = $"更新目录信息失败{err}";
- iResult--;
- }
- err = "";
- if (updateCellingPrice(jo, out err) != 0)
- {
- error = $"{error};更新限价信息失败{err}";
- iResult--;
- }
- return iResult;
- }
- private void tsmUpdateLevelTypeOfAllMappedData_Click(object sender, EventArgs e)
- {
- batchUpdateMappedInsuInfo(updateAuxInfoWrapper);
- }
- private void tsmSingleUpdateInsuInfo_Click(object sender, EventArgs e)
- {
- if ((dgvHISDirectory.CurrentRow == null) || (rbMaped.Checked != true))
- {
- MessageBox.Show("请查询HIS目录对照关系,注意选择已对照!");
- return;
- }
- int iMapped = dgvHISDirectory.CurrentRow.Index;
- string insuCode = dgvHISDirectory.Rows[iMapped].Cells["insuCode"].Value.ToString();
- if (string.IsNullOrEmpty(insuCode))
- {
- MessageBox.Show("未检测到对应的医保目录,请检查该目录是否已对照!");
- return;
- }
- JObject jo = new JObject();
- jo.Add("code", dgvHISDirectory.Rows[iMapped].Cells["insuCode"].Value.ToString());
- jo.Add("HisType", rbgDirecType_C.SelectedIndex + 1);
- string error;
- if (updateAuxAndCellPrice(jo, out error) != 0)
- {
- MessageBox.Show($"更新失败{error}");
- }
- else
- {
- MessageBox.Show("更新成功!");
- }
- }
- private void dgvHISDirectory_SelectionChanged(object sender, EventArgs e)
- {
- int i = dgvHISDirectory.CurrentRow.Index;
- if (dgvHISDirectory.Rows[i].Cells["insuCode"].Value.ToString() != "")
- {
- tbInsuCode.Text = dgvHISDirectory.Rows[i].Cells["insuCode"].Value.ToString();
- tbCenterDirectoryFilter.Text = "";
- tbApprovalNO.Text = "";
- }
- else
- {
- tbInsuCode.Text = "";
- if (rbOnlyName.Checked)
- {
- tbInsuCode.Text = "";
- tbApprovalNO.Text = "";
- tbCenterDirectoryFilter.Text = "%" + dgvHISDirectory.Rows[i].Cells["itemDesc"].Value.ToString() + "%";
- }
- if (rbOnlyApprNO.Checked)
- {
- tbCenterDirectoryFilter.Text = "";
- tbInsuCode.Text = "";
- tbApprovalNO.Text = "%" + dgvHISDirectory.Rows[i].Cells["pprovalNo"].Value.ToString() + "%";
- }
- if (rbBoth.Checked)
- {
- tbInsuCode.Text = "";
- tbCenterDirectoryFilter.Text = "%" + dgvHISDirectory.Rows[i].Cells["itemDesc"].Value.ToString() + "%";
- tbApprovalNO.Text = "%" + dgvHISDirectory.Rows[i].Cells["pprovalNo"].Value.ToString() + "%";
- }
- }
- }
- private void tsmSingleUpdateSelfRatioInfo_Click(object sender, EventArgs e)
- {
- if ((dgvHISDirectory.CurrentRow == null) || (rbMaped.Checked != true))
- {
- MessageBox.Show("请查询HIS目录对照关系,注意选择已对照!");
- return;
- }
- int iMapped = dgvHISDirectory.CurrentRow.Index;
- string insuCode = dgvHISDirectory.Rows[iMapped].Cells["insuCode"].Value.ToString();
- if (string.IsNullOrEmpty(insuCode))
- {
- MessageBox.Show("未检测到对应的医保目录,请检查该目录是否已对照!");
- return;
- }
- JObject jo = new JObject();
- jo.Add("code", dgvHISDirectory.Rows[iMapped].Cells["insuCode"].Value.ToString());
- jo.Add("HisType", rbgDirecType_C.SelectedIndex + 1);
- string error;
- if (updateSelfRatioInfo(jo, out error) != 0)
- {
- MessageBox.Show($"更新失败{error}");
- }
- else
- {
- MessageBox.Show("更新成功!");
- }
- }
- private void tsmUpdateSelfRatioOfAllMapped_Click(object sender, EventArgs e)
- {
- batchUpdateMappedInsuInfo(updateSelfRatioWrapper);
- }
- public int UpdateDictionaryBySelf(AddSingleDictionary addDic, out string errMsg)
- {
- string outParam = "", HBDictionaryDr = "";
- JObject joRtn;
- JObject jo = addDic.joPamam;
- try
- {
- //if (JsonHelper.getDestValue(jo, "operateType") == "0")
- //{
- //插入并获取字典主表的DR
- JObject joDic = JObject.FromObject(jo["dicObj"]);
- joRtn = mIS.insertDictionary(joDic);
- if (JsonHelper.parseIrisRtnValue(joRtn, out errMsg) != 0)
- {
- return -1;
- }
- else
- {
- HBDictionaryDr = JsonHelper.getDestValue(joRtn, "data.HBDictionaryDr");
- if (HBDictionaryDr == "")
- {
- errMsg = "HBDictionaryDr返回值为空";
- return -1;
- }
- }
- //}
- //else
- //{
- // if (addDic.dr != null)
- // {
- // HBDictionaryDr = addDic.dr["hBDictionaryID"].ToString();
- // }
- // else
- // {
- // errMsg = "修改状态下未获得字典主表ID!请联系管理员";
- // return -1;
- // }
- //}
- //插入明细表
- JObject joDicDetail = JObject.FromObject(jo["detailObj"]);
- joDicDetail.Add("HBDictionaryDr", HBDictionaryDr);
- JArray jaParams = new JArray();
- jaParams.Add(joDicDetail);
- joRtn = mIS.insertDictionaryDataDetail(jaParams);
- if (JsonHelper.parseIrisRtnValue(joRtn, out errMsg) != 0)
- {
- return -1;
- }
- else
- {
- return 0;
- }
- }
- catch (Exception ex)
- {
- errMsg = ex.Message;
- return -1;
- }
- }
- private string SelectExcelFile()
- {
- //打开窗口选择文件
- OpenFileDialog openFileDialog = new OpenFileDialog
- {
- InitialDirectory = System.Environment.GetFolderPath(Environment.SpecialFolder.Desktop), // 设置初始目录
- Filter = "Excel files (*.xlsx)|*.xlsx", // 设置文件过滤器
- FilterIndex = 1, // 设置默认的文件过滤器索引
- RestoreDirectory = true // 对话框关闭前是否恢复原始目录
- };
- string selectedFilePath = "";
- if (openFileDialog.ShowDialog() == DialogResult.OK)
- {
- selectedFilePath = openFileDialog.FileName;
- }
- return selectedFilePath;
- }
- private int ImportMapRelation(object[] o, out string errMsg, DataLoader.ProgressCallback callback, DataLoader.ProgressMaxCallback maxCallback, BackgroundWorker worker)
- {
- int iFalse = 0;
- string err = "";
- string excelPath = o[0].ToString();
- errMsg = "";
- //加载EXCEL
- using (ExcelPackage package = new ExcelPackage(excelPath))
- {
- ExcelWorksheet worksheet = package.Workbook.Worksheets[0];
- int colCount = worksheet.Dimension.End.Column; //get Column Count
- int rowCount = worksheet.Dimension.End.Row ; //get row count
- if (maxCallback != null)
- {
- maxCallback(rowCount - 1); //去除首行
- }
- //建立索引字典
- Dictionary<string, int> indexDic = new Dictionary<string, int>();
- //通过第一行来确定每列的数据与后台对应关系
- for (int col = 1; col <= colCount; col++)
- {
- string colHearder = worksheet.Cells[1, col].Value?.ToString().Trim();
- switch (colHearder)
- {
- case "HIS编码":
- indexDic.Add("HISCode", col);
- break;
- case "HIS名称":
- indexDic.Add("HISName", col);
- break;
- case "目录类型":
- indexDic.Add("HisType", col);
- break;
- case "医保编码":
- indexDic.Add("InsuCode", col);
- break;
- case "医保名称":
- indexDic.Add("InsuName", col);
- break;
- default:
- break;
- }
- }
- Global.writeLog(JsonConvert.SerializeObject(indexDic));
- JArray jaTmp = new JArray();
- for (int row = 2; row <= rowCount; row++)
- {
- // 检查是否应取消操作
- if (worker.CancellationPending)
- {
- errMsg = "操作取消!";
- return -1; // 或者其他表示取消的返回值
- }
- JObject joTmp = new JObject();
- //for (int col = 1; col <= colCount; col++)
- //{
- joTmp.Add("HospitalDr", Global.inf.hospitalDr); //医院编号
- joTmp.Add("InterfaceDr", Global.inf.interfaceDr); // 接口编号 - HBMedInsuInterface 类型(假设用字符串表示)
- //joTmp.Add("ChargeItemDr", worksheet.Cells[row, indexDic["ChargeItemDr"]]?.Value?.ToString().Trim()); // 收费项ID - %Integer
- joTmp.Add("HISCode", worksheet.Cells[row, indexDic["HISCode"]]?.Value?.ToString().Trim()); // HIS编码 - %String
- joTmp.Add("HISName", worksheet.Cells[row, indexDic["HISName"]]?.Value?.ToString().Trim()); // HIS名称 - %String
- //joTmp.Add("DiretoryDr", worksheet.Cells[row, indexDic["Direcotry_Dr"]]?.Value?.ToString().Trim()); // 医保目录Dr - HBMedInsuDirectory(字符串处理)
- joTmp.Add("HisType", worksheet.Cells[row, indexDic["HisType"]]?.Value?.ToString().Trim()); // 医院目录类型 - %String
- joTmp.Add("State", "1"); // 状态 - 1.已对照 2.已对照但未上传 3 已对照且已上传
- joTmp.Add("UpdateDate", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")); // 更新时间 - %DateTime
- joTmp.Add("InsuCode", worksheet.Cells[row, indexDic["InsuCode"]]?.Value?.ToString().Trim()); // 医保编码 - %String
- joTmp.Add("InsuName", worksheet.Cells[row, indexDic["InsuName"]]?.Value?.ToString().Trim()); // 医保名称
- //}
- jaTmp.Add(joTmp);
- if (callback != null)
- {
- callback(row - 1);
- }
- //每50条传一次
- if (((row - 1) % 50 == 0) || ((row + 0) == rowCount))
- {
- JObject joIn = new JObject();
- joIn.Add(new JProperty("params", jaTmp));
- joIn.Add("code", "09010040");
- InvokeHelper invoker = new InvokeHelper();
- JObject joRtn = invoker.invokeInsuService(joIn.ToString(), "导入对照关系");
- // 更新对照关系表返回的数据
- if (JsonHelper.parseIrisRtnValue(joRtn, out err) != 0)
- {
- iFalse++;
- errMsg = errMsg + "\r\n" + err;
- }
- jaTmp = new JArray();
- }
- }
- }
- return iFalse ;
- }
- private void tsmImportMapRelation_Click(object sender, EventArgs e)
- {
- object[] o = new object[] { SelectExcelFile() } ;
- DataLoader _dataLoader;
- _dataLoader = new DataLoader(ImportMapRelation, this);
- _dataLoader.SetProgressBar(ProgressBarStyle.Continuous, "正在导入...", 50);
- _dataLoader.Start(o,(result, errMsg) =>
- {
- MessageBox.Show(errMsg);
- });
- }
- private void tsmImportExcelDir_Click(object sender, EventArgs e)
- {
- object[] o = new object[] { SelectExcelFile() };
- DataLoader _dataLoader;
- _dataLoader = new DataLoader(ImportExcelDir, this);
- _dataLoader.SetProgressBar(ProgressBarStyle.Continuous, "正在导入...", 50);
- _dataLoader.Start(o, (result, errMsg) =>
- {
- MessageBox.Show(errMsg);
- });
- }
- private int ImportExcelDir(object[] o, out string errMsg, DataLoader.ProgressCallback callback, DataLoader.ProgressMaxCallback maxCallback, BackgroundWorker worker)
- {
- int iFalse = 0;
- string err = "";
- string excelPath = o[0]?.ToString();
- if (string.IsNullOrEmpty(excelPath))
- {
- errMsg = "文件路径无效。";
- return -1;
- }
- // 定义字段映射:Excel列名 -> JSON字段名
- var columnMapping = new Dictionary<string, string>
- {
- //{ "医院编号", "HospitalDr" },
- //{ "接口编号", "InterfaceDr" },
- { "医保编码", "Code" },
- { "医保名称", "Name" },
- { "医院目录类型", "HisType" },
- { "医院类型名称", "HisTypeName" },
- { "医保本地编码", "LocateCode" },
- { "医保本地名称", "LocateName" },
- { "本位码", "DrugSafetyStandardCode" },
- { "剂型编码", "DosageFormCode" },
- { "剂型名称", "DosageFormName" },
- { "类别编码", "CategoryCode" },
- { "类别名称", "CategoryName" },
- { "规格", "Specification" },
- { "规格代码", "SpecificationCode" },
- { "包装单位", "UnitOfPackag" },
- { "计价单位", "UnitOfValuation" },
- { "开始日期", "StartDate" },
- { "结束日期", "EndDate" },
- { "拼音助记码", "PinyinSearchCode" },
- { "说明", "Instructions" },
- { "除外内容", "ExceptContent" },
- { "项目内涵", "Connotation" },
- { "有效标志", "ValidFlag" },
- { "备注", "Note" },
- { "批准文号", "ApprovalNO" },
- { "版本号", "VersionNO" },
- { "版本名称", "VersionName" },
- { "使用标志", "UseFlag" },
- { "特殊药品标志", "SpecialFlag" },
- { "限制标志", "LimitFlag" },
- { "限制范围", "LimitRange" },
- { "唯一记录号", "UniqueRecordNO" },
- { "厂家", "Manufacturers" },
- { "国家项目编码", "NationalCode" },
- { "国家项目名称", "NationalName" },
- { "更新时间", "UpdateTime" },
- { "收费项目等级", "ChargeItemLevel" },
- { "收费项目等级名称", "ChargeItemLevelName" },
- { "自付比例", "SelfPercent" },
- { "医疗收费项目类别", "ChargeItemType" },
- { "收费标准", "ChargeStandards" },
- { "最高限价", "CeilingPrice" },
- { "包装材质", "PackagingMaterial" },
- { "最小包装数量", "MinPackagingQuantity" },
- { "最小制剂单位", "MinDosageUnit" },
- { "最小包装单位", "MinPackagingUnit" },
- { "累计增负标志", "CumulativeNegativeBurdenFlag" },
- { "目录类型", "ListType" },
- { "目录支付比例", "DirectoryPayPercent" }
- };
- errMsg = "";
- //加载EXCEL
- using (ExcelPackage package = new ExcelPackage(excelPath))
- {
- var worksheet = package.Workbook.Worksheets[0];
- int colCount = worksheet.Dimension?.Columns ?? 0;
- int rowCount = worksheet.Dimension?.Rows ?? 0;
- if (rowCount < 2)
- {
- errMsg = "Excel 文件中没有有效的数据行。";
- return -1;
- }
- if (maxCallback != null)
- maxCallback(rowCount - 1);
- // 建立索引字典
- var indexDic = new Dictionary<string, int>();
- for (int col = 1; col <= colCount; col++)
- {
- var header = worksheet.Cells[1, col].Value?.ToString().Trim();
- if (columnMapping.TryGetValue(header, out string jsonField))
- {
- indexDic[jsonField] = col;
- }
- else
- {
- // 可选:记录未识别的列头
- Global.writeLog($"未知列头: {header}");
- }
- }
- Global.writeLog(JsonConvert.SerializeObject(indexDic));
- JArray jaTmp = new JArray();
- for (int row = 2; row <= rowCount; row++)
- {
- Global.writeLog(callback.Target.GetType().Name);
- // 检查是否应取消操作
- if ( worker.CancellationPending)
- {
- errMsg = "操作取消!";
- return -1; // 或者其他表示取消的返回值
- }
- if (callback != null)
- callback(row - 1);
- JObject joTmp = new JObject();
- foreach (var pair in indexDic)
- {
- string fieldName = pair.Key;
- int colIndex = pair.Value;
- var cellValue = worksheet.Cells[row, colIndex]?.Value?.ToString().Trim();
- joTmp.Add(fieldName, cellValue ?? string.Empty);
- }
- //手动增加医院ID 和接口ID
- joTmp.Add("HospitalDr", Global.inf.hospitalDr); //医院编号
- joTmp.Add("InterfaceDr", Global.inf.interfaceDr); // 接口编号
- jaTmp.Add(joTmp);
- //每50条传一次
- if (((row - 1) % 50 == 0) || ((row ) == rowCount))
- {
- JObject joIn = new JObject();
- joIn.Add(new JProperty("params", jaTmp));
- joIn.Add("code", "09010035");
- InvokeHelper invoker = new InvokeHelper();
- JObject joRtn = invoker.invokeInsuService(joIn.ToString(), "更新医保目录");
- // 更新对照关系表返回的数据
- if (JsonHelper.parseIrisRtnValue(joRtn, out err) != 0)
- {
- iFalse++;
- errMsg = errMsg + "\r\n" + err;
- }
- jaTmp = new JArray();
- }
- }
- }
- if (iFalse == 0)
- {
- errMsg = "全部导入";
- }
- else
- {
- errMsg = "导入有错误,请检查日志";
- }
- return iFalse;
- }
- private void tsmExportMappedDataByLeft_Click(object sender, EventArgs e)
- {
- }
- }
- public class OutParamWrapper
- {
- public string Value { get; set; }
- }
- }
|