sz_his_api_controller.go 77KB

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