his_api_controller.go 132KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783
  1. package sg
  2. import (
  3. "archive/zip"
  4. "bytes"
  5. "encoding/json"
  6. "fmt"
  7. "gdyb/controllers"
  8. "gdyb/enums"
  9. "gdyb/models"
  10. "gdyb/service"
  11. "gdyb/utils"
  12. "github.com/astaxie/beego"
  13. "github.com/jinzhu/gorm"
  14. "github.com/shopspring/decimal"
  15. "io"
  16. "io/ioutil"
  17. "math/rand"
  18. "net/http"
  19. "os"
  20. "path/filepath"
  21. "strconv"
  22. "strings"
  23. "syscall"
  24. "time"
  25. "unsafe"
  26. )
  27. type HisApiController struct {
  28. controllers.BaseAuthAPIController
  29. }
  30. func HisManagerApiRegistRouters() {
  31. beego.Router("/api/register/get", &HisApiController{}, "get:GetRegisterInfo")
  32. beego.Router("/api/diag/upload", &HisApiController{}, "get:GetUploadDiag")
  33. beego.Router("/api/upload/get", &HisApiController{}, "get:GetUploadInfo")
  34. beego.Router("/api/settle/query", &HisApiController{}, "get:GetSettleAccounts")
  35. beego.Router("/api/checkaccount/get", &HisApiController{}, "get:GetCheckAccount")
  36. beego.Router("/api/checkdetailaccount/get", &HisApiController{}, "get:GetCheckDetailAccount")
  37. beego.Router("/api/refund/post", &HisApiController{}, "get:Refund")
  38. //beego.Router("/api/sscard", &HisApiController{}, "get:Sscard")
  39. beego.Router("/api/refundnumber/post", &HisApiController{}, "get:RefundNumber")
  40. beego.Router("/api/refunddetail/post", &HisApiController{}, "get:RefundDetail")
  41. beego.Router("/api/treatment/check", &HisApiController{}, "get:CheckTreatment")
  42. beego.Router("/api/record/put", &HisApiController{}, "get:PutRecord")
  43. beego.Router("/api/patient/info", &HisApiController{}, "get:GetHisPatientInfo")
  44. beego.Router("/api/org/info", &HisApiController{}, "get:GetOrgInfo")
  45. //beego.Router("/api/testcard", &HisApiController{}, "get:TestGetBasBaseInfo")
  46. //beego.Router("/api/testpay", &HisApiController{}, "get:TestPay")
  47. beego.Router("/api/pre_upload/get", &HisApiController{}, "get:GetPreUploadInfo")
  48. beego.Router("/api/settle/get", &HisApiController{}, "get:GetSettleInfo")
  49. beego.Router("/api/310", &HisApiController{}, "get:Check310")
  50. beego.Router("/api/390", &HisApiController{}, "get:Check390")
  51. }
  52. //func (c *HisApiController) TestPay() {
  53. // DllDef2 := syscall.MustLoadDLL("SSSE32.dll")
  54. // readCards := DllDef2.MustFindProc("BankTrans")
  55. // inputData := make(map[string]interface{})
  56. // inputData["transId"] = "05"
  57. // inputData["amount"] = "0.01"
  58. // inputData["traceNo"] = "20210227093601325405377"
  59. // inputData["cardNo"] = "F36084348"
  60. // inputData["id"] = "44022919620927046X"
  61. // //jsonStr := `
  62. // // {
  63. // // "transId": "05",
  64. // // "amount":"1.00",
  65. // // "traceNo":"20210227093601325405377",
  66. // // "cardNo":"F36084348",
  67. // // "id":"44022919620927046X"
  68. // //
  69. // // }
  70. // //`
  71. //
  72. // bytes_arr, _ := json.Marshal(inputData)
  73. // str3 := make([]byte, 256)
  74. // ret4, _, err4 := readCards.Call(StrPtr(string(bytes_arr)), (uintptr)(unsafe.Pointer(&str3[0])))
  75. // fmt.Println(":", string(str3))
  76. //
  77. // if err4 != nil {
  78. // fmt.Println("SSCard的运算结果为:", ret4)
  79. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  80. // return
  81. // }
  82. //
  83. //}
  84. //func (c *HisApiController) TestGetBasBaseInfo() {
  85. //
  86. // //result := C.Init(StrPtr("http://igb.hsa.gdgov.cn/gdyb_inf/poc/api/card/initDll"), StrPtr("440200"))
  87. // //fmt.Println(result)
  88. // //cs1 := C.CString("")
  89. // //cs2 := C.CString("")
  90. // //C.ReadCardBas(cs1, IntPtr(1024), cs2, IntPtr(1024))
  91. // //fmt.Println(cs1)
  92. // //fmt.Println(cs2)
  93. // //C.free(unsafe.Pointer(cs1))
  94. // //C.free(unsafe.Pointer(cs2))
  95. //
  96. // //
  97. //
  98. // DllDef := syscall.MustLoadDLL("SSCard.dll")
  99. // Iinit := DllDef.MustFindProc("Init")
  100. // readCard := DllDef.MustFindProc("ReadCardBas")
  101. // ret, _, err := Iinit.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_inf/poc/api/card/initDll"), StrPtr("440200"))
  102. // if ret != 0 {
  103. // fmt.Println("SSCard的报错原因:", err)
  104. // fmt.Println("SSCard的运算结果为:", ret)
  105. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  106. // return
  107. // }
  108. //
  109. // result := int(ret)
  110. // fmt.Println("SSCard的运算结果为1:", result)
  111. //
  112. // //path := ""
  113. // //bytePath := []byte( "\x00")
  114. // //bytePath2 := []byte( "\x00")
  115. // //ssss
  116. //
  117. // str := make([]byte, 256)
  118. // str1 := make([]byte, 256)
  119. // s2 := []byte(string(str))
  120. // s3 := []byte(string(str1))
  121. // ret2, _, err2 := readCard.Call((uintptr)(unsafe.Pointer(&s2[0])), IntPtr(256), (uintptr)(unsafe.Pointer(&s3[0])), IntPtr(256))
  122. // fmt.Println(" Add(4,5)的结果为:", ret2)
  123. // fmt.Println(" str:", s2)
  124. // fmt.Println(" str1:", s3)
  125. // if err2 != nil {
  126. // fmt.Println("SSCard的运算结果为:", ret2)
  127. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  128. // return
  129. // }
  130. //
  131. // //DllDef := syscall.MustLoadDLL("SSCard.dll")
  132. //
  133. //}
  134. func (c *HisApiController) GetOrgInfo() {
  135. miConfig, _ := service.FindMedicalInsuranceInfo(9919)
  136. service.Gdyb1201("", miConfig.OrgName, "1122", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1, "")
  137. }
  138. func (c *HisApiController) GetHisPatientInfo() {
  139. medical_insurance_card := c.GetString("medical_insurance_card")
  140. id_card_type, _ := c.GetInt64("id_card_type")
  141. id_card := c.GetString("id_card")
  142. adminInfo := c.GetAdminUserInfo()
  143. config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  144. miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  145. appRole, _ := service.GetAppRole(adminInfo.CurrentOrgId)
  146. IdCardNo := ""
  147. if id_card_type == 1 {
  148. IdCardNo = medical_insurance_card
  149. } else if id_card_type == 2 {
  150. IdCardNo = id_card
  151. }
  152. if config.IsOpen == 1 {
  153. api := "http://127.0.0.1:9532/" + "gdyb/one?cert_no=" + IdCardNo + "&org_name=" + miConfig.OrgName + "&doctor=" + appRole.UserName + "&fixmedins_code=" + miConfig.Code + "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  154. resp, requestErr := http.Get(api)
  155. if requestErr != nil {
  156. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  157. return
  158. }
  159. defer resp.Body.Close()
  160. body, ioErr := ioutil.ReadAll(resp.Body)
  161. if ioErr != nil {
  162. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  163. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  164. return
  165. }
  166. var respJSON map[string]interface{}
  167. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  168. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  169. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  170. return
  171. }
  172. userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  173. userJSONBytes, _ := json.Marshal(userJSON)
  174. var res ResultTwo
  175. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  176. utils.ErrorLog("解析失败:%v", err)
  177. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  178. return
  179. }
  180. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  181. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  182. infoStr := string(Iinfos)
  183. idetinfoStr := string(Idetinfos)
  184. if res.Infcode == 0 {
  185. his := models.VMHisPatient{
  186. Status: 1,
  187. Ctime: time.Now().Unix(),
  188. Mtime: time.Now().Unix(),
  189. PsnNo: res.Output.Baseinfo.PsnNo,
  190. PsnCertType: res.Output.Baseinfo.PsnCertType,
  191. Certno: res.Output.Baseinfo.Certno,
  192. PsnName: res.Output.Baseinfo.PsnName,
  193. Gend: res.Output.Baseinfo.Gend,
  194. Naty: res.Output.Baseinfo.Naty,
  195. Brdy: res.Output.Baseinfo.Brdy,
  196. Age: res.Output.Baseinfo.Age,
  197. Iinfo: infoStr,
  198. Idetinfo: idetinfoStr,
  199. UserOrgId: adminInfo.CurrentOrgId,
  200. IsReturn: 1,
  201. IdCardType: id_card_type,
  202. }
  203. c.ServeSuccessJSON(map[string]interface{}{
  204. "info": his,
  205. })
  206. } else {
  207. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  208. return
  209. }
  210. }
  211. }
  212. //func (c *HisApiController) Sscard() {
  213. // id_card_type, _ := c.GetInt64("id_card_type")
  214. // adminUser := c.GetAdminUserInfo()
  215. // miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  216. //
  217. // r := CardInit()
  218. // fmt.Println(r)
  219. // //if r == 0 {
  220. // switch id_card_type {
  221. // case 1:
  222. // basStr, err := GetBasBaseInfo()
  223. //
  224. // if err != nil {
  225. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  226. // return
  227. //
  228. // } else {
  229. // fmt.Println(basStr)
  230. //
  231. // bas := strings.Split(basStr, "|")
  232. //
  233. // basNumber := bas[1]
  234. //
  235. // //basNumber := bas[2]
  236. // card_sn := bas[3]
  237. //
  238. // appRole, _ := service.GetAppRole(adminUser.CurrentOrgId)
  239. //
  240. // api := "http://127.0.0.1:9532/" + "gdyb/one?cert_no=" + basNumber + "&org_name=" + miConfig.OrgName + "&doctor=" + appRole.UserName + "&fixmedins_code=" + miConfig.Code + "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(int64(id_card_type), 10) + "&card_sn=" + card_sn
  241. // resp, requestErr := http.Get(api)
  242. // if requestErr != nil {
  243. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  244. // return
  245. // }
  246. // defer resp.Body.Close()
  247. // body, ioErr := ioutil.ReadAll(resp.Body)
  248. // if ioErr != nil {
  249. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  250. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  251. // return
  252. // }
  253. // var respJSON map[string]interface{}
  254. //
  255. // if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  256. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  257. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  258. // return
  259. // }
  260. //
  261. // userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  262. // userJSONBytes, _ := json.Marshal(userJSON)
  263. // var res ResultTwo
  264. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  265. // utils.ErrorLog("解析失败:%v", err)
  266. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  267. // return
  268. // }
  269. // Iinfos, _ := json.Marshal(res.Output.Iinfo)
  270. // Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  271. // infoStr := string(Iinfos)
  272. // idetinfoStr := string(Idetinfos)
  273. //
  274. // if res.Infcode == 0 {
  275. // his := models.VMHisPatient{
  276. // Status: 1,
  277. // Ctime: time.Now().Unix(),
  278. // Mtime: time.Now().Unix(),
  279. // PsnNo: res.Output.Baseinfo.PsnNo,
  280. // PsnCertType: res.Output.Baseinfo.PsnCertType,
  281. // Certno: res.Output.Baseinfo.Certno,
  282. // PsnName: res.Output.Baseinfo.PsnName,
  283. // Gend: res.Output.Baseinfo.Gend,
  284. // Naty: res.Output.Baseinfo.Naty,
  285. // Brdy: res.Output.Baseinfo.Brdy,
  286. // Age: res.Output.Baseinfo.Age,
  287. // Iinfo: infoStr,
  288. // Idetinfo: idetinfoStr,
  289. // UserOrgId: adminUser.CurrentOrgId,
  290. // IsReturn: 1,
  291. // IdCardType: id_card_type,
  292. // }
  293. //
  294. // patient, err := service.GetPatientByNumber(basNumber, adminUser.CurrentOrgId)
  295. // if err == gorm.ErrRecordNotFound {
  296. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  297. // return
  298. //
  299. // } else if err != nil {
  300. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  301. // return
  302. //
  303. // } else {
  304. // c.ServeSuccessJSON(map[string]interface{}{
  305. // "patient": patient,
  306. // "his": his,
  307. // "number": basNumber,
  308. // })
  309. // }
  310. // } else {
  311. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  312. // return
  313. // }
  314. //
  315. // }
  316. //
  317. // break
  318. // case 2:
  319. // ////SFZStr, err := GetSFZBaseInfo()
  320. // //if err != nil {
  321. // // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  322. // // return
  323. // //
  324. // //} else {
  325. // //
  326. // // id_card_str := strings.Split(SFZStr, "^")
  327. // // id_card_number := id_card_str[0]
  328. // //appRole, _ := service.GetAppRole(adminUser.CurrentOrgId)
  329. // //
  330. // //api := "http://127.0.0.1:9532/" + "gdyb/one?cert_no=" + id_card_number + "&org_name=" + miConfig.OrgName + "&doctor=" + appRole.UserName + "&fixmedins_code=" + miConfig.Code + "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(int64(id_card_type), 10)
  331. // //resp, requestErr := http.Get(api)
  332. // //if requestErr != nil {
  333. // // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  334. // // return
  335. // //}
  336. // //defer resp.Body.Close()
  337. // //body, ioErr := ioutil.ReadAll(resp.Body)
  338. // //if ioErr != nil {
  339. // // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  340. // // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  341. // // return
  342. // //}
  343. // //var respJSON map[string]interface{}
  344. // //
  345. // //if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  346. // // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  347. // // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  348. // // return
  349. // //}
  350. // //
  351. // //userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  352. // //userJSONBytes, _ := json.Marshal(userJSON)
  353. // //var res ResultTwo
  354. // //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  355. // // utils.ErrorLog("解析失败:%v", err)
  356. // // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  357. // // return
  358. // //}
  359. // //Iinfos, _ := json.Marshal(res.Output.Iinfo)
  360. // //Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  361. // //infoStr := string(Iinfos)
  362. // //idetinfoStr := string(Idetinfos)
  363. // //
  364. // //if res.Infcode == 0 {
  365. // // his := models.VMHisPatient{
  366. // // Status: 1,
  367. // // Ctime: time.Now().Unix(),
  368. // // Mtime: time.Now().Unix(),
  369. // // PsnNo: res.Output.Baseinfo.PsnNo,
  370. // // PsnCertType: res.Output.Baseinfo.PsnCertType,
  371. // // Certno: res.Output.Baseinfo.Certno,
  372. // // PsnName: res.Output.Baseinfo.PsnName,
  373. // // Gend: res.Output.Baseinfo.Gend,
  374. // // Naty: res.Output.Baseinfo.Naty,
  375. // // Brdy: res.Output.Baseinfo.Brdy,
  376. // // Age: res.Output.Baseinfo.Age,
  377. // // Iinfo: infoStr,
  378. // // Idetinfo: idetinfoStr,
  379. // // UserOrgId: adminUser.CurrentOrgId,
  380. // // IsReturn: 1,
  381. // // IdCardType: id_card_type,
  382. // // }
  383. //
  384. // // patient, err := service.GetPatientByNumber(id_card_number, adminUser.CurrentOrgId)
  385. // // if err == gorm.ErrRecordNotFound {
  386. // // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  387. // // return
  388. // //
  389. // // } else if err != nil {
  390. // // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  391. // // return
  392. // //
  393. // // } else {
  394. // // c.ServeSuccessJSON(map[string]interface{}{
  395. // // "patient": patient,
  396. // // "number": id_card_number,
  397. // // })
  398. // // }
  399. // //}
  400. // break
  401. // case 3:
  402. //
  403. // break
  404. //
  405. // }
  406. //}
  407. //func GetBasBaseInfo() (jsonStr string, err error) {
  408. //
  409. // handle, err := syscall.LoadLibrary("SSCard.dll")
  410. // if err != nil {
  411. // fmt.Printf("Error: %s\n", err)
  412. // return "", err
  413. // }
  414. // defer syscall.FreeLibrary(handle)
  415. // str := make([]byte, 256)
  416. // str1 := make([]byte, 256)
  417. // add, err := syscall.GetProcAddress(handle, "ReadCardBas")
  418. // if err != nil {
  419. // fmt.Printf("Error: %s\n", err)
  420. // return "", err
  421. // }
  422. // ret, _, _ := syscall.Syscall(add, (uintptr)(unsafe.Pointer(&str[0])), IntPtr(1024), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(1024))
  423. // if err != nil {
  424. // fmt.Printf("Error: %s\n", err)
  425. // }
  426. // fmt.Println("> Add(4,5)的结果为:", ret)
  427. // //return nil
  428. //
  429. // //
  430. // //handle := syscall.NewLazyDLL("SSCard.dll")
  431. // //ReadCardBas := handle.NewProc("ReadCardBas")
  432. // //
  433. // //var str2 [1024]C.char
  434. // //var str3 [1024]C.char
  435. // //
  436. // //
  437. // //
  438. // ////sssssswwwww
  439. // ////a := 256
  440. // //
  441. // //r, _, _ := ReadCardBas.Call(&str2, 1024, &str3, 1024)
  442. // //fmt.Println(r)
  443. // ////p := (*byte)(unsafe.Pointer(r))
  444. // // define a slice to fill with the p string
  445. // //data := make([]byte, 0)
  446. //
  447. // // loop until find '\0'
  448. // //if *p != 0 {
  449. // //
  450. // // //data = append(data, *p) // append 1 byte
  451. // // //r += unsafe.Sizeof(byte(0)) // move r to next byte
  452. // // //p = (*byte)(unsafe.Pointer(r)) // get the byte value
  453. // //} else {
  454. // // return "", nil
  455. // //
  456. // //}
  457. //
  458. // return "", nil
  459. //
  460. //}
  461. //func GetSFZBaseInfo() (jsonStr string, err error) {
  462. // //handle := syscall.MustLoadDLL("SSCard.dll")
  463. //
  464. // str := make([]byte, 256)
  465. // str1 := make([]byte, 256)
  466. // r, _, _ := ReadIDCardBas.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(1024), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(1024))
  467. //
  468. // fmt.Println(r)
  469. // return string(str), nil
  470. //}
  471. //func GetQRBaseInfo() (jsonStr string, err error) {
  472. // handle := syscall.LoadDLL("SSCard.dll")
  473. // ReadCardBas := handle.FindProc("GetQRBase")
  474. //
  475. // str := make([]byte, 256)
  476. // str1 := make([]byte, 256)
  477. // r, _, _ := ReadCardBas.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(1024), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(1024))
  478. //
  479. // fmt.Println(string(str))
  480. // fmt.Println(r)
  481. // return string(str), nil
  482. //}
  483. //func CardInit() int {
  484. // DllTestDef := syscall.MustLoadDLL("SSCard.dll")
  485. // add := DllTestDef.MustFindProc("Init")
  486. // ret, _, err := add.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_inf/poc/api/card/initDll"), StrPtr("440200"))
  487. // if err != nil {
  488. // fmt.Println("SSCard的运算结果为:", ret)
  489. // }
  490. // result := int(ret)
  491. // return result
  492. //}
  493. //func CardInit() int {
  494. // ret, _, err := add.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_inf/poc/api/card/initDll"), StrPtr("440200"))
  495. // if err != nil {
  496. // fmt.Println("SSCard的运算结果为:", ret)
  497. // }
  498. // fmt.Println(err)
  499. // result := int(ret)
  500. // return result
  501. //}
  502. func IntPtr(n int) uintptr {
  503. return uintptr(n)
  504. }
  505. func StrPtr(s string) uintptr {
  506. return uintptr(unsafe.Pointer(syscall.StringBytePtr(s)))
  507. }
  508. type ResultTwo struct {
  509. ErrMsg string `json:"err_msg"`
  510. InfRefmsgid string `json:"inf_refmsgid"`
  511. Infcode int64 `json:"infcode"`
  512. Output struct {
  513. Baseinfo struct {
  514. Age float64 `json:"age"`
  515. Brdy string `json:"brdy"`
  516. Certno string `json:"certno"`
  517. Gend string `json:"gend"`
  518. Naty string `json:"naty"`
  519. PsnCertType string `json:"psn_cert_type"`
  520. PsnName string `json:"psn_name"`
  521. PsnNo string `json:"psn_no"`
  522. } `json:"baseinfo"`
  523. Idetinfo []interface{} `json:"idetinfo"`
  524. Iinfo []struct {
  525. Balc int64 `json:"balc"`
  526. CvlservFlag string `json:"cvlserv_flag"`
  527. EmpName string `json:"emp_name"`
  528. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  529. Insutype string `json:"insutype"`
  530. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  531. PausInsuDate interface{} `json:"paus_insu_date"`
  532. PsnInsuDate string `json:"psn_insu_date"`
  533. PsnInsuStas string `json:"psn_insu_stas"`
  534. PsnType string `json:"psn_type"`
  535. } `json:"insuinfo"`
  536. } `json:"output"`
  537. RefmsgTime string `json:"refmsg_time"`
  538. RespondTime string `json:"respond_time"`
  539. Signtype interface{} `json:"signtype"`
  540. WarnInfo interface{} `json:"warn_info"`
  541. }
  542. type ResultThree struct {
  543. Cainfo interface{} `json:"cainfo"`
  544. ErrMsg string `json:"err_msg"`
  545. InfRefmsgid string `json:"inf_refmsgid"`
  546. Infcode int64 `json:"infcode"`
  547. Output struct {
  548. Data struct {
  549. IptOtpNo string `json:"ipt_otp_no"`
  550. MdtrtID string `json:"mdtrt_id"`
  551. PsnNo string `json:"psn_no"`
  552. } `json:"data"`
  553. } `json:"output"`
  554. RefmsgTime string `json:"refmsg_time"`
  555. RespondTime string `json:"respond_time"`
  556. Signtype interface{} `json:"signtype"`
  557. WarnMsg interface{} `json:"warn_msg"`
  558. }
  559. type ResultFour struct {
  560. Cainfo string `json:"cainfo"`
  561. ErrMsg string `json:"err_msg"`
  562. InfRefmsgid string `json:"inf_refmsgid"`
  563. Infcode int64 `json:"infcode"`
  564. Output struct {
  565. Result []struct {
  566. BasMednFlag string `json:"bas_medn_flag"`
  567. ChldMedcFlag string `json:"chld_medc_flag"`
  568. ChrgitmLv string `json:"chrgitm_lv"`
  569. Cnt float64 `json:"cnt"`
  570. DetItemFeeSumamt float64 `json:"det_item_fee_sumamt"`
  571. DrtReimFlag string `json:"drt_reim_flag"`
  572. FeedetlSn string `json:"feedetl_sn"`
  573. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  574. HiNegoDrugFlag string `json:"hi_nego_drug_flag"`
  575. InscpScpAmt float64 `json:"inscp_scp_amt"`
  576. ListSpItemFlag string `json:"list_sp_item_flag"`
  577. LmtUsedFlag string `json:"lmt_used_flag"`
  578. MedChrgitmType string `json:"med_chrgitm_type"`
  579. Memo string `json:"memo"`
  580. OverlmtAmt float64 `json:"overlmt_amt"`
  581. PreselfpayAmt float64 `json:"preselfpay_amt"`
  582. Pric float64 `json:"pric"`
  583. PricUplmtAmt float64 `json:"pric_uplmt_amt"`
  584. SelfpayProp float64 `json:"selfpay_prop"`
  585. } `json:"result"`
  586. } `json:"output"`
  587. RefmsgTime string `json:"refmsg_time"`
  588. RespondTime string `json:"respond_time"`
  589. Signtype string `json:"signtype"`
  590. WarnMsg string `json:"warn_msg"`
  591. }
  592. type ResultFive struct {
  593. Insutype string `json:"insutype"`
  594. }
  595. type ResultSix struct {
  596. Cainfo interface{} `json:"cainfo"`
  597. ErrMsg string `json:"err_msg"`
  598. InfRefmsgid string `json:"inf_refmsgid"`
  599. Infcode int64 `json:"infcode"`
  600. Output struct {
  601. } `json:"output"`
  602. RefmsgTime string `json:"refmsg_time"`
  603. RespondTime string `json:"respond_time"`
  604. Signtype interface{} `json:"signtype"`
  605. WarnMsg interface{} `json:"warn_msg"`
  606. }
  607. type ResultSeven struct {
  608. Cainfo string `json:"cainfo"`
  609. ErrMsg string `json:"err_msg"`
  610. InfRefmsgid string `json:"inf_refmsgid"`
  611. Infcode int64 `json:"infcode"`
  612. Output struct {
  613. Setldetail []interface{} `json:"setldetail"`
  614. Setlinfo struct {
  615. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  616. AcctPay float64 `json:"acct_pay"`
  617. ActPayDedc float64 `json:"act_pay_dedc"`
  618. Age float64 `json:"age"`
  619. Balc float64 `json:"balc"`
  620. Brdy string `json:"brdy"`
  621. Certno string `json:"certno"`
  622. ClrOptins string `json:"clr_optins"`
  623. ClrType string `json:"clr_type"`
  624. ClrWay string `json:"clr_way"`
  625. CvlservFlag string `json:"cvlserv_flag"`
  626. CvlservPay float64 `json:"cvlserv_pay"`
  627. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  628. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  629. Gend string `json:"gend"`
  630. HifesPay float64 `json:"hifes_pay"`
  631. HifmiPay float64 `json:"hifmi_pay"`
  632. HifpPay float64 `json:"hifp_pay"`
  633. HospPartAmt float64 `json:"hosp_part_amt"`
  634. InscpScpAmt float64 `json:"inscp_scp_amt"`
  635. Insutype string `json:"insutype"`
  636. MafPay float64 `json:"maf_pay"`
  637. MdtrtCertType string `json:"mdtrt_cert_type"`
  638. HifobPay float64 `json:"hifob_pay"`
  639. MdtrtID string `json:"mdtrt_id"`
  640. MedType string `json:"med_type"`
  641. MedfeeSumamt float64 `json:"medfee_sumamt"`
  642. MedinsSetlID string `json:"medins_setl_id"`
  643. Naty string `json:"naty"`
  644. OthPay float64 `json:"oth_pay"`
  645. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  646. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  647. PreselfpayAmt float64 `json:"preselfpay_amt"`
  648. PsnCashPay float64 `json:"psn_cash_pay"`
  649. PsnCertType string `json:"psn_cert_type"`
  650. PsnName string `json:"psn_name"`
  651. PsnNo string `json:"psn_no"`
  652. PsnPartAmt float64 `json:"psn_part_amt"`
  653. PsnType string `json:"psn_type"`
  654. SetlID string `json:"setl_id"`
  655. SetlTime string `json:"setl_time"`
  656. } `json:"setlinfo"`
  657. } `json:"output"`
  658. RefmsgTime string `json:"refmsg_time"`
  659. RespondTime string `json:"respond_time"`
  660. Signtype interface{} `json:"signtype"`
  661. WarnMsg interface{} `json:"warn_msg"`
  662. }
  663. type ResultEight struct {
  664. Cainfo string `json:"cainfo"`
  665. ErrMsg string `json:"err_msg"`
  666. InfRefmsgid string `json:"inf_refmsgid"`
  667. Infcode int64 `json:"infcode"`
  668. Output struct {
  669. Stmtinfo struct {
  670. SetlOptins string `json:"setl_optins"`
  671. StmtRslt string `json:"stmt_rslt"`
  672. StmtRsltDscr string `json:"stmt_rslt_dscr"`
  673. } `json:"stmtinfo"`
  674. } `json:"output"`
  675. RefmsgTime string `json:"refmsg_time"`
  676. RespondTime string `json:"respond_time"`
  677. Signtype interface{} `json:"signtype"`
  678. WarnMsg interface{} `json:"warn_msg"`
  679. }
  680. type ResultNine struct {
  681. Cainfo string `json:"cainfo"`
  682. ErrMsg string `json:"err_msg"`
  683. InfRefmsgid string `json:"inf_refmsgid"`
  684. Infcode int64 `json:"infcode"`
  685. Output struct {
  686. FileQuryNo string `json:"file_qury_no"`
  687. } `json:"output"`
  688. RefmsgTime string `json:"refmsg_time"`
  689. RespondTime string `json:"respond_time"`
  690. Signtype interface{} `json:"signtype"`
  691. WarnMsg interface{} `json:"warn_msg"`
  692. }
  693. type ResultTen struct {
  694. Cainfo string `json:"cainfo"`
  695. ErrMsg string `json:"err_msg"`
  696. InfRefmsgid string `json:"inf_refmsgid"`
  697. Infcode int64 `json:"infcode"`
  698. Output struct {
  699. DldEndtime string `json:"dld_endtime"`
  700. FileQuryNo string `json:"file_qury_no"`
  701. Filename string `json:"filename"`
  702. } `json:"output"`
  703. RefmsgTime string `json:"refmsg_time"`
  704. RespondTime string `json:"respond_time"`
  705. Signtype interface{} `json:"signtype"`
  706. WarnMsg interface{} `json:"warn_msg"`
  707. }
  708. type ResultEleven struct {
  709. Cainfo string `json:"cainfo"`
  710. ErrMsg string `json:"err_msg"`
  711. InfRefmsgid string `json:"inf_refmsgid"`
  712. Infcode int64 `json:"infcode"`
  713. Output struct {
  714. Setlinfo struct {
  715. FixmedinsName string `json:"fixmedins_name"`
  716. FixmedinsCode string `json:"fixmedins_code"`
  717. PsnNo string `json:"psn_no"`
  718. PsnName string `json:"psn_name"`
  719. HifobPay float64 `json:"hifob_pay"`
  720. Gend string `json:"gend"`
  721. Brdy string `json:"brdy"`
  722. PsnCertType string `json:"psn_cert_type"`
  723. PsnType string `json:"psn_type"`
  724. EmpName string `json:"emp_name"`
  725. Certno string `json:"certno"`
  726. Insutype string `json:"insutype"`
  727. MedfeeSumamt float64 `json:"medfee_sumamt"`
  728. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  729. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  730. PreselfpayAmt float64 `json:"preselfpay_amt"`
  731. InscpScpAmt float64 `json:"inscp_scp_amt"`
  732. ActPayDedc float64 `json:"act_pay_dedc"`
  733. HifpPay float64 `json:"hifp_pay"`
  734. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  735. CvlservPay float64 `json:"cvlserv_pay"`
  736. HifesPay float64 `json:"hifes_pay"`
  737. HifmiPay float64 `json:"hifmi_pay"`
  738. MafPay float64 `json:"maf_pay"`
  739. OthPay float64 `json:"oth_pay"`
  740. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  741. PsnPay float64 `json:"psn_pay"`
  742. AcctPay float64 `json:"acct_pay"`
  743. CashPayamt float64 `json:"cash_payamt"`
  744. Balc float64 `json:"balc"`
  745. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  746. MedinsSetlId string `json:"medins_setl_id"`
  747. RefdSetlFlag string `json:"refd_setl_flag"`
  748. SetlTime string `json:"setl_time"`
  749. MedType string `json:"med_type"`
  750. HospLv string `json:"hosp_lv"`
  751. } `json:"setlinfo"`
  752. } `json:"output"`
  753. RefmsgTime string `json:"refmsg_time"`
  754. RespondTime string `json:"respond_time"`
  755. Signtype interface{} `json:"signtype"`
  756. WarnMsg interface{} `json:"warn_msg"`
  757. }
  758. type ResultTwelve struct {
  759. Cainfo string `json:"cainfo"`
  760. ErrMsg string `json:"err_msg"`
  761. InfRefmsgid string `json:"inf_refmsgid"`
  762. Infcode int64 `json:"infcode"`
  763. Output struct {
  764. MdtrtId string `json:"mdtrt_id"`
  765. ChrgBchno string `json:"chrg_bchno"`
  766. PsnNo string `json:"psn_no"`
  767. } `json:"output"`
  768. RefmsgTime string `json:"refmsg_time"`
  769. RespondTime string `json:"respond_time"`
  770. Signtype interface{} `json:"signtype"`
  771. WarnMsg interface{} `json:"warn_msg"`
  772. }
  773. type Custom struct {
  774. DetItemFeeSumamt string
  775. Cut string
  776. FeedetlSn string
  777. Price string
  778. MedListCodg string
  779. Type int64
  780. AdviceId int64
  781. ProjectId int64
  782. ItemId int64
  783. }
  784. //获取个人信息----挂号-----上传就诊信息
  785. func (c *HisApiController) GetRegisterInfo() {
  786. id, _ := c.GetInt64("id")
  787. record_time := c.GetString("record_time")
  788. settlementValue, _ := c.GetInt64("settlement_value")
  789. medical_insurance_card := c.GetString("medical_insurance_card")
  790. name := c.GetString("name")
  791. id_card_type, _ := c.GetInt64("id_card_type")
  792. certificates, _ := c.GetInt64("certificates")
  793. medical_care, _ := c.GetInt64("medical_care")
  794. birthday := c.GetString("birthday")
  795. age, _ := c.GetInt64("age")
  796. id_card := c.GetString("id_card")
  797. register_type, _ := c.GetInt64("register")
  798. doctor, _ := c.GetInt64("doctor")
  799. department, _ := c.GetInt64("department")
  800. gender, _ := c.GetInt64("sex")
  801. phone := c.GetString("phone")
  802. registration_fee, _ := c.GetFloat("registration_fee")
  803. medical_expenses, _ := c.GetFloat("medical_expenses")
  804. social_type, _ := c.GetInt64("social_type")
  805. admin_user_id, _ := c.GetInt64("admin_user_id")
  806. diagnosis_id, _ := c.GetInt64("diagnosis")
  807. sick_type, _ := c.GetInt64("sick_type")
  808. reg_type := c.GetString("p_type")
  809. timeLayout := "2006-01-02"
  810. loc, _ := time.LoadLocation("Local")
  811. birthdays, _ := time.ParseInLocation(timeLayout+" 15:04:05", birthday+" 00:00:00", loc)
  812. birthUnix := birthdays.Unix()
  813. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  814. if err != nil {
  815. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  816. return
  817. }
  818. recordDateTime := theTime.Unix()
  819. adminInfo := c.GetAdminUserInfo()
  820. var patient service.Patients
  821. if id == 0 {
  822. patient, _ = service.GetPatientByIDCard(id_card, adminInfo.CurrentOrgId)
  823. } else {
  824. patient, _ = service.GetPatientByIDTwo(adminInfo.CurrentOrgId, id)
  825. }
  826. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  827. if patientPrescription.ID == 0 {
  828. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  829. }
  830. //adminRole, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, adminInfo.AdminUser.Id)
  831. diagnosisConfig, _ := service.FindDiagnoseById(diagnosis_id)
  832. sickConfig, _ := service.FindSickById(sick_type)
  833. miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  834. if patient.ID == 0 {
  835. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  836. return
  837. }
  838. if len(patient.IdCardNo) == 0 {
  839. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeIDCartNo)
  840. return
  841. }
  842. config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  843. if config.IsOpen == 1 {
  844. api := "http://127.0.0.1:9532/" + "gdyb/one?cert_no=" + patient.IdCardNo + "&org_name=" + miConfig.OrgName + "&doctor=" + patientPrescription.Doctor + "&fixmedins_code=" + miConfig.Code + "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  845. resp, requestErr := http.Get(api)
  846. if requestErr != nil {
  847. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  848. return
  849. }
  850. defer resp.Body.Close()
  851. body, ioErr := ioutil.ReadAll(resp.Body)
  852. if ioErr != nil {
  853. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  854. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  855. return
  856. }
  857. var respJSON map[string]interface{}
  858. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  859. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  860. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  861. return
  862. }
  863. userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  864. userJSONBytes, _ := json.Marshal(userJSON)
  865. var res ResultTwo
  866. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  867. utils.ErrorLog("解析失败:%v", err)
  868. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  869. return
  870. }
  871. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  872. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  873. infoStr := string(Iinfos)
  874. idetinfoStr := string(Idetinfos)
  875. if res.Infcode == 0 {
  876. his := models.VMHisPatient{
  877. Name: name,
  878. Gender: gender,
  879. Birthday: birthUnix,
  880. MedicalTreatmentType: medical_care,
  881. IdType: certificates,
  882. IdCardNo: id_card,
  883. BalanceAccountsType: settlementValue,
  884. SocialType: social_type,
  885. MedicalInsuranceNumber: medical_insurance_card,
  886. RegisterType: register_type,
  887. RegisterCost: registration_fee,
  888. TreatmentCost: medical_expenses,
  889. Status: 1,
  890. Ctime: time.Now().Unix(),
  891. Mtime: time.Now().Unix(),
  892. PsnNo: res.Output.Baseinfo.PsnNo,
  893. PsnCertType: res.Output.Baseinfo.PsnCertType,
  894. Certno: res.Output.Baseinfo.Certno,
  895. PsnName: res.Output.Baseinfo.PsnName,
  896. Gend: res.Output.Baseinfo.Gend,
  897. Naty: res.Output.Baseinfo.Naty,
  898. Brdy: res.Output.Baseinfo.Brdy,
  899. Age: res.Output.Baseinfo.Age,
  900. Iinfo: infoStr,
  901. Idetinfo: idetinfoStr,
  902. PatientId: patient.ID,
  903. RecordDate: theTime.Unix(),
  904. UserOrgId: adminInfo.CurrentOrgId,
  905. AdminUserId: admin_user_id,
  906. IsReturn: 1,
  907. IdCardType: id_card_type,
  908. Doctor: doctor,
  909. Departments: department,
  910. }
  911. timestamp := time.Now().Unix()
  912. tempTime := time.Unix(timestamp, 0)
  913. timeFormat := tempTime.Format("20060102150405")
  914. chrgBchno := rand.Intn(100000) + 10000
  915. ipt_otp_no := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  916. count, _ := service.FindHisRegisterRecord(theTime.Unix(), patient.ID, adminInfo.CurrentOrgId)
  917. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  918. doctor_id := strconv.FormatInt(patientPrescription.DoctorId, 10)
  919. IdCardNo := ""
  920. if id_card_type == 1 {
  921. IdCardNo = medical_insurance_card
  922. } else {
  923. IdCardNo = patient.IdCardNo
  924. }
  925. if count <= 0 {
  926. api := "http://127.0.0.1:9532/" + "gdyb/two?cert_no=" + IdCardNo + "&insutype=" +
  927. res.Output.Iinfo[0].Insutype + "&psn_no=" + res.Output.Baseinfo.PsnNo +
  928. "&org_name=" + miConfig.OrgName + "&doctor=" + patientPrescription.Doctor + "&ipt_otp_no=" + ipt_otp_no +
  929. "&dept=" + department.Name + "&fixmedins_code=" + miConfig.Code + "&dept_code=" + department.Number + "&doctor_id=" + doctor_id + "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(int64(id_card_type), 10)
  930. resp, requestErr := http.Get(api)
  931. if requestErr != nil {
  932. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  933. return
  934. }
  935. defer resp.Body.Close()
  936. body, ioErr := ioutil.ReadAll(resp.Body)
  937. if ioErr != nil {
  938. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  939. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  940. return
  941. }
  942. var respJSON map[string]interface{}
  943. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  944. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  945. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  946. return
  947. }
  948. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  949. userJSONBytes, _ := json.Marshal(respJSON)
  950. var res ResultThree
  951. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  952. utils.ErrorLog("解析失败:%v", err)
  953. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  954. return
  955. }
  956. if res.Infcode == -1 {
  957. adminUser := c.GetAdminUserInfo()
  958. errlog := &models.HisOrderError{
  959. UserOrgId: adminUser.CurrentOrgId,
  960. Ctime: time.Now().Unix(),
  961. Mtime: time.Now().Unix(),
  962. ErrMsg: res.ErrMsg,
  963. Status: 1,
  964. PatientId: id,
  965. RecordTime: recordDateTime,
  966. Stage: 2,
  967. }
  968. service.CreateErrMsgLog(errlog)
  969. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterTwoException)
  970. return
  971. }
  972. his.Number = res.Output.Data.MdtrtID
  973. his.PsnNo = res.Output.Data.PsnNo
  974. his.IptOtpNo = res.Output.Data.IptOtpNo
  975. his.IdCardNo = patient.IdCardNo
  976. his.PhoneNumber = patient.Phone
  977. his.UserOrgId = adminInfo.CurrentOrgId
  978. his.Ctime = time.Now().Unix()
  979. his.Mtime = time.Now().Unix()
  980. his.Status = 1
  981. err := service.CreateHisPatientTwo(&his)
  982. if err == nil {
  983. api2 := "http://127.0.0.1:9532/" + "gdyb/four?psn_no=" + his.PsnNo +
  984. "&mdtrt_id=" + his.Number + "&doctor=" + patientPrescription.Doctor + "&department=" + department.Name +
  985. "&diag=" + diagnosisConfig.ClassName + "&org_name=" + miConfig.OrgName + "&med_type=" + reg_type + "&doctor_id=" + strconv.FormatInt(patientPrescription.DoctorId, 10) + "&fixmedins_code=" + miConfig.Code + "&diag_code=" + diagnosisConfig.CountryCode +
  986. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&sick_code=" + sickConfig.CountryCode + "&sick_name=" + sickConfig.ClassName
  987. resp2, requestErr2 := http.Get(api2)
  988. if requestErr2 != nil {
  989. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  990. return
  991. }
  992. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  993. if ioErr2 != nil {
  994. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  995. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  996. return
  997. }
  998. var respJSON2 map[string]interface{}
  999. if err := json.Unmarshal([]byte(string(body2)), &respJSON2); err != nil {
  1000. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1001. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1002. return
  1003. }
  1004. respJSON2 = respJSON2["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1005. userJSONBytes2, _ := json.Marshal(respJSON2)
  1006. var res2 ResultSix
  1007. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  1008. utils.ErrorLog("解析失败:%v", err)
  1009. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1010. return
  1011. }
  1012. if res2.Infcode == -1 {
  1013. adminUser := c.GetAdminUserInfo()
  1014. errlog := &models.HisOrderError{
  1015. UserOrgId: adminUser.CurrentOrgId,
  1016. Ctime: time.Now().Unix(),
  1017. Mtime: time.Now().Unix(),
  1018. ErrMsg: res2.ErrMsg,
  1019. Status: 1,
  1020. PatientId: id,
  1021. RecordTime: recordDateTime,
  1022. Stage: 3,
  1023. }
  1024. service.CreateErrMsgLog(errlog)
  1025. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterThreeException)
  1026. return
  1027. }
  1028. c.ServeSuccessJSON(map[string]interface{}{
  1029. "his_info": his,
  1030. })
  1031. } else {
  1032. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1033. return
  1034. }
  1035. } else {
  1036. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  1037. return
  1038. }
  1039. } else {
  1040. adminUser := c.GetAdminUserInfo()
  1041. errlog := &models.HisOrderError{
  1042. UserOrgId: adminUser.CurrentOrgId,
  1043. Ctime: time.Now().Unix(),
  1044. Mtime: time.Now().Unix(),
  1045. ErrMsg: res.ErrMsg,
  1046. Status: 1,
  1047. PatientId: id,
  1048. RecordTime: recordDateTime,
  1049. Stage: 1,
  1050. }
  1051. service.CreateErrMsgLog(errlog)
  1052. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeGdybOneException)
  1053. return
  1054. }
  1055. } else {
  1056. timeStr := time.Now().Format("2006-01-02")
  1057. timeArr := strings.Split(timeStr, "-")
  1058. var str = timeArr[0] + timeArr[1] + timeArr[2] + strconv.FormatInt(patient.ID, 10)
  1059. his, err := service.GetHisPatientInfo(adminInfo.CurrentOrgId, patient.ID, recordDateTime)
  1060. var hisPatient models.XtHisPatient
  1061. if err == gorm.ErrRecordNotFound || his.ID == 0 {
  1062. hisPatient = models.XtHisPatient{
  1063. Name: name,
  1064. Age: age,
  1065. Gender: gender,
  1066. Birthday: birthUnix,
  1067. Phone: phone,
  1068. MedicalTreatmentType: medical_care,
  1069. IdType: certificates,
  1070. IdCardNo: id_card,
  1071. BalanceAccountsType: settlementValue,
  1072. SocialType: social_type,
  1073. MedicalInsuranceNumber: medical_insurance_card,
  1074. RegisterType: register_type,
  1075. RegisterCost: registration_fee,
  1076. TreatmentCost: medical_expenses,
  1077. AdminUserId: admin_user_id,
  1078. UserOrgId: adminInfo.CurrentOrgId,
  1079. Status: 1,
  1080. RecordDate: recordDateTime,
  1081. IsReturn: 1,
  1082. PatientId: patient.ID,
  1083. Ctime: time.Now().Unix(),
  1084. Mtime: time.Now().Unix(),
  1085. Number: str,
  1086. }
  1087. service.CreateHisPatient(&hisPatient)
  1088. }
  1089. c.ServeSuccessJSON(map[string]interface{}{
  1090. "his_info": hisPatient,
  1091. })
  1092. }
  1093. }
  1094. //上传明细----预结算----确认订单
  1095. func (c *HisApiController) GetUploadInfo() {
  1096. id, _ := c.GetInt64("id")
  1097. record_time := c.GetString("record_time")
  1098. pay_way, _ := c.GetInt64("pay_way")
  1099. pay_price, _ := c.GetFloat("pay_price")
  1100. pay_card_no := c.GetString("pay_card_no")
  1101. discount_price, _ := c.GetFloat("discount_price")
  1102. preferential_price, _ := c.GetFloat("preferential_price")
  1103. reality_price, _ := c.GetFloat("reality_price")
  1104. found_price, _ := c.GetFloat("found_price")
  1105. medical_insurance_price, _ := c.GetFloat("medical_insurance_price")
  1106. private_price, _ := c.GetFloat("private_price")
  1107. settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  1108. admin_user_id, _ := c.GetInt64("admin_user_id")
  1109. timeLayout := "2006-01-02"
  1110. loc, _ := time.LoadLocation("Local")
  1111. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  1112. if err != nil {
  1113. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1114. return
  1115. }
  1116. recordDateTime := theTime.Unix()
  1117. adminUser := c.GetAdminUserInfo()
  1118. var prescriptions []*models.HisPrescription
  1119. var start_time int64
  1120. var end_time int64
  1121. data := make(map[string]interface{})
  1122. if settle_accounts_type == 1 { //日结
  1123. prescriptions, _ = service.GetHisPrescription(adminUser.CurrentOrgId, id, recordDateTime)
  1124. data["pre"] = prescriptions
  1125. } else { //月结
  1126. start_time_str := c.GetString("start_time")
  1127. end_time_str := c.GetString("end_time")
  1128. timeLayout := "2006-01-02"
  1129. loc, _ := time.LoadLocation("Local")
  1130. theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  1131. if err != nil {
  1132. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1133. return
  1134. }
  1135. recordStartTime := theStartTime.Unix()
  1136. start_time = recordStartTime
  1137. theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  1138. if err != nil {
  1139. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1140. return
  1141. }
  1142. recordEndTime := theEndTime.Unix()
  1143. end_time = recordEndTime
  1144. prescriptions, _ = service.GetMonthHisPrescription(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime)
  1145. data["pre"] = prescriptions
  1146. }
  1147. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  1148. his, _ := service.GetVMHisPatientInfo(adminUser.CurrentOrgId, id, recordDateTime)
  1149. timestamp := time.Now().Unix()
  1150. tempTime := time.Unix(timestamp, 0)
  1151. timeFormat := tempTime.Format("20060102150405")
  1152. chrgBchno := rand.Intn(100000) + 10000
  1153. chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  1154. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  1155. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  1156. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  1157. strconv.FormatInt(his.PatientId, 10)
  1158. client := &http.Client{}
  1159. data["psn_no"] = his.PsnNo
  1160. data["mdtrt_id"] = his.Number
  1161. data["chrg_bchno"] = chrg_bchno
  1162. data["org_name"] = miConfig.OrgName
  1163. data["doctor"] = roles.UserName
  1164. data["doctor_id"] = strconv.FormatInt(roles.AdminUserId, 10)
  1165. data["dept"] = strconv.FormatInt(patientPrescription.Departments, 10)
  1166. data["fixmedins_code"] = miConfig.Code
  1167. if department.ID == 0 && adminUser.CurrentOrgId == 9919 {
  1168. data["dept_code"] = "15"
  1169. } else {
  1170. data["dept_code"] = department.Number
  1171. }
  1172. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  1173. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  1174. data["secret_key"] = miConfig.SecretKey
  1175. var ids []int64
  1176. for _, item := range prescriptions {
  1177. ids = append(ids, item.ID)
  1178. }
  1179. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  1180. if config.IsOpen == 1 { //对接了医保,走医保流程
  1181. bytesData, _ := json.Marshal(data)
  1182. req, _ := http.NewRequest("POST", "http://127.0.0.1:9532/"+"gdyb/five", bytes.NewReader(bytesData))
  1183. resp, _ := client.Do(req)
  1184. defer resp.Body.Close()
  1185. body, ioErr := ioutil.ReadAll(resp.Body)
  1186. if ioErr != nil {
  1187. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1188. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1189. return
  1190. }
  1191. var respJSON map[string]interface{}
  1192. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1193. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1194. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1195. return
  1196. }
  1197. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1198. userJSONBytes, _ := json.Marshal(respJSON)
  1199. var res ResultFour
  1200. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  1201. utils.ErrorLog("解析失败:%v", err)
  1202. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1203. return
  1204. }
  1205. if res.Infcode == 0 {
  1206. order := &models.HisOrder{
  1207. UserOrgId: adminUser.CurrentOrgId,
  1208. HisPatientId: his.ID,
  1209. PatientId: his.PatientId,
  1210. SettleAccountsDate: recordDateTime,
  1211. Ctime: time.Now().Unix(),
  1212. Mtime: time.Now().Unix(),
  1213. Status: 1,
  1214. Number: chrg_bchno,
  1215. Infcode: res.Infcode,
  1216. WarnMsg: res.WarnMsg,
  1217. Cainfo: res.Cainfo,
  1218. ErrMsg: res.ErrMsg,
  1219. RespondTime: res.RefmsgTime,
  1220. InfRefmsgid: res.InfRefmsgid,
  1221. OrderStatus: 1,
  1222. PayWay: pay_way,
  1223. PayPrice: pay_price,
  1224. PayCardNo: pay_card_no,
  1225. DiscountPrice: discount_price,
  1226. PreferentialPrice: preferential_price,
  1227. RealityPrice: reality_price,
  1228. FoundPrice: found_price,
  1229. MedicalInsurancePrice: medical_insurance_price,
  1230. PrivatePrice: private_price,
  1231. IsMedicineInsurance: 1,
  1232. SettleType: settle_accounts_type,
  1233. SettleStartTime: start_time,
  1234. SettleEndTime: end_time,
  1235. Creator: roles.ID,
  1236. Modify: roles.ID,
  1237. }
  1238. err = service.CreateOrder(order)
  1239. if err != nil {
  1240. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  1241. return
  1242. }
  1243. for _, item := range res.Output.Result {
  1244. temp := strings.Split(item.FeedetlSn, "-")
  1245. var advice_id int64 = 0
  1246. var project_id int64 = 0
  1247. var types int64 = 0
  1248. id, _ := strconv.ParseInt(temp[2], 10, 64)
  1249. types, _ = strconv.ParseInt(temp[1], 10, 64)
  1250. if temp[1] == "1" {
  1251. advice_id = id
  1252. project_id = 0
  1253. } else if temp[1] == "2" {
  1254. advice_id = 0
  1255. project_id = id
  1256. }
  1257. info := &models.HisOrderInfo{
  1258. OrderNumber: order.Number,
  1259. FeedetlSn: item.FeedetlSn,
  1260. UploadDate: time.Now().Unix(),
  1261. AdviceId: advice_id,
  1262. DetItemFeeSumamt: item.DetItemFeeSumamt,
  1263. Cnt: item.Cnt,
  1264. Pric: float64(item.Pric),
  1265. PatientId: his.PatientId,
  1266. PricUplmtAmt: item.PricUplmtAmt,
  1267. SelfpayProp: item.SelfpayProp,
  1268. FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  1269. OverlmtAmt: item.OverlmtAmt,
  1270. PreselfpayAmt: item.PreselfpayAmt,
  1271. BasMednFlag: item.BasMednFlag,
  1272. MedChrgitmType: item.MedChrgitmType,
  1273. HiNegoDrugFlag: item.HiNegoDrugFlag,
  1274. Status: 1,
  1275. Memo: item.Memo,
  1276. Mtime: time.Now().Unix(),
  1277. InscpScpAmt: item.InscpScpAmt,
  1278. DrtReimFlag: item.DrtReimFlag,
  1279. Ctime: time.Now().Unix(),
  1280. ListSpItemFlag: item.ListSpItemFlag,
  1281. ChldMedcFlag: item.ChldMedcFlag,
  1282. LmtUsedFlag: item.LmtUsedFlag,
  1283. ChrgitmLv: item.ChrgitmLv,
  1284. UserOrgId: adminUser.CurrentOrgId,
  1285. HisPatientId: his.ID,
  1286. OrderId: order.ID,
  1287. ProjectId: project_id,
  1288. Type: types,
  1289. }
  1290. service.CreateOrderInfo(info)
  1291. }
  1292. service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  1293. service.UpDatePrescriptionInfoNumber(adminUser.CurrentOrgId, patientPrescription.PatientId, chrg_bchno, recordDateTime)
  1294. var total float64
  1295. for _, item := range prescriptions {
  1296. if item.Type == 1 { //药品
  1297. for _, subItem := range item.HisDoctorAdviceInfo {
  1298. total = total + (subItem.Price * subItem.PrescribingNumber)
  1299. }
  1300. }
  1301. if item.Type == 2 { //项目
  1302. for _, subItem := range item.HisPrescriptionProject {
  1303. total = total + (subItem.Price * float64(subItem.Count))
  1304. }
  1305. }
  1306. }
  1307. for _, item := range prescriptions {
  1308. for _, subItem := range item.HisAdditionalCharge {
  1309. total = total + (subItem.Price * float64(subItem.Count))
  1310. }
  1311. }
  1312. allTotal := fmt.Sprintf("%.2f", total)
  1313. if res.Infcode == 0 {
  1314. var rf []*ResultFive
  1315. json.Unmarshal([]byte(his.Iinfo), &rf)
  1316. psn_no := his.PsnNo
  1317. mdtrt_id := his.Number
  1318. chrg_bchno := chrg_bchno
  1319. cert_no := his.Certno
  1320. insutype := rf[0].Insutype
  1321. if his.IdCardType == 1 {
  1322. cert_no = his.MedicalInsuranceNumber
  1323. } else {
  1324. cert_no = his.Certno
  1325. }
  1326. api := "http://127.0.0.1:9532/" + "gdyb/eight?cert_no=" + cert_no + "&insutype=" +
  1327. insutype + "&psn_no=" + psn_no + "&chrg_bchno=" + chrg_bchno + "&mdtrt_id=" + mdtrt_id +
  1328. "&total=" + allTotal + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code + "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" +
  1329. miConfig.SecretKey + "&med_type=" + strconv.FormatInt(patientPrescription.RegisterType, 10) + "&id_card_type=" + strconv.FormatInt(int64(his.IdCardType), 10)
  1330. resp, requestErr := http.Get(api)
  1331. if requestErr != nil {
  1332. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1333. return
  1334. }
  1335. defer resp.Body.Close()
  1336. body, ioErr := ioutil.ReadAll(resp.Body)
  1337. if ioErr != nil {
  1338. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1339. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1340. return
  1341. }
  1342. var respJSON map[string]interface{}
  1343. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  1344. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1345. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1346. return
  1347. }
  1348. fmt.Println(respJSON)
  1349. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1350. userJSONBytes, _ := json.Marshal(respJSON)
  1351. var res ResultSeven
  1352. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  1353. utils.ErrorLog("解析失败:%v", err)
  1354. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1355. return
  1356. }
  1357. if res.Infcode == -1 {
  1358. errlog := &models.HisOrderError{
  1359. UserOrgId: adminUser.CurrentOrgId,
  1360. Ctime: time.Now().Unix(),
  1361. Mtime: time.Now().Unix(),
  1362. Number: chrg_bchno,
  1363. ErrMsg: res.ErrMsg,
  1364. Status: 1,
  1365. PatientId: id,
  1366. RecordTime: recordDateTime,
  1367. Stage: 6,
  1368. }
  1369. service.CreateErrMsgLog(errlog)
  1370. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  1371. return
  1372. } else {
  1373. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  1374. order.OrderStatus = 2
  1375. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  1376. order.SetlId = res.Output.Setlinfo.SetlID
  1377. order.PsnNo = res.Output.Setlinfo.PsnNo
  1378. order.PsnName = res.Output.Setlinfo.PsnName
  1379. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  1380. order.Certno = res.Output.Setlinfo.Certno
  1381. order.Gend = res.Output.Setlinfo.Gend
  1382. order.Naty = res.Output.Setlinfo.Naty
  1383. order.Age = res.Output.Setlinfo.Age
  1384. order.Insutype = res.Output.Setlinfo.Insutype
  1385. order.PsnType = res.Output.Setlinfo.PsnType
  1386. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  1387. order.SetlTime = res.Output.Setlinfo.SetlTime
  1388. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  1389. order.MedType = res.Output.Setlinfo.MedType
  1390. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  1391. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  1392. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  1393. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  1394. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  1395. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  1396. order.HifpPay = res.Output.Setlinfo.HifpPay
  1397. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  1398. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  1399. order.HifesPay = res.Output.Setlinfo.HifesPay
  1400. order.HifobPay = res.Output.Setlinfo.HifobPay
  1401. order.MafPay = res.Output.Setlinfo.MafPay
  1402. order.OthPay = res.Output.Setlinfo.OthPay
  1403. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  1404. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  1405. order.AcctPay = res.Output.Setlinfo.AcctPay
  1406. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  1407. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  1408. order.Balc = res.Output.Setlinfo.Balc
  1409. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  1410. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  1411. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  1412. order.ClrWay = res.Output.Setlinfo.ClrWay
  1413. order.Creator = order.Creator
  1414. order.Modify = roles.ID
  1415. setlDetail, _ := json.Marshal(res.Output.Setldetail)
  1416. detailStr := string(setlDetail)
  1417. order.SetlDetail = detailStr
  1418. err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  1419. err = service.UpDateOrder(order)
  1420. if err == nil {
  1421. c.ServeSuccessJSON(map[string]interface{}{
  1422. "msg": "结算成功",
  1423. })
  1424. } else {
  1425. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  1426. return
  1427. }
  1428. }
  1429. } else {
  1430. adminUser := c.GetAdminUserInfo()
  1431. errlog := &models.HisOrderError{
  1432. UserOrgId: adminUser.CurrentOrgId,
  1433. Ctime: time.Now().Unix(),
  1434. Mtime: time.Now().Unix(),
  1435. ErrMsg: res.ErrMsg,
  1436. Status: 1,
  1437. PatientId: id,
  1438. RecordTime: recordDateTime,
  1439. Stage: 4,
  1440. }
  1441. service.CreateErrMsgLog(errlog)
  1442. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  1443. return
  1444. }
  1445. } else {
  1446. adminUser := c.GetAdminUserInfo()
  1447. errlog := &models.HisOrderError{
  1448. UserOrgId: adminUser.CurrentOrgId,
  1449. Ctime: time.Now().Unix(),
  1450. Mtime: time.Now().Unix(),
  1451. ErrMsg: res.ErrMsg,
  1452. Status: 1,
  1453. PatientId: id,
  1454. RecordTime: recordDateTime,
  1455. Stage: 4,
  1456. }
  1457. service.CreateErrMsgLog(errlog)
  1458. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCalOrderException)
  1459. return
  1460. }
  1461. } else {
  1462. var total float64
  1463. for _, item := range prescriptions {
  1464. if item.Type == 1 { //药品
  1465. for _, subItem := range item.HisDoctorAdviceInfo {
  1466. total = total + (subItem.Price * subItem.PrescribingNumber)
  1467. }
  1468. }
  1469. if item.Type == 2 { //项目
  1470. for _, subItem := range item.HisPrescriptionProject {
  1471. total = total + (subItem.Price * float64(subItem.Count))
  1472. }
  1473. }
  1474. for _, subItem := range item.HisAdditionalCharge {
  1475. total = total + (subItem.Price * float64(subItem.Count))
  1476. }
  1477. }
  1478. allTotal := fmt.Sprintf("%.2f", total)
  1479. totals, _ := strconv.ParseFloat(allTotal, 64)
  1480. order := &models.HisOrder{
  1481. UserOrgId: adminUser.CurrentOrgId,
  1482. HisPatientId: his.ID,
  1483. PatientId: id,
  1484. SettleAccountsDate: recordDateTime,
  1485. Ctime: time.Now().Unix(),
  1486. Mtime: time.Now().Unix(),
  1487. Status: 1,
  1488. OrderStatus: 2,
  1489. Number: chrg_bchno,
  1490. MedfeeSumamt: totals,
  1491. PayWay: pay_way,
  1492. PayPrice: pay_price,
  1493. PayCardNo: pay_card_no,
  1494. DiscountPrice: discount_price,
  1495. PreferentialPrice: preferential_price,
  1496. RealityPrice: reality_price,
  1497. FoundPrice: found_price,
  1498. MedicalInsurancePrice: medical_insurance_price,
  1499. PrivatePrice: private_price,
  1500. }
  1501. err = service.CreateOrder(order)
  1502. if err != nil {
  1503. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  1504. return
  1505. }
  1506. var customs []*Custom
  1507. for _, item := range prescriptions {
  1508. if item.Type == 1 { //药品
  1509. for _, subItem := range item.HisDoctorAdviceInfo {
  1510. cus := &Custom{
  1511. AdviceId: subItem.ID,
  1512. ProjectId: 0,
  1513. DetItemFeeSumamt: fmt.Sprintf("%.2f", subItem.Price*subItem.PrescribingNumber),
  1514. Cut: fmt.Sprintf("%.2f", subItem.PrescribingNumber),
  1515. FeedetlSn: subItem.FeedetlSn,
  1516. Price: fmt.Sprintf("%.2f", subItem.Price),
  1517. MedListCodg: subItem.MedListCodg,
  1518. Type: 1,
  1519. }
  1520. customs = append(customs, cus)
  1521. }
  1522. }
  1523. if item.Type == 2 { //项目
  1524. for _, subItem := range item.HisPrescriptionProject {
  1525. cus := &Custom{
  1526. AdviceId: 0,
  1527. ProjectId: subItem.ID,
  1528. DetItemFeeSumamt: fmt.Sprintf("%.2f", subItem.Price*float64(subItem.Count)),
  1529. Cut: fmt.Sprintf("%.2f", float64(subItem.Count)),
  1530. FeedetlSn: subItem.FeedetlSn,
  1531. Price: fmt.Sprintf("%.2f", float64(subItem.Price)),
  1532. MedListCodg: subItem.MedListCodg,
  1533. Type: 2,
  1534. }
  1535. customs = append(customs, cus)
  1536. }
  1537. }
  1538. for _, item := range item.HisAdditionalCharge {
  1539. cus := &Custom{
  1540. ItemId: item.ID,
  1541. AdviceId: 0,
  1542. ProjectId: 0,
  1543. DetItemFeeSumamt: fmt.Sprintf("%.2f", item.Price),
  1544. Cut: fmt.Sprintf("%.2f", float64(item.Count)),
  1545. FeedetlSn: item.FeedetlSn,
  1546. Price: fmt.Sprintf("%.2f", float64(item.Price)),
  1547. MedListCodg: item.XtHisAddtionConfig.Code,
  1548. Type: 3,
  1549. }
  1550. customs = append(customs, cus)
  1551. }
  1552. }
  1553. for _, item := range customs {
  1554. var advice_id int64 = 0
  1555. var project_id int64 = 0
  1556. var item_id int64 = 0
  1557. var types int64 = 0
  1558. if item.Type == 1 {
  1559. advice_id = item.AdviceId
  1560. project_id = 0
  1561. item_id = 0
  1562. } else if item.Type == 2 {
  1563. advice_id = 0
  1564. item_id = 0
  1565. project_id = item.ProjectId
  1566. } else if item.Type == 3 {
  1567. advice_id = 0
  1568. item_id = item.ItemId
  1569. project_id = 0
  1570. }
  1571. detItemFeeSumamt, _ := strconv.ParseFloat(item.DetItemFeeSumamt, 32)
  1572. cut, _ := strconv.ParseFloat(item.Cut, 32)
  1573. pric, _ := strconv.ParseFloat(item.Price, 32)
  1574. info := &models.HisOrderInfo{
  1575. OrderNumber: order.Number,
  1576. UploadDate: time.Now().Unix(),
  1577. AdviceId: advice_id,
  1578. DetItemFeeSumamt: detItemFeeSumamt,
  1579. Cnt: cut,
  1580. Pric: pric,
  1581. PatientId: id,
  1582. Status: 1,
  1583. Mtime: time.Now().Unix(),
  1584. Ctime: time.Now().Unix(),
  1585. UserOrgId: adminUser.CurrentOrgId,
  1586. HisPatientId: his.ID,
  1587. OrderId: order.ID,
  1588. ProjectId: project_id,
  1589. Type: types,
  1590. ItemId: item_id,
  1591. }
  1592. service.CreateOrderInfo(info)
  1593. }
  1594. //err := service.UpDateAddtionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  1595. err = service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  1596. err = service.UpDatePrescriptionInfoNumber(adminUser.CurrentOrgId, id, chrg_bchno, recordDateTime)
  1597. err = service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  1598. if err == nil {
  1599. c.ServeSuccessJSON(map[string]interface{}{
  1600. "msg": "结算成功",
  1601. })
  1602. } else {
  1603. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  1604. return
  1605. }
  1606. }
  1607. }
  1608. func (c *HisApiController) GetPreUploadInfo() {
  1609. id, _ := c.GetInt64("id")
  1610. record_time := c.GetString("record_time")
  1611. settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  1612. admin_user_id, _ := c.GetInt64("admin_user_id")
  1613. timeLayout := "2006-01-02"
  1614. loc, _ := time.LoadLocation("Local")
  1615. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  1616. if err != nil {
  1617. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1618. return
  1619. }
  1620. recordDateTime := theTime.Unix()
  1621. adminUser := c.GetAdminUserInfo()
  1622. var prescriptions []*models.HisPrescription
  1623. var start_time int64
  1624. var end_time int64
  1625. data := make(map[string]interface{})
  1626. if settle_accounts_type == 1 { //日结
  1627. prescriptions, _ = service.GetHisPrescription(adminUser.CurrentOrgId, id, recordDateTime)
  1628. data["pre"] = prescriptions
  1629. } else { //月结
  1630. start_time_str := c.GetString("start_time")
  1631. end_time_str := c.GetString("end_time")
  1632. timeLayout := "2006-01-02"
  1633. loc, _ := time.LoadLocation("Local")
  1634. theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  1635. if err != nil {
  1636. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1637. return
  1638. }
  1639. recordStartTime := theStartTime.Unix()
  1640. start_time = recordStartTime
  1641. theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  1642. if err != nil {
  1643. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1644. return
  1645. }
  1646. recordEndTime := theEndTime.Unix()
  1647. end_time = recordEndTime
  1648. prescriptions, _ = service.GetMonthHisPrescription(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime)
  1649. data["pre"] = prescriptions
  1650. }
  1651. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  1652. his, _ := service.GetVMHisPatientInfo(adminUser.CurrentOrgId, id, recordDateTime)
  1653. timestamp := time.Now().Unix()
  1654. tempTime := time.Unix(timestamp, 0)
  1655. timeFormat := tempTime.Format("20060102150405")
  1656. chrgBchno := rand.Intn(100000) + 10000
  1657. chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  1658. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  1659. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  1660. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  1661. strconv.FormatInt(his.PatientId, 10)
  1662. client := &http.Client{}
  1663. data["psn_no"] = his.PsnNo
  1664. data["mdtrt_id"] = his.Number
  1665. data["chrg_bchno"] = chrg_bchno
  1666. data["org_name"] = miConfig.OrgName
  1667. data["doctor"] = roles.UserName
  1668. data["doctor_id"] = strconv.FormatInt(roles.AdminUserId, 10)
  1669. data["dept"] = strconv.FormatInt(patientPrescription.Departments, 10)
  1670. data["fixmedins_code"] = miConfig.Code
  1671. data["dept_code"] = department.Number
  1672. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  1673. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  1674. data["secret_key"] = miConfig.SecretKey
  1675. var ids []int64
  1676. for _, item := range prescriptions {
  1677. ids = append(ids, item.ID)
  1678. }
  1679. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  1680. if config.IsOpen == 1 { //对接了医保,走医保流程
  1681. bytesData, _ := json.Marshal(data)
  1682. req, _ := http.NewRequest("POST", "http://127.0.0.1:9532/"+"gdyb/five", bytes.NewReader(bytesData))
  1683. resp, _ := client.Do(req)
  1684. defer resp.Body.Close()
  1685. body, ioErr := ioutil.ReadAll(resp.Body)
  1686. if ioErr != nil {
  1687. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1688. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1689. return
  1690. }
  1691. var respJSON map[string]interface{}
  1692. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1693. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1694. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1695. return
  1696. }
  1697. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1698. userJSONBytes, _ := json.Marshal(respJSON)
  1699. var res ResultFour
  1700. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  1701. utils.ErrorLog("解析失败:%v", err)
  1702. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1703. return
  1704. }
  1705. if res.Infcode == 0 {
  1706. order := &models.HisOrder{
  1707. UserOrgId: adminUser.CurrentOrgId,
  1708. HisPatientId: his.ID,
  1709. PatientId: his.PatientId,
  1710. SettleAccountsDate: recordDateTime,
  1711. Ctime: time.Now().Unix(),
  1712. Mtime: time.Now().Unix(),
  1713. Status: 1,
  1714. Number: chrg_bchno,
  1715. Infcode: res.Infcode,
  1716. WarnMsg: res.WarnMsg,
  1717. Cainfo: res.Cainfo,
  1718. ErrMsg: res.ErrMsg,
  1719. RespondTime: res.RefmsgTime,
  1720. InfRefmsgid: res.InfRefmsgid,
  1721. OrderStatus: 1,
  1722. IsMedicineInsurance: 1,
  1723. SettleType: settle_accounts_type,
  1724. SettleStartTime: start_time,
  1725. SettleEndTime: end_time,
  1726. Creator: roles.ID,
  1727. Modify: roles.ID,
  1728. }
  1729. err = service.CreateOrder(order)
  1730. if err != nil {
  1731. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  1732. return
  1733. }
  1734. for _, item := range res.Output.Result {
  1735. temp := strings.Split(item.FeedetlSn, "-")
  1736. var advice_id int64 = 0
  1737. var project_id int64 = 0
  1738. var types int64 = 0
  1739. id, _ := strconv.ParseInt(temp[2], 10, 64)
  1740. types, _ = strconv.ParseInt(temp[1], 10, 64)
  1741. if temp[1] == "1" {
  1742. advice_id = id
  1743. project_id = 0
  1744. } else if temp[1] == "2" {
  1745. advice_id = 0
  1746. project_id = id
  1747. }
  1748. info := &models.HisOrderInfo{
  1749. OrderNumber: order.Number,
  1750. FeedetlSn: item.FeedetlSn,
  1751. UploadDate: time.Now().Unix(),
  1752. AdviceId: advice_id,
  1753. DetItemFeeSumamt: item.DetItemFeeSumamt,
  1754. Cnt: item.Cnt,
  1755. Pric: float64(item.Pric),
  1756. PatientId: his.PatientId,
  1757. PricUplmtAmt: item.PricUplmtAmt,
  1758. SelfpayProp: item.SelfpayProp,
  1759. FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  1760. OverlmtAmt: item.OverlmtAmt,
  1761. PreselfpayAmt: item.PreselfpayAmt,
  1762. BasMednFlag: item.BasMednFlag,
  1763. MedChrgitmType: item.MedChrgitmType,
  1764. HiNegoDrugFlag: item.HiNegoDrugFlag,
  1765. Status: 1,
  1766. Memo: item.Memo,
  1767. Mtime: time.Now().Unix(),
  1768. InscpScpAmt: item.InscpScpAmt,
  1769. DrtReimFlag: item.DrtReimFlag,
  1770. Ctime: time.Now().Unix(),
  1771. ListSpItemFlag: item.ListSpItemFlag,
  1772. ChldMedcFlag: item.ChldMedcFlag,
  1773. LmtUsedFlag: item.LmtUsedFlag,
  1774. ChrgitmLv: item.ChrgitmLv,
  1775. UserOrgId: adminUser.CurrentOrgId,
  1776. HisPatientId: his.ID,
  1777. OrderId: order.ID,
  1778. ProjectId: project_id,
  1779. Type: types,
  1780. }
  1781. service.CreateOrderInfo(info)
  1782. }
  1783. service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  1784. service.UpDatePrescriptionInfoNumber(adminUser.CurrentOrgId, patientPrescription.PatientId, chrg_bchno, recordDateTime)
  1785. var total float64
  1786. for _, item := range prescriptions {
  1787. if item.Type == 1 { //药品
  1788. for _, subItem := range item.HisDoctorAdviceInfo {
  1789. total = total + (subItem.Price * subItem.PrescribingNumber)
  1790. }
  1791. }
  1792. if item.Type == 2 { //项目
  1793. for _, subItem := range item.HisPrescriptionProject {
  1794. total = total + (subItem.Price * float64(subItem.Count))
  1795. }
  1796. }
  1797. }
  1798. for _, item := range prescriptions {
  1799. for _, subItem := range item.HisAdditionalCharge {
  1800. total = total + (subItem.Price * float64(subItem.Count))
  1801. }
  1802. }
  1803. allTotal := fmt.Sprintf("%.2f", total)
  1804. if res.Infcode == 0 {
  1805. var rf []*ResultFive
  1806. json.Unmarshal([]byte(his.Iinfo), &rf)
  1807. psn_no := his.PsnNo
  1808. mdtrt_id := his.Number
  1809. chrg_bchno := chrg_bchno
  1810. cert_no := his.Certno
  1811. insutype := rf[0].Insutype
  1812. if his.IdCardType == 1 {
  1813. cert_no = his.MedicalInsuranceNumber
  1814. } else {
  1815. cert_no = his.Certno
  1816. }
  1817. api := "http://127.0.0.1:9532/" + "gdyb/seven?cert_no=" + cert_no + "&insutype=" +
  1818. insutype + "&psn_no=" + psn_no + "&chrg_bchno=" + chrg_bchno + "&mdtrt_id=" + mdtrt_id +
  1819. "&total=" + allTotal + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code + "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" +
  1820. miConfig.SecretKey + "&med_type=" + strconv.FormatInt(patientPrescription.RegisterType, 10) + "&id_card_type=" + strconv.FormatInt(int64(his.IdCardType), 10)
  1821. resp, requestErr := http.Get(api)
  1822. if requestErr != nil {
  1823. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1824. return
  1825. }
  1826. defer resp.Body.Close()
  1827. body, ioErr := ioutil.ReadAll(resp.Body)
  1828. if ioErr != nil {
  1829. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1830. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1831. return
  1832. }
  1833. var respJSON map[string]interface{}
  1834. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  1835. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1836. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1837. return
  1838. }
  1839. fmt.Println(respJSON)
  1840. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1841. userJSONBytes, _ := json.Marshal(respJSON)
  1842. var res ResultSeven
  1843. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  1844. utils.ErrorLog("解析失败:%v", err)
  1845. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1846. return
  1847. }
  1848. if res.Infcode == -1 {
  1849. errlog := &models.HisOrderError{
  1850. UserOrgId: adminUser.CurrentOrgId,
  1851. Ctime: time.Now().Unix(),
  1852. Mtime: time.Now().Unix(),
  1853. Number: chrg_bchno,
  1854. ErrMsg: res.ErrMsg,
  1855. Status: 1,
  1856. PatientId: id,
  1857. RecordTime: recordDateTime,
  1858. Stage: 7,
  1859. }
  1860. service.CreateErrMsgLog(errlog)
  1861. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  1862. return
  1863. } else {
  1864. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  1865. order.OrderStatus = 1
  1866. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  1867. order.SetlId = res.Output.Setlinfo.SetlID
  1868. order.PsnNo = res.Output.Setlinfo.PsnNo
  1869. order.PsnName = res.Output.Setlinfo.PsnName
  1870. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  1871. order.Certno = res.Output.Setlinfo.Certno
  1872. order.Gend = res.Output.Setlinfo.Gend
  1873. order.Naty = res.Output.Setlinfo.Naty
  1874. order.Age = res.Output.Setlinfo.Age
  1875. order.Insutype = res.Output.Setlinfo.Insutype
  1876. order.PsnType = res.Output.Setlinfo.PsnType
  1877. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  1878. order.SetlTime = res.Output.Setlinfo.SetlTime
  1879. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  1880. order.MedType = res.Output.Setlinfo.MedType
  1881. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  1882. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  1883. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  1884. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  1885. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  1886. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  1887. order.HifpPay = res.Output.Setlinfo.HifpPay
  1888. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  1889. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  1890. order.HifesPay = res.Output.Setlinfo.HifesPay
  1891. order.HifobPay = res.Output.Setlinfo.HifobPay
  1892. order.MafPay = res.Output.Setlinfo.MafPay
  1893. order.OthPay = res.Output.Setlinfo.OthPay
  1894. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  1895. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  1896. order.AcctPay = res.Output.Setlinfo.AcctPay
  1897. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  1898. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  1899. order.Balc = res.Output.Setlinfo.Balc
  1900. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  1901. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  1902. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  1903. order.ClrWay = res.Output.Setlinfo.ClrWay
  1904. order.Creator = order.Creator
  1905. order.Modify = roles.ID
  1906. setlDetail, _ := json.Marshal(res.Output.Setldetail)
  1907. detailStr := string(setlDetail)
  1908. order.SetlDetail = detailStr
  1909. //err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  1910. err = service.UpDateOrder(order)
  1911. if err == nil {
  1912. c.ServeSuccessJSON(map[string]interface{}{
  1913. "msg": "预结算成功",
  1914. })
  1915. } else {
  1916. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  1917. return
  1918. }
  1919. }
  1920. } else {
  1921. adminUser := c.GetAdminUserInfo()
  1922. errlog := &models.HisOrderError{
  1923. UserOrgId: adminUser.CurrentOrgId,
  1924. Ctime: time.Now().Unix(),
  1925. Mtime: time.Now().Unix(),
  1926. ErrMsg: res.ErrMsg,
  1927. Status: 1,
  1928. PatientId: id,
  1929. RecordTime: recordDateTime,
  1930. Stage: 4,
  1931. }
  1932. service.CreateErrMsgLog(errlog)
  1933. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  1934. return
  1935. }
  1936. } else {
  1937. adminUser := c.GetAdminUserInfo()
  1938. errlog := &models.HisOrderError{
  1939. UserOrgId: adminUser.CurrentOrgId,
  1940. Ctime: time.Now().Unix(),
  1941. Mtime: time.Now().Unix(),
  1942. ErrMsg: res.ErrMsg,
  1943. Status: 1,
  1944. PatientId: id,
  1945. RecordTime: recordDateTime,
  1946. Stage: 4,
  1947. }
  1948. service.CreateErrMsgLog(errlog)
  1949. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCalOrderException)
  1950. return
  1951. }
  1952. } else {
  1953. var total float64
  1954. for _, item := range prescriptions {
  1955. if item.Type == 1 { //药品
  1956. for _, subItem := range item.HisDoctorAdviceInfo {
  1957. total = total + (subItem.Price * subItem.PrescribingNumber)
  1958. }
  1959. }
  1960. if item.Type == 2 { //项目
  1961. for _, subItem := range item.HisPrescriptionProject {
  1962. total = total + (subItem.Price * float64(subItem.Count))
  1963. }
  1964. }
  1965. for _, subItem := range item.HisAdditionalCharge {
  1966. total = total + (subItem.Price * float64(subItem.Count))
  1967. }
  1968. }
  1969. allTotal := fmt.Sprintf("%.2f", total)
  1970. totals, _ := strconv.ParseFloat(allTotal, 64)
  1971. order := &models.HisOrder{
  1972. UserOrgId: adminUser.CurrentOrgId,
  1973. HisPatientId: his.ID,
  1974. PatientId: id,
  1975. SettleAccountsDate: recordDateTime,
  1976. Ctime: time.Now().Unix(),
  1977. Mtime: time.Now().Unix(),
  1978. Status: 1,
  1979. OrderStatus: 2,
  1980. Number: chrg_bchno,
  1981. MedfeeSumamt: totals,
  1982. }
  1983. err = service.CreateOrder(order)
  1984. if err != nil {
  1985. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  1986. return
  1987. }
  1988. var customs []*Custom
  1989. for _, item := range prescriptions {
  1990. if item.Type == 1 { //药品
  1991. for _, subItem := range item.HisDoctorAdviceInfo {
  1992. cus := &Custom{
  1993. AdviceId: subItem.ID,
  1994. ProjectId: 0,
  1995. DetItemFeeSumamt: fmt.Sprintf("%.2f", subItem.Price*subItem.PrescribingNumber),
  1996. Cut: fmt.Sprintf("%.2f", subItem.PrescribingNumber),
  1997. FeedetlSn: subItem.FeedetlSn,
  1998. Price: fmt.Sprintf("%.2f", subItem.Price),
  1999. MedListCodg: subItem.MedListCodg,
  2000. Type: 1,
  2001. }
  2002. customs = append(customs, cus)
  2003. }
  2004. }
  2005. if item.Type == 2 { //项目
  2006. for _, subItem := range item.HisPrescriptionProject {
  2007. cus := &Custom{
  2008. AdviceId: 0,
  2009. ProjectId: subItem.ID,
  2010. DetItemFeeSumamt: fmt.Sprintf("%.2f", subItem.Price*float64(subItem.Count)),
  2011. Cut: fmt.Sprintf("%.2f", float64(subItem.Count)),
  2012. FeedetlSn: subItem.FeedetlSn,
  2013. Price: fmt.Sprintf("%.2f", float64(subItem.Price)),
  2014. MedListCodg: subItem.MedListCodg,
  2015. Type: 2,
  2016. }
  2017. customs = append(customs, cus)
  2018. }
  2019. }
  2020. for _, item := range item.HisAdditionalCharge {
  2021. cus := &Custom{
  2022. ItemId: item.ID,
  2023. AdviceId: 0,
  2024. ProjectId: 0,
  2025. DetItemFeeSumamt: fmt.Sprintf("%.2f", item.Price),
  2026. Cut: fmt.Sprintf("%.2f", float64(item.Count)),
  2027. FeedetlSn: item.FeedetlSn,
  2028. Price: fmt.Sprintf("%.2f", float64(item.Price)),
  2029. MedListCodg: item.XtHisAddtionConfig.Code,
  2030. Type: 3,
  2031. }
  2032. customs = append(customs, cus)
  2033. }
  2034. }
  2035. for _, item := range customs {
  2036. var advice_id int64 = 0
  2037. var project_id int64 = 0
  2038. var item_id int64 = 0
  2039. var types int64 = 0
  2040. if item.Type == 1 {
  2041. advice_id = item.AdviceId
  2042. project_id = 0
  2043. item_id = 0
  2044. } else if item.Type == 2 {
  2045. advice_id = 0
  2046. item_id = 0
  2047. project_id = item.ProjectId
  2048. } else if item.Type == 3 {
  2049. advice_id = 0
  2050. item_id = item.ItemId
  2051. project_id = 0
  2052. }
  2053. detItemFeeSumamt, _ := strconv.ParseFloat(item.DetItemFeeSumamt, 32)
  2054. cut, _ := strconv.ParseFloat(item.Cut, 32)
  2055. pric, _ := strconv.ParseFloat(item.Price, 32)
  2056. info := &models.HisOrderInfo{
  2057. OrderNumber: order.Number,
  2058. UploadDate: time.Now().Unix(),
  2059. AdviceId: advice_id,
  2060. DetItemFeeSumamt: detItemFeeSumamt,
  2061. Cnt: cut,
  2062. Pric: pric,
  2063. PatientId: id,
  2064. Status: 1,
  2065. Mtime: time.Now().Unix(),
  2066. Ctime: time.Now().Unix(),
  2067. UserOrgId: adminUser.CurrentOrgId,
  2068. HisPatientId: his.ID,
  2069. OrderId: order.ID,
  2070. ProjectId: project_id,
  2071. Type: types,
  2072. ItemId: item_id,
  2073. }
  2074. service.CreateOrderInfo(info)
  2075. }
  2076. //err := service.UpDateAddtionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  2077. err = service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  2078. err = service.UpDatePrescriptionInfoNumber(adminUser.CurrentOrgId, id, chrg_bchno, recordDateTime)
  2079. err = service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  2080. if err == nil {
  2081. c.ServeSuccessJSON(map[string]interface{}{
  2082. "msg": "结算成功",
  2083. })
  2084. } else {
  2085. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  2086. return
  2087. }
  2088. }
  2089. }
  2090. func (c *HisApiController) GetSettleInfo() {
  2091. id, _ := c.GetInt64("id")
  2092. order_id, _ := c.GetInt64("order_id")
  2093. record_time := c.GetString("record_time")
  2094. pay_way, _ := c.GetInt64("pay_way")
  2095. pay_price, _ := c.GetFloat("pay_price")
  2096. pay_card_no := c.GetString("pay_card_no")
  2097. discount_price, _ := c.GetFloat("discount_price")
  2098. preferential_price, _ := c.GetFloat("preferential_price")
  2099. reality_price, _ := c.GetFloat("reality_price")
  2100. found_price, _ := c.GetFloat("found_price")
  2101. medical_insurance_price, _ := c.GetFloat("medical_insurance_price")
  2102. private_price, _ := c.GetFloat("private_price")
  2103. settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  2104. admin_user_id, _ := c.GetInt64("admin_user_id")
  2105. timeLayout := "2006-01-02"
  2106. loc, _ := time.LoadLocation("Local")
  2107. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  2108. if err != nil {
  2109. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  2110. return
  2111. }
  2112. recordDateTime := theTime.Unix()
  2113. adminUser := c.GetAdminUserInfo()
  2114. var prescriptions []*models.HisPrescription
  2115. data := make(map[string]interface{})
  2116. if settle_accounts_type == 1 { //日结
  2117. prescriptions, _ = service.GetHisPrescription(adminUser.CurrentOrgId, id, recordDateTime)
  2118. data["pre"] = prescriptions
  2119. } else { //月结
  2120. start_time_str := c.GetString("start_time")
  2121. end_time_str := c.GetString("end_time")
  2122. timeLayout := "2006-01-02"
  2123. loc, _ := time.LoadLocation("Local")
  2124. theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  2125. if err != nil {
  2126. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  2127. return
  2128. }
  2129. recordStartTime := theStartTime.Unix()
  2130. theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  2131. if err != nil {
  2132. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  2133. return
  2134. }
  2135. recordEndTime := theEndTime.Unix()
  2136. prescriptions, _ = service.GetMonthHisPrescription(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime)
  2137. data["pre"] = prescriptions
  2138. }
  2139. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  2140. his, _ := service.GetVMHisPatientInfo(adminUser.CurrentOrgId, id, recordDateTime)
  2141. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  2142. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  2143. strconv.FormatInt(his.PatientId, 10)
  2144. order_src, _ := service.GetHisOrderByID(order_id)
  2145. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  2146. if config.IsOpen == 1 { //对接了医保,走医保流程
  2147. var total float64
  2148. for _, item := range prescriptions {
  2149. if item.Type == 1 { //药品
  2150. for _, subItem := range item.HisDoctorAdviceInfo {
  2151. total = total + (subItem.Price * subItem.PrescribingNumber)
  2152. }
  2153. }
  2154. if item.Type == 2 { //项目
  2155. for _, subItem := range item.HisPrescriptionProject {
  2156. total = total + (subItem.Price * float64(subItem.Count))
  2157. }
  2158. }
  2159. }
  2160. for _, item := range prescriptions {
  2161. for _, subItem := range item.HisAdditionalCharge {
  2162. total = total + (subItem.Price * float64(subItem.Count))
  2163. }
  2164. }
  2165. allTotal := fmt.Sprintf("%.2f", total)
  2166. var rf []*ResultFive
  2167. json.Unmarshal([]byte(his.Iinfo), &rf)
  2168. psn_no := order_src.PsnNo
  2169. mdtrt_id := order_src.MdtrtId
  2170. chrg_bchno := order_src.Number
  2171. cert_no := order_src.Certno
  2172. insutype := rf[0].Insutype
  2173. if his.IdCardType == 1 {
  2174. cert_no = his.MedicalInsuranceNumber
  2175. } else {
  2176. cert_no = his.Certno
  2177. }
  2178. api := "http://127.0.0.1:9532/" + "gdyb/eight?cert_no=" + cert_no + "&insutype=" +
  2179. insutype + "&psn_no=" + psn_no + "&chrg_bchno=" + chrg_bchno + "&mdtrt_id=" + mdtrt_id +
  2180. "&total=" + allTotal + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code + "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" +
  2181. miConfig.SecretKey + "&med_type=" + strconv.FormatInt(patientPrescription.RegisterType, 10) + "&id_card_type=" + strconv.FormatInt(int64(his.IdCardType), 10) + "&fulamt_ownpay_amt=" + strconv.FormatFloat(order_src.FulamtOwnpayAmt, 'E', -1, 64) + "&overlmt_selfpay=" + strconv.FormatFloat(order_src.OverlmtSelfPay, 'E', -1, 64) + "&preselfpay_amt=" + strconv.FormatFloat(order_src.PreselfpayAmt, 'E', -1, 64) + "&inscp_scp_amt=" + strconv.FormatFloat(order_src.InscpScpAmt, 'E', -1, 64)
  2182. resp, requestErr := http.Get(api)
  2183. if requestErr != nil {
  2184. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2185. return
  2186. }
  2187. defer resp.Body.Close()
  2188. body, ioErr := ioutil.ReadAll(resp.Body)
  2189. if ioErr != nil {
  2190. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2191. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2192. return
  2193. }
  2194. var respJSON map[string]interface{}
  2195. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  2196. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2197. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2198. return
  2199. }
  2200. fmt.Println(respJSON)
  2201. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2202. userJSONBytes, _ := json.Marshal(respJSON)
  2203. var res ResultSeven
  2204. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  2205. utils.ErrorLog("解析失败:%v", err)
  2206. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2207. return
  2208. }
  2209. if res.Infcode == -1 {
  2210. errlog := &models.HisOrderError{
  2211. UserOrgId: adminUser.CurrentOrgId,
  2212. Ctime: time.Now().Unix(),
  2213. Mtime: time.Now().Unix(),
  2214. Number: chrg_bchno,
  2215. ErrMsg: res.ErrMsg,
  2216. Status: 1,
  2217. PatientId: id,
  2218. RecordTime: recordDateTime,
  2219. Stage: 6,
  2220. }
  2221. service.CreateErrMsgLog(errlog)
  2222. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  2223. return
  2224. } else {
  2225. order_src.OrderStatus = 2
  2226. order_src.PayWay = pay_way
  2227. order_src.PayPrice = pay_price
  2228. order_src.PayCardNo = pay_card_no
  2229. order_src.DiscountPrice = discount_price
  2230. order_src.PreferentialPrice = preferential_price
  2231. order_src.RealityPrice = reality_price
  2232. order_src.FoundPrice = found_price
  2233. order_src.MedicalInsurancePrice = medical_insurance_price
  2234. order_src.PrivatePrice = private_price
  2235. order_src.MdtrtId = res.Output.Setlinfo.MdtrtID
  2236. order_src.SetlId = res.Output.Setlinfo.SetlID
  2237. order_src.PsnNo = res.Output.Setlinfo.PsnNo
  2238. order_src.PsnName = res.Output.Setlinfo.PsnName
  2239. order_src.PsnCertType = res.Output.Setlinfo.PsnCertType
  2240. order_src.Certno = res.Output.Setlinfo.Certno
  2241. order_src.Gend = res.Output.Setlinfo.Gend
  2242. order_src.Naty = res.Output.Setlinfo.Naty
  2243. order_src.Age = res.Output.Setlinfo.Age
  2244. order_src.Insutype = res.Output.Setlinfo.Insutype
  2245. order_src.PsnType = res.Output.Setlinfo.PsnType
  2246. order_src.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  2247. order_src.SetlTime = res.Output.Setlinfo.SetlTime
  2248. order_src.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  2249. order_src.MedType = res.Output.Setlinfo.MedType
  2250. order_src.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  2251. order_src.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  2252. order_src.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  2253. order_src.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  2254. order_src.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  2255. order_src.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  2256. order_src.HifpPay = res.Output.Setlinfo.HifpPay
  2257. order_src.CvlservPay = res.Output.Setlinfo.CvlservPay
  2258. order_src.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  2259. order_src.HifesPay = res.Output.Setlinfo.HifesPay
  2260. order_src.HifobPay = res.Output.Setlinfo.HifobPay
  2261. order_src.MafPay = res.Output.Setlinfo.MafPay
  2262. order_src.OthPay = res.Output.Setlinfo.OthPay
  2263. order_src.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  2264. order_src.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  2265. order_src.AcctPay = res.Output.Setlinfo.AcctPay
  2266. order_src.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  2267. order_src.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  2268. order_src.Balc = res.Output.Setlinfo.Balc
  2269. order_src.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  2270. order_src.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  2271. order_src.ClrOptins = res.Output.Setlinfo.ClrOptins
  2272. order_src.ClrWay = res.Output.Setlinfo.ClrWay
  2273. order_src.Creator = order_src.Creator
  2274. order_src.Modify = roles.ID
  2275. setlDetail, _ := json.Marshal(res.Output.Setldetail)
  2276. detailStr := string(setlDetail)
  2277. order_src.SetlDetail = detailStr
  2278. err = service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  2279. err = service.UpDateOrder(order_src)
  2280. if err == nil {
  2281. c.ServeSuccessJSON(map[string]interface{}{
  2282. "msg": "结算成功",
  2283. })
  2284. } else {
  2285. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  2286. return
  2287. }
  2288. }
  2289. }
  2290. }
  2291. //退款
  2292. func (c *HisApiController) Refund() {
  2293. order_id, _ := c.GetInt64("order_id")
  2294. number := c.GetString("number")
  2295. record_time := c.GetString("record_time")
  2296. patient_id, _ := c.GetInt64("patient_id")
  2297. timeLayout := "2006-01-02"
  2298. loc, _ := time.LoadLocation("Local")
  2299. adminUser := c.GetAdminUserInfo()
  2300. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  2301. fmt.Println(err)
  2302. if err != nil {
  2303. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  2304. return
  2305. }
  2306. recordDateTime := theTime.Unix()
  2307. his, _ := service.GetVMHisPatientInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  2308. //patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  2309. var order models.HisOrder
  2310. order, _ = service.GetHisOrderByID(order_id)
  2311. if order.ID == 0 {
  2312. order, _ = service.GetHisOrderThree(recordDateTime, patient_id, adminUser.CurrentOrgId)
  2313. }
  2314. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  2315. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  2316. if config.IsOpen == 1 { //对接了医保,走医保流程
  2317. api := "http://127.0.0.1:9532/" + "gdyb/nine?psn_no=" + his.PsnNo +
  2318. "&mdtrt_id=" + his.Number + "&doctor=" + "张俊杰" + "&setl_id=" + order.SetlId + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  2319. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  2320. resp, requestErr := http.Get(api)
  2321. if requestErr != nil {
  2322. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2323. return
  2324. }
  2325. body, ioErr := ioutil.ReadAll(resp.Body)
  2326. if ioErr != nil {
  2327. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2328. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2329. return
  2330. }
  2331. var respJSON map[string]interface{}
  2332. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  2333. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2334. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2335. return
  2336. }
  2337. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2338. userJSONBytes, _ := json.Marshal(respJSON)
  2339. fmt.Println(respJSON)
  2340. fmt.Println(userJSONBytes)
  2341. api2 := "http://127.0.0.1:9532/" + "gdyb/six?psn_no=" + his.PsnNo +
  2342. "&mdtrt_id=" + his.Number + "&chrg_bchno=" + order.Number + "&doctor=" + "张俊杰" + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  2343. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  2344. resp2, requestErr2 := http.Get(api2)
  2345. if requestErr2 != nil {
  2346. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2347. return
  2348. }
  2349. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  2350. if ioErr2 != nil {
  2351. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  2352. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2353. return
  2354. }
  2355. var respJSON2 map[string]interface{}
  2356. if err := json.Unmarshal([]byte(string(body2)), &respJSON2); err != nil {
  2357. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2358. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2359. return
  2360. }
  2361. //api3 := "http://127.0.0.1:9532/" + "gdyb/three?psn_no=" + his.PsnNo +
  2362. // "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  2363. // "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  2364. //resp3, requestErr3 := http.Get(api3)
  2365. //if requestErr3 != nil {
  2366. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2367. // return
  2368. //}
  2369. //
  2370. //body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  2371. //if ioErr3 != nil {
  2372. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  2373. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2374. // return
  2375. //}
  2376. //var respJSON3 map[string]interface{}
  2377. //if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  2378. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2379. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2380. // return
  2381. //}
  2382. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId)
  2383. //service.UpdataRegStatus(patient_id, recordDateTime, adminUser.CurrentOrgId)
  2384. if err == nil {
  2385. c.ServeSuccessJSON(map[string]interface{}{
  2386. "msg": "退费成功",
  2387. })
  2388. } else {
  2389. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2390. return
  2391. }
  2392. } else {
  2393. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId)
  2394. if err == nil {
  2395. c.ServeSuccessJSON(map[string]interface{}{
  2396. "msg": "退费成功",
  2397. })
  2398. } else {
  2399. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2400. return
  2401. }
  2402. }
  2403. }
  2404. func (c *HisApiController) RefundNumber() {
  2405. record_time := c.GetString("record_time")
  2406. patient_id, _ := c.GetInt64("patient_id")
  2407. timeLayout := "2006-01-02"
  2408. loc, _ := time.LoadLocation("Local")
  2409. adminUser := c.GetAdminUserInfo()
  2410. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  2411. fmt.Println(err)
  2412. if err != nil {
  2413. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  2414. return
  2415. }
  2416. recordDateTime := theTime.Unix()
  2417. his, _ := service.GetVMHisPatientInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  2418. //patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  2419. //order, _ := service.GetHisOrderByID(order_id)
  2420. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  2421. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  2422. if config.IsOpen == 1 { //对接了医保,走医保流程
  2423. api3 := "http://127.0.0.1:9532/" + "gdyb/three?psn_no=" + his.PsnNo +
  2424. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + "张俊杰" + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  2425. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  2426. resp3, requestErr3 := http.Get(api3)
  2427. if requestErr3 != nil {
  2428. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2429. return
  2430. }
  2431. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  2432. if ioErr3 != nil {
  2433. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  2434. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2435. return
  2436. }
  2437. var respJSON3 map[string]interface{}
  2438. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  2439. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2440. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2441. return
  2442. }
  2443. //err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId)
  2444. service.UpdataRegStatus(patient_id, recordDateTime, adminUser.CurrentOrgId)
  2445. if err == nil {
  2446. c.ServeSuccessJSON(map[string]interface{}{
  2447. "msg": "退费成功",
  2448. })
  2449. } else {
  2450. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2451. return
  2452. }
  2453. } else {
  2454. //err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId)
  2455. //if err == nil {
  2456. // c.ServeSuccessJSON(map[string]interface{}{
  2457. // "msg": "退费成功",
  2458. // })
  2459. //} else {
  2460. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2461. // return
  2462. //}
  2463. }
  2464. }
  2465. func (c *HisApiController) RefundDetail() {
  2466. order_id, _ := c.GetInt64("order_id")
  2467. number := c.GetString("number")
  2468. record_time := c.GetString("record_time")
  2469. patient_id, _ := c.GetInt64("patient_id")
  2470. timeLayout := "2006-01-02"
  2471. loc, _ := time.LoadLocation("Local")
  2472. adminUser := c.GetAdminUserInfo()
  2473. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  2474. fmt.Println(err)
  2475. if err != nil {
  2476. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  2477. return
  2478. }
  2479. recordDateTime := theTime.Unix()
  2480. his, _ := service.GetVMHisPatientInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  2481. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  2482. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  2483. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  2484. var order models.HisOrder
  2485. order, _ = service.GetHisOrderByID(order_id)
  2486. if order.ID == 0 {
  2487. order, _ = service.GetHisOrderThree(recordDateTime, patient_id, adminUser.CurrentOrgId)
  2488. }
  2489. if config.IsOpen == 1 { //对接了医保,走医保流程
  2490. api2 := "http://127.0.0.1:9532/" + "gdyb/six?psn_no=" + his.PsnNo +
  2491. "&mdtrt_id=" + his.Number + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  2492. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  2493. resp2, requestErr2 := http.Get(api2)
  2494. if requestErr2 != nil {
  2495. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2496. return
  2497. }
  2498. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  2499. if ioErr2 != nil {
  2500. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  2501. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2502. return
  2503. }
  2504. var respJSON2 map[string]interface{}
  2505. if err := json.Unmarshal([]byte(string(body2)), &respJSON2); err != nil {
  2506. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2507. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2508. return
  2509. }
  2510. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId)
  2511. if err == nil {
  2512. c.ServeSuccessJSON(map[string]interface{}{
  2513. "msg": "退费成功",
  2514. })
  2515. } else {
  2516. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2517. return
  2518. }
  2519. } else {
  2520. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId)
  2521. if err == nil {
  2522. c.ServeSuccessJSON(map[string]interface{}{
  2523. "msg": "退费成功",
  2524. })
  2525. } else {
  2526. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2527. return
  2528. }
  2529. }
  2530. }
  2531. //对账
  2532. func (c *HisApiController) GetCheckAccount() {
  2533. start_time := c.GetString("start_time")
  2534. end_time := c.GetString("end_time")
  2535. insutype := c.GetString("insutype")
  2536. clr_type := c.GetString("clr_type")
  2537. admin_user_id, _ := c.GetInt64("admin_user_id")
  2538. adminUser := c.GetAdminUserInfo()
  2539. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  2540. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  2541. timeLayout := "2006-01-02"
  2542. loc, _ := time.LoadLocation("Local")
  2543. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  2544. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  2545. orders, _ := service.GetOrderByTime(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, insutype, clr_type)
  2546. orders_two, _ := service.GetOrderByTimeThree(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, insutype, clr_type)
  2547. fixmedins_setl_cnt := int64(len(orders_two))
  2548. //撤销的算2条数据为一笔
  2549. for _, item := range orders_two {
  2550. if item.OrderStatus == 3 {
  2551. fixmedins_setl_cnt = fixmedins_setl_cnt + 1
  2552. }
  2553. }
  2554. var medfee_sumamt float64
  2555. var acct_pay float64
  2556. var fund_pay_sumamt float64
  2557. for _, item := range orders {
  2558. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  2559. acct_pay = acct_pay + item.AcctPay
  2560. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  2561. }
  2562. var user_name string
  2563. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  2564. if role.ID == 0 {
  2565. user_name = "张俊杰"
  2566. } else {
  2567. user_name = role.UserName
  2568. }
  2569. if config.IsOpen == 1 {
  2570. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  2571. "insutype=" + insutype +
  2572. "&clr_type=" + clr_type +
  2573. "&setl_optins=" + "定点医保中心" +
  2574. "&stmt_begndate=" + start_time +
  2575. "&stm_enddate=" + end_time +
  2576. "&medfee_sumamt=" + fmt.Sprintf("%.2f", medfee_sumamt) +
  2577. "&fund_pay_sumamt=" + fmt.Sprintf("%.2f", fund_pay_sumamt) +
  2578. "&acct_pay=" + fmt.Sprintf("%.2f", acct_pay) +
  2579. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  2580. "&fixmedins_code=" + miConfig.Code +
  2581. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  2582. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  2583. "&secret_key=" + miConfig.SecretKey +
  2584. "&org_name=" + miConfig.OrgName +
  2585. "&doctor=" + user_name
  2586. fmt.Println(api)
  2587. resp, requestErr := http.Get(api)
  2588. if requestErr != nil {
  2589. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2590. return
  2591. }
  2592. body, ioErr := ioutil.ReadAll(resp.Body)
  2593. fmt.Println(body)
  2594. if ioErr != nil {
  2595. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2596. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2597. return
  2598. }
  2599. var respJSON map[string]interface{}
  2600. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  2601. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2602. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2603. return
  2604. }
  2605. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2606. userJSONBytes, _ := json.Marshal(respJSON)
  2607. var res ResultEight
  2608. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  2609. utils.ErrorLog("解析失败:%v", err)
  2610. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2611. return
  2612. }
  2613. if res.Infcode == 0 {
  2614. micc := &models.MedicalInsuranceCostCompare{
  2615. StartTime: startime.Unix(),
  2616. EndTime: endtime.Unix(),
  2617. Insutype: insutype,
  2618. CheckType: 1,
  2619. Num: fixmedins_setl_cnt,
  2620. Mtime: time.Now().Unix(),
  2621. Status: 1,
  2622. UserOrgId: adminUser.CurrentOrgId,
  2623. CostTotal: medfee_sumamt,
  2624. FuncTotal: fund_pay_sumamt,
  2625. PsnPay: acct_pay,
  2626. Creator: admin_user_id,
  2627. Ctime: time.Now().Unix(),
  2628. }
  2629. err := service.CreateMedicalInsuranceCostCompareRecord(micc)
  2630. if err == nil {
  2631. c.ServeSuccessJSON(map[string]interface{}{
  2632. "stmt_rslt": res.Output.Stmtinfo.StmtRslt,
  2633. "stmt_rslt_dscr": res.Output.Stmtinfo.StmtRsltDscr,
  2634. })
  2635. } else {
  2636. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2637. }
  2638. } else {
  2639. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2640. }
  2641. }
  2642. }
  2643. func (c *HisApiController) Check310() {
  2644. adminUser := c.GetAdminUserInfo()
  2645. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  2646. var user_name string
  2647. user_name = "张俊杰"
  2648. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  2649. "insutype=" + "310" +
  2650. "&clr_type=" + "11" +
  2651. "&setl_optins=" + "定点医保中心" +
  2652. "&stmt_begndate=" + "2021-03-01" +
  2653. "&stm_enddate=" + "2021-03-31" +
  2654. "&medfee_sumamt=" + "11521" +
  2655. "&fund_pay_sumamt=" + "10166.66" +
  2656. "&acct_pay=" + "0" +
  2657. "&fixmedins_setl_cnt=" + "7" +
  2658. "&fixmedins_code=" + miConfig.Code +
  2659. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  2660. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  2661. "&secret_key=" + miConfig.SecretKey +
  2662. "&org_name=" + miConfig.OrgName +
  2663. "&doctor=" + user_name
  2664. fmt.Println(api)
  2665. resp, requestErr := http.Get(api)
  2666. if requestErr != nil {
  2667. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2668. return
  2669. }
  2670. body, ioErr := ioutil.ReadAll(resp.Body)
  2671. fmt.Println(body)
  2672. if ioErr != nil {
  2673. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2674. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2675. return
  2676. }
  2677. var respJSON map[string]interface{}
  2678. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  2679. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2680. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2681. return
  2682. }
  2683. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2684. userJSONBytes, _ := json.Marshal(respJSON)
  2685. var res ResultEight
  2686. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  2687. utils.ErrorLog("解析失败:%v", err)
  2688. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2689. return
  2690. }
  2691. }
  2692. func (c *HisApiController) Check390() {
  2693. adminUser := c.GetAdminUserInfo()
  2694. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  2695. var user_name string
  2696. user_name = "张俊杰"
  2697. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  2698. "insutype=" + "390" +
  2699. "&clr_type=" + "11" +
  2700. "&setl_optins=" + "定点医保中心" +
  2701. "&stmt_begndate=" + "2021-03-01" +
  2702. "&stm_enddate=" + "2021-03-31" +
  2703. "&medfee_sumamt=" + "209318.43" +
  2704. "&fund_pay_sumamt=" + "188029.12" +
  2705. "&acct_pay=" + "0" +
  2706. "&fixmedins_setl_cnt=" + "48" +
  2707. "&fixmedins_code=" + miConfig.Code +
  2708. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  2709. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  2710. "&secret_key=" + miConfig.SecretKey +
  2711. "&org_name=" + miConfig.OrgName +
  2712. "&doctor=" + user_name
  2713. fmt.Println(api)
  2714. resp, requestErr := http.Get(api)
  2715. if requestErr != nil {
  2716. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2717. return
  2718. }
  2719. body, ioErr := ioutil.ReadAll(resp.Body)
  2720. fmt.Println(body)
  2721. if ioErr != nil {
  2722. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2723. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2724. return
  2725. }
  2726. var respJSON map[string]interface{}
  2727. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  2728. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2729. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2730. return
  2731. }
  2732. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2733. userJSONBytes, _ := json.Marshal(respJSON)
  2734. var res ResultEight
  2735. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  2736. utils.ErrorLog("解析失败:%v", err)
  2737. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2738. return
  2739. }
  2740. }
  2741. //对账明细
  2742. func (c *HisApiController) GetCheckDetailAccount() {
  2743. start_time := c.GetString("start_time")
  2744. end_time := c.GetString("end_time")
  2745. admin_user_id, _ := c.GetInt64("admin_user_id")
  2746. adminUser := c.GetAdminUserInfo()
  2747. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  2748. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  2749. timeLayout := "2006-01-02"
  2750. loc, _ := time.LoadLocation("Local")
  2751. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  2752. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  2753. orders, _ := service.GetOrderByTimeTwo(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  2754. Mkdir(miConfig.OrgName)
  2755. file := strconv.FormatInt(adminUser.CurrentOrgId, 10) + strconv.FormatInt(time.Now().Unix(), 10)
  2756. file_name := file + ".txt"
  2757. zip_name := file + ".zip"
  2758. zip_path := miConfig.OrgName + "/" + zip_name
  2759. file_path := miConfig.OrgName + "/" + file_name
  2760. decimal.DivisionPrecision = 2
  2761. var medfee_sumamt float64
  2762. var psn_cash_pay float64
  2763. var fund_pay_sumamt float64
  2764. fixmedins_setl_cnt := int64(len(orders))
  2765. for _, item := range orders {
  2766. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  2767. psn_cash_pay = psn_cash_pay + item.PsnCashPay
  2768. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  2769. }
  2770. f, err := os.Create(miConfig.OrgName + "/" + file_name)
  2771. defer f.Close()
  2772. if err != nil {
  2773. fmt.Println(err.Error())
  2774. } else {
  2775. for _, item := range orders {
  2776. var refd_setl_flag string
  2777. if item.OrderStatus == 2 {
  2778. refd_setl_flag = "0"
  2779. }
  2780. if item.OrderStatus == 3 {
  2781. refd_setl_flag = "1"
  2782. }
  2783. var str string
  2784. str = item.SetlId + " " +
  2785. item.MdtrtId + " " +
  2786. item.PsnNo + " " +
  2787. fmt.Sprintf("%.2f", item.MedfeeSumamt) + " " +
  2788. fmt.Sprintf("%.2f", item.FundPaySumamt) + " " +
  2789. fmt.Sprintf("%.2f", item.AcctPay) + " " + refd_setl_flag + "\n"
  2790. _, err = f.Write([]byte(str))
  2791. }
  2792. }
  2793. Zip(file_path, zip_path)
  2794. fmt.Println(ReadFile(zip_path))
  2795. fmt.Println(string(ReadFile(zip_path)))
  2796. if config.IsOpen == 1 {
  2797. var user_name string
  2798. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  2799. if role.ID == 0 {
  2800. user_name = "管理员"
  2801. } else {
  2802. user_name = role.UserName
  2803. }
  2804. baseParams := models.BaseParams{
  2805. SecretKey: miConfig.SecretKey,
  2806. FixmedinsCode: miConfig.Code,
  2807. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  2808. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  2809. OrgName: miConfig.OrgName,
  2810. Doctor: user_name,
  2811. }
  2812. result := service.Gdyb9101(baseParams, zip_name, ReadFile(zip_path))
  2813. var dat map[string]interface{}
  2814. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  2815. fmt.Println(dat)
  2816. } else {
  2817. fmt.Println(err)
  2818. }
  2819. userJSONBytes, _ := json.Marshal(dat)
  2820. var res ResultNine
  2821. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  2822. utils.ErrorLog("解析失败:%v", err)
  2823. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2824. return
  2825. }
  2826. if res.Infcode == 0 {
  2827. api := "http://127.0.0.1:9532/" + "gdyb/twelve?" +
  2828. "file_qury_no=" + res.Output.FileQuryNo +
  2829. "&setl_optins=" + "定点医保中心" +
  2830. "&stmt_begndate=" + start_time +
  2831. "&stm_enddate=" + end_time +
  2832. "&medfee_sumamt=" + fmt.Sprintf("%.2f", medfee_sumamt) +
  2833. "&fund_pay_sumamt=" + fmt.Sprintf("%.2f", fund_pay_sumamt) +
  2834. "&cash_payamt=" + fmt.Sprintf("%.2f", psn_cash_pay) +
  2835. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  2836. "&fixmedins_code=" + miConfig.Code +
  2837. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  2838. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  2839. "&secret_key=" + miConfig.SecretKey +
  2840. "&org_name=" + miConfig.OrgName +
  2841. "&doctor=" + user_name
  2842. resp, requestErr := http.Get(api)
  2843. if requestErr != nil {
  2844. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2845. return
  2846. }
  2847. body, ioErr := ioutil.ReadAll(resp.Body)
  2848. if ioErr != nil {
  2849. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2850. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2851. return
  2852. }
  2853. var respJSON map[string]interface{}
  2854. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  2855. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2856. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2857. return
  2858. }
  2859. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2860. userJSONBytes, _ := json.Marshal(respJSON)
  2861. var res ResultTen
  2862. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  2863. utils.ErrorLog("解析失败:%v", err)
  2864. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2865. return
  2866. }
  2867. if res.Infcode == 0 {
  2868. service.Gdyb9102(baseParams, zip_name, res.Output.FileQuryNo)
  2869. micc := &models.MedicalInsuranceCostCompare{
  2870. StartTime: startime.Unix(),
  2871. EndTime: endtime.Unix(),
  2872. Insutype: "0",
  2873. CheckType: 2,
  2874. Num: fixmedins_setl_cnt,
  2875. Mtime: time.Now().Unix(),
  2876. Status: 1,
  2877. UserOrgId: adminUser.CurrentOrgId,
  2878. CostTotal: medfee_sumamt,
  2879. FuncTotal: fund_pay_sumamt,
  2880. PsnPay: psn_cash_pay,
  2881. Creator: admin_user_id,
  2882. Ctime: time.Now().Unix(),
  2883. }
  2884. service.CreateMedicalInsuranceCostCompareRecord(micc)
  2885. c.ServeSuccessJSON(map[string]interface{}{
  2886. "msg": "明细对账成功",
  2887. })
  2888. }
  2889. } else {
  2890. }
  2891. }
  2892. }
  2893. func (c *HisApiController) GetSettleAccounts() {
  2894. //id, _ := c.GetInt64("id")
  2895. //record_time := c.GetString("record_time")
  2896. order_id, _ := c.GetInt64("order_id")
  2897. admin_user_id, _ := c.GetInt64("admin_user_id")
  2898. //timeLayout := "2006-01-02"
  2899. //loc, _ := time.LoadLocation("Local")
  2900. //
  2901. //theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  2902. //if err != nil {
  2903. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  2904. // return
  2905. //}
  2906. //recordDateTime := theTime.Unix()
  2907. adminUser := c.GetAdminUserInfo()
  2908. //his, _ := service.GetVMHisPatientInfo(adminUser.CurrentOrgId, id, recordDateTime)
  2909. order, _ := service.GetHisOrderByID(order_id)
  2910. orderInfos, _ := service.GetHisOrderInfoByNumber(order.Number)
  2911. var bedCostTotal float64 = 0 //床位总费
  2912. var bedCostSelfTotal float64 = 0 //床位自费
  2913. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  2914. var operationCostTotal float64 = 0 //手术费
  2915. var operationCostSelfTotal float64 = 0 //手术费
  2916. var operationCostPartSelfTotal float64 = 0 //手术费
  2917. var otherCostTotal float64 = 0 //其他费用
  2918. var otherCostSelfTotal float64 = 0 //其他费用
  2919. var otherCostPartSelfTotal float64 = 0 //其他费用
  2920. var materialCostTotal float64 = 0 //材料费
  2921. var materialCostSelfTotal float64 = 0 //材料费
  2922. var materialCostPartSelfTotal float64 = 0 //材料费
  2923. var westernMedicineCostTotal float64 = 0 //西药费
  2924. var westernMedicineCostSelfTotal float64 = 0 //西药费
  2925. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  2926. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  2927. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  2928. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  2929. var checkCostTotal float64 = 0 //检查费
  2930. var checkCostSelfTotal float64 = 0 //检查费
  2931. var checkCostPartSelfTotal float64 = 0 //检查费
  2932. var laboratoryCostTotal float64 = 0 //化验费
  2933. var laboratoryCostSelfTotal float64 = 0 //化验费
  2934. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  2935. var treatCostTotal float64 = 0 //治疗费用
  2936. var treatCostSelfTotal float64 = 0 //治疗费用
  2937. var treatCostPartSelfTotal float64 = 0 //治疗费用
  2938. decimal.DivisionPrecision = 2
  2939. for _, item := range orderInfos {
  2940. if item.MedChrgitmType == "01" { //床位费
  2941. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2942. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2943. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2944. }
  2945. if item.MedChrgitmType == "03" { //检查费
  2946. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2947. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2948. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2949. }
  2950. if item.MedChrgitmType == "04" { //化验费
  2951. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2952. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2953. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2954. }
  2955. if item.MedChrgitmType == "05" { //治疗费
  2956. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2957. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2958. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2959. }
  2960. if item.MedChrgitmType == "06" { //手术费
  2961. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2962. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2963. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2964. }
  2965. if item.MedChrgitmType == "08" { //材料费
  2966. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2967. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2968. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2969. }
  2970. if item.MedChrgitmType == "09" { //西药费
  2971. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2972. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2973. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2974. }
  2975. if item.MedChrgitmType == "11" { //中成费
  2976. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2977. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2978. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2979. }
  2980. if item.MedChrgitmType == "14" { //其他费
  2981. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2982. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2983. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2984. }
  2985. }
  2986. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  2987. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  2988. var user_name string
  2989. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  2990. if role.ID == 0 {
  2991. user_name = "管理员"
  2992. } else {
  2993. user_name = role.UserName
  2994. }
  2995. baseParams := models.BaseParams{
  2996. SecretKey: miConfig.SecretKey,
  2997. FixmedinsCode: miConfig.Code,
  2998. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  2999. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  3000. OrgName: miConfig.OrgName,
  3001. Doctor: user_name,
  3002. }
  3003. businessParams := models.BusinessParams{
  3004. PsnNo: order.PsnNo,
  3005. MdtrtId: order.MdtrtId,
  3006. SetlId: order.SetlId,
  3007. }
  3008. if config.IsOpen == 1 {
  3009. result := service.Gdyb5203(baseParams, businessParams)
  3010. var dat map[string]interface{}
  3011. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  3012. fmt.Println(dat)
  3013. } else {
  3014. fmt.Println(err)
  3015. }
  3016. userJSONBytes, _ := json.Marshal(dat)
  3017. var res ResultEleven
  3018. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  3019. utils.ErrorLog("解析失败:%v", err)
  3020. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3021. return
  3022. }
  3023. printor_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  3024. charge_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, order.Creator)
  3025. if res.Infcode == 0 {
  3026. c.ServeSuccessJSON(map[string]interface{}{
  3027. "charge_admin": charge_admin,
  3028. "printor_admin": printor_admin,
  3029. "info": res.Output.Setlinfo,
  3030. "bedCostTotal": bedCostTotal,
  3031. "bedCostSelfTotal": bedCostSelfTotal,
  3032. "bedCostPartSelfTotal": bedCostPartSelfTotal,
  3033. "operationCostTotal": operationCostTotal,
  3034. "operationCostSelfTotal": operationCostSelfTotal,
  3035. "operationCostPartSelfTotal": operationCostPartSelfTotal,
  3036. "otherCostTotal": otherCostTotal,
  3037. "otherCostSelfTotal": otherCostSelfTotal,
  3038. "otherCostPartSelfTotal": otherCostPartSelfTotal,
  3039. "materialCostTotal": materialCostTotal,
  3040. "materialCostSelfTotal": materialCostSelfTotal,
  3041. "materialCostPartSelfTotal": materialCostPartSelfTotal,
  3042. "westernMedicineCostTotal": westernMedicineCostTotal,
  3043. "westernMedicineCostSelfTotal": westernMedicineCostSelfTotal,
  3044. "westernMedicineCostPartSelfTotal": westernMedicineCostPartSelfTotal,
  3045. "chineseTraditionalMedicineCostTotal": chineseTraditionalMedicineCostTotal,
  3046. "chineseTraditionalMedicineCostSelfTotal": chineseTraditionalMedicineCostSelfTotal,
  3047. "chineseTraditionalMedicineCostPartSelfTotal": chineseTraditionalMedicineCostPartSelfTotal,
  3048. "checkCostTotal": checkCostTotal,
  3049. "checkCostSelfTotal": checkCostSelfTotal,
  3050. "checkCostPartSelfTotal": checkCostPartSelfTotal,
  3051. "laboratoryCostTotal": laboratoryCostTotal,
  3052. "laboratoryCostSelfTotal": laboratoryCostSelfTotal,
  3053. "laboratoryCostPartSelfTotal": laboratoryCostPartSelfTotal,
  3054. "treatCostTotal": treatCostTotal,
  3055. "treatCostSelfTotal": treatCostSelfTotal,
  3056. "treatCostPartSelfTotal": treatCostPartSelfTotal,
  3057. })
  3058. }
  3059. }
  3060. }
  3061. func (c *HisApiController) GetCode() {
  3062. name := c.GetString("name")
  3063. codg := c.GetString("codg")
  3064. adminUser := c.GetAdminUserInfo()
  3065. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  3066. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  3067. var user_name string
  3068. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, adminUser.AdminUser.Id)
  3069. if role.ID == 0 {
  3070. user_name = "xxx"
  3071. } else {
  3072. user_name = role.UserName
  3073. }
  3074. baseParams := &models.BaseParams{
  3075. SecretKey: miConfig.SecretKey,
  3076. FixmedinsCode: miConfig.Code,
  3077. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  3078. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  3079. OrgName: miConfig.OrgName,
  3080. Doctor: user_name,
  3081. }
  3082. if config.IsOpen == 1 {
  3083. result := service.Gdyb3301(baseParams, name, codg)
  3084. var dat map[string]interface{}
  3085. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  3086. fmt.Println(dat)
  3087. } else {
  3088. fmt.Println(err)
  3089. }
  3090. }
  3091. }
  3092. func (c *HisApiController) CheckTreatment() {
  3093. patient_id, _ := c.GetInt64("patient_id", 0)
  3094. record_time := c.GetString("record_time")
  3095. insutype := c.GetString("insutype")
  3096. timeLayout := "2006-01-02"
  3097. loc, _ := time.LoadLocation("Local")
  3098. adminUser := c.GetAdminUserInfo()
  3099. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  3100. fmt.Println(err)
  3101. if err != nil {
  3102. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  3103. return
  3104. }
  3105. recordDateTime := theTime.Unix()
  3106. his, _ := service.GetVMHisPatientInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  3107. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  3108. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  3109. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  3110. var user_name string
  3111. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, adminUser.AdminUser.Id)
  3112. if role.ID == 0 {
  3113. user_name = "xxx"
  3114. } else {
  3115. user_name = role.UserName
  3116. }
  3117. baseParams := models.BaseParams{
  3118. SecretKey: miConfig.SecretKey,
  3119. FixmedinsCode: miConfig.Code,
  3120. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  3121. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  3122. OrgName: miConfig.OrgName,
  3123. Doctor: user_name,
  3124. }
  3125. if config.IsOpen == 1 {
  3126. result := service.Gdyb2001(baseParams, his.PsnNo, insutype, strconv.FormatInt(patientPrescription.RegisterType, 10))
  3127. var dat map[string]interface{}
  3128. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  3129. fmt.Println(dat)
  3130. } else {
  3131. fmt.Println(err)
  3132. }
  3133. }
  3134. }
  3135. func (c *HisApiController) PutRecord() {
  3136. id, _ := c.GetInt64("id")
  3137. record_time := c.GetString("record_time")
  3138. timeLayout := "2006-01-02"
  3139. loc, _ := time.LoadLocation("Local")
  3140. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  3141. if err != nil {
  3142. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  3143. return
  3144. }
  3145. recordDateTime := theTime.Unix()
  3146. adminInfo := c.GetAdminUserInfo()
  3147. patient, _ := service.GetPatientByID(adminInfo.CurrentOrgId, id)
  3148. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  3149. miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  3150. fmt.Println(miConfig.SecretKey)
  3151. if patient == nil {
  3152. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  3153. return
  3154. }
  3155. if len(patient.IdCardNo) == 0 {
  3156. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeIDCartNo)
  3157. return
  3158. }
  3159. config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  3160. if config.IsOpen == 1 {
  3161. api := "http://127.0.0.1:9532/" + "gdyb/one?cert_no=" + patient.IdCardNo + "&org_name=" + miConfig.OrgName + "&doctor=" + patientPrescription.Doctor + "&fixmedins_code=" + miConfig.Code + "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  3162. resp, requestErr := http.Get(api)
  3163. if requestErr != nil {
  3164. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3165. return
  3166. }
  3167. defer resp.Body.Close()
  3168. body, ioErr := ioutil.ReadAll(resp.Body)
  3169. if ioErr != nil {
  3170. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  3171. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3172. return
  3173. }
  3174. var respJSON map[string]interface{}
  3175. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  3176. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3177. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3178. return
  3179. }
  3180. userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  3181. userJSONBytes, _ := json.Marshal(userJSON)
  3182. var res ResultTwo
  3183. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  3184. utils.ErrorLog("解析失败:%v", err)
  3185. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3186. return
  3187. }
  3188. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  3189. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  3190. infoStr := string(Iinfos)
  3191. idetinfoStr := string(Idetinfos)
  3192. if res.Infcode == 0 {
  3193. his := models.VMHisPatient{
  3194. Status: 1,
  3195. Ctime: time.Now().Unix(),
  3196. Mtime: time.Now().Unix(),
  3197. PsnNo: res.Output.Baseinfo.PsnNo,
  3198. PsnCertType: res.Output.Baseinfo.PsnCertType,
  3199. Certno: res.Output.Baseinfo.Certno,
  3200. PsnName: res.Output.Baseinfo.PsnName,
  3201. Gend: res.Output.Baseinfo.Gend,
  3202. Naty: res.Output.Baseinfo.Naty,
  3203. Brdy: res.Output.Baseinfo.Brdy,
  3204. Age: res.Output.Baseinfo.Age,
  3205. Iinfo: infoStr,
  3206. Idetinfo: idetinfoStr,
  3207. PatientId: patient.ID,
  3208. RecordDate: theTime.Unix(),
  3209. UserOrgId: adminInfo.CurrentOrgId,
  3210. AdminUserId: adminInfo.AdminUser.Id,
  3211. IsReturn: 1,
  3212. }
  3213. doctor_id := strconv.FormatInt(patientPrescription.DoctorId, 10)
  3214. result := service.Gdyb2503(his.PsnNo, res.Output.Iinfo[0].Insutype, miConfig.OrgName, patientPrescription.Doctor, miConfig.Code, doctor_id, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, "重症尿毒症透析(血透)", "M07801")
  3215. result2 := service.Gdyb5301(his.PsnNo, res.Output.Iinfo[0].Insutype, miConfig.OrgName, patientPrescription.Doctor, miConfig.Code, doctor_id, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, "重症尿毒症透析(血透)", "M07801")
  3216. var dat map[string]interface{}
  3217. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  3218. fmt.Println(dat)
  3219. } else {
  3220. fmt.Println(err)
  3221. }
  3222. var dat2 map[string]interface{}
  3223. if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  3224. fmt.Println(dat2)
  3225. } else {
  3226. fmt.Println(err)
  3227. }
  3228. } else {
  3229. adminUser := c.GetAdminUserInfo()
  3230. errlog := &models.HisOrderError{
  3231. UserOrgId: adminUser.CurrentOrgId,
  3232. Ctime: time.Now().Unix(),
  3233. Mtime: time.Now().Unix(),
  3234. ErrMsg: res.ErrMsg,
  3235. Status: 1,
  3236. PatientId: id,
  3237. RecordTime: recordDateTime,
  3238. Stage: 1,
  3239. }
  3240. service.CreateErrMsgLog(errlog)
  3241. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeGdybOneException)
  3242. return
  3243. }
  3244. }
  3245. }
  3246. func (c *HisApiController) GetUploadDiag() {
  3247. id, _ := c.GetInt64("id")
  3248. record_time := c.GetString("record_time")
  3249. diagnosis_id, _ := c.GetInt64("diagnosis")
  3250. sick_type, _ := c.GetInt64("sick_type")
  3251. reg_type, _ := c.GetInt64("reg_type")
  3252. timeLayout := "2006-01-02"
  3253. loc, _ := time.LoadLocation("Local")
  3254. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  3255. if err != nil {
  3256. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  3257. return
  3258. }
  3259. var patientPrescription models.HisPrescriptionInfo
  3260. recordDateTime := theTime.Unix()
  3261. adminInfo := c.GetAdminUserInfo()
  3262. patientPrescription, _ = service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  3263. if patientPrescription.ID == 0 {
  3264. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  3265. }
  3266. miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  3267. diagnosisConfig, _ := service.FindDiagnoseById(diagnosis_id)
  3268. his, _ := service.GetVMHisPatientInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  3269. sickConfig, _ := service.FindSickById(sick_type)
  3270. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  3271. api2 := "http://127.0.0.1:9532/" + "gdyb/four?psn_no=" + his.PsnNo +
  3272. "&mdtrt_id=" + his.Number + "&doctor=" + patientPrescription.Doctor + "&department=" + department.Name +
  3273. "&diag=" + diagnosisConfig.ClassName + "&org_name=" + miConfig.OrgName + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&doctor_id=" + strconv.FormatInt(patientPrescription.DoctorId, 10) + "&fixmedins_code=" + miConfig.Code + "&diag_code=" + diagnosisConfig.CountryCode +
  3274. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&sick_code=" + sickConfig.CountryCode + "&sick_name=" + sickConfig.ClassName
  3275. resp2, requestErr2 := http.Get(api2)
  3276. if requestErr2 != nil {
  3277. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3278. return
  3279. }
  3280. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  3281. if ioErr2 != nil {
  3282. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  3283. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3284. return
  3285. }
  3286. var respJSON2 map[string]interface{}
  3287. if err := json.Unmarshal([]byte(string(body2)), &respJSON2); err != nil {
  3288. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3289. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3290. return
  3291. }
  3292. respJSON2 = respJSON2["data"].(map[string]interface{})["pre"].(map[string]interface{})
  3293. userJSONBytes2, _ := json.Marshal(respJSON2)
  3294. var res2 ResultSix
  3295. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  3296. utils.ErrorLog("解析失败:%v", err)
  3297. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3298. return
  3299. }
  3300. if res2.Infcode == -1 {
  3301. adminUser := c.GetAdminUserInfo()
  3302. errlog := &models.HisOrderError{
  3303. UserOrgId: adminUser.CurrentOrgId,
  3304. Ctime: time.Now().Unix(),
  3305. Mtime: time.Now().Unix(),
  3306. ErrMsg: res2.ErrMsg,
  3307. Status: 1,
  3308. PatientId: id,
  3309. RecordTime: recordDateTime,
  3310. Stage: 3,
  3311. }
  3312. service.CreateErrMsgLog(errlog)
  3313. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterThreeException)
  3314. return
  3315. }
  3316. c.ServeSuccessJSON(map[string]interface{}{
  3317. "msg": "上传成功",
  3318. })
  3319. }
  3320. func PathExists(path string) (bool, error) {
  3321. _, err := os.Stat(path)
  3322. if err == nil {
  3323. return true, nil
  3324. }
  3325. if os.IsNotExist(err) {
  3326. return false, nil
  3327. }
  3328. return false, err
  3329. }
  3330. //创建文件夹
  3331. func Mkdir(dir string) {
  3332. // 创建文件夹
  3333. exist, err := PathExists(dir)
  3334. if err != nil {
  3335. fmt.Println(err.Error())
  3336. } else {
  3337. if exist {
  3338. fmt.Println(dir + "文件夹已存在!")
  3339. } else {
  3340. // 文件夹名称,权限
  3341. err := os.Mkdir(dir, os.ModePerm)
  3342. if err != nil {
  3343. fmt.Println(dir+"文件夹创建失败:", err.Error())
  3344. } else {
  3345. fmt.Println(dir + "文件夹创建成功!")
  3346. }
  3347. }
  3348. }
  3349. }
  3350. //压缩文件
  3351. func Zip(srcFile string, destZip string) error {
  3352. zipfile, err := os.Create(destZip)
  3353. if err != nil {
  3354. return err
  3355. }
  3356. defer zipfile.Close()
  3357. archive := zip.NewWriter(zipfile)
  3358. defer archive.Close()
  3359. filepath.Walk(srcFile, func(path string, info os.FileInfo, err error) error {
  3360. if err != nil {
  3361. return err
  3362. }
  3363. header, err := zip.FileInfoHeader(info)
  3364. if err != nil {
  3365. return err
  3366. }
  3367. header.Name = strings.TrimPrefix(path, filepath.Dir(srcFile)+"/")
  3368. // header.Name = path
  3369. if info.IsDir() {
  3370. header.Name += "/"
  3371. } else {
  3372. header.Method = zip.Deflate
  3373. }
  3374. writer, err := archive.CreateHeader(header)
  3375. if err != nil {
  3376. return err
  3377. }
  3378. if !info.IsDir() {
  3379. file, err := os.Open(path)
  3380. if err != nil {
  3381. return err
  3382. }
  3383. defer file.Close()
  3384. _, err = io.Copy(writer, file)
  3385. }
  3386. return err
  3387. })
  3388. return err
  3389. }
  3390. func ReadFile(filePath string) []byte {
  3391. f, err := os.Open(filePath)
  3392. if err != nil {
  3393. fmt.Println("read file fail", err)
  3394. return nil
  3395. }
  3396. defer f.Close()
  3397. fd, err := ioutil.ReadAll(f)
  3398. if err != nil {
  3399. fmt.Println("read to fd fail", err)
  3400. return nil
  3401. }
  3402. return fd
  3403. }
  3404. func RemoveRepeatedCode(arr []string) (newArr []string) {
  3405. newArr = make([]string, 0)
  3406. for i := 0; i < len(arr); i++ {
  3407. repeat := false
  3408. for j := i + 1; j < len(arr); j++ {
  3409. if arr[i] == arr[j] {
  3410. repeat = true
  3411. break
  3412. }
  3413. }
  3414. if !repeat {
  3415. newArr = append(newArr, arr[i])
  3416. }
  3417. }
  3418. return
  3419. }
  3420. //func ShowMessage1(caption, text string, style uintptr) (result int) {
  3421. // user32, _ := syscall.LoadLibrary("SSCard.dll")
  3422. // messageBox, _ := syscall.GetProcAddress(user32, "MessageBoxW")
  3423. // defer syscall.FreeLibrary(user32)
  3424. //
  3425. // ret, _, _ := syscall.Syscall9(messageBox,
  3426. // 4,
  3427. // 0,
  3428. // StrPtr(text),
  3429. // StrPtr(caption),
  3430. // style,
  3431. // 0, 0, 0, 0, 0)
  3432. // result = int(ret)
  3433. // return
  3434. //}
  3435. //func StrPtr3(s string) uintptr {
  3436. // return uintptr(unsafe.Pointer(syscall.StringToUTF16Ptr(s)))
  3437. //}