sz_his_api_controller.go 65KB

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