sz_his_api_controller.go 92KB

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