sz_his_api_controller.go 91KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732
  1. package sz
  2. import (
  3. "encoding/json"
  4. "fmt"
  5. "gdyb/controllers"
  6. "gdyb/enums"
  7. "gdyb/models"
  8. "gdyb/service"
  9. "gdyb/utils"
  10. "github.com/astaxie/beego"
  11. "github.com/axgle/mahonia"
  12. "math"
  13. "math/rand"
  14. "strconv"
  15. "strings"
  16. //"strings"
  17. "syscall"
  18. "time"
  19. "unsafe"
  20. )
  21. type Result struct {
  22. Transtime string `json:"transTime"`
  23. Transtype string `json:"transType"`
  24. Transreturncode string `json:"transReturnCode"`
  25. Transreturnmessage string `json:"transReturnMessage"`
  26. Transversion string `json:"transVersion"`
  27. Serialnumber string `json:"serialNumber"`
  28. Cardarea string `json:"cardArea"`
  29. Hospitalcode string `json:"hospitalCode"`
  30. Operatorcode string `json:"operatorCode"`
  31. Operatorname string `json:"operatorName"`
  32. Operatorpass string `json:"operatorPass"`
  33. Transbody struct {
  34. Akc190 string `json:"akc190"`
  35. Listsize int `json:"listsize"`
  36. Outputlist []struct {
  37. Aae072 string `json:"aae072"`
  38. Bkc369 string `json:"bkc369"`
  39. Bkf500 string `json:"bkf500"`
  40. Aka111 string `json:"aka111"`
  41. Ake001 string `json:"ake001"`
  42. Ake002 string `json:"ake002"`
  43. Bkm017 string `json:"bkm017"`
  44. Ake005 string `json:"ake005"`
  45. Ake006 string `json:"ake006"`
  46. Akc225 float64 `json:"akc225"`
  47. Akc226 float64 `json:"akc226"`
  48. Akc264 float64 `json:"akc264"`
  49. Aka065 string `json:"aka065"`
  50. Cka319 float64 `json:"cka319"`
  51. Akc268 float64 `json:"akc268"`
  52. } `json:"outputlist"`
  53. } `json:"transBody"`
  54. Verifycode string `json:"verifyCode"`
  55. Extenddeviceid string `json:"extendDeviceId"`
  56. Transchannel string `json:"transChannel"`
  57. Extenduserid string `json:"extendUserId"`
  58. Extendserialnumber string `json:"extendSerialNumber"`
  59. Caz055 string `json:"caz055"`
  60. Aae501 string `json:"aae501"`
  61. }
  62. type ResultOne struct {
  63. Transtime string `json:"transTime"`
  64. Transtype string `json:"transType"`
  65. Transreturncode string `json:"transReturnCode"`
  66. Transreturnmessage string `json:"transReturnMessage"`
  67. Transversion string `json:"transVersion"`
  68. Serialnumber string `json:"serialNumber"`
  69. Cardarea string `json:"cardArea"`
  70. Hospitalcode string `json:"hospitalCode"`
  71. Operatorcode string `json:"operatorCode"`
  72. Operatorname string `json:"operatorName"`
  73. Operatorpass string `json:"operatorPass"`
  74. Transbody struct {
  75. Ckc618 string `json:"ckc618"`
  76. Akc264 float64 `json:"akc264"`
  77. Akb068 int `json:"akb068"`
  78. Akb066 float64 `json:"akb066"`
  79. Akb067 int `json:"akb067"`
  80. Aae240 float64 `json:"aae240"`
  81. Outputlist []struct {
  82. Aaa036 string `json:"aaa036"`
  83. Aae019 float64 `json:"aae019"`
  84. } `json:"outputlist"`
  85. Outputlist2 []interface{} `json:"outputlist2"`
  86. } `json:"transBody"`
  87. Verifycode string `json:"verifyCode"`
  88. Extenddeviceid string `json:"extendDeviceId"`
  89. Transchannel string `json:"transChannel"`
  90. Extenduserid string `json:"extendUserId"`
  91. Extendserialnumber string `json:"extendSerialNumber"`
  92. Caz055 string `json:"caz055"`
  93. Aae501 string `json:"aae501"`
  94. }
  95. type ResultTwo struct {
  96. Transtime string `json:"transTime"`
  97. Transtype string `json:"transType"`
  98. Transreturncode string `json:"transReturnCode"`
  99. Transreturnmessage string `json:"transReturnMessage"`
  100. Transversion string `json:"transVersion"`
  101. Serialnumber string `json:"serialNumber"`
  102. Cardarea string `json:"cardArea"`
  103. Hospitalcode string `json:"hospitalCode"`
  104. Operatorcode string `json:"operatorCode"`
  105. Operatorname string `json:"operatorName"`
  106. Operatorpass string `json:"operatorPass"`
  107. Transbody struct {
  108. Ckc618 string `json:"ckc618"`
  109. Akc264 float64 `json:"akc264"`
  110. Akb068 float64 `json:"akb068"`
  111. Akb066 float64 `json:"akb066"`
  112. Akb067 float64 `json:"akb067"`
  113. Aae240 float64 `json:"aae240"`
  114. Outputlist1 []struct {
  115. Aka111 string `json:"aka111"`
  116. Bka058 float64 `json:"bka058"`
  117. } `json:"outputlist1"`
  118. Outputlist2 []struct {
  119. Aaa036 string `json:"aaa036"`
  120. Aae019 float64 `json:"aae019"`
  121. } `json:"outputlist2"`
  122. Outputlist3 []interface{} `json:"outputlist3"`
  123. } `json:"transBody"`
  124. Verifycode string `json:"verifyCode"`
  125. Extenddeviceid string `json:"extendDeviceId"`
  126. Transchannel string `json:"transChannel"`
  127. Extenduserid string `json:"extendUserId"`
  128. Extendserialnumber string `json:"extendSerialNumber"`
  129. Caz055 string `json:"caz055"`
  130. Aae501 string `json:"aae501"`
  131. }
  132. type ResultThree struct {
  133. Transtime string `json:"transTime"`
  134. Transtype string `json:"transType"`
  135. Transreturncode string `json:"transReturnCode"`
  136. Transreturnmessage string `json:"transReturnMessage"`
  137. Transversion string `json:"transVersion"`
  138. Serialnumber string `json:"serialNumber"`
  139. Cardarea string `json:"cardArea"`
  140. Hospitalcode string `json:"hospitalCode"`
  141. Operatorcode string `json:"operatorCode"`
  142. Operatorname string `json:"operatorName"`
  143. Operatorpass string `json:"operatorPass"`
  144. Transbody struct {
  145. Baz700 string `json:"baz700"`
  146. Ckc618 string `json:"ckc618"`
  147. } `json:"transBody"`
  148. Verifycode string `json:"verifyCode"`
  149. Extenddeviceid string `json:"extendDeviceId"`
  150. Transchannel string `json:"transChannel"`
  151. Extenduserid string `json:"extendUserId"`
  152. Extendserialnumber string `json:"extendSerialNumber"`
  153. Caz055 string `json:"caz055"`
  154. Aae501 string `json:"aae501"`
  155. }
  156. type ResultFive struct {
  157. Transtime string `json:"transTime"`
  158. Transtype string `json:"transType"`
  159. Transreturncode string `json:"transReturnCode"`
  160. Transreturnmessage string `json:"transReturnMessage"`
  161. Transversion string `json:"transVersion"`
  162. Serialnumber string `json:"serialNumber"`
  163. Cardarea string `json:"cardArea"`
  164. Hospitalcode string `json:"hospitalCode"`
  165. Operatorcode string `json:"operatorCode"`
  166. Operatorname string `json:"operatorName"`
  167. Operatorpass string `json:"operatorPass"`
  168. Transbody struct {
  169. Akc190 string `json:"akc190"`
  170. Listsize int `json:"listsize"`
  171. Outputlist []struct {
  172. Aae072 string `json:"aae072"`
  173. Bkf500 string `json:"bkf500"`
  174. Baz700 string `json:"baz700"`
  175. Bce574 string `json:"bce574"`
  176. } `json:"outputlist"`
  177. } `json:"transBody"`
  178. Verifycode string `json:"verifyCode"`
  179. Extenddeviceid string `json:"extendDeviceId"`
  180. Transchannel string `json:"transChannel"`
  181. Extenduserid string `json:"extendUserId"`
  182. Extendserialnumber string `json:"extendSerialNumber"`
  183. Caz055 string `json:"caz055"`
  184. Aae501 string `json:"aae501"`
  185. }
  186. type ResultFour struct {
  187. Transtime string `json:"transTime"`
  188. Transtype string `json:"transType"`
  189. Transreturncode string `json:"transReturnCode"`
  190. Transreturnmessage string `json:"transReturnMessage"`
  191. Transversion string `json:"transVersion"`
  192. Serialnumber string `json:"serialNumber"`
  193. Cardarea string `json:"cardArea"`
  194. Hospitalcode string `json:"hospitalCode"`
  195. Operatorcode string `json:"operatorCode"`
  196. Operatorname string `json:"operatorName"`
  197. Operatorpass string `json:"operatorPass"`
  198. Transbody struct {
  199. Akc190 string `json:"akc190"`
  200. Akc194 int `json:"akc194"`
  201. Bae917 int64 `json:"bae917"`
  202. Aka018 string `json:"aka018"`
  203. Aka030 string `json:"aka030"`
  204. Ckc618 string `json:"ckc618"`
  205. Akc264 int `json:"akc264"`
  206. Akb068 int `json:"akb068"`
  207. Akb066 int `json:"akb066"`
  208. Akb067 int `json:"akb067"`
  209. Cke298 float64 `json:"cke298"`
  210. Aae240 float64 `json:"aae240"`
  211. Outputlist1 []struct {
  212. Aae072 string `json:"aae072"`
  213. Bkc369 string `json:"bkc369"`
  214. Bkf500 string `json:"bkf500"`
  215. Aka111 string `json:"aka111"`
  216. Ake001 string `json:"ake001"`
  217. Ake002 string `json:"ake002"`
  218. Bkm017 string `json:"bkm017"`
  219. Ake005 string `json:"ake005"`
  220. Ake006 string `json:"ake006"`
  221. Ala026 string `json:"ala026"`
  222. Aka070 string `json:"aka070"`
  223. Aka074 string `json:"aka074"`
  224. Akc226 int `json:"akc226"`
  225. Akc225 int `json:"akc225"`
  226. Akc264 int `json:"akc264"`
  227. Aka067 string `json:"aka067"`
  228. Akc271 int `json:"akc271"`
  229. Bkc320 string `json:"bkc320"`
  230. Cke400 string `json:"cke400"`
  231. Ckc618 string `json:"ckc618"`
  232. Bka069 int64 `json:"bka069"`
  233. Aka018 string `json:"aka018"`
  234. Aka030 string `json:"aka030"`
  235. Aka065 string `json:"aka065"`
  236. Cka319 int `json:"cka319"`
  237. Akc268 int `json:"akc268"`
  238. } `json:"outputlist1"`
  239. Outputlist2 []struct {
  240. Aka111 string `json:"aka111"`
  241. Bka058 int `json:"bka058"`
  242. } `json:"outputlist2"`
  243. Outputlist3 []struct {
  244. Aaa036 string `json:"aaa036"`
  245. Aae019 int `json:"aae019"`
  246. } `json:"outputlist3"`
  247. } `json:"transBody"`
  248. Verifycode string `json:"verifyCode"`
  249. Extenddeviceid string `json:"extendDeviceId"`
  250. Transchannel string `json:"transChannel"`
  251. Extenduserid string `json:"extendUserId"`
  252. Extendserialnumber string `json:"extendSerialNumber"`
  253. Caz055 string `json:"caz055"`
  254. Aae501 string `json:"aae501"`
  255. }
  256. type SZHisApiController struct {
  257. controllers.BaseAuthAPIController
  258. }
  259. func SZHisManagerApiRegistRouters() {
  260. //挂号
  261. beego.Router("/sz/api/register/get", &SZHisApiController{}, "get:GetRegisterInfo")
  262. //上传明细,预结算
  263. //beego.Router("/sz/api/upload/get", &SZHisApiController{}, "get:GetUploadInfo")
  264. //结算
  265. beego.Router("/sz/api/settle/get", &SZHisApiController{}, "get:GetSettleInfo")
  266. //退费
  267. beego.Router("/sz/api/refund/get", &SZHisApiController{}, "get:Refund")
  268. beego.Router("/sz/api/monthrefund/get", &SZHisApiController{}, "get:MonthRefund")
  269. //查询交易
  270. beego.Router("/sz/api/settle/query", &SZHisApiController{}, "get:GetSettleAccounts")
  271. //撤销明细
  272. beego.Router("/sz/api/detail/cancel", &SZHisApiController{}, "get:CancelOrderDetail")
  273. //
  274. ////机构药品目录备案
  275. //beego.Router("/sz/api/drug/get", &SZHisApiController{}, "get:GetDrugList")
  276. ////协议机构诊疗项目
  277. //beego.Router("/sz/api/treatment/get", &SZHisApiController{}, "get:GetTreatmentProject")
  278. ////协议机构目录备案撤销
  279. //beego.Router("/sz/api/revocation/get", &SZHisApiController{}, "get:GetRevocation")
  280. //
  281. ////定点机构约定信息查询
  282. ////beego.Router("/sz/api/information/query/get",&SZHisApiController{},"get:GetInformationQuery")
  283. ////-医药师信息登记
  284. //beego.Router("/sz/api/doctor/get", &SZHisApiController{}, "get:GetDoctorList")
  285. ////医药师执业状态变更
  286. //beego.Router("/sz/api/medical/get", &SZHisApiController{}, "get:GetMedicalList")
  287. ////医药师信息更新
  288. //beego.Router("/sz/api/update/medical/get", &SZHisApiController{}, "get:GetUpdateMedicalList")
  289. ////协议机构材料目录备案
  290. //
  291. //beego.Router("/sz/api/goods/get", &SZHisApiController{}, "get:GetGoodsList")
  292. }
  293. func IntPtr(n int) uintptr {
  294. return uintptr(n)
  295. }
  296. func StrPtr(s string) uintptr {
  297. return uintptr(unsafe.Pointer(syscall.StringBytePtr(s)))
  298. }
  299. type Custom struct {
  300. DetItemFeeSumamt string
  301. Cut string
  302. FeedetlSn string
  303. Price string
  304. MedListCodg string
  305. Type int64
  306. AdviceId int64
  307. ProjectId int64
  308. ItemId int64
  309. }
  310. //获取读卡信息 -- 门诊挂号
  311. func (c *SZHisApiController) GetRegisterInfo() {
  312. adminInfo := c.GetAdminUserInfo()
  313. admin_user_id, _ := c.GetInt64("admin_user_id")
  314. patient_id, _ := c.GetInt64("id")
  315. record_time := c.GetString("record_time")
  316. settlementValue, _ := c.GetInt64("settlement_value")
  317. medical_insurance_card := c.GetString("medical_insurance_card")
  318. name := c.GetString("name")
  319. id_card_type, _ := c.GetInt64("id_card_type")
  320. certificates, _ := c.GetInt64("certificates")
  321. medical_care, _ := c.GetInt64("medical_care")
  322. birthday := c.GetString("birthday")
  323. id_card := c.GetString("id_card")
  324. register_type, _ := c.GetInt64("register")
  325. doctor, _ := c.GetInt64("doctor")
  326. department, _ := c.GetInt64("department")
  327. gender, _ := c.GetInt64("sex")
  328. registration_fee, _ := c.GetFloat("registration_fee")
  329. medical_expenses, _ := c.GetFloat("medical_expenses")
  330. social_type, _ := c.GetInt64("social_type")
  331. is_yidi, _ := c.GetInt64("is_yidi")
  332. timeLayout := "2006-01-02"
  333. loc, _ := time.LoadLocation("Local")
  334. birthdays, _ := time.ParseInLocation(timeLayout+" 15:04:05", birthday+" 00:00:00", loc)
  335. birthUnix := birthdays.Unix()
  336. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  337. if err != nil {
  338. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  339. return
  340. }
  341. var patient service.Patients
  342. if patient_id == 0 {
  343. patient, _ = service.GetPatientByIDCard(id_card, adminInfo.CurrentOrgId)
  344. } else {
  345. patient, _ = service.GetPatientByIDTwo(adminInfo.CurrentOrgId, patient_id)
  346. }
  347. miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  348. if patient.ID == 0 {
  349. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  350. return
  351. }
  352. if len(patient.IdCardNo) == 0 {
  353. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeIDCartNo)
  354. return
  355. }
  356. adminRole, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, admin_user_id)
  357. his, _ := service.GetHisPatientInfo(adminInfo.CurrentOrgId, patient_id, theTime.Unix())
  358. var custom_code string
  359. var custom_project_name string
  360. var allPrice float64
  361. switch register_type {
  362. case 1:
  363. custom_code = "110100002"
  364. custom_project_name = "普通门诊"
  365. allPrice = 10
  366. break
  367. case 3:
  368. custom_code = "110200002-2"
  369. custom_project_name = "主任医师"
  370. allPrice = 10
  371. break
  372. case 2:
  373. custom_code = "110200002-3"
  374. custom_project_name = "副主任医师"
  375. allPrice = 10
  376. break
  377. case 4:
  378. custom_code = "0"
  379. custom_project_name = "免受诊金"
  380. allPrice = 0
  381. break
  382. case 5:
  383. custom_code = "110200002-1"
  384. custom_project_name = "专家"
  385. allPrice = 10
  386. break
  387. }
  388. if his.ID == 0 {
  389. var doctor_name string
  390. var doctor_code string
  391. if adminRole.ID == 0 {
  392. doctor_name = "黄亦轩"
  393. doctor_code = "1001"
  394. } else {
  395. doctor_name = adminRole.UserName
  396. doctor_code = strconv.FormatInt(admin_user_id, 10)
  397. }
  398. month := time.Unix(1557042972, 0).Format("1")
  399. year := time.Now().Format("2006")
  400. month = time.Now().Format("01")
  401. day := time.Now().Format("02")
  402. //流水号
  403. //
  404. number := miConfig.Code + year + month + day +
  405. fmt.Sprintf("%07v", rand.New(rand.NewSource(time.Now().UnixNano())).Int31n(10000000)) // 定点协议机构编码(5位)+日期(8位)+流水号(7位)
  406. mz_number := year + month + day + strconv.FormatInt(patient_id, 10) +
  407. fmt.Sprintf("%07v", rand.New(rand.NewSource(time.Now().UnixNano())).Int31n(10000000))
  408. //1.判断读卡类型
  409. //2.读卡 获取交易验证码,医疗证号,发卡地区行政区划代码
  410. yiliao_number, id_card_number, verifyCode, version_code, err, ret4 := ReadBasCardGetNumber("MZ002" + "|" + number + "|" + miConfig.Code + "|")
  411. dept_code := "0305"
  412. is_yidi = 1
  413. if err != nil {
  414. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  415. return
  416. }
  417. tempPatient, _ := service.GetPatientByNumber(id_card_number, adminInfo.CurrentOrgId)
  418. //根据业务的人员信息跟设备读社保卡获取的信息进行匹配,判断是否为同一个人,相同则进行挂号操作,不同则报错
  419. if tempPatient.ID == patient_id {
  420. if ret4 == 0 { //本地卡流程
  421. if is_yidi == 1 {
  422. //本地就医流程
  423. //挂号
  424. resp_result := service.SzybMZ002(doctor_name, doctor_code, miConfig.Code, dept_code, yiliao_number, verifyCode, number, mz_number, version_code, custom_code, custom_project_name, allPrice)
  425. var dat map[string]interface{}
  426. if err := json.Unmarshal([]byte(resp_result), &dat); err == nil {
  427. fmt.Println(dat)
  428. } else {
  429. fmt.Println(err)
  430. }
  431. userJSONBytes, _ := json.Marshal(dat)
  432. var res ResultOne
  433. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  434. utils.ErrorLog("解析失败:%v", err)
  435. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  436. return
  437. }
  438. if res.Transreturncode == "00000000" {
  439. his := models.VMHisPatient{
  440. Name: name,
  441. Gender: gender,
  442. Birthday: birthUnix,
  443. MedicalTreatmentType: medical_care,
  444. IdType: certificates,
  445. IdCardNo: id_card,
  446. BalanceAccountsType: settlementValue,
  447. SocialType: social_type,
  448. MedicalInsuranceNumber: medical_insurance_card,
  449. RegisterType: register_type,
  450. RegisterCost: registration_fee,
  451. TreatmentCost: medical_expenses,
  452. Status: 1,
  453. Ctime: time.Now().Unix(),
  454. Mtime: time.Now().Unix(),
  455. Iinfo: resp_result,
  456. PatientId: patient.ID,
  457. RecordDate: theTime.Unix(),
  458. UserOrgId: adminInfo.CurrentOrgId,
  459. AdminUserId: admin_user_id,
  460. IsReturn: 1,
  461. IdCardType: id_card_type,
  462. Doctor: doctor,
  463. Departments: department,
  464. YiliaoNumber: yiliao_number,
  465. MzNumber: number,
  466. Number: mz_number,
  467. }
  468. service.CreateHisPatientTwo(&his)
  469. c.ServeSuccessJSON(map[string]interface{}{
  470. "msg": "挂号成功",
  471. })
  472. } else {
  473. c.ServeSuccessJSON(map[string]interface{}{
  474. "failed_code": -10,
  475. "msg": res.Transreturnmessage,
  476. })
  477. return
  478. }
  479. } else {
  480. //异地就医流程
  481. //异地走鉴权流程
  482. //authResult := CardAuth(number)
  483. //fmt.Println(authResult)
  484. //tempPatient, _ := service.GetPatientByNumber(id_card_number, adminInfo.CurrentOrgId)
  485. //if tempPatient.ID == patient_id {
  486. resp_result := service.SzybMZ002(doctor_name, doctor_code, miConfig.Code, "0305", yiliao_number, verifyCode, number, mz_number, version_code, custom_code, custom_project_name, allPrice)
  487. var dat map[string]interface{}
  488. if err := json.Unmarshal([]byte(resp_result), &dat); err == nil {
  489. fmt.Println(dat)
  490. } else {
  491. fmt.Println(err)
  492. }
  493. userJSONBytes, _ := json.Marshal(dat)
  494. var res ResultOne
  495. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  496. utils.ErrorLog("解析失败:%v", err)
  497. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  498. return
  499. }
  500. if res.Transreturncode == "00000000" {
  501. his := models.VMHisPatient{
  502. Name: name,
  503. Gender: gender,
  504. Birthday: birthUnix,
  505. MedicalTreatmentType: medical_care,
  506. IdType: certificates,
  507. IdCardNo: id_card,
  508. BalanceAccountsType: settlementValue,
  509. SocialType: social_type,
  510. MedicalInsuranceNumber: medical_insurance_card,
  511. RegisterType: register_type,
  512. RegisterCost: registration_fee,
  513. TreatmentCost: medical_expenses,
  514. Status: 1,
  515. Ctime: time.Now().Unix(),
  516. Mtime: time.Now().Unix(),
  517. Iinfo: resp_result,
  518. PatientId: patient.ID,
  519. RecordDate: theTime.Unix(),
  520. UserOrgId: adminInfo.CurrentOrgId,
  521. AdminUserId: admin_user_id,
  522. IsReturn: 1,
  523. IdCardType: id_card_type,
  524. Doctor: doctor,
  525. Departments: department,
  526. YiliaoNumber: yiliao_number,
  527. MzNumber: number,
  528. Number: mz_number,
  529. }
  530. service.CreateHisPatientTwo(&his)
  531. c.ServeSuccessJSON(map[string]interface{}{
  532. "msg": "挂号成功",
  533. })
  534. } else {
  535. c.ServeSuccessJSON(map[string]interface{}{
  536. "failed_code": -10,
  537. "msg": res.Transreturnmessage,
  538. })
  539. return
  540. }
  541. }
  542. } else { //异地卡流程
  543. //readCardBasResult := ReadCardBasHSM(number)
  544. //fmt.Println(readCardBasResult)
  545. //是否异地就医,是的话走鉴权流程,不是的话走门诊挂号
  546. if is_yidi == 1 { //1本地就医
  547. resp_result := service.SzybMZ002(doctor_name, doctor_code, miConfig.Code, "0305", yiliao_number, verifyCode, number, mz_number, version_code, custom_code, custom_project_name, allPrice)
  548. var dat map[string]interface{}
  549. if err := json.Unmarshal([]byte(resp_result), &dat); err == nil {
  550. fmt.Println(dat)
  551. } else {
  552. fmt.Println(err)
  553. }
  554. userJSONBytes, _ := json.Marshal(dat)
  555. var res ResultOne
  556. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  557. utils.ErrorLog("解析失败:%v", err)
  558. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  559. return
  560. }
  561. if res.Transreturncode == "00000000" {
  562. his := models.VMHisPatient{
  563. Name: name,
  564. Gender: gender,
  565. Birthday: birthUnix,
  566. MedicalTreatmentType: medical_care,
  567. IdType: certificates,
  568. IdCardNo: id_card,
  569. BalanceAccountsType: settlementValue,
  570. SocialType: social_type,
  571. MedicalInsuranceNumber: medical_insurance_card,
  572. RegisterType: register_type,
  573. RegisterCost: registration_fee,
  574. TreatmentCost: medical_expenses,
  575. Status: 1,
  576. Ctime: time.Now().Unix(),
  577. Mtime: time.Now().Unix(),
  578. Iinfo: resp_result,
  579. PatientId: patient.ID,
  580. RecordDate: theTime.Unix(),
  581. UserOrgId: adminInfo.CurrentOrgId,
  582. AdminUserId: admin_user_id,
  583. IsReturn: 1,
  584. IdCardType: id_card_type,
  585. Doctor: doctor,
  586. Departments: department,
  587. YiliaoNumber: yiliao_number,
  588. MzNumber: number,
  589. Number: mz_number,
  590. }
  591. service.CreateHisPatientTwo(&his)
  592. c.ServeSuccessJSON(map[string]interface{}{
  593. "msg": "挂号成功",
  594. })
  595. } else {
  596. c.ServeSuccessJSON(map[string]interface{}{
  597. "failed_code": -10,
  598. "msg": res.Transreturnmessage,
  599. })
  600. return
  601. }
  602. } else { //异地就医需要走鉴权流程
  603. //authResult := CardAuth(number)
  604. //fmt.Println(authResult)
  605. resp_result := service.SzybMZ002(doctor_name, doctor_code, miConfig.Code, "0305", yiliao_number, verifyCode, number, mz_number, version_code, custom_code, custom_project_name, allPrice)
  606. var dat map[string]interface{}
  607. if err := json.Unmarshal([]byte(resp_result), &dat); err == nil {
  608. fmt.Println(dat)
  609. } else {
  610. fmt.Println(err)
  611. }
  612. userJSONBytes, _ := json.Marshal(dat)
  613. var res ResultOne
  614. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  615. utils.ErrorLog("解析失败:%v", err)
  616. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  617. return
  618. }
  619. if res.Transreturncode == "00000000" {
  620. his := models.VMHisPatient{
  621. Name: name,
  622. Gender: gender,
  623. Birthday: birthUnix,
  624. MedicalTreatmentType: medical_care,
  625. IdType: certificates,
  626. IdCardNo: id_card,
  627. BalanceAccountsType: settlementValue,
  628. SocialType: social_type,
  629. MedicalInsuranceNumber: medical_insurance_card,
  630. RegisterType: register_type,
  631. RegisterCost: registration_fee,
  632. TreatmentCost: medical_expenses,
  633. Status: 1,
  634. Ctime: time.Now().Unix(),
  635. Mtime: time.Now().Unix(),
  636. Iinfo: resp_result,
  637. PatientId: patient.ID,
  638. RecordDate: theTime.Unix(),
  639. UserOrgId: adminInfo.CurrentOrgId,
  640. AdminUserId: admin_user_id,
  641. IsReturn: 1,
  642. IdCardType: id_card_type,
  643. Doctor: doctor,
  644. Departments: department,
  645. YiliaoNumber: yiliao_number,
  646. MzNumber: number,
  647. Number: mz_number,
  648. }
  649. service.CreateHisPatientTwo(&his)
  650. c.ServeSuccessJSON(map[string]interface{}{
  651. "msg": "挂号成功",
  652. })
  653. } else {
  654. c.ServeSuccessJSON(map[string]interface{}{
  655. "failed_code": -10,
  656. "msg": res.Transreturnmessage,
  657. })
  658. return
  659. }
  660. }
  661. }
  662. } else {
  663. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  664. return
  665. }
  666. } else {
  667. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  668. return
  669. }
  670. }
  671. //上传明细----结算----确认订单
  672. func (c *SZHisApiController) GetSettleInfo() {
  673. pay_way, _ := c.GetInt64("pay_way")
  674. pay_price, _ := c.GetFloat("pay_price")
  675. pay_card_no := c.GetString("pay_card_no")
  676. discount_price, _ := c.GetFloat("discount_price")
  677. preferential_price, _ := c.GetFloat("preferential_price")
  678. reality_price, _ := c.GetFloat("reality_price")
  679. found_price, _ := c.GetFloat("found_price")
  680. medical_insurance_price, _ := c.GetFloat("medical_insurance_price")
  681. private_price, _ := c.GetFloat("private_price")
  682. settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  683. patient_id, _ := c.GetInt64("id")
  684. record_time := c.GetString("record_time")
  685. admin_user_id, _ := c.GetInt64("admin_user_id")
  686. timestamp := time.Now().Unix()
  687. tempTime := time.Unix(timestamp, 0)
  688. timeFormat := tempTime.Format("20060102150405")
  689. chrgBchno := rand.Intn(10000) + 1000
  690. chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(1, 10)
  691. adminUser := c.GetAdminUserInfo()
  692. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  693. month := time.Unix(1557042972, 0).Format("1")
  694. year := time.Now().Format("2006")
  695. month = time.Now().Format("01")
  696. day := time.Now().Format("02")
  697. timeLayout := "2006-01-02"
  698. loc, _ := time.LoadLocation("Local")
  699. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  700. fmt.Println(err)
  701. if err != nil {
  702. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  703. return
  704. }
  705. recordDateTime := theTime.Unix()
  706. var prescriptions []*models.HisPrescription
  707. var start_time int64
  708. var end_time int64
  709. if settle_accounts_type == 1 { //日结
  710. prescriptions, _ = service.GetHisPrescription(adminUser.CurrentOrgId, patient_id, recordDateTime)
  711. } else { //月结
  712. start_time_str := c.GetString("start_time")
  713. end_time_str := c.GetString("end_time")
  714. timeLayout := "2006-01-02"
  715. loc, _ := time.LoadLocation("Local")
  716. theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  717. if err != nil {
  718. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  719. return
  720. }
  721. recordStartTime := theStartTime.Unix()
  722. start_time = recordStartTime
  723. theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  724. if err != nil {
  725. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  726. return
  727. }
  728. recordEndTime := theEndTime.Unix()
  729. end_time = recordEndTime
  730. prescriptions, _ = service.GetMonthHisPrescription(adminUser.CurrentOrgId, patient_id, recordStartTime, recordEndTime)
  731. }
  732. var ids []int64
  733. for _, item := range prescriptions {
  734. ids = append(ids, item.ID)
  735. }
  736. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  737. adminRole_two, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  738. adminRole, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  739. his, err := service.GetHisPatientInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  740. mz_number := his.Number
  741. number := miConfig.Code + year + month + day +
  742. fmt.Sprintf("%07v", rand.New(rand.NewSource(time.Now().UnixNano())).Int31n(10000000)) // 定点协议机构编码(5位)+日期(8位)+流水号(7位)
  743. var doctor_name string
  744. var doctor_code string
  745. var drug_doctor_code string
  746. drug_doctor_code = adminRole_two.DoctorCode
  747. drug_doctor_name := adminRole_two.UserName
  748. if adminRole.ID == 0 {
  749. doctor_name = "黄亦轩"
  750. doctor_code = "1"
  751. } else {
  752. doctor_name = adminRole.UserName
  753. doctor_code = strconv.FormatInt(admin_user_id, 10)
  754. }
  755. verifyCode, version_code := ReadCardGetCode("FY001" + "|" + number + "|" + miConfig.Code)
  756. //verifyCode := "000000|bf885fa312a7f92861d6b61542a637fa"
  757. //version_code := "V0.3"
  758. var customs []*models.CustomDetail
  759. for _, item := range prescriptions {
  760. if item.Type == 1 { //药品
  761. for _, subItem := range item.HisDoctorAdviceInfo {
  762. fmt.Println(subItem.BaseDrugLib.MedicalInsuranceNumber)
  763. if len(subItem.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  764. _, dose_code := service.GetDoseCode(subItem.BaseDrugLib.DrugDosageForm, adminUser.CurrentOrgId)
  765. detItemFeeSumamt, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", subItem.Price*subItem.PrescribingNumber), 64)
  766. price, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", subItem.Price), 64)
  767. temp := strings.Split(subItem.FeedetlSn, "-")
  768. newFl := fmt.Sprintf("%07v", rand.New(rand.NewSource(time.Now().UnixNano())).Int31n(10000000)) + "-" + temp[1] + "-" + temp[2]
  769. cus := &models.CustomDetail{
  770. PrescriptionNumber: chrg_bchno,
  771. OrderType: "1",
  772. ChargeSerialNumber: newFl,
  773. Code: subItem.BaseDrugLib.MedicalInsuranceNumber,
  774. CodeName: subItem.BaseDrugLib.DrugName,
  775. Flag: "1",
  776. Price: price,
  777. Count: subItem.PrescribingNumber,
  778. ChargeOrderDate: year + month + day,
  779. DoctorCode: doctor_code,
  780. Total: detItemFeeSumamt,
  781. DoseCode: dose_code,
  782. Spec: subItem.BaseDrugLib.DrugSpec,
  783. }
  784. customs = append(customs, cus)
  785. }
  786. }
  787. }
  788. if item.Type == 2 { //项目
  789. for _, subItem := range item.HisPrescriptionProject {
  790. if len(subItem.HisProject.MedicalCode) > 0 {
  791. detItemFeeSumamt, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", subItem.Price*float64(subItem.Count)), 64)
  792. count, _ := strconv.ParseFloat(fmt.Sprintf("%f", subItem.Count), 64)
  793. temp := strings.Split(subItem.FeedetlSn, "-")
  794. newFl := fmt.Sprintf("%07v", rand.New(rand.NewSource(time.Now().UnixNano())).Int31n(10000000)) + "-" + temp[1] + "-" + temp[2]
  795. cus := &models.CustomDetail{
  796. PrescriptionNumber: chrg_bchno,
  797. OrderType: "1",
  798. ChargeSerialNumber: newFl,
  799. Code: subItem.HisProject.MedicalCode,
  800. CodeName: subItem.HisProject.ProjectName,
  801. Flag: "1",
  802. Price: subItem.Price,
  803. Count: count,
  804. ChargeOrderDate: year + month + day,
  805. DoctorCode: doctor_code,
  806. Total: detItemFeeSumamt,
  807. DoseCode: "",
  808. Spec: "",
  809. }
  810. customs = append(customs, cus)
  811. }
  812. }
  813. }
  814. //
  815. //for _, subItem := range item.HisAdditionalCharge {
  816. // if len(subItem.XtHisAddtionConfig.Code) > 0 {
  817. // detItemFeeSumamt, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", subItem.Price*float64(subItem.Count)), 64)
  818. //
  819. // count, _ := strconv.ParseFloat(fmt.Sprintf("%f", subItem.Count), 64)
  820. // cus := &models.CustomDetail{
  821. // PrescriptionNumber: chrg_bchno,
  822. // OrderType: "1",
  823. // ChargeSerialNumber: subItem.FeedetlSn,
  824. // Code: subItem.XtHisAddtionConfig.Code,
  825. // CodeName: subItem.XtHisAddtionConfig.Name,
  826. // Flag: "1",
  827. // Price: subItem.Price,
  828. // Count: count,
  829. // ChargeOrderDate: year + month + day,
  830. // DoctorCode: doctor_code,
  831. // Total: detItemFeeSumamt,
  832. // DoseCode: "",
  833. // Spec: subItem.XtHisAddtionConfig.,
  834. // }
  835. // customs = append(customs, cus)
  836. // }
  837. //}
  838. }
  839. var pagesize int = 50
  840. var start int = 1
  841. var stop int
  842. var pagecount int
  843. var curpage int
  844. var isSuccess bool = true
  845. //总页数,向上取整,注意除之前要先转换类型为float64
  846. pagecount = int(math.Ceil(float64(len(customs)) / float64(pagesize)))
  847. var ress []*Result
  848. for curpage = 1; curpage <= pagecount; curpage++ {
  849. if curpage == 1 {
  850. start = 1
  851. } else {
  852. start = (curpage-1)*pagesize + 1
  853. }
  854. stop = curpage * pagesize
  855. if stop > len(customs) {
  856. stop = len(customs)
  857. }
  858. result := service.SzybFY001(doctor_name, doctor_code, miConfig.Code, customs[start-1:stop], verifyCode, number, mz_number, version_code, drug_doctor_code)
  859. fmt.Println(result)
  860. var dat map[string]interface{}
  861. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  862. fmt.Println(dat)
  863. } else {
  864. fmt.Println(err)
  865. }
  866. userJSONBytes, _ := json.Marshal(dat)
  867. var res Result
  868. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  869. utils.ErrorLog("解析失败:%v", err)
  870. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  871. return
  872. }
  873. if res.Transreturncode == "00000000" {
  874. ress = append(ress, &res)
  875. } else {
  876. isSuccess = false
  877. errlog := &models.HisOrderError{
  878. UserOrgId: adminUser.CurrentOrgId,
  879. Ctime: time.Now().Unix(),
  880. Mtime: time.Now().Unix(),
  881. Number: chrg_bchno,
  882. ErrMsg: res.Transreturnmessage,
  883. Status: 1,
  884. PatientId: patient_id,
  885. RecordTime: recordDateTime,
  886. Stage: 4,
  887. }
  888. service.CreateErrMsgLog(errlog)
  889. c.ServeSuccessJSON(map[string]interface{}{
  890. "failed_code": -10,
  891. "msg": res.Transreturnmessage,
  892. })
  893. return
  894. }
  895. //设置变量,根据变量的值来判断上传是否成功
  896. }
  897. if isSuccess == true {
  898. order := &models.HisOrder{
  899. UserOrgId: adminUser.CurrentOrgId,
  900. HisPatientId: 0,
  901. PatientId: patient_id,
  902. SettleAccountsDate: recordDateTime,
  903. Ctime: time.Now().Unix(),
  904. Mtime: time.Now().Unix(),
  905. Status: 1,
  906. Number: chrg_bchno,
  907. Infcode: 0,
  908. WarnMsg: "",
  909. Cainfo: "",
  910. ErrMsg: "",
  911. RespondTime: "",
  912. InfRefmsgid: "",
  913. OrderStatus: 1,
  914. IsMedicineInsurance: 1,
  915. SettleType: settle_accounts_type,
  916. SettleStartTime: start_time,
  917. SettleEndTime: end_time,
  918. Creator: admin_user_id,
  919. Modify: admin_user_id,
  920. OrgSetlNumber: number,
  921. }
  922. data, _ := json.Marshal(ress)
  923. order.DetailLog = string(data)
  924. err = service.CreateOrder(order)
  925. if err != nil {
  926. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  927. return
  928. }
  929. for _, subItem := range ress {
  930. for _, item := range subItem.Transbody.Outputlist {
  931. temp := strings.Split(item.Bkf500, "-")
  932. var advice_id int64 = 0
  933. var project_id int64 = 0
  934. var types int64 = 0
  935. id, _ := strconv.ParseInt(temp[2], 10, 64)
  936. types, _ = strconv.ParseInt(temp[1], 10, 64)
  937. if temp[1] == "1" {
  938. advice_id = id
  939. project_id = 0
  940. } else if temp[1] == "2" {
  941. advice_id = 0
  942. project_id = id
  943. }
  944. info := &models.HisOrderInfo{
  945. OrderNumber: order.Number,
  946. FeedetlSn: item.Bkf500,
  947. UploadDate: time.Now().Unix(),
  948. AdviceId: advice_id,
  949. DetItemFeeSumamt: item.Akc264,
  950. Cnt: item.Akc226,
  951. Pric: float64(item.Akc225),
  952. PatientId: patient_id,
  953. Status: 1,
  954. ChrgitmLv: item.Aka065,
  955. Mtime: time.Now().Unix(),
  956. Ctime: time.Now().Unix(),
  957. UserOrgId: adminUser.CurrentOrgId,
  958. OrderId: order.ID,
  959. ProjectId: project_id,
  960. Type: types,
  961. OverPricPsnPay: item.Akc268,
  962. AllowReimburse: item.Cka319,
  963. }
  964. service.CreateOrderInfo(info)
  965. }
  966. }
  967. service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  968. service.UpDatePrescriptionInfoNumber(adminUser.CurrentOrgId, patient_id, chrg_bchno, recordDateTime)
  969. var total float64
  970. for _, item := range prescriptions {
  971. if item.Type == 1 { //药品
  972. for _, subItem := range item.HisDoctorAdviceInfo {
  973. total = total + (subItem.Price * subItem.PrescribingNumber)
  974. }
  975. }
  976. if item.Type == 2 { //项目
  977. for _, subItem := range item.HisPrescriptionProject {
  978. total = total + (subItem.Price * float64(subItem.Count))
  979. }
  980. }
  981. }
  982. for _, item := range prescriptions {
  983. for _, subItem := range item.HisAdditionalCharge {
  984. total = total + (subItem.Price * float64(subItem.Count))
  985. }
  986. }
  987. yiliao_number, id_card_number, verifyCode, version_code, _, ret4 := ReadBasCardGetNumber("FY005" + "|" + number + "|" + miConfig.Code + "|")
  988. if ret4 == 0 {
  989. //根据业务的人员信息跟设备读社保卡获取的信息进行匹配,判断是否为同一个人,相同则进行挂号操作,不同则报错
  990. tempPatient, _ := service.GetPatientByNumber(id_card_number, adminUser.CurrentOrgId)
  991. if tempPatient.ID == patient_id {
  992. result_three := service.SzybFY005(doctor_name, doctor_code, miConfig.Code, total, yiliao_number, verifyCode, number, mz_number, version_code, drug_doctor_code, drug_doctor_name)
  993. var dat map[string]interface{}
  994. if err := json.Unmarshal([]byte(result_three), &dat); err == nil {
  995. fmt.Println(dat)
  996. } else {
  997. fmt.Println(err)
  998. }
  999. userJSONBytes, _ := json.Marshal(dat)
  1000. var res ResultTwo
  1001. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  1002. utils.ErrorLog("解析失败:%v", err)
  1003. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1004. return
  1005. }
  1006. if res.Transreturncode == "00000000" {
  1007. order.OrderStatus = 2
  1008. order.PayWay = pay_way
  1009. order.PayPrice = pay_price
  1010. order.PayCardNo = pay_card_no
  1011. order.DiscountPrice = discount_price
  1012. order.PreferentialPrice = preferential_price
  1013. order.RealityPrice = reality_price
  1014. order.FoundPrice = found_price
  1015. order.MedicalInsurancePrice = medical_insurance_price
  1016. order.PrivatePrice = private_price
  1017. order.Modify = admin_user_id
  1018. order.MedfeeSumamt = res.Transbody.Akc264
  1019. order.SetlId = res.Transbody.Ckc618
  1020. order.FundPaySumamt = res.Transbody.Akb068
  1021. order.AcctPay = res.Transbody.Akb066
  1022. order.PsnCashPay = res.Transbody.Akb067
  1023. order.PsnPartAmt = res.Transbody.Akb067
  1024. order.AccountPrice = res.Transbody.Aae240
  1025. order.MzNumber = mz_number
  1026. order.YiliaoNumber = yiliao_number
  1027. setlDetailOne, _ := json.Marshal(res.Transbody.Outputlist1)
  1028. detailStrOne := string(setlDetailOne)
  1029. order.SzChargeInfo = detailStrOne
  1030. setlDetailTwo, _ := json.Marshal(res.Transbody.Outputlist2)
  1031. detailStrTwo := string(setlDetailTwo)
  1032. order.SzProjectInfo = detailStrTwo
  1033. setlDetailThree, _ := json.Marshal(res.Transbody.Outputlist3)
  1034. detailStrThree := string(setlDetailThree)
  1035. order.SzMedicineInsuranceInfo = detailStrThree
  1036. order.Cainfo = result_three
  1037. err = service.UpdataOrderStatusTwo(order.Number, adminUser.CurrentOrgId)
  1038. err = service.UpDateOrderTwo(order)
  1039. c.ServeSuccessJSON(map[string]interface{}{
  1040. "msg": "结算成功",
  1041. })
  1042. } else {
  1043. //结算报错
  1044. errlog := &models.HisOrderError{
  1045. UserOrgId: adminUser.CurrentOrgId,
  1046. Ctime: time.Now().Unix(),
  1047. Mtime: time.Now().Unix(),
  1048. Number: chrg_bchno,
  1049. ErrMsg: res.Transreturnmessage,
  1050. Status: 1,
  1051. PatientId: patient_id,
  1052. RecordTime: recordDateTime,
  1053. Stage: 6,
  1054. }
  1055. service.CreateErrMsgLog(errlog)
  1056. c.ServeSuccessJSON(map[string]interface{}{
  1057. "failed_code": -10,
  1058. "msg": res.Transreturnmessage,
  1059. })
  1060. }
  1061. } else {
  1062. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  1063. return
  1064. }
  1065. } else {
  1066. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  1067. return
  1068. }
  1069. } else {
  1070. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePreSettleFaildParamWrong)
  1071. return
  1072. }
  1073. }
  1074. //结算
  1075. //func (c *SZHisApiController) GetSettleInfo() {
  1076. // patient_id, _ := c.GetInt64("id")
  1077. // order_id, _ := c.GetInt64("order_id")
  1078. // record_time := c.GetString("record_time")
  1079. // pay_way, _ := c.GetInt64("pay_way")
  1080. // pay_price, _ := c.GetFloat("pay_price")
  1081. // pay_card_no := c.GetString("pay_card_no")
  1082. // discount_price, _ := c.GetFloat("discount_price")
  1083. // preferential_price, _ := c.GetFloat("preferential_price")
  1084. // reality_price, _ := c.GetFloat("reality_price")
  1085. // found_price, _ := c.GetFloat("found_price")
  1086. // medical_insurance_price, _ := c.GetFloat("medical_insurance_price")
  1087. // private_price, _ := c.GetFloat("private_price")
  1088. // settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  1089. // admin_user_id, _ := c.GetInt64("admin_user_id")
  1090. //
  1091. // timeLayout := "2006-01-02"
  1092. // loc, _ := time.LoadLocation("Local")
  1093. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  1094. // if err != nil {
  1095. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1096. // return
  1097. // }
  1098. // recordDateTime := theTime.Unix()
  1099. // adminUser := c.GetAdminUserInfo()
  1100. //
  1101. // var prescriptions []*models.HisPrescription
  1102. //
  1103. // data := make(map[string]interface{})
  1104. // if settle_accounts_type == 1 { //日结
  1105. // prescriptions, _ = service.GetHisPrescription(adminUser.CurrentOrgId, patient_id, recordDateTime)
  1106. // data["pre"] = prescriptions
  1107. //
  1108. // } else { //月结
  1109. // start_time_str := c.GetString("start_time")
  1110. // end_time_str := c.GetString("end_time")
  1111. // timeLayout := "2006-01-02"
  1112. // loc, _ := time.LoadLocation("Local")
  1113. // theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  1114. // if err != nil {
  1115. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1116. // return
  1117. // }
  1118. // recordStartTime := theStartTime.Unix()
  1119. // theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  1120. // if err != nil {
  1121. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1122. // return
  1123. // }
  1124. // recordEndTime := theEndTime.Unix()
  1125. // prescriptions, _ = service.GetMonthHisPrescription(adminUser.CurrentOrgId, patient_id, recordStartTime, recordEndTime)
  1126. // data["pre"] = prescriptions
  1127. //
  1128. // }
  1129. //
  1130. // roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  1131. // his, _ := service.GetVMHisPatientInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  1132. // miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  1133. // strconv.FormatInt(his.PatientId, 10)
  1134. //
  1135. // order_src, _ := service.GetHisOrderByID(order_id)
  1136. //
  1137. // if order_src.ID == 0 {
  1138. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  1139. // return
  1140. // }
  1141. //
  1142. // config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  1143. // if config.IsOpen == 1 { //对接了医保,走医保流程
  1144. // if order_src.OrderStatus != 2 {
  1145. // var total float64
  1146. // for _, item := range prescriptions {
  1147. // if item.Type == 1 { //药品
  1148. // for _, subItem := range item.HisDoctorAdviceInfo {
  1149. // total = total + (subItem.Price * subItem.PrescribingNumber)
  1150. // }
  1151. // }
  1152. // if item.Type == 2 { //项目
  1153. // for _, subItem := range item.HisPrescriptionProject {
  1154. // total = total + (subItem.Price * float64(subItem.Count))
  1155. // }
  1156. // }
  1157. // }
  1158. //
  1159. // for _, item := range prescriptions {
  1160. // for _, subItem := range item.HisAdditionalCharge {
  1161. // total = total + (subItem.Price * float64(subItem.Count))
  1162. // }
  1163. // }
  1164. //
  1165. // patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  1166. //
  1167. // adminRole_two, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  1168. //
  1169. // var drug_doctor string
  1170. // drug_doctor = adminRole_two.DoctorCode
  1171. // drug_doctor_name := adminRole_two.UserName
  1172. // //结算流程
  1173. // var doctor_name string
  1174. // var doctor_code string
  1175. // if roles.ID == 0 {
  1176. // doctor_name = "黄亦轩"
  1177. // doctor_code = "1010"
  1178. // } else {
  1179. // doctor_name = roles.UserName
  1180. // doctor_code = strconv.FormatInt(admin_user_id, 10)
  1181. // }
  1182. // number := order_src.OrgSetlNumber
  1183. // mz_number := his.Number
  1184. // verifyCode, version_code := ReadCardGetCode("FY005" + "|" + number + "|" + miConfig.Code)
  1185. //
  1186. // //verifyCode := "000000|707c35a62c2f0609d7b0a811649f3913"
  1187. // //version_code := "V0.3"
  1188. // yiliao_number, id_card_number, verifyCode, version_code, err, ret4 := ReadBasCardGetNumber("FY005" + "|" + number + "|" + miConfig.Code)
  1189. // yiliao_number := his.YiliaoNumber
  1190. // result_three := service.SzybFY005(doctor_name, doctor_code, miConfig.Code, total, yiliao_number, verifyCode, number, mz_number, version_code, drug_doctor, drug_doctor_name)
  1191. // var dat map[string]interface{}
  1192. // if err := json.Unmarshal([]byte(result_three), &dat); err == nil {
  1193. // fmt.Println(dat)
  1194. // } else {
  1195. // fmt.Println(err)
  1196. // }
  1197. // userJSONBytes, _ := json.Marshal(dat)
  1198. // var res ResultTwo
  1199. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  1200. // utils.ErrorLog("解析失败:%v", err)
  1201. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1202. // return
  1203. // }
  1204. //
  1205. // if res.Transreturncode == "00000000" {
  1206. // order_src.OrderStatus = 2
  1207. // order_src.PayWay = pay_way
  1208. // order_src.PayPrice = pay_price
  1209. // order_src.PayCardNo = pay_card_no
  1210. // order_src.DiscountPrice = discount_price
  1211. // order_src.PreferentialPrice = preferential_price
  1212. // order_src.RealityPrice = reality_price
  1213. // order_src.FoundPrice = found_price
  1214. // order_src.MedicalInsurancePrice = medical_insurance_price
  1215. // order_src.PrivatePrice = private_price
  1216. // order_src.Creator = order_src.Creator
  1217. // order_src.Modify = roles.ID
  1218. // order_src.MedfeeSumamt = res.Transbody.Akc264
  1219. // order_src.SetlId = res.Transbody.Ckc618
  1220. // order_src.FundPaySumamt = res.Transbody.Akb068
  1221. // order_src.AcctPay = res.Transbody.Akb066
  1222. // order_src.PsnCashPay = res.Transbody.Akb067
  1223. // order_src.PsnPartAmt = res.Transbody.Akb067
  1224. // order_src.AccountPrice = res.Transbody.Aae240
  1225. // order_src.MzNumber = mz_number
  1226. // order_src.YiliaoNumber = yiliao_number
  1227. // setlDetailOne, _ := json.Marshal(res.Transbody.Outputlist1)
  1228. // detailStrOne := string(setlDetailOne)
  1229. // order_src.SzChargeInfo = detailStrOne
  1230. // setlDetailTwo, _ := json.Marshal(res.Transbody.Outputlist2)
  1231. // detailStrTwo := string(setlDetailTwo)
  1232. // order_src.SzProjectInfo = detailStrTwo
  1233. // setlDetailThree, _ := json.Marshal(res.Transbody.Outputlist3)
  1234. // detailStrThree := string(setlDetailThree)
  1235. // order_src.SzMedicineInsuranceInfo = detailStrThree
  1236. // order_src.Cainfo = result_three
  1237. //
  1238. // err = service.UpdataOrderStatusTwo(order_src.Number, adminUser.CurrentOrgId)
  1239. // err = service.UpDateOrder(order_src)
  1240. //
  1241. // c.ServeSuccessJSON(map[string]interface{}{
  1242. // "msg": "结算成功",
  1243. // })
  1244. // } else {
  1245. // //version_code := "0.03"
  1246. // c.ServeSuccessJSON(map[string]interface{}{
  1247. // "failed_code": -10,
  1248. // "msg": res.Transreturnmessage,
  1249. // })
  1250. //
  1251. // }
  1252. // } else {
  1253. //
  1254. // //错误提示
  1255. //
  1256. // }
  1257. // } else {
  1258. // //错误提示
  1259. //
  1260. // }
  1261. //}
  1262. //当月退费
  1263. func (c *SZHisApiController) Refund() {
  1264. order_id, _ := c.GetInt64("order_id")
  1265. record_time := c.GetString("record_time")
  1266. patient_id, _ := c.GetInt64("patient_id")
  1267. admin_user_id, _ := c.GetInt64("admin_user_id")
  1268. timeLayout := "2006-01-02"
  1269. loc, _ := time.LoadLocation("Local")
  1270. adminUser := c.GetAdminUserInfo()
  1271. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  1272. fmt.Println(err)
  1273. if err != nil {
  1274. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1275. return
  1276. }
  1277. recordDateTime := theTime.Unix()
  1278. fmt.Println(recordDateTime)
  1279. var order models.HisOrder
  1280. order, _ = service.GetHisOrderByID(order_id)
  1281. if order.ID == 0 {
  1282. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  1283. return
  1284. }
  1285. his, _ := service.GetHisPatientInfo(adminUser.CurrentOrgId, patient_id, theTime.Unix())
  1286. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  1287. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  1288. //结算流程
  1289. var doctor_name string
  1290. var doctor_code string
  1291. if roles.ID == 0 {
  1292. doctor_name = "黄亦轩"
  1293. doctor_code = "1001"
  1294. } else {
  1295. doctor_name = roles.UserName
  1296. doctor_code = strconv.FormatInt(admin_user_id, 10)
  1297. }
  1298. month := time.Unix(1557042972, 0).Format("1")
  1299. year := time.Now().Format("2006")
  1300. month = time.Now().Format("01")
  1301. day := time.Now().Format("02")
  1302. //number := miConfig.Code + year + month + day + "1367866"
  1303. number := miConfig.Code + year + month + day +
  1304. fmt.Sprintf("%07v", rand.New(rand.NewSource(time.Now().UnixNano())).Int31n(10000000)) // 定点协议机构编码(5位)+日期(8位)+流水号(7位)
  1305. //number := miConfig.Code + year + month + day + "1590003"
  1306. //流水号
  1307. //number_two := miConfig.Code + "-" + year + month + day + "-" + strconv.FormatInt(patient_id, 10)
  1308. verifyCode, version_code := ReadCardGetCode("JY002" + "|" + number + "|" + miConfig.Code)
  1309. //version_code := "V0.3"
  1310. //
  1311. //verifyCode := "000000|9972fca7ba9471c7dbe08324b2e31f70"
  1312. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  1313. if config.IsOpen == 1 { //对接了医保,走医保流程
  1314. result := service.SzybJY002(doctor_name, doctor_code, miConfig.Code, order.OrgSetlNumber, order.MzNumber, verifyCode, number, version_code)
  1315. fmt.Println(result)
  1316. var dat map[string]interface{}
  1317. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  1318. fmt.Println(dat)
  1319. } else {
  1320. fmt.Println(err)
  1321. }
  1322. userJSONBytes, _ := json.Marshal(dat)
  1323. var res ResultThree
  1324. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  1325. utils.ErrorLog("解析失败:%v", err)
  1326. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1327. return
  1328. }
  1329. if res.Transreturncode == "00000000" {
  1330. service.UpdataOrderlog(order_id, adminUser.CurrentOrgId, result)
  1331. service.UpdataOrderStatusSZ(order_id, order.Number, adminUser.CurrentOrgId, his.MzNumber, his.Number)
  1332. c.ServeSuccessJSON(map[string]interface{}{
  1333. "msg": "退费成功",
  1334. })
  1335. } else {
  1336. c.ServeSuccessJSON(map[string]interface{}{
  1337. "failed_code": -10,
  1338. "msg": res.Transreturnmessage,
  1339. })
  1340. }
  1341. }
  1342. }
  1343. //跨月退费
  1344. func (c *SZHisApiController) MonthRefund() {
  1345. order_id, _ := c.GetInt64("order_id")
  1346. record_time := c.GetString("record_time")
  1347. patient_id, _ := c.GetInt64("patient_id")
  1348. admin_user_id, _ := c.GetInt64("admin_user_id")
  1349. timeLayout := "2006-01-02"
  1350. loc, _ := time.LoadLocation("Local")
  1351. adminUser := c.GetAdminUserInfo()
  1352. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  1353. fmt.Println(err)
  1354. if err != nil {
  1355. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1356. return
  1357. }
  1358. recordDateTime := theTime.Unix()
  1359. var order models.HisOrder
  1360. order, _ = service.GetHisOrderByID(order_id)
  1361. if order.ID == 0 {
  1362. order, _ = service.GetHisOrderThree(recordDateTime, patient_id, adminUser.CurrentOrgId)
  1363. }
  1364. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  1365. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  1366. //结算流程
  1367. var doctor_name string
  1368. var doctor_code string
  1369. if roles.ID == 0 {
  1370. doctor_name = "黄亦轩"
  1371. doctor_code = "1001"
  1372. } else {
  1373. doctor_name = roles.UserName
  1374. doctor_code = strconv.FormatInt(admin_user_id, 10)
  1375. }
  1376. month := time.Unix(1557042972, 0).Format("1")
  1377. year := time.Now().Format("2006")
  1378. month = time.Now().Format("01")
  1379. day := time.Now().Format("02")
  1380. //流水号
  1381. number_two := miConfig.Code + "-" + year + month + day + "-" + strconv.FormatInt(patient_id, 10)
  1382. //verifyCode,version_code := ReadCardGetCode("JY002" + "|" + number_two + "|" + miConfig.Code)
  1383. version_code := "0.03"
  1384. fmt.Println(number_two)
  1385. verifyCode := "000000|0872038667cc34efdc35ce4668589a5f"
  1386. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  1387. if config.IsOpen == 1 { //对接了医保,走医保流程
  1388. result := service.SzybJY003(doctor_name, doctor_code, miConfig.Code, order.OrgSetlNumber, order.MzNumber, verifyCode, version_code)
  1389. fmt.Println(result)
  1390. var dat map[string]interface{}
  1391. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  1392. fmt.Println(dat)
  1393. } else {
  1394. fmt.Println(err)
  1395. }
  1396. userJSONBytes, _ := json.Marshal(dat)
  1397. var res ResultThree
  1398. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  1399. utils.ErrorLog("解析失败:%v", err)
  1400. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1401. return
  1402. }
  1403. if res.Transreturncode == "00000000" {
  1404. c.ServeSuccessJSON(map[string]interface{}{
  1405. "msg": "退费成功",
  1406. })
  1407. } else {
  1408. }
  1409. }
  1410. }
  1411. //查询
  1412. func (c *SZHisApiController) GetSettleAccounts() {
  1413. order_id, _ := c.GetInt64("order_id")
  1414. record_time := c.GetString("record_time")
  1415. patient_id, _ := c.GetInt64("patient_id")
  1416. admin_user_id, _ := c.GetInt64("admin_user_id")
  1417. timeLayout := "2006-01-02"
  1418. loc, _ := time.LoadLocation("Local")
  1419. adminUser := c.GetAdminUserInfo()
  1420. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  1421. fmt.Println(err)
  1422. if err != nil {
  1423. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1424. return
  1425. }
  1426. recordDateTime := theTime.Unix()
  1427. var order models.HisOrder
  1428. order, _ = service.GetHisOrderByID(order_id)
  1429. if order.ID == 0 {
  1430. order, _ = service.GetHisOrderThree(recordDateTime, patient_id, adminUser.CurrentOrgId)
  1431. }
  1432. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  1433. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  1434. //结算流程
  1435. var doctor_name string
  1436. var doctor_code string
  1437. if roles.ID == 0 {
  1438. doctor_name = "黄亦轩"
  1439. doctor_code = "1001"
  1440. } else {
  1441. doctor_name = roles.UserName
  1442. doctor_code = strconv.FormatInt(admin_user_id, 10)
  1443. }
  1444. //month := time.Unix(1557042972, 0).Format("1")
  1445. //year := time.Now().Format("2006")
  1446. //month = time.Now().Format("01")
  1447. //day := time.Now().Format("02")
  1448. //流水号
  1449. //number_two := miConfig.Code + "-" + year + month + day + "-" + strconv.FormatInt(patient_id, 10)
  1450. //fmt.Println(number_two)
  1451. verifyCode, version_code := ReadCardGetCode("JY001" + "|" + order.OrgSetlNumber + "|" + miConfig.Code)
  1452. //version_code := "V0.3"
  1453. //verifyCode := "000000|2c9854287e7c3cbc34439ab8e5157816"
  1454. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  1455. if config.IsOpen == 1 { //对接了医保,走医保流程
  1456. result := service.SzybJY001(doctor_name, doctor_code, miConfig.Code, order.OrgSetlNumber, order.MzNumber, verifyCode, version_code)
  1457. fmt.Println(result)
  1458. var dat map[string]interface{}
  1459. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  1460. fmt.Println(dat)
  1461. } else {
  1462. fmt.Println(err)
  1463. }
  1464. userJSONBytes, _ := json.Marshal(dat)
  1465. var res ResultFour
  1466. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  1467. utils.ErrorLog("解析失败:%v", err)
  1468. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1469. return
  1470. }
  1471. if res.Transreturncode == "00000000" {
  1472. c.ServeSuccessJSON(map[string]interface{}{
  1473. "result": res,
  1474. })
  1475. } else {
  1476. c.ServeSuccessJSON(map[string]interface{}{
  1477. "failed_code": -10,
  1478. "msg": res.Transreturnmessage,
  1479. })
  1480. }
  1481. }
  1482. }
  1483. //费用录入取消
  1484. func (c *SZHisApiController) CancelOrderDetail() {
  1485. order_id, _ := c.GetInt64("order_id")
  1486. record_time := c.GetString("record_time")
  1487. patient_id, _ := c.GetInt64("patient_id")
  1488. admin_user_id, _ := c.GetInt64("admin_user_id")
  1489. timeLayout := "2006-01-02"
  1490. loc, _ := time.LoadLocation("Local")
  1491. adminUser := c.GetAdminUserInfo()
  1492. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  1493. fmt.Println(err)
  1494. if err != nil {
  1495. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1496. return
  1497. }
  1498. recordDateTime := theTime.Unix()
  1499. var order models.HisOrder
  1500. order, _ = service.GetHisOrderByID(order_id)
  1501. if order.ID == 0 {
  1502. order, _ = service.GetHisOrderThree(recordDateTime, patient_id, adminUser.CurrentOrgId)
  1503. }
  1504. order_infos, _ := service.GetHisOrderInfoByNumber(order.Number)
  1505. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  1506. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  1507. //结算流程
  1508. var doctor_name string
  1509. var doctor_code string
  1510. if roles.ID == 0 {
  1511. doctor_name = "黄亦轩"
  1512. doctor_code = "1001"
  1513. } else {
  1514. doctor_name = roles.UserName
  1515. doctor_code = strconv.FormatInt(admin_user_id, 10)
  1516. }
  1517. var customs []*models.CustomDetail
  1518. for _, item := range order_infos {
  1519. cus := &models.CustomDetail{
  1520. PrescriptionNumber: item.OrderNumber,
  1521. ChargeSerialNumber: item.FeedetlSn,
  1522. }
  1523. customs = append(customs, cus)
  1524. }
  1525. his, _ := service.GetHisPatientInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  1526. verifyCode, version_code := ReadCardGetCode("FY002" + "|" + order.OrgSetlNumber + "|" + miConfig.Code)
  1527. var pagesize int = 50
  1528. var start int = 1
  1529. var stop int
  1530. var pagecount int
  1531. var curpage int
  1532. var isSuccess bool = true
  1533. var ress []*ResultFive
  1534. //总页数,向上取整,注意除之前要先转换类型为float64
  1535. pagecount = int(math.Ceil(float64(len(customs)) / float64(pagesize)))
  1536. for curpage = 1; curpage <= pagecount; curpage++ {
  1537. if curpage == 1 {
  1538. start = 1
  1539. } else {
  1540. start = (curpage-1)*pagesize + 1
  1541. }
  1542. stop = curpage * pagesize
  1543. if stop > len(customs) {
  1544. stop = len(customs)
  1545. }
  1546. result := service.SzybFY002(doctor_name, doctor_code, miConfig.Code, customs[start-1:stop], verifyCode, order.OrgSetlNumber, his.Number, version_code)
  1547. fmt.Println(result)
  1548. var dat map[string]interface{}
  1549. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  1550. fmt.Println(dat)
  1551. } else {
  1552. fmt.Println(err)
  1553. }
  1554. userJSONBytes, _ := json.Marshal(dat)
  1555. var res ResultFive
  1556. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  1557. utils.ErrorLog("解析失败:%v", err)
  1558. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1559. return
  1560. }
  1561. if res.Transreturncode == "00000000" {
  1562. ress = append(ress, &res)
  1563. } else {
  1564. isSuccess = false
  1565. //预结算报错
  1566. errlog := &models.HisOrderError{
  1567. UserOrgId: adminUser.CurrentOrgId,
  1568. Ctime: time.Now().Unix(),
  1569. Mtime: time.Now().Unix(),
  1570. ErrMsg: res.Transreturnmessage,
  1571. Status: 1,
  1572. PatientId: patient_id,
  1573. RecordTime: recordDateTime,
  1574. Stage: 11,
  1575. }
  1576. service.CreateErrMsgLog(errlog)
  1577. c.ServeSuccessJSON(map[string]interface{}{
  1578. "faild_code": -10,
  1579. "msg": res.Transreturnmessage,
  1580. })
  1581. return
  1582. }
  1583. }
  1584. if isSuccess == true {
  1585. service.UpdataOrderInfoStatus(order.ID, order.Number, adminUser.CurrentOrgId)
  1586. c.ServeSuccessJSON(map[string]interface{}{
  1587. "msg": "撤销成功",
  1588. })
  1589. }
  1590. }
  1591. //获取verifyCode
  1592. func ReadCardGetCode(request string) (string, string) {
  1593. request = request + "|"
  1594. DllDef2 := syscall.MustLoadDLL("SSCardDriver_SZ.dll")
  1595. readCards := DllDef2.MustFindProc("iVerifyCode")
  1596. str := request
  1597. str3 := make([]byte, 256)
  1598. ret4, _, _ := readCards.Call(StrPtr(str), (uintptr)(unsafe.Pointer(&str3[0])))
  1599. fmt.Println(":", string(str3))
  1600. fmt.Println(":", ConvertToString(string(str3), "gbk", "utf-8"))
  1601. if ret4 == 0 {
  1602. result := string(str3)
  1603. fmt.Println(result)
  1604. result_arr := strings.Split(result, "|")
  1605. verifyCode := result_arr[0] + "|" + result_arr[1]
  1606. versionCode := result_arr[2]
  1607. return verifyCode, versionCode
  1608. }
  1609. return "", ""
  1610. }
  1611. ////读卡
  1612. func ReadBasCardGetNumber(request string) (string, string, string, string, error, int64) {
  1613. DllDef2 := syscall.MustLoadDLL("SSCardDriver_SZ.dll")
  1614. readCards := DllDef2.MustFindProc("iReadCardBas")
  1615. str := request
  1616. str3 := make([]byte, 256)
  1617. ret4, _, err := readCards.Call(IntPtr(1), StrPtr(str), (uintptr)(unsafe.Pointer(&str3[0])))
  1618. fmt.Println(":", string(str3))
  1619. fmt.Println(":", ConvertToString(string(str3), "gbk", "utf-8"))
  1620. if ret4 == 0 {
  1621. result := string(str3)
  1622. fmt.Println(result)
  1623. result_arr := strings.Split(result, "|")
  1624. //医疗证号
  1625. yiliao_number := result_arr[12]
  1626. //根据业务的人员信息跟设备读社保卡获取的信息进行匹配,判断是否为同一个人,相同则进行挂号操作,不同则报错
  1627. id_card_number := result_arr[1]
  1628. verifyCode := result_arr[11] + result_arr[13]
  1629. versionCode := result_arr[14]
  1630. return yiliao_number, id_card_number, verifyCode, versionCode, err, 1
  1631. }
  1632. return "", "", "", "", err, 0
  1633. }
  1634. //
  1635. ////iReadCardBas_HSM_Step1 ---- 1903 iCardInnerAuthentication --- iReadCardBas_HSM_Step2
  1636. //func ReadCardBasHSM(number string) string {
  1637. // DllDef2 := syscall.MustLoadDLL("SSSE32.dll")
  1638. // readCards := DllDef2.MustFindProc("iReadCardBas_HSM_Step1")
  1639. // str := make([]byte, 256)
  1640. // ret, _, _ := readCards.Call(IntPtr(3), (uintptr)(unsafe.Pointer(&str[0])))
  1641. // fmt.Println(":", string(str))
  1642. //
  1643. // result_arr := strings.Split(string(str), "|")
  1644. //
  1645. // if ret == 0 {
  1646. // readCards := DllDef2.MustFindProc("iCardInnerAuthentication")
  1647. // str2 := make([]byte, 256)
  1648. // str3 := "" + "|" + "" + "|" + "440300" + "|" + "" + "|" + "" + "|" + result_arr[1] + "|" + result_arr[2] + "|" + result_arr[3] + "|" + result_arr[4] + "|" + result_arr[5] + "|" + "" + "|" + "" + "|"
  1649. // ret2, _, _ := readCards.Call(StrPtr(str3), (uintptr)(unsafe.Pointer(&str2[0])))
  1650. // fmt.Println(":", string(str2))
  1651. //
  1652. // if ret2 == 0 {
  1653. // result_arr := strings.Split(string(str2), "|")
  1654. //
  1655. // if result_arr[2] == "0" {
  1656. // readCards := DllDef2.MustFindProc("iReadCardBas_HSM_Step2")
  1657. // str4 := result_arr[4] + "|" + result_arr[5]
  1658. // str5 := make([]byte, 256)
  1659. // ret3, _, _ := readCards.Call(StrPtr(str4), StrPtr(number), (uintptr)(unsafe.Pointer(&str5[0])))
  1660. //
  1661. // if ret3 == 0 {
  1662. // return string(str5)
  1663. //
  1664. // } else {
  1665. // return ""
  1666. // }
  1667. // } else {
  1668. // return ""
  1669. // }
  1670. // }
  1671. // return ""
  1672. // }
  1673. // return ""
  1674. //
  1675. //}
  1676. //
  1677. ////1904卡鉴权
  1678. //func CardAuth(request string) string {
  1679. // DllDef2 := syscall.MustLoadDLL("SSSE32.dll")
  1680. // readCards := DllDef2.MustFindProc("iCardAuthentication")
  1681. // str := request
  1682. // str3 := make([]byte, 256)
  1683. // ret4, _, _ := readCards.Call(StrPtr(str), (uintptr)(unsafe.Pointer(&str3[0])))
  1684. // fmt.Println(":", string(str3))
  1685. //
  1686. // if ret4 == 0 {
  1687. // return string(str3)
  1688. // }
  1689. // return ""
  1690. //}
  1691. //func (c *SZHisApiController) GetDrugList() {
  1692. //
  1693. // adminUserInfo := c.GetAdminUserInfo()
  1694. // orgId := adminUserInfo.CurrentOrgId
  1695. // fmt.Println(orgId)
  1696. // //获取药品库数据
  1697. // list, _ := service.GetDrugList(orgId)
  1698. // //获取药品剂型
  1699. // drugs, _ := service.GetDrugDosageForm(orgId)
  1700. // for _, item := range list {
  1701. // fmt.Println(item.DrugDosageForm)
  1702. // for _, it := range drugs {
  1703. //
  1704. // if item.DrugDosageForm == it.Value {
  1705. // item.DrugDosageName = it.Name
  1706. // }
  1707. // }
  1708. // }
  1709. // fmt.Print("长度", len(list))
  1710. // miConfig, _ := service.FindMedicalInsuranceInfo(orgId)
  1711. // var doctor_name string
  1712. // var doctor_code string
  1713. //
  1714. // doctor_name = "黄亦轩"
  1715. // doctor_code = "1001"
  1716. //
  1717. // var pagesize int = 50
  1718. // var start int = 1
  1719. // var stop int
  1720. // var pagecount int
  1721. // var curpage int
  1722. // var isSuccess bool = true
  1723. // //总页数,向上取整,注意除之前要先转换类型为float64
  1724. // pagecount = int(math.Ceil(float64(len(list)) / float64(pagesize)))
  1725. // fmt.Println("pageCount22222", pagecount)
  1726. // var ress []*Result
  1727. // for curpage = 1; curpage <= pagecount; curpage++ {
  1728. // if curpage == 1 {
  1729. // start = 1
  1730. // } else {
  1731. // start = (curpage-1)*pagesize + 1
  1732. // }
  1733. // stop = curpage * pagesize
  1734. // if stop > len(list) {
  1735. // stop = len(list)
  1736. // }
  1737. // //这里就可以查看开始和结束了
  1738. // var customs []*models.DrugDetail
  1739. // for _, item := range list {
  1740. //
  1741. // detail := &models.DrugDetail{
  1742. //
  1743. // MedicalInsuranceNumber: item.MedicalInsuranceNumber,
  1744. // Code: item.Code,
  1745. // DrugName: item.DrugName,
  1746. // DrugSpec: item.DrugSpec,
  1747. // DrugDosageName: item.DrugDosageName,
  1748. // ManufacturerName: item.ManufacturerName,
  1749. // MinUnit: item.MinUnit,
  1750. // RetailPrice: item.RetailPrice,
  1751. // LastPrice: item.LastPrice,
  1752. // LimitRemark: item.LimitRemark,
  1753. // }
  1754. // customs = append(customs, detail)
  1755. // }
  1756. //
  1757. // result := service.SzybML008(doctor_name, doctor_code, miConfig.Code, customs[start-1:stop])
  1758. // fmt.Println("reuslt9999999999999", result)
  1759. //
  1760. // var dat map[string]interface{}
  1761. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  1762. // //fmt.Println(dat)
  1763. // } else {
  1764. // //fmt.Println(err)
  1765. // }
  1766. //
  1767. // userJSONBytes, _ := json.Marshal(dat)
  1768. //
  1769. // var res Result
  1770. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  1771. // utils.ErrorLog("解析失败:%v", err)
  1772. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1773. // return
  1774. // }
  1775. // if res.Transreturncode == "00000000" {
  1776. // ress = append(ress, &res)
  1777. // } else {
  1778. // isSuccess = false
  1779. // //失败
  1780. //
  1781. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorDrugPreSettleFaildParamWrong)
  1782. // return
  1783. // }
  1784. // fmt.Println(isSuccess)
  1785. // }
  1786. //}
  1787. //func (c *SZHisApiController) GetTreatmentProject() {
  1788. // fmt.Println("触发了吗2222222222")
  1789. // adminUserInfo := c.GetAdminUserInfo()
  1790. // orgId := adminUserInfo.CurrentOrgId
  1791. //
  1792. // //获取药品库数据
  1793. // list, _ := service.GetMyPorjecgList(orgId)
  1794. //
  1795. // miConfig, _ := service.FindMedicalInsuranceInfo(orgId)
  1796. // var doctor_name string
  1797. // var doctor_code string
  1798. //
  1799. // doctor_name = "黄亦轩"
  1800. // doctor_code = "1001"
  1801. //
  1802. // var pagesize int = 50
  1803. // var start int = 1
  1804. // var stop int
  1805. // var pagecount int
  1806. // var curpage int
  1807. // var isSuccess bool = true
  1808. // //总页数,向上取整,注意除之前要先转换类型为float64
  1809. // pagecount = int(math.Ceil(float64(len(list)) / float64(pagesize)))
  1810. //
  1811. // var ress []*Result
  1812. // for curpage = 1; curpage <= pagecount; curpage++ {
  1813. // if curpage == 1 {
  1814. // start = 1
  1815. // } else {
  1816. // start = (curpage-1)*pagesize + 1
  1817. // }
  1818. // stop = curpage * pagesize
  1819. // if stop > len(list) {
  1820. // stop = len(list)
  1821. // }
  1822. // //这里就可以查看开始和结束了
  1823. // fmt.Println(list[start-1 : stop])
  1824. // var customs []*models.ProjectDetail
  1825. // for _, item := range list {
  1826. //
  1827. // detail := &models.ProjectDetail{
  1828. //
  1829. // SocialSecurityDirectoryCode: item.MedicalCode, //社保目录
  1830. // ProjectName: item.ProjectName,
  1831. // Price: item.Price,
  1832. // Category: strconv.FormatInt(item.Category, 10),
  1833. // Remark: item.Remark,
  1834. // }
  1835. // customs = append(customs, detail)
  1836. // }
  1837. // result := service.SzybML009(doctor_name, doctor_code, miConfig.Code, customs)
  1838. // fmt.Println("reuslt9999999999999999", result)
  1839. // var dat map[string]interface{}
  1840. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  1841. // fmt.Println(dat)
  1842. // } else {
  1843. // fmt.Println(err)
  1844. // }
  1845. //
  1846. // userJSONBytes, _ := json.Marshal(dat)
  1847. //
  1848. // var res Result
  1849. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  1850. // utils.ErrorLog("解析失败:%v", err)
  1851. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1852. // return
  1853. // }
  1854. // if res.Transreturncode == "00000000" {
  1855. // ress = append(ress, &res)
  1856. // } else {
  1857. // isSuccess = false
  1858. // //失败
  1859. //
  1860. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorDrugPreSettleFaildParamWrong)
  1861. // return
  1862. // }
  1863. // fmt.Println(isSuccess)
  1864. // }
  1865. //}
  1866. func (c *SZHisApiController) GetRevocation() {
  1867. adminUserInfo := c.GetAdminUserInfo()
  1868. orgId := adminUserInfo.CurrentOrgId
  1869. id, _ := c.GetInt64("id")
  1870. //用来区分是药品的撤销还是耗材的撤销 1.药品 2.诊疗项目 3.材料 5.辅助器具项目
  1871. type_id, _ := c.GetInt64("type_id")
  1872. fmt.Println("type_id2222222", type_id)
  1873. if type_id == 1 {
  1874. //获取药品库数据
  1875. list, _ := service.GetDrugListByDetail(orgId, id)
  1876. miConfig, _ := service.FindMedicalInsuranceInfo(orgId)
  1877. var doctor_name string
  1878. var doctor_code string
  1879. doctor_name = "黄亦轩"
  1880. doctor_code = "1001"
  1881. var pagesize int = 50
  1882. var start int = 1
  1883. var stop int
  1884. var pagecount int
  1885. var curpage int
  1886. var isSuccess bool = true
  1887. //总页数,向上取整,注意除之前要先转换类型为float64
  1888. pagecount = int(math.Ceil(float64(len(list)) / float64(pagesize)))
  1889. var ress []*Result
  1890. for curpage = 1; curpage <= pagecount; curpage++ {
  1891. if curpage == 1 {
  1892. start = 1
  1893. } else {
  1894. start = (curpage-1)*pagesize + 1
  1895. }
  1896. stop = curpage * pagesize
  1897. if stop > len(list) {
  1898. stop = len(list)
  1899. }
  1900. //这里就可以查看开始和结束了
  1901. fmt.Println(list[start-1 : stop])
  1902. var customs []*models.DrugDetail
  1903. for _, item := range list {
  1904. fmt.Println("医疗机构编码", item.MedicalInsuranceNumber)
  1905. detail := &models.DrugDetail{
  1906. MedicalInsuranceNumber: item.MedicalInsuranceNumber, //社保目录
  1907. Code: item.Code, //协议机构内部目录编码
  1908. DrugName: item.DrugName, //协议机构内部目录名称
  1909. DrugSpec: item.DrugSpec,
  1910. ManufacturerName: item.ManufacturerName,
  1911. MinUnit: item.MinUnit,
  1912. RetailPrice: item.RetailPrice, //协议机构内部项目收费价格
  1913. LimitRemark: item.LimitRemark,
  1914. }
  1915. customs = append(customs, detail)
  1916. }
  1917. result := service.SzybML010(doctor_name, doctor_code, miConfig.Code, customs, type_id)
  1918. fmt.Println("reuslt", result)
  1919. var dat map[string]interface{}
  1920. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  1921. fmt.Println(dat)
  1922. } else {
  1923. fmt.Println(err)
  1924. }
  1925. userJSONBytes, _ := json.Marshal(dat)
  1926. var res Result
  1927. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  1928. utils.ErrorLog("解析失败:%v", err)
  1929. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1930. return
  1931. }
  1932. if res.Transreturncode == "00000000" {
  1933. ress = append(ress, &res)
  1934. } else {
  1935. isSuccess = false
  1936. //失败
  1937. c.ServeFailJSONWithSGJErrorCode(enums.ErrorDrugReturnFaildParamWrong)
  1938. return
  1939. }
  1940. fmt.Println(isSuccess)
  1941. }
  1942. if type_id == 2 {
  1943. //获取药品库数据
  1944. list, _ := service.GetMyPorjecgListDetail(orgId, id)
  1945. miConfig, _ := service.FindMedicalInsuranceInfo(orgId)
  1946. var doctor_name string
  1947. var doctor_code string
  1948. doctor_name = "黄亦轩"
  1949. doctor_code = "1001"
  1950. var pagesize int = 50
  1951. var start int = 1
  1952. var stop int
  1953. var pagecount int
  1954. var curpage int
  1955. var isSuccess bool = true
  1956. //总页数,向上取整,注意除之前要先转换类型为float64
  1957. pagecount = int(math.Ceil(float64(len(list)) / float64(pagesize)))
  1958. var ress []*Result
  1959. for curpage = 1; curpage <= pagecount; curpage++ {
  1960. if curpage == 1 {
  1961. start = 1
  1962. } else {
  1963. start = (curpage-1)*pagesize + 1
  1964. }
  1965. stop = curpage * pagesize
  1966. if stop > len(list) {
  1967. stop = len(list)
  1968. }
  1969. //这里就可以查看开始和结束了
  1970. fmt.Println(list[start-1 : stop])
  1971. var customs []*models.DrugDetail
  1972. for _, item := range list {
  1973. detail := &models.DrugDetail{
  1974. SocialSecurityDirectoryCode: item.MedicalCode,
  1975. }
  1976. customs = append(customs, detail)
  1977. }
  1978. result := service.SzybML010(doctor_name, doctor_code, miConfig.Code, customs, type_id)
  1979. fmt.Println("reuslt", result)
  1980. var dat map[string]interface{}
  1981. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  1982. fmt.Println(dat)
  1983. } else {
  1984. fmt.Println(err)
  1985. }
  1986. userJSONBytes, _ := json.Marshal(dat)
  1987. var res Result
  1988. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  1989. utils.ErrorLog("解析失败:%v", err)
  1990. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1991. return
  1992. }
  1993. if res.Transreturncode == "00000000" {
  1994. ress = append(ress, &res)
  1995. } else {
  1996. isSuccess = false
  1997. //失败
  1998. c.ServeFailJSONWithSGJErrorCode(enums.ErrorDrugReturnFaildParamWrong)
  1999. return
  2000. }
  2001. fmt.Println(isSuccess)
  2002. }
  2003. }
  2004. if type_id == 3 {
  2005. //获取药品库数据
  2006. list, _ := service.GetGoodListByDetail(orgId, id)
  2007. miConfig, _ := service.FindMedicalInsuranceInfo(orgId)
  2008. var doctor_name string
  2009. var doctor_code string
  2010. doctor_name = "黄亦轩"
  2011. doctor_code = "1001"
  2012. var pagesize int = 50
  2013. var start int = 1
  2014. var stop int
  2015. var pagecount int
  2016. var curpage int
  2017. var isSuccess bool = true
  2018. //总页数,向上取整,注意除之前要先转换类型为float64
  2019. pagecount = int(math.Ceil(float64(len(list)) / float64(pagesize)))
  2020. var ress []*Result
  2021. for curpage = 1; curpage <= pagecount; curpage++ {
  2022. if curpage == 1 {
  2023. start = 1
  2024. } else {
  2025. start = (curpage-1)*pagesize + 1
  2026. }
  2027. stop = curpage * pagesize
  2028. if stop > len(list) {
  2029. stop = len(list)
  2030. }
  2031. //这里就可以查看开始和结束了
  2032. fmt.Println(list[start-1 : stop])
  2033. var customs []*models.DrugDetail
  2034. for _, item := range list {
  2035. fmt.Println("医疗机构编码", item.MedicalInsuranceNumber)
  2036. detail := &models.DrugDetail{
  2037. SocialSecurityDirectoryCode: item.SocialSecurityDirectoryCode,
  2038. ManufacturerName: item.ManufacturerName,
  2039. }
  2040. customs = append(customs, detail)
  2041. }
  2042. result := service.SzybML010(doctor_name, doctor_code, miConfig.Code, customs, type_id)
  2043. fmt.Println("reuslt", result)
  2044. var dat map[string]interface{}
  2045. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  2046. fmt.Println(dat)
  2047. } else {
  2048. fmt.Println(err)
  2049. }
  2050. userJSONBytes, _ := json.Marshal(dat)
  2051. var res Result
  2052. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  2053. utils.ErrorLog("解析失败:%v", err)
  2054. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2055. return
  2056. }
  2057. if res.Transreturncode == "00000000" {
  2058. ress = append(ress, &res)
  2059. } else {
  2060. isSuccess = false
  2061. //失败
  2062. c.ServeFailJSONWithSGJErrorCode(enums.ErrorDrugReturnFaildParamWrong)
  2063. return
  2064. }
  2065. fmt.Println(isSuccess)
  2066. }
  2067. }
  2068. }
  2069. //func (c *SZHisApiController) GetInformationQuery() {
  2070. //
  2071. // var doctor_name string
  2072. // var doctor_code string
  2073. //
  2074. // doctor_name = "黄亦轩"
  2075. // doctor_code = "1001"
  2076. // miConfig, _ := service.FindMedicalInsuranceInfo(10028)
  2077. // result := service.SzybML010(doctor_name, doctor_code, miConfig.Code, customs)
  2078. // fmt.Println("reuslt9999999999999999", result)
  2079. // var dat map[string]interface{}
  2080. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  2081. // fmt.Println(dat)
  2082. // } else {
  2083. // fmt.Println(err)
  2084. // }
  2085. //
  2086. // userJSONBytes, _ := json.Marshal(dat)
  2087. //
  2088. // var res Result
  2089. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  2090. // utils.ErrorLog("解析失败:%v", err)
  2091. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2092. // return
  2093. // }
  2094. // if res.Transreturncode == "00000000" {
  2095. // ress = append(ress, &res)
  2096. // } else {
  2097. // isSuccess = false
  2098. // //失败
  2099. //
  2100. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePreSettleFaildParamWrong)
  2101. // return
  2102. // }
  2103. // fmt.Println(isSuccess)
  2104. //
  2105. //}
  2106. }
  2107. func (c *SZHisApiController) GetDoctorList() {
  2108. adminUserInfo := c.GetAdminUserInfo()
  2109. orgid := adminUserInfo.CurrentOrgId
  2110. fmt.Println("or3gi", orgid)
  2111. //获取所有医生护士信息
  2112. list, _ := service.GetDoctorList(9671)
  2113. //获取所有角色名称
  2114. roleList, _ := service.GetRoleList(9671)
  2115. miConfig, _ := service.FindMedicalInsuranceInfo(9671)
  2116. for _, item := range list {
  2117. for _, it := range roleList {
  2118. if item.RoleId == it.ID {
  2119. item.Name = it.RoleName
  2120. }
  2121. }
  2122. }
  2123. var doctor_name string
  2124. var doctor_code string
  2125. doctor_name = "黄亦轩"
  2126. doctor_code = "1001"
  2127. var pagesize int = 50
  2128. var start int = 1
  2129. var stop int
  2130. var pagecount int
  2131. var curpage int
  2132. var isSuccess bool = true
  2133. //总页数,向上取整,注意除之前要先转换类型为float64
  2134. pagecount = int(math.Ceil(float64(len(list)) / float64(pagesize)))
  2135. var ress []*Result
  2136. for curpage = 1; curpage <= pagecount; curpage++ {
  2137. if curpage == 1 {
  2138. start = 1
  2139. } else {
  2140. start = (curpage-1)*pagesize + 1
  2141. }
  2142. stop = curpage * pagesize
  2143. if stop > len(list) {
  2144. stop = len(list)
  2145. }
  2146. //这里就可以查看开始和结束了
  2147. fmt.Println(list[start-1 : stop])
  2148. var customs []*models.DocDetail
  2149. for _, item := range list {
  2150. fmt.Println("医护类别", item.Name)
  2151. sex := strconv.FormatInt(item.Sex, 10)
  2152. card_type := strconv.FormatInt(item.CardType, 10)
  2153. is_active := strconv.FormatInt(item.IsActive, 10)
  2154. detail := &models.DocDetail{
  2155. UserName: item.UserName,
  2156. RoleId: item.Name,
  2157. Sex: sex,
  2158. CardType: card_type,
  2159. IdCard: item.IdCard,
  2160. Phone: "",
  2161. WorkMajorName: item.WorkMajorName,
  2162. Nation: item.Nation,
  2163. BirthDay: 20201022,
  2164. WorkTime: 12,
  2165. Education: strconv.FormatInt(item.Education, 10),
  2166. StudyMajorName: item.StudyMajorName,
  2167. CertificateCode: "", //证书编码
  2168. MedicalCode: item.MedicalCode, //医师资格编码
  2169. MedicalRangeCode: strconv.FormatInt(item.MedicalRangeCode, 10), //医师执业范围代码
  2170. MedicalLevel: strconv.FormatInt(item.MedicalLevel, 10), //医生级别
  2171. TypeJob: strconv.FormatInt(item.DoctorTypeJob, 10), //职业类别
  2172. DoctorNumber: item.DoctorNumber, //医师编号
  2173. Licensing: strconv.FormatInt(item.Licensing, 10), //职业标志
  2174. DoctorServiceStatus: "", //医师医保服务资格状态
  2175. MonitoringLevel: "", //监控等级
  2176. DrugPsychotropicSubstances: "", //毒麻精神药品资格
  2177. HealthCareCode: "", // 母婴保健技术考核合格证书编号
  2178. PlanningTechnicalServiceCode: "", //计划生育技术服务人员合格证编号
  2179. PharmacistType: "", //药师类别
  2180. PharmacistPracticeCategory: "", //药师执业类别
  2181. PharmacistsLicensing: "", //药师执业范围
  2182. PharmacistRegistrationNumber: item.PharmacistRegistrationNumber, //执业药师注册证编号
  2183. OfficeCode: "", //科室编码
  2184. JobNumber: item.JobNumber, //工号
  2185. PostName: "", //职位名称
  2186. TechnicalJobLevelCode: "", //专业技术职务级别编码
  2187. IsActive: is_active, //在职与否
  2188. PrescriptionQualificationIdentification: item.PharmacistRegistrationNumber, //处方资格标识
  2189. IdentificationOutpatients: "", //门诊大病医师标识
  2190. OutpatientIllnessCategory: item.OutpatientIllnessCategory, //门诊大病类别
  2191. StartTime: 1233, //开始日期
  2192. }
  2193. customs = append(customs, detail)
  2194. }
  2195. result := service.SzybYS001(doctor_name, doctor_code, miConfig.Code, customs)
  2196. fmt.Println("reuslt9999999999999999", result)
  2197. var dat map[string]interface{}
  2198. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  2199. fmt.Println(dat)
  2200. } else {
  2201. fmt.Println(err)
  2202. }
  2203. userJSONBytes, _ := json.Marshal(dat)
  2204. var res Result
  2205. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  2206. utils.ErrorLog("解析失败:%v", err)
  2207. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2208. return
  2209. }
  2210. if res.Transreturncode == "00000000" {
  2211. ress = append(ress, &res)
  2212. } else {
  2213. isSuccess = false
  2214. //失败
  2215. c.ServeFailJSONWithSGJErrorCode(enums.ErrorDoctorLoginFaildParamWrong)
  2216. return
  2217. }
  2218. fmt.Println(isSuccess)
  2219. }
  2220. }
  2221. func (c *SZHisApiController) GetMedicalList() {
  2222. adminUserInfo := c.GetAdminUserInfo()
  2223. orgId := adminUserInfo.CurrentOrgId
  2224. id, _ := c.GetInt64("id")
  2225. fmt.Println("id22222222", id)
  2226. //获取所有医生护士信息
  2227. list, _ := service.GetDoctorListByDetail(orgId, id)
  2228. //获取所有角色名称
  2229. roleList, _ := service.GetRoleList(orgId)
  2230. miConfig, _ := service.FindMedicalInsuranceInfo(orgId)
  2231. for _, item := range list {
  2232. for _, it := range roleList {
  2233. if item.RoleId == it.ID {
  2234. item.Name = it.RoleName
  2235. }
  2236. }
  2237. }
  2238. var doctor_name string
  2239. var doctor_code string
  2240. doctor_name = "黄亦轩"
  2241. doctor_code = "1001"
  2242. var pagesize int = 50
  2243. var start int = 1
  2244. var stop int
  2245. var pagecount int
  2246. var curpage int
  2247. var isSuccess bool = true
  2248. //总页数,向上取整,注意除之前要先转换类型为float64
  2249. pagecount = int(math.Ceil(float64(len(list)) / float64(pagesize)))
  2250. var ress []*Result
  2251. for curpage = 1; curpage <= pagecount; curpage++ {
  2252. if curpage == 1 {
  2253. start = 1
  2254. } else {
  2255. start = (curpage-1)*pagesize + 1
  2256. }
  2257. stop = curpage * pagesize
  2258. if stop > len(list) {
  2259. stop = len(list)
  2260. }
  2261. //这里就可以查看开始和结束了
  2262. fmt.Println(list[start-1 : stop])
  2263. var customs []*models.DocDetail
  2264. for _, item := range list {
  2265. fmt.Println("医护类别", item.Name)
  2266. detail := &models.DocDetail{
  2267. StaffCode: "H27224269",
  2268. UserName: item.UserName,
  2269. RoleId: item.Name,
  2270. Sex: "1",
  2271. CardType: "01",
  2272. IdCard: "430526199408156511",
  2273. Phone: "13318464642",
  2274. WorkMajorName: "医生",
  2275. Nation: "01",
  2276. BirthDay: 20201022,
  2277. WorkTime: 20201022,
  2278. Education: "21",
  2279. StudyMajorName: "医生",
  2280. CertificateCode: "y2222222", //证书编码
  2281. MedicalCode: "y2222222", //医师资格编码
  2282. MedicalRangeCode: "101", //医师执业范围代码
  2283. MedicalLevel: "1", //医生级别
  2284. TypeJob: "1", //职业类别
  2285. DoctorNumber: "22222", //医师编号b
  2286. Licensing: "1", //职业标志
  2287. DoctorServiceStatus: "1", //医师医保服务资格状态
  2288. MonitoringLevel: "1", //监控等级
  2289. DrugPsychotropicSubstances: "1", //毒麻精神药品资格
  2290. HealthCareCode: "1001", // 母婴保健技术考核合格证书编号
  2291. PlanningTechnicalServiceCode: "1002", //计划生育技术服务人员合格证编号
  2292. PharmacistType: "1", //药师类别
  2293. PharmacistPracticeCategory: "1", //药师执业类别
  2294. PharmacistsLicensing: "1", //药师执业范围
  2295. PharmacistRegistrationNumber: "000200", //执业药师注册证编号
  2296. OfficeCode: "9933", //科室编码
  2297. JobNumber: "82021344", //工号
  2298. PostName: "主任", //职位名称
  2299. TechnicalJobLevelCode: "231", //专业技术职务级别编码
  2300. IsActive: "1", //在职与否
  2301. PrescriptionQualificationIdentification: "1", //处方资格标识
  2302. IdentificationOutpatients: "1", //门诊大病医师标识
  2303. OutpatientIllnessCategory: "血友病", //门诊大病类别
  2304. StartTime: 20210311, //开始日期
  2305. }
  2306. customs = append(customs, detail)
  2307. }
  2308. result := service.SzybYS002(doctor_name, doctor_code, miConfig.Code, customs)
  2309. fmt.Println("reuslt9999999999999999", result)
  2310. var dat map[string]interface{}
  2311. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  2312. fmt.Println(dat)
  2313. } else {
  2314. fmt.Println(err)
  2315. }
  2316. userJSONBytes, _ := json.Marshal(dat)
  2317. var res Result
  2318. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  2319. utils.ErrorLog("解析失败:%v", err)
  2320. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2321. return
  2322. }
  2323. if res.Transreturncode == "00000000" {
  2324. ress = append(ress, &res)
  2325. } else {
  2326. isSuccess = false
  2327. //失败
  2328. c.ServeFailJSONWithSGJErrorCode(enums.ErrorDrugReturnFaildParamWrong)
  2329. return
  2330. }
  2331. fmt.Println(isSuccess)
  2332. }
  2333. }
  2334. func (c *SZHisApiController) GetUpdateMedicalList() {
  2335. adminUserInfo := c.GetAdminUserInfo()
  2336. orgId := adminUserInfo.CurrentOrgId
  2337. //获取所有医生护士信息
  2338. list, _ := service.GetDoctorList(orgId)
  2339. //获取所有角色名称
  2340. roleList, _ := service.GetRoleList(orgId)
  2341. miConfig, _ := service.FindMedicalInsuranceInfo(orgId)
  2342. for _, item := range list {
  2343. for _, it := range roleList {
  2344. if item.RoleId == it.ID {
  2345. item.Name = it.RoleName
  2346. }
  2347. }
  2348. }
  2349. var doctor_name string
  2350. var doctor_code string
  2351. doctor_name = "黄亦轩"
  2352. doctor_code = "1001"
  2353. var pagesize int = 50
  2354. var start int = 1
  2355. var stop int
  2356. var pagecount int
  2357. var curpage int
  2358. var isSuccess bool = true
  2359. //总页数,向上取整,注意除之前要先转换类型为float64
  2360. pagecount = int(math.Ceil(float64(len(list)) / float64(pagesize)))
  2361. var ress []*Result
  2362. for curpage = 1; curpage <= pagecount; curpage++ {
  2363. if curpage == 1 {
  2364. start = 1
  2365. } else {
  2366. start = (curpage-1)*pagesize + 1
  2367. }
  2368. stop = curpage * pagesize
  2369. if stop > len(list) {
  2370. stop = len(list)
  2371. }
  2372. //这里就可以查看开始和结束了
  2373. fmt.Println(list[start-1 : stop])
  2374. var customs []*models.DocDetail
  2375. for _, item := range list {
  2376. fmt.Println("医护类别", item.Name)
  2377. detail := &models.DocDetail{
  2378. StaffCode: "", //医护人员编码
  2379. UserName: item.UserName, //医护人员姓名
  2380. RoleId: item.Name, //医护人员类别
  2381. Sex: "", //性别
  2382. CardType: "", //证件类型
  2383. IdCard: "", //证件号码
  2384. Phone: "", //联系电话
  2385. WorkMajorName: "", //现从事专业名称
  2386. Nation: "", //民族
  2387. BirthDay: 20201022, //出生日期
  2388. WorkTime: 12, //参加工作日期
  2389. Education: "", //学历
  2390. StudyMajorName: "", //所学的专业名称
  2391. CertificateCode: "", //证书编码
  2392. MedicalCode: "", //医师资格编码
  2393. MedicalRangeCode: "", //医师执业范围代码
  2394. MedicalLevel: "", //医生级别
  2395. TypeJob: "", //职业类别
  2396. DoctorNumber: "", //医师编号
  2397. Licensing: "", //职业标志
  2398. DoctorServiceStatus: "", //医师医保服务资格状态
  2399. MonitoringLevel: "", //监控等级
  2400. DrugPsychotropicSubstances: "", //毒麻精神药品资格
  2401. HealthCareCode: "", // 母婴保健技术考核合格证书编号
  2402. PlanningTechnicalServiceCode: "", //计划生育技术服务人员合格证编号
  2403. PharmacistType: "", //药师类别
  2404. PharmacistPracticeCategory: "", //药师执业类别
  2405. PharmacistsLicensing: "", //药师执业范围
  2406. PharmacistRegistrationNumber: "", //执业药师注册证编号
  2407. OfficeCode: "", //科室编码
  2408. JobNumber: "", //工号
  2409. PostName: "", //职位名称
  2410. TechnicalJobLevelCode: "", //专业技术职务级别编码
  2411. IsActive: "", //在职与否
  2412. PrescriptionQualificationIdentification: "", //处方资格标识
  2413. IdentificationOutpatients: "", //门诊大病医师标识
  2414. OutpatientIllnessCategory: "", //门诊大病类别
  2415. StartTime: 1233, //开始日期
  2416. EndTime: 123333,
  2417. }
  2418. customs = append(customs, detail)
  2419. }
  2420. result := service.SzybYS003(doctor_name, doctor_code, miConfig.Code, customs)
  2421. fmt.Println("reuslt9999999999999999", result)
  2422. var dat map[string]interface{}
  2423. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  2424. fmt.Println(dat)
  2425. } else {
  2426. fmt.Println(err)
  2427. }
  2428. userJSONBytes, _ := json.Marshal(dat)
  2429. var res Result
  2430. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  2431. utils.ErrorLog("解析失败:%v", err)
  2432. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2433. return
  2434. }
  2435. if res.Transreturncode == "00000000" {
  2436. ress = append(ress, &res)
  2437. } else {
  2438. isSuccess = false
  2439. //失败
  2440. c.ServeFailJSONWithSGJErrorCode(enums.ErrorDrugPreSettleFaildParamWrong)
  2441. return
  2442. }
  2443. fmt.Println(isSuccess)
  2444. }
  2445. }
  2446. //func (c *SZHisApiController) GetGoodsList() {
  2447. //
  2448. // adminUserInfo := c.GetAdminUserInfo()
  2449. // orgId := adminUserInfo.CurrentOrgId
  2450. // fmt.Println(orgId)
  2451. // //获取所有耗材信息
  2452. // list, _ := service.GetGoodInformationList(orgId)
  2453. // fmt.Println("list22222", list)
  2454. // //获取单位
  2455. // miConfig, _ := service.FindMedicalInsuranceInfo(orgId)
  2456. // var doctor_name string
  2457. // var doctor_code string
  2458. //
  2459. // doctor_name = "黄亦轩"
  2460. // doctor_code = "1001"
  2461. //
  2462. // var pagesize int = 50
  2463. // var start int = 1
  2464. // var stop int
  2465. // var pagecount int
  2466. // var curpage int
  2467. // var isSuccess bool = true
  2468. // //总页数,向上取整,注意除之前要先转换类型为float64
  2469. // pagecount = int(math.Ceil(float64(len(list)) / float64(pagesize)))
  2470. //
  2471. // var ress []*Result
  2472. // for curpage = 1; curpage <= pagecount; curpage++ {
  2473. // if curpage == 1 {
  2474. // start = 1
  2475. // } else {
  2476. // start = (curpage-1)*pagesize + 1
  2477. // }
  2478. // stop = curpage * pagesize
  2479. // if stop > len(list) {
  2480. // stop = len(list)
  2481. // }
  2482. // //这里就可以查看开始和结束了
  2483. // fmt.Println(list[start-1 : stop])
  2484. // var customs []*models.GoodDetail
  2485. // for _, item := range list {
  2486. //
  2487. // detail := &models.GoodDetail{
  2488. // GoodName: item.GoodName,
  2489. // SocialSecurityDirectoryCode: item.SocialSecurityDirectoryCode,
  2490. // ManufacturerName: item.ManufacturerName,
  2491. // ProductionType: item.ProductionType,
  2492. // SpecialMedical: item.SpecialMedical,
  2493. // BuyPrice: item.BuyPrice,
  2494. // SellPrice: item.SellPrice,
  2495. // Remark: item.Remark,
  2496. // }
  2497. // customs = append(customs, detail)
  2498. // }
  2499. //
  2500. // result := service.SzybYML007(doctor_name, doctor_code, miConfig.Code, customs[start-1:stop])
  2501. // fmt.Println("reuslt8888", result)
  2502. // var dat map[string]interface{}
  2503. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  2504. // fmt.Println(dat)
  2505. // } else {
  2506. // fmt.Println(err)
  2507. // }
  2508. //
  2509. // userJSONBytes, _ := json.Marshal(dat)
  2510. //
  2511. // var res Result
  2512. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  2513. // utils.ErrorLog("解析失败:%v", err)
  2514. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2515. // return
  2516. // }
  2517. // if res.Transreturncode == "00000000" {
  2518. // ress = append(ress, &res)
  2519. // } else {
  2520. // isSuccess = false
  2521. // //失败
  2522. //
  2523. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorDrugPreSettleFaildParamWrong)
  2524. // return
  2525. // }
  2526. // fmt.Println(isSuccess)
  2527. //
  2528. // }
  2529. //}
  2530. type Charset string
  2531. const (
  2532. UTF8 = Charset("UTF-8")
  2533. GB18030 = Charset("GB18030")
  2534. )
  2535. func ConvertToString(src string, srcCode string, tagCode string) string {
  2536. srcCoder := mahonia.NewDecoder(srcCode)
  2537. srcResult := srcCoder.ConvertString(src)
  2538. tagCoder := mahonia.NewDecoder(tagCode)
  2539. _, cdata, _ := tagCoder.Translate([]byte(srcResult), true)
  2540. result := string(cdata)
  2541. return result
  2542. }