his_api_controller.go 105KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018
  1. package controllers
  2. import (
  3. "XT_New/enums"
  4. "XT_New/models"
  5. "XT_New/service"
  6. "XT_New/utils"
  7. "bytes"
  8. "encoding/json"
  9. "fmt"
  10. "github.com/astaxie/beego"
  11. "github.com/jinzhu/gorm"
  12. "io/ioutil"
  13. "math/rand"
  14. "net/http"
  15. "reflect"
  16. "strconv"
  17. "strings"
  18. "syscall"
  19. "time"
  20. "unsafe"
  21. )
  22. type HisApiController struct {
  23. BaseAuthAPIController
  24. }
  25. func HisManagerApiRegistRouters() {
  26. beego.Router("/api/hispatient/list", &HisApiController{}, "get:GetHisPatientList")
  27. beego.Router("/api/hispatient/get", &HisApiController{}, "get:GetHisPatientInfo")
  28. beego.Router("/api/hisprescription/config", &HisApiController{}, "get:GetHisPrescriptionConfig")
  29. beego.Router("/api/hisprescription/delete", &HisApiController{}, "post:DeletePrescription")
  30. beego.Router("/api/advice/delete", &HisApiController{}, "post:DeleteDoctorAdvice")
  31. beego.Router("/api/project/delete", &HisApiController{}, "post:DeleteProject")
  32. beego.Router("/api/addition_charge/delete", &HisApiController{}, "post:DeleteAddition")
  33. beego.Router("/api/hisprescription/list", &HisApiController{}, "get:GetHisPrescriptionList")
  34. beego.Router("/api/hisprescription/info", &HisApiController{}, "get:GetHisPrescriptionInfo")
  35. beego.Router("/api/hisprescription/create", &HisApiController{}, "post:CreateHisPrescription")
  36. beego.Router("/api/hisprescription/edit", &HisApiController{}, "post:EditHisPrescription")
  37. beego.Router("/api/doctorworkstation/casehistory/list", &HisApiController{}, "get:GetHisPatientCaseHistoryList")
  38. beego.Router("/api/doctorworkstation/casehistory/get", &HisApiController{}, "get:GetHisPatientCaseHistory")
  39. beego.Router("/api/doctorworkstation/casehistory/create", &HisApiController{}, "get:CreateHisPatientCaseHistory")
  40. beego.Router("/api/doctorworkstation/casehistorytemplate/create", &HisApiController{}, "get:CreateCaseHistoryTemplate")
  41. beego.Router("/api/doctorworkstation/casehistorytemplate/get", &HisApiController{}, "get:GetCaseHistoryTemplate")
  42. beego.Router("/api/hisorder/list", &HisApiController{}, "get:GetHisOrderList")
  43. beego.Router("/api/hisorder/get", &HisApiController{}, "get:GetHisOrder")
  44. beego.Router("/api/register/get", &HisApiController{}, "get:GetRegisterInfo")
  45. beego.Router("/api/upload/get", &HisApiController{}, "get:GetUploadInfo")
  46. beego.Router("/api/refund/post", &HisApiController{}, "post:Refund")
  47. beego.Router("/api/medicalinsurance/config", &HisApiController{}, "get:GetMedicalInsuranceConfig")
  48. beego.Router("/api/doctor/list", &HisApiController{}, "get:GetAdminUsers")
  49. //beego.Router("/api/medicalinsurance/config", &HisApiController{}, "get:GetMedicalInsuranceConfig")
  50. //新增附加费用
  51. //beego.Router("/api/his/additionalcharge", &HisApiController{}, "Post:AdditionalCharge")
  52. //beego.Router("/api/additionalcharge/get", &HisApiController{}, "Get:GetAdditionalcharge")
  53. beego.Router("/api/hisprescription/get", &DialysisApiController{}, "Get:GetLastOrNextHisPrescription")
  54. beego.Router("/api/callhisprescription/get", &DialysisApiController{}, "Get:GetCallHisPrescription")
  55. beego.Router("/api/dayprescription/get", &HisApiController{}, "get:GetHisDayPrescription")
  56. beego.Router("/api/charge/list", &HisApiController{}, "get:GetHisChargePatientList")
  57. beego.Router("/api/unregister/list", &HisApiController{}, "get:GetHisUnRegisterPatientList")
  58. }
  59. func (c *HisApiController) Sscard() {
  60. //r := CardInit()
  61. //if r == 0 {
  62. // GetBaseInfo()
  63. //}
  64. //c.ServeSuccessJSON(map[string]interface{}{
  65. // "list": "11",
  66. //})
  67. }
  68. func GetBaseInfo() error {
  69. //handle := syscall.MustLoadDLL("SSCard.dll")
  70. //ReadCardBas := handle.MustFindProc("ReadCardBas")
  71. //
  72. //str := make([]byte, 256)
  73. //str1 := make([]byte, 256)
  74. //r, _, ferr := ReadCardBas.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(1024), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(1024))
  75. //if ferr != nil {
  76. // fmt.Println("ReadCardBas 报错", ferr.Error())
  77. // return ferr
  78. //}
  79. //
  80. //fmt.Println(string(str))
  81. //
  82. //fmt.Println(r)
  83. return nil
  84. }
  85. func CardInit() int {
  86. //DllTestDef := syscall.MustLoadDLL("SSCard.dll")
  87. //add := DllTestDef.MustFindProc("Init")
  88. //ret, _, err := add.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_inf/poc/api/card/initDll"), StrPtr("440200"))
  89. //if err != nil {
  90. // fmt.Println("SSCard的运算结果为:", ret)
  91. //}
  92. //result := int(ret)
  93. return 0
  94. }
  95. func IntPtr(n int) uintptr {
  96. return uintptr(n)
  97. }
  98. func StrPtr(s string) uintptr {
  99. return uintptr(unsafe.Pointer(syscall.StringBytePtr(s)))
  100. }
  101. func (c *HisApiController) GetHisPatientList() {
  102. types, _ := c.GetInt64("type", 0)
  103. record_date := c.GetString("record_date")
  104. timeLayout := "2006-01-02"
  105. loc, _ := time.LoadLocation("Local")
  106. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_date+" 00:00:00", loc)
  107. if err != nil {
  108. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  109. return
  110. }
  111. recordDateTime := theTime.Unix()
  112. adminInfo := c.GetAdminUserInfo()
  113. patients, _ := service.GetScheduleHisPatientList(adminInfo.CurrentOrgId, "", recordDateTime)
  114. patients_two, _ := service.GetHisPatientList(adminInfo.CurrentOrgId, "", recordDateTime)
  115. patients = append(patients, patients_two...)
  116. patients = RemoveRepeatedPatient(patients)
  117. var total_one int64
  118. var total_two int64
  119. //获取当前用户的信息
  120. adminUserInfo, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, adminInfo.AdminUser.Id)
  121. doctors, _ := service.GetHisAdminUserDoctors(adminInfo.CurrentOrgId)
  122. //获取所有科室信息
  123. department, _ := service.GetAllDepartMent(adminInfo.CurrentOrgId)
  124. for _, item := range patients {
  125. if item.HisPrescription == nil || len(item.HisPrescription) <= 0 {
  126. total_one = total_one + 1
  127. }
  128. if item.HisPrescription != nil && len(item.HisPrescription) > 0 {
  129. total_two = total_two + 1
  130. }
  131. }
  132. if types == 0 {
  133. c.ServeSuccessJSON(map[string]interface{}{
  134. "list": patients,
  135. "total_one": total_one,
  136. "total_two": total_two,
  137. "info": adminUserInfo,
  138. "doctors": doctors,
  139. "department": department,
  140. })
  141. } else if types == 1 { //未就诊
  142. var patientsOne []*service.Patients
  143. for _, item := range patients {
  144. if item.HisPrescription == nil || len(item.HisPrescription) <= 0 {
  145. patientsOne = append(patientsOne, item)
  146. }
  147. }
  148. c.ServeSuccessJSON(map[string]interface{}{
  149. "list": patientsOne,
  150. "total_one": total_one,
  151. "total_two": total_two,
  152. "info": adminUserInfo,
  153. "doctors": doctors,
  154. "department": department,
  155. })
  156. } else if types == 2 { //已就诊
  157. var patientsTwo []*service.Patients
  158. for _, item := range patients {
  159. if item.HisPrescription != nil && len(item.HisPrescription) > 0 {
  160. patientsTwo = append(patientsTwo, item)
  161. }
  162. }
  163. c.ServeSuccessJSON(map[string]interface{}{
  164. "list": patientsTwo,
  165. "total_one": total_one,
  166. "total_two": total_two,
  167. "info": adminUserInfo,
  168. "doctors": doctors,
  169. "department": department,
  170. })
  171. }
  172. }
  173. func (c *HisApiController) GetHisPatientInfo() {
  174. patient_id, _ := c.GetInt64("patient_id")
  175. record_date := c.GetString("record_date")
  176. number := c.GetString("number")
  177. start_time := c.GetString("start_time")
  178. end_time := c.GetString("end_time")
  179. timeLayout := "2006-01-02"
  180. loc, _ := time.LoadLocation("Local")
  181. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_date+" 00:00:00", loc)
  182. if err != nil {
  183. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  184. return
  185. }
  186. recordDateTime := theTime.Unix()
  187. startTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  188. if err != nil {
  189. }
  190. startRecordDateTime := startTime.Unix()
  191. endTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  192. if err != nil {
  193. }
  194. endRecordDateTime := endTime.Unix()
  195. admin := c.GetAdminUserInfo()
  196. his_patient_info, _ := service.GetHisPatientInfo(admin.CurrentOrgId, patient_id, recordDateTime)
  197. xt_patient_info, _ := service.GetXTPatientInfo(admin.CurrentOrgId, patient_id)
  198. prescriptions, _ := service.GetHisPrescription(admin.CurrentOrgId, patient_id, recordDateTime)
  199. monthPrescriptions, _ := service.GetMonthHisPrescription(admin.CurrentOrgId, patient_id, startRecordDateTime, endRecordDateTime)
  200. case_history, _ := service.GetHisPatientCaseHistoryInfo(admin.CurrentOrgId, patient_id, recordDateTime)
  201. patientPrescriptionInfo, _ := service.FindPatientPrescriptionInfo(admin.CurrentOrgId, patient_id, recordDateTime)
  202. order, _ := service.GetHisOrder(admin.CurrentOrgId, number, patient_id)
  203. doctors, _ := service.GetHisAdminUserDoctors(admin.CurrentOrgId)
  204. //获取所有科室信息
  205. department, _ := service.GetAllDepartMent(admin.CurrentOrgId)
  206. c.ServeSuccessJSON(map[string]interface{}{
  207. "his_info": his_patient_info,
  208. "xt_info": xt_patient_info,
  209. "prescription": prescriptions,
  210. "case_history": case_history,
  211. "info": patientPrescriptionInfo,
  212. "month_prescriptions": monthPrescriptions,
  213. "order": order,
  214. "doctors": doctors,
  215. "department": department,
  216. })
  217. return
  218. }
  219. func (c *HisApiController) GetHisPrescriptionConfig() {
  220. adminInfo := c.GetAdminUserInfo()
  221. //获取医嘱模版
  222. advices, _ := service.FindAllHisAdviceTemplate(adminInfo.CurrentOrgId)
  223. //获取所有基础药
  224. drugs, _ := service.GetAllDrugLibList(adminInfo.CurrentOrgId)
  225. drugways, _, _ := service.GetDrugWayDics(adminInfo.CurrentOrgId)
  226. efs, _, _ := service.GetExecutionFrequencyDics(adminInfo.CurrentOrgId)
  227. doctors, _ := service.GetHisAdminUserDoctors(adminInfo.CurrentOrgId)
  228. //获取所有科室信息
  229. department, _ := service.GetAllDepartMent(adminInfo.CurrentOrgId)
  230. //获取诊断信息
  231. sick, _ := service.FindAllSick(adminInfo.CurrentOrgId)
  232. diagnose, _ := service.FindAllDiagnose(adminInfo.CurrentOrgId)
  233. additions, _ := service.FindAllAddition(adminInfo.CurrentOrgId)
  234. c.ServeSuccessJSON(map[string]interface{}{
  235. "drugs": drugs,
  236. "advices_template": advices,
  237. "drugways": drugways,
  238. "efs": efs,
  239. "doctors": doctors,
  240. "department": department,
  241. "sick": sick,
  242. "additions": additions,
  243. "diagnose": diagnose,
  244. })
  245. }
  246. func (c *HisApiController) CreateHisPrescription() {
  247. record_date := c.GetString("record_date")
  248. patient_id, _ := c.GetInt64("patient_id")
  249. reg_type, _ := c.GetInt64("reg_type")
  250. diagnose, _ := c.GetInt64("diagnose")
  251. sick_type, _ := c.GetInt64("sick_type")
  252. sick_history := c.GetString("sick_history")
  253. doctor_id, _ := c.GetInt64("doctor", 0)
  254. department, _ := c.GetInt64("department", 0)
  255. his_patient_id, _ := c.GetInt64("his_patient_id")
  256. dataBody := make(map[string]interface{}, 0)
  257. err := json.Unmarshal(c.Ctx.Input.RequestBody, &dataBody)
  258. if err != nil {
  259. utils.ErrorLog(err.Error())
  260. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  261. return
  262. }
  263. timeLayout := "2006-01-02"
  264. loc, _ := time.LoadLocation("Local")
  265. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_date+" 00:00:00", loc)
  266. if err != nil {
  267. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  268. return
  269. }
  270. adminInfo := c.GetAdminUserInfo()
  271. recordDateTime := theTime.Unix()
  272. role, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, doctor_id)
  273. info, _ := service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, patient_id, recordDateTime)
  274. var hpInfo models.HisPrescriptionInfo
  275. if info.ID == 0 {
  276. var randNum int
  277. randNum = rand.Intn(10000) + 1000
  278. timestamp := time.Now().Unix()
  279. tempTime := time.Unix(timestamp, 0)
  280. timeFormat := tempTime.Format("20060102150405")
  281. p_number := timeFormat + strconv.FormatInt(int64(randNum), 10) + strconv.FormatInt(int64(adminInfo.CurrentOrgId), 10) + strconv.FormatInt(int64(patient_id), 10)
  282. hpInfo = models.HisPrescriptionInfo{
  283. UserOrgId: adminInfo.CurrentOrgId,
  284. RecordDate: theTime.Unix(),
  285. PatientId: patient_id,
  286. Status: 1,
  287. Ctime: time.Now().Unix(),
  288. Mtime: time.Now().Unix(),
  289. Creator: adminInfo.AdminUser.Id,
  290. Modifier: adminInfo.AdminUser.Id,
  291. Diagnosis: diagnose,
  292. SickHistory: sick_history,
  293. Departments: department,
  294. RegisterType: reg_type,
  295. PrescriptionNumber: p_number,
  296. PrescriptionStatus: 1,
  297. Doctor: role.UserName,
  298. DoctorId: doctor_id,
  299. SickType: sick_type,
  300. }
  301. service.SavePatientPrescriptionInfo(hpInfo)
  302. } else {
  303. hpInfo = models.HisPrescriptionInfo{
  304. ID: info.ID,
  305. UserOrgId: adminInfo.CurrentOrgId,
  306. RecordDate: info.RecordDate,
  307. PatientId: info.PatientId,
  308. Status: 1,
  309. Ctime: info.Ctime,
  310. Mtime: time.Now().Unix(),
  311. Creator: info.Creator,
  312. Modifier: adminInfo.AdminUser.Id,
  313. Diagnosis: diagnose,
  314. SickHistory: sick_history,
  315. Departments: department,
  316. RegisterType: reg_type,
  317. PrescriptionNumber: info.PrescriptionNumber,
  318. Doctor: role.UserName,
  319. PrescriptionStatus: info.PrescriptionStatus,
  320. DoctorId: doctor_id,
  321. SickType: sick_type,
  322. }
  323. service.SavePatientPrescriptionInfo(hpInfo)
  324. }
  325. if dataBody["prescriptions"] != nil && reflect.TypeOf(dataBody["prescriptions"]).String() == "[]interface {}" {
  326. prescriptions, _ := dataBody["prescriptions"].([]interface{})
  327. if len(prescriptions) > 0 {
  328. for _, item := range prescriptions {
  329. items := item.(map[string]interface{})
  330. if items["id"] == nil || reflect.TypeOf(items["id"]).String() != "float64" {
  331. utils.ErrorLog("id")
  332. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  333. return
  334. }
  335. id := int64(items["id"].(float64))
  336. if items["type"] == nil || reflect.TypeOf(items["type"]).String() != "float64" {
  337. utils.ErrorLog("type")
  338. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  339. return
  340. }
  341. types := int64(items["type"].(float64))
  342. if items["pre_time"] == nil || reflect.TypeOf(items["pre_time"]).String() != "string" {
  343. utils.ErrorLog("pre_time")
  344. }
  345. preTime, _ := items["pre_time"].(string)
  346. timeLayout := "2006-01-02"
  347. loc, _ := time.LoadLocation("Local")
  348. theTime2, err := time.ParseInLocation(timeLayout+" 15:04", preTime, loc)
  349. if err != nil {
  350. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  351. return
  352. }
  353. pTime := theTime2.Unix()
  354. ctime := time.Now().Unix()
  355. prescription := &models.HisPrescription{
  356. ID: id,
  357. PatientId: patient_id,
  358. UserOrgId: adminInfo.CurrentOrgId,
  359. RecordDate: recordDateTime,
  360. Ctime: ctime,
  361. Mtime: ctime,
  362. Type: types,
  363. Modifier: adminInfo.AdminUser.Id,
  364. Creator: adminInfo.AdminUser.Id,
  365. Status: 1,
  366. Doctor: role.UserName,
  367. HisPatientId: his_patient_id,
  368. OrderStatus: 1,
  369. BatchNumber: "",
  370. PrescriptionNumber: hpInfo.PrescriptionNumber,
  371. PreTime: pTime,
  372. }
  373. service.SaveHisPrescription(prescription)
  374. //更改患者挂号状态
  375. _, err2 := service.UpdateHisPatientIsReturn(patient_id, recordDateTime, adminInfo.CurrentOrgId)
  376. fmt.Println("更改失败", err2)
  377. if items["advices"] != nil && reflect.TypeOf(items["advices"]).String() == "[]interface {}" {
  378. advices := items["advices"].([]interface{})
  379. //group := service.GetMaxAdviceGroupID(adminInfo.CurrentOrgId)
  380. groupNo := int64(0)
  381. ctime := time.Now().Unix()
  382. mtime := ctime
  383. if len(advices) > 0 {
  384. for _, advice := range advices {
  385. var s models.HisDoctorAdviceInfo
  386. s.PrescriptionId = prescription.ID
  387. s.AdviceType = 2
  388. s.AdviceDoctor = adminInfo.AdminUser.Id
  389. s.StopState = 2
  390. s.ExecutionState = 2
  391. s.AdviceDate = recordDateTime
  392. s.Status = 1
  393. s.UserOrgId = adminInfo.CurrentOrgId
  394. s.RecordDate = recordDateTime
  395. s.StartTime = prescription.PreTime
  396. s.Groupno = groupNo
  397. s.CreatedTime = ctime
  398. s.UpdatedTime = mtime
  399. s.PatientId = patient_id
  400. s.HisPatientId = his_patient_id
  401. errcode := c.setAdviceWithJSON(&s, advice.(map[string]interface{}))
  402. if errcode > 0 {
  403. c.ServeFailJSONWithSGJErrorCode(errcode)
  404. return
  405. }
  406. service.CreateHisDoctorAdvice(&s)
  407. var randNum int
  408. randNum = rand.Intn(10000) + 1000
  409. timestamp := time.Now().Unix()
  410. tempTime := time.Unix(timestamp, 0)
  411. timeFormat := tempTime.Format("20060102150405")
  412. s.FeedetlSn = timeFormat + strconv.FormatInt(int64(randNum), 10) + "-" + "1" + "-" + strconv.FormatInt(s.ID, 10)
  413. service.CreateHisDoctorAdvice(&s)
  414. }
  415. }
  416. }
  417. if items["project"] != nil && reflect.TypeOf(items["project"]).String() == "[]interface {}" {
  418. projects := items["project"].([]interface{})
  419. if len(projects) > 0 {
  420. for _, project := range projects {
  421. var p models.HisPrescriptionProject
  422. p.PrescriptionId = prescription.ID
  423. p.Ctime = time.Now().Unix()
  424. p.Mtime = time.Now().Unix()
  425. p.PatientId = patient_id
  426. p.RecordDate = recordDateTime
  427. p.UserOrgId = adminInfo.CurrentOrgId
  428. p.HisPatientId = his_patient_id
  429. p.Status = 1
  430. errcode := c.setProjectWithJSON(&p, project.(map[string]interface{}))
  431. if errcode > 0 {
  432. c.ServeFailJSONWithSGJErrorCode(errcode)
  433. return
  434. }
  435. service.CreateHisProjectTwo(&p)
  436. var randNum int
  437. randNum = rand.Intn(10000) + 1000
  438. timestamp := time.Now().Unix()
  439. tempTime := time.Unix(timestamp, 0)
  440. timeFormat := tempTime.Format("20060102150405")
  441. p.FeedetlSn = timeFormat + strconv.FormatInt(int64(randNum), 10) + "-" + "2" + "-" + strconv.FormatInt(p.ID, 10)
  442. service.SaveHisProjectTwo(&p)
  443. }
  444. }
  445. }
  446. if items["addition"] != nil && reflect.TypeOf(items["addition"]).String() == "[]interface {}" {
  447. addition := items["addition"].([]interface{})
  448. //group := service.GetMaxAdviceGroupID(adminInfo.CurrentOrgId)
  449. ctime := time.Now().Unix()
  450. mtime := ctime
  451. if len(addition) > 0 {
  452. for _, item := range addition {
  453. var s models.HisAdditionalCharge
  454. s.PrescriptionId = prescription.ID
  455. s.Status = 1
  456. s.UserOrgId = adminInfo.CurrentOrgId
  457. s.RecordDate = recordDateTime
  458. s.CreatedTime = ctime
  459. s.UpdatedTime = mtime
  460. s.PatientId = patient_id
  461. s.HisPatientId = his_patient_id
  462. errcode := c.setAddtionWithJSON(&s, item.(map[string]interface{}), adminInfo.CurrentOrgId)
  463. if errcode > 0 {
  464. c.ServeFailJSONWithSGJErrorCode(errcode)
  465. return
  466. }
  467. service.CreateAdditionalCharge(&s)
  468. var randNum int
  469. randNum = rand.Intn(10000) + 1000
  470. timestamp := time.Now().Unix()
  471. tempTime := time.Unix(timestamp, 0)
  472. timeFormat := tempTime.Format("20060102150405")
  473. s.FeedetlSn = timeFormat + strconv.FormatInt(int64(randNum), 10) + "-" + "3" + "-" + strconv.FormatInt(s.ID, 10)
  474. service.CreateAdditionalCharge(&s)
  475. }
  476. }
  477. }
  478. }
  479. }
  480. }
  481. if err == nil {
  482. c.ServeSuccessJSON(map[string]interface{}{
  483. "msg": "保存成功",
  484. })
  485. return
  486. } else {
  487. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  488. return
  489. }
  490. }
  491. func (c *HisApiController) EditHisPrescription() {
  492. record_date := c.GetString("record_date")
  493. patient_id, _ := c.GetInt64("patient_id")
  494. reg_type, _ := c.GetInt64("reg_type")
  495. diagnose, _ := c.GetInt64("diagnose")
  496. sick_type, _ := c.GetInt64("sick_type")
  497. sick_history := c.GetString("sick_history")
  498. doctor_id, _ := c.GetInt64("doctor", 0)
  499. department, _ := c.GetInt64("department", 0)
  500. his_patient_id, _ := c.GetInt64("his_patient_id")
  501. dataBody := make(map[string]interface{}, 0)
  502. err := json.Unmarshal(c.Ctx.Input.RequestBody, &dataBody)
  503. if err != nil {
  504. utils.ErrorLog(err.Error())
  505. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  506. return
  507. }
  508. timeLayout := "2006-01-02"
  509. loc, _ := time.LoadLocation("Local")
  510. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_date+" 00:00:00", loc)
  511. if err != nil {
  512. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  513. return
  514. }
  515. adminInfo := c.GetAdminUserInfo()
  516. recordDateTime := theTime.Unix()
  517. role, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, doctor_id)
  518. info, _ := service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, patient_id, recordDateTime)
  519. var hpInfo models.HisPrescriptionInfo
  520. if info.ID == 0 {
  521. var randNum int
  522. randNum = rand.Intn(10000) + 1000
  523. timestamp := time.Now().Unix()
  524. tempTime := time.Unix(timestamp, 0)
  525. timeFormat := tempTime.Format("20060102150405")
  526. p_number := timeFormat + strconv.FormatInt(int64(randNum), 10) + strconv.FormatInt(int64(adminInfo.CurrentOrgId), 10) + strconv.FormatInt(int64(patient_id), 10)
  527. hpInfo = models.HisPrescriptionInfo{
  528. UserOrgId: adminInfo.CurrentOrgId,
  529. RecordDate: theTime.Unix(),
  530. PatientId: patient_id,
  531. Status: 1,
  532. Ctime: time.Now().Unix(),
  533. Mtime: time.Now().Unix(),
  534. Creator: adminInfo.AdminUser.Id,
  535. Modifier: adminInfo.AdminUser.Id,
  536. Diagnosis: diagnose,
  537. SickHistory: sick_history,
  538. Departments: department,
  539. RegisterType: reg_type,
  540. PrescriptionNumber: p_number,
  541. PrescriptionStatus: 1,
  542. Doctor: role.UserName,
  543. DoctorId: doctor_id,
  544. SickType: sick_type,
  545. }
  546. service.SavePatientPrescriptionInfo(hpInfo)
  547. } else {
  548. hpInfo = models.HisPrescriptionInfo{
  549. ID: info.ID,
  550. UserOrgId: adminInfo.CurrentOrgId,
  551. RecordDate: info.RecordDate,
  552. PatientId: info.PatientId,
  553. Status: 1,
  554. Ctime: info.Ctime,
  555. Mtime: time.Now().Unix(),
  556. Creator: info.Creator,
  557. Modifier: adminInfo.AdminUser.Id,
  558. Diagnosis: diagnose,
  559. SickHistory: sick_history,
  560. Departments: department,
  561. RegisterType: reg_type,
  562. PrescriptionNumber: info.PrescriptionNumber,
  563. Doctor: role.UserName,
  564. PrescriptionStatus: info.PrescriptionStatus,
  565. DoctorId: doctor_id,
  566. SickType: sick_type,
  567. }
  568. service.SavePatientPrescriptionInfo(hpInfo)
  569. }
  570. if dataBody["prescriptions"] != nil && reflect.TypeOf(dataBody["prescriptions"]).String() == "[]interface {}" {
  571. prescriptions, _ := dataBody["prescriptions"].([]interface{})
  572. if len(prescriptions) > 0 {
  573. for _, item := range prescriptions {
  574. items := item.(map[string]interface{})
  575. if items["id"] == nil || reflect.TypeOf(items["id"]).String() != "float64" {
  576. utils.ErrorLog("id")
  577. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  578. return
  579. }
  580. id := int64(items["id"].(float64))
  581. if items["type"] == nil || reflect.TypeOf(items["type"]).String() != "float64" {
  582. utils.ErrorLog("type")
  583. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  584. return
  585. }
  586. types := int64(items["type"].(float64))
  587. historyPrescription, _ := service.GetHisPrescriptionByID(adminInfo.CurrentOrgId, id)
  588. ctime := time.Now().Unix()
  589. prescription := &models.HisPrescription{
  590. ID: id,
  591. PatientId: patient_id,
  592. UserOrgId: adminInfo.CurrentOrgId,
  593. RecordDate: recordDateTime,
  594. Ctime: ctime,
  595. Mtime: ctime,
  596. Type: types,
  597. Modifier: adminInfo.AdminUser.Id,
  598. Creator: adminInfo.AdminUser.Id,
  599. Status: 1,
  600. Doctor: role.UserName,
  601. HisPatientId: his_patient_id,
  602. OrderStatus: 1,
  603. BatchNumber: "",
  604. PrescriptionNumber: hpInfo.PrescriptionNumber,
  605. }
  606. if historyPrescription.ID > 0 {
  607. prescription.PreTime = historyPrescription.PreTime
  608. }
  609. service.SaveHisPrescription(prescription)
  610. if items["advices"] != nil && reflect.TypeOf(items["advices"]).String() == "[]interface {}" {
  611. advices := items["advices"].([]interface{})
  612. //group := service.GetMaxAdviceGroupID(adminInfo.CurrentOrgId)
  613. groupNo := int64(0)
  614. ctime := time.Now().Unix()
  615. mtime := ctime
  616. if len(advices) > 0 {
  617. for _, advice := range advices {
  618. var s models.HisDoctorAdviceInfo
  619. s.PrescriptionId = prescription.ID
  620. s.AdviceType = 2
  621. s.AdviceDoctor = adminInfo.AdminUser.Id
  622. s.StopState = 2
  623. s.ExecutionState = 2
  624. s.AdviceDate = recordDateTime
  625. s.Status = 1
  626. s.UserOrgId = adminInfo.CurrentOrgId
  627. s.RecordDate = recordDateTime
  628. s.StartTime = prescription.PreTime
  629. s.Groupno = groupNo
  630. s.CreatedTime = ctime
  631. s.UpdatedTime = mtime
  632. s.PatientId = patient_id
  633. s.HisPatientId = his_patient_id
  634. errcode := c.setAdviceWithJSONTwo(&s, advice.(map[string]interface{}))
  635. if errcode > 0 {
  636. c.ServeFailJSONWithSGJErrorCode(errcode)
  637. return
  638. }
  639. service.CreateHisDoctorAdvice(&s)
  640. }
  641. }
  642. }
  643. if items["project"] != nil && reflect.TypeOf(items["project"]).String() == "[]interface {}" {
  644. projects := items["project"].([]interface{})
  645. if len(projects) > 0 {
  646. for _, project := range projects {
  647. var p models.HisPrescriptionProject
  648. p.PrescriptionId = prescription.ID
  649. p.Ctime = time.Now().Unix()
  650. p.Mtime = time.Now().Unix()
  651. p.PatientId = patient_id
  652. p.RecordDate = recordDateTime
  653. p.UserOrgId = adminInfo.CurrentOrgId
  654. p.HisPatientId = his_patient_id
  655. p.Status = 1
  656. errcode := c.setProjectWithJSONTwo(&p, project.(map[string]interface{}))
  657. if errcode > 0 {
  658. c.ServeFailJSONWithSGJErrorCode(errcode)
  659. return
  660. }
  661. service.CreateHisProjectTwo(&p)
  662. }
  663. }
  664. }
  665. if items["addition"] != nil && reflect.TypeOf(items["addition"]).String() == "[]interface {}" {
  666. addition := items["addition"].([]interface{})
  667. //group := service.GetMaxAdviceGroupID(adminInfo.CurrentOrgId)
  668. ctime := time.Now().Unix()
  669. mtime := ctime
  670. if len(addition) > 0 {
  671. for _, item := range addition {
  672. var s models.HisAdditionalCharge
  673. s.PrescriptionId = prescription.ID
  674. s.Status = 1
  675. s.UserOrgId = adminInfo.CurrentOrgId
  676. s.RecordDate = recordDateTime
  677. s.CreatedTime = ctime
  678. s.UpdatedTime = mtime
  679. s.PatientId = patient_id
  680. s.HisPatientId = his_patient_id
  681. errcode := c.setAddtionWithJSONTwo(&s, item.(map[string]interface{}), adminInfo.CurrentOrgId)
  682. if errcode > 0 {
  683. c.ServeFailJSONWithSGJErrorCode(errcode)
  684. return
  685. }
  686. service.CreateAdditionalCharge(&s)
  687. }
  688. }
  689. }
  690. }
  691. }
  692. }
  693. if err == nil {
  694. c.ServeSuccessJSON(map[string]interface{}{
  695. "msg": "保存成功",
  696. })
  697. return
  698. } else {
  699. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  700. return
  701. }
  702. }
  703. func (c *HisApiController) DeletePrescription() {
  704. prescription_id, _ := c.GetInt64("id")
  705. //TODO 需要判断是否已经结算
  706. err := service.DelelteHisPrescription(prescription_id, c.GetAdminUserInfo().CurrentOrgId)
  707. if err == nil {
  708. c.ServeSuccessJSON(map[string]interface{}{
  709. "msg": "删除成功",
  710. })
  711. return
  712. } else {
  713. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  714. return
  715. }
  716. }
  717. func (c *HisApiController) DeleteDoctorAdvice() {
  718. id, _ := c.GetInt64("id")
  719. //TODO 需要判断是否已经结算
  720. err := service.DelelteDoctorAdvice(id, c.GetAdminUserInfo().CurrentOrgId)
  721. if err == nil {
  722. c.ServeSuccessJSON(map[string]interface{}{
  723. "msg": "删除成功",
  724. })
  725. return
  726. } else {
  727. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  728. return
  729. }
  730. }
  731. func (c *HisApiController) DeleteProject() {
  732. id, _ := c.GetInt64("id")
  733. //TODO 需要判断是否已经结算
  734. err := service.DelelteProject(id, c.GetAdminUserInfo().CurrentOrgId)
  735. if err == nil {
  736. c.ServeSuccessJSON(map[string]interface{}{
  737. "msg": "删除成功",
  738. })
  739. return
  740. } else {
  741. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  742. return
  743. }
  744. }
  745. func (c *HisApiController) CreateHisAdditionalCharge() {
  746. his_patient_id, _ := c.GetInt64("his_patient_id")
  747. patient_id, _ := c.GetInt64("patient_id")
  748. record_date := c.GetString("record_date")
  749. timeLayout := "2006-01-02"
  750. loc, _ := time.LoadLocation("Local")
  751. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_date+" 00:00:00", loc)
  752. if err != nil {
  753. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  754. return
  755. }
  756. adminInfo := c.GetAdminUserInfo()
  757. recordDateTime := theTime.Unix()
  758. dataBody := make(map[string]interface{}, 0)
  759. err = json.Unmarshal(c.Ctx.Input.RequestBody, &dataBody)
  760. if err != nil {
  761. utils.ErrorLog(err.Error())
  762. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  763. return
  764. }
  765. var additions []*models.HisAdditionalCharge
  766. if dataBody["addition"] != nil && reflect.TypeOf(dataBody["addition"]).String() == "[]interface {}" {
  767. additions, _ := dataBody["addition"].([]interface{})
  768. if len(additions) > 0 {
  769. for _, item := range additions {
  770. items := item.(map[string]interface{})
  771. if items["item_id"] == nil || reflect.TypeOf(items["item_id"]).String() != "float64" {
  772. utils.ErrorLog("item_id")
  773. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  774. return
  775. }
  776. item_id := int64(items["item_id"].(float64))
  777. if items["item_name"] == nil || reflect.TypeOf(items["item_name"]).String() != "string" {
  778. utils.ErrorLog("item_name")
  779. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  780. return
  781. }
  782. item_name := items["item_name"].(string)
  783. if items["price"] == nil || reflect.TypeOf(items["price"]).String() != "string" {
  784. utils.ErrorLog("price")
  785. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  786. return
  787. }
  788. price, _ := strconv.ParseFloat(items["price"].(string), 64)
  789. ctime := time.Now().Unix()
  790. additional := &models.HisAdditionalCharge{
  791. PatientId: patient_id,
  792. HisPatientId: his_patient_id,
  793. UserOrgId: adminInfo.CurrentOrgId,
  794. RecordDate: recordDateTime,
  795. CreatedTime: ctime,
  796. UpdatedTime: ctime,
  797. Modifier: adminInfo.AdminUser.Id,
  798. Creator: adminInfo.AdminUser.Id,
  799. Price: price,
  800. ItemName: item_name,
  801. ItemId: item_id,
  802. Status: 1,
  803. }
  804. additions = append(additions, additional)
  805. }
  806. }
  807. }
  808. for _, item := range additions {
  809. service.CreateAddtionalCharge(item)
  810. }
  811. c.ServeSuccessJSON(map[string]interface{}{
  812. "msg": "创建成功",
  813. })
  814. }
  815. func (c *HisApiController) CreateHisPatientCaseHistory() {
  816. blood_fat := c.GetString("blood_fat")
  817. bloodfatfloat, _ := strconv.ParseFloat(blood_fat, 64)
  818. //fmt.Println("33333333", bloodfatfloat)
  819. blood_sugar := c.GetString("blood_sugar")
  820. bloodsugarfloat, _ := strconv.ParseFloat(blood_sugar, 64)
  821. fmt.Println(bloodsugarfloat)
  822. chief_conplaint := c.GetString("chief_conplaint")
  823. dbp := c.GetString("dbp")
  824. dbpfloat, _ := strconv.ParseFloat(dbp, 64)
  825. delivery_way, _ := c.GetInt64("delivery_way")
  826. diagnostic := c.GetString("diagnostic")
  827. fmt.Println("diagnostic", diagnostic)
  828. family_history := c.GetString("family_history")
  829. fmt.Println(family_history)
  830. height := c.GetString("height")
  831. history_of_present_illness := c.GetString("history_of_present_illness")
  832. is_infect, _ := c.GetInt64("is_infect")
  833. fmt.Println("is", is_infect)
  834. past_history := c.GetString("past_history")
  835. patient_id, _ := c.GetInt64("patient_id")
  836. his_patient_id, _ := c.GetInt64("his_patient_id")
  837. fmt.Println("patient_id", patient_id)
  838. personal_history := c.GetString("personal_history")
  839. pulse := c.GetString("pulse")
  840. pulsefloat, _ := strconv.ParseFloat(pulse, 64)
  841. sbp := c.GetString("sbp")
  842. sbpfloat, _ := strconv.ParseFloat(sbp, 64)
  843. heightfloat, _ := strconv.ParseFloat(height, 64)
  844. sicktype := c.GetString("sick_type")
  845. fmt.Println("sicketype", sicktype)
  846. sick_type, _ := strconv.ParseInt(sicktype, 10, 64)
  847. symptom := c.GetString("symptom")
  848. sick_date := c.GetString("sick_date")
  849. temperatures := c.GetString("temperature")
  850. fmt.Println("temperatures", temperatures)
  851. temperature, _ := strconv.ParseFloat(temperatures, 64)
  852. record_date := c.GetString("record_date")
  853. breathing := c.GetString("breathing")
  854. doctor_advice := c.GetString("doctor_advice")
  855. remark := c.GetString("remark")
  856. breathingfloat, _ := strconv.ParseFloat(breathing, 64)
  857. fmt.Println("breathingfloat", breathingfloat)
  858. sick, _ := c.GetInt64("sick")
  859. diagnose, _ := c.GetInt64("diagnose")
  860. timeLayout := "2006-01-02"
  861. loc, _ := time.LoadLocation("Local")
  862. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_date+" 00:00:00", loc)
  863. if err != nil {
  864. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  865. return
  866. }
  867. recordDateTime := theTime.Unix()
  868. fmt.Println("recordDataTime", recordDateTime)
  869. sickTime, err := time.ParseInLocation(timeLayout+" 15:04:05", sick_date+" 00:00:00", loc)
  870. if err != nil {
  871. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  872. return
  873. }
  874. sickTimes := sickTime.Unix()
  875. ctime := time.Now().Unix()
  876. caseHistory := models.HisPatientCaseHistory{
  877. HisPatientId: his_patient_id,
  878. PatientId: patient_id,
  879. Temperature: temperature,
  880. BloodSugar: bloodsugarfloat,
  881. Pulse: pulsefloat,
  882. Sbp: sbpfloat,
  883. Dbp: dbpfloat,
  884. Height: heightfloat,
  885. BloodFat: bloodfatfloat,
  886. SickType: sick_type,
  887. Symptom: symptom,
  888. SickDate: sickTimes,
  889. IsInfect: is_infect,
  890. HistoryOfPresentIllness: history_of_present_illness,
  891. PastHistory: past_history,
  892. Doctor: c.GetAdminUserInfo().AdminUser.Id,
  893. ChiefConplaint: chief_conplaint,
  894. PersonalHistory: personal_history,
  895. FamilyHistory: family_history,
  896. Diagnostic: diagnostic,
  897. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  898. Status: 1,
  899. Ctime: ctime,
  900. Mtime: ctime,
  901. RecordDate: recordDateTime,
  902. DeliveryWay: delivery_way,
  903. Breathing: breathingfloat,
  904. DoctorAdvice: doctor_advice,
  905. Remark: remark,
  906. Sick: sick,
  907. Diagnose: diagnose,
  908. }
  909. err = service.SaveHisPatientCaseHistory(&caseHistory)
  910. if err != nil {
  911. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
  912. return
  913. }
  914. c.ServeSuccessJSON(map[string]interface{}{
  915. "caseHistory": caseHistory,
  916. })
  917. return
  918. //查询该患者是否有病历
  919. //_, errcode := service.GetHisPatientCaseHistoryById(his_patient_id)
  920. //if errcode == gorm.ErrRecordNotFound {
  921. // err = service.SaveHisPatientCaseHistory(caseHistory)
  922. // if err != nil {
  923. // c.ServeSuccessJSON(map[string]interface{}{
  924. // "msg": "保存成功",
  925. // })
  926. // }
  927. //} else if errcode == nil {
  928. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
  929. // return
  930. //}
  931. }
  932. func (c *HisApiController) GetHisPatientCaseHistoryList() {
  933. patient_id, _ := c.GetInt64("patient_id", 0)
  934. adminUser := c.GetAdminUserInfo()
  935. caseHistorys, _ := service.GetHisPatientCaseHistoryList(adminUser.CurrentOrgId, patient_id)
  936. c.ServeSuccessJSON(map[string]interface{}{
  937. "list": caseHistorys,
  938. })
  939. }
  940. func (c *HisApiController) GetHisPatientCaseHistory() {
  941. record_date, _ := c.GetInt64("record_date", 0)
  942. patient_id, _ := c.GetInt64("patient_id", 0)
  943. admin := c.GetAdminUserInfo()
  944. info, _ := service.GetHisPatientInfo(admin.CurrentOrgId, patient_id, record_date)
  945. case_history, _ := service.GetHisPatientCaseHistoryInfo(admin.CurrentOrgId, patient_id, record_date)
  946. c.ServeSuccessJSON(map[string]interface{}{
  947. "info": info,
  948. "case_history": case_history,
  949. })
  950. }
  951. func (c *HisApiController) CreateCaseHistoryTemplate() {
  952. template_name := c.GetString("template_name")
  953. fmt.Println("template_name22222222222222", template_name)
  954. template_remark := c.GetString("template_remark")
  955. doctor := c.GetAdminUserInfo().AdminUser.Id
  956. diagnostic := c.GetString("diagnostic")
  957. chief_conplaint := c.GetString("chief_conplain")
  958. history_of_present_illness := c.GetString("history_of_present_illness")
  959. past_history := c.GetString("past_history")
  960. personal_history := c.GetString("personal_history")
  961. family_history := c.GetString("family_history")
  962. user_name := c.GetString("user_name")
  963. doctor_advice := c.GetString("doctor_advice")
  964. remark := c.GetString("remark")
  965. //record_date := c.GetString("record_date")
  966. //fmt.Println("record_date--------",record_date)
  967. //timeLayout := "2006-01-02"
  968. //loc, _ := time.LoadLocation("Local")
  969. //
  970. //theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_date+" 00:00:00", loc)
  971. //if err != nil {
  972. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  973. // return
  974. //}
  975. //recordDateTime := theTime.Unix()
  976. ctime := time.Now().Unix()
  977. template := models.HisCaseHistoryTemplate{
  978. HistoryOfPresentIllness: history_of_present_illness,
  979. PastHistory: past_history,
  980. ChiefConplaint: chief_conplaint,
  981. PersonalHistory: personal_history,
  982. FamilyHistory: family_history,
  983. Diagnostic: diagnostic,
  984. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  985. Status: 1,
  986. Ctime: ctime,
  987. Mtime: ctime,
  988. RecordDate: time.Now().Unix(),
  989. TemplateName: template_name,
  990. TemplateRemark: template_remark,
  991. Creator: doctor,
  992. Modifier: doctor,
  993. UserName: user_name,
  994. DoctorAdvice: doctor_advice,
  995. Remark: remark,
  996. }
  997. err := service.SaveHisPatientCaseHistoryTemplate(template)
  998. if err == nil {
  999. c.ServeSuccessJSON(map[string]interface{}{
  1000. "msg": "保存成功",
  1001. })
  1002. } else {
  1003. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1004. return
  1005. }
  1006. }
  1007. func (c *HisApiController) GetCaseHistoryTemplate() {
  1008. timeLayout := "2006-01-02"
  1009. loc, _ := time.LoadLocation("Local")
  1010. keyword := c.GetString("keyword")
  1011. start_time := c.GetString("start_time")
  1012. end_time := c.GetString("end_time")
  1013. startTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  1014. endTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  1015. admin := c.GetAdminUserInfo()
  1016. template, _ := service.GetHisPatientCaseHistoryTemplate(admin.CurrentOrgId, startTime.Unix(), endTime.Unix(), keyword)
  1017. //history, _ := service.GetHisPatientCaseHistory(admin.CurrentOrgId)
  1018. c.ServeSuccessJSON(map[string]interface{}{
  1019. "template": template,
  1020. //"history": history,
  1021. })
  1022. }
  1023. func (c *HisApiController) setAdviceWithJSONTwo(advice *models.HisDoctorAdviceInfo, json map[string]interface{}) int {
  1024. if json["drug_name"] == nil || reflect.TypeOf(json["drug_name"]).String() != "string" {
  1025. utils.ErrorLog("drug_name")
  1026. return enums.ErrorCodeParamWrong
  1027. }
  1028. adviceName, _ := json["drug_name"].(string)
  1029. if len(adviceName) == 0 {
  1030. utils.ErrorLog("len(advice_name) == 0")
  1031. return enums.ErrorCodeParamWrong
  1032. }
  1033. advice.AdviceName = adviceName
  1034. adviceDesc, _ := json["advice_desc"].(string)
  1035. advice.AdviceDesc = adviceDesc
  1036. if json["drug_spec"] != nil && reflect.TypeOf(json["drug_spec"]).String() == "string" {
  1037. drugSpec, _ := strconv.ParseFloat(json["drug_spec"].(string), 64)
  1038. advice.DrugSpec = drugSpec
  1039. }
  1040. if json["remark"] != nil && reflect.TypeOf(json["remark"]).String() == "string" {
  1041. remark, _ := json["remark"].(string)
  1042. advice.Remark = remark
  1043. }
  1044. if json["id"] == nil {
  1045. advice.DrugId = 0
  1046. } else {
  1047. if json["id"] != nil || reflect.TypeOf(json["id"]).String() == "float64" {
  1048. drug_id := int64(json["id"].(float64))
  1049. advice.DrugId = drug_id
  1050. }
  1051. }
  1052. if json["advice_id"] != nil && reflect.TypeOf(json["advice_id"]).String() == "float64" {
  1053. advice_id := int64(json["advice_id"].(float64))
  1054. advice.ID = advice_id
  1055. if advice.ID > 0 {
  1056. hisAdvice, err := service.GetHisDoctorAdvicesById(advice.ID)
  1057. if err == nil {
  1058. if hisAdvice.ID > 0 {
  1059. advice.ExecutionTime = hisAdvice.ExecutionTime
  1060. advice.ExecutionStaff = hisAdvice.ExecutionStaff
  1061. advice.ExecutionState = hisAdvice.ExecutionState
  1062. advice.CheckTime = hisAdvice.CheckTime
  1063. advice.Checker = hisAdvice.Checker
  1064. advice.CheckState = hisAdvice.CheckState
  1065. advice.StartTime = hisAdvice.StartTime
  1066. advice.FeedetlSn = hisAdvice.FeedetlSn
  1067. }
  1068. }
  1069. }
  1070. }
  1071. //
  1072. //if json["execution_time"] != nil && reflect.TypeOf(json["execution_time"]).String() == "string" {
  1073. // execution_time, _ := strconv.ParseInt(json["execution_time"].(string), 10,64)
  1074. // advice.ExecutionTime = execution_time
  1075. //}
  1076. //
  1077. //
  1078. //
  1079. //if json["execution_staff"] != nil && reflect.TypeOf(json["execution_staff"]).String() == "string" {
  1080. // execution_staff, _ := strconv.ParseInt(json["execution_staff"].(string), 10,64)
  1081. // advice.ExecutionStaff = execution_staff
  1082. //}
  1083. //
  1084. //
  1085. //
  1086. //if json["execution_state"] != nil && reflect.TypeOf(json["execution_state"]).String() == "string" {
  1087. // execution_state, _ := strconv.ParseInt(json["execution_state"].(string), 10,64)
  1088. // advice.ExecutionState = execution_state
  1089. //}
  1090. //
  1091. //
  1092. //if json["check_time"] != nil && reflect.TypeOf(json["check_time"]).String() == "string" {
  1093. // check_time, _ := strconv.ParseInt(json["check_time"].(string), 10,64)
  1094. // advice.CheckTime = check_time
  1095. //}
  1096. //
  1097. //
  1098. //if json["check_state"] != nil && reflect.TypeOf(json["check_state"]).String() == "string" {
  1099. // check_state, _ := strconv.ParseInt(json["check_state"].(string), 10,64)
  1100. // advice.CheckState = check_state
  1101. //}
  1102. //
  1103. //
  1104. //if json["checker"] != nil && reflect.TypeOf(json["checker"]).String() == "string" {
  1105. // checker, _ := strconv.ParseInt(json["checker"].(string), 10,64)
  1106. // advice.Checker = checker
  1107. //}
  1108. //
  1109. //if json["start_time"] != nil && reflect.TypeOf(json["start_time"]).String() == "string" {
  1110. // start_time, _ := strconv.ParseInt(json["start_time"].(string), 10,64)
  1111. // advice.StartTime = start_time
  1112. //}
  1113. if json["min_unit"] != nil && reflect.TypeOf(json["min_unit"]).String() == "string" {
  1114. drugSpecUnit, _ := json["min_unit"].(string)
  1115. advice.DrugSpecUnit = drugSpecUnit
  1116. }
  1117. if json["single_dose"] != nil && reflect.TypeOf(json["single_dose"]).String() == "string" {
  1118. singleDose, _ := strconv.ParseFloat(json["single_dose"].(string), 64)
  1119. advice.SingleDose = singleDose
  1120. }
  1121. if json["single_dose_unit"] != nil && reflect.TypeOf(json["single_dose_unit"]).String() == "string" {
  1122. singleDoseUnit, _ := json["single_dose_unit"].(string)
  1123. advice.SingleDoseUnit = singleDoseUnit
  1124. }
  1125. if json["prescribing_number"] != nil && reflect.TypeOf(json["prescribing_number"]).String() == "string" {
  1126. prescribingNumber, _ := strconv.ParseFloat(json["prescribing_number"].(string), 64)
  1127. advice.PrescribingNumber = prescribingNumber
  1128. }
  1129. if json["prescribing_number_unit"] != nil && reflect.TypeOf(json["prescribing_number_unit"]).String() == "string" {
  1130. prescribingNumberUnit, _ := json["prescribing_number_unit"].(string)
  1131. advice.PrescribingNumberUnit = prescribingNumberUnit
  1132. }
  1133. if json["delivery_way"] != nil && reflect.TypeOf(json["delivery_way"]).String() == "string" {
  1134. deliveryWay, _ := json["delivery_way"].(string)
  1135. advice.DeliveryWay = deliveryWay
  1136. }
  1137. if json["execution_frequency"] != nil && reflect.TypeOf(json["execution_frequency"]).String() == "string" {
  1138. executionFrequency, _ := json["execution_frequency"].(string)
  1139. advice.ExecutionFrequency = executionFrequency
  1140. }
  1141. if json["retail_price"] != nil || reflect.TypeOf(json["retail_price"]).String() == "string" {
  1142. price, _ := strconv.ParseFloat(json["retail_price"].(string), 64)
  1143. advice.Price = price
  1144. }
  1145. if json["medical_insurance_number"] != nil || reflect.TypeOf(json["medical_insurance_number"]).String() == "string" {
  1146. med_list_codg, _ := json["medical_insurance_number"].(string)
  1147. advice.MedListCodg = med_list_codg
  1148. }
  1149. if json["day"] != nil || reflect.TypeOf(json["day"]).String() == "float64" {
  1150. day := int64(json["day"].(float64))
  1151. advice.Day = day
  1152. }
  1153. return 0
  1154. }
  1155. func (c *HisApiController) setProjectWithJSONTwo(project *models.HisPrescriptionProject, json map[string]interface{}) int {
  1156. if json["id"] != nil || reflect.TypeOf(json["id"]).String() == "float64" {
  1157. id := int64(json["id"].(float64))
  1158. project.ID = id
  1159. historyProject, _ := service.GetHisProjectByID(id)
  1160. project.FeedetlSn = historyProject.FeedetlSn
  1161. }
  1162. if json["project_id"] != nil || reflect.TypeOf(json["project_id"]).String() == "float64" {
  1163. project_id := int64(json["project_id"].(float64))
  1164. project.ProjectId = project_id
  1165. }
  1166. // if json["price"] != nil || reflect.TypeOf(json["price"]).String() == "float64" {
  1167. // price := int64(json["price"].(float64))
  1168. // formatInt_price := strconv.FormatInt(price, 10)
  1169. // float_price, _ := strconv.ParseFloat(formatInt_price, 64)
  1170. // project.Price = float_price
  1171. // }
  1172. if json["price"] != nil || reflect.TypeOf(json["price"]).String() == "string" {
  1173. price, _ := strconv.ParseFloat(json["price"].(string), 64)
  1174. project.Price = price
  1175. }
  1176. if json["total"] != nil && reflect.TypeOf(json["total"]).String() == "string" {
  1177. total, _ := json["total"].(string)
  1178. totals, _ := strconv.ParseInt(total, 10, 64)
  1179. project.Count = totals
  1180. }
  1181. if json["medical_code"] != nil && reflect.TypeOf(json["medical_code"]).String() == "string" {
  1182. medical_code, _ := json["medical_code"].(string)
  1183. project.MedListCodg = medical_code
  1184. }
  1185. if json["single_dose"] != nil && reflect.TypeOf(json["single_dose"]).String() == "string" {
  1186. single_dose, _ := json["single_dose"].(string)
  1187. project.SingleDose = single_dose
  1188. }
  1189. if json["delivery_way"] != nil && reflect.TypeOf(json["delivery_way"]).String() == "string" {
  1190. delivery_way, _ := json["delivery_way"].(string)
  1191. project.DeliveryWay = delivery_way
  1192. }
  1193. if json["execution_frequency"] != nil && reflect.TypeOf(json["execution_frequency"]).String() == "string" {
  1194. execution_frequency, _ := json["execution_frequency"].(string)
  1195. project.ExecutionFrequency = execution_frequency
  1196. }
  1197. if json["remark"] != nil && reflect.TypeOf(json["remark"]).String() == "string" {
  1198. remark, _ := json["remark"].(string)
  1199. project.Remark = remark
  1200. }
  1201. if json["number_days"] != nil && reflect.TypeOf(json["number_days"]).String() == "string" {
  1202. day, _ := json["number_days"].(string)
  1203. project.Day = day
  1204. }
  1205. if json["unit"] != nil && reflect.TypeOf(json["unit"]).String() == "string" {
  1206. unit, _ := json["unit"].(string)
  1207. project.Unit = unit
  1208. }
  1209. return 0
  1210. }
  1211. func (c *HisApiController) setAddtionWithJSONTwo(additionalCharge *models.HisAdditionalCharge, json map[string]interface{}, org_id int64) int {
  1212. if json["id"] != nil || reflect.TypeOf(json["id"]).String() == "float64" {
  1213. id := int64(json["id"].(float64))
  1214. historyAddtions, _ := service.GetHisAdditionByID(id)
  1215. additionalCharge.ID = id
  1216. additionalCharge.FeedetlSn = historyAddtions.FeedetlSn
  1217. }
  1218. if json["item_id"] != nil || reflect.TypeOf(json["item_id"]).String() == "float64" {
  1219. item_id := int64(json["item_id"].(float64))
  1220. additionalCharge.ItemId = item_id
  1221. config, _ := service.GetAdditionChargeByID(org_id, item_id)
  1222. if config.ID > 0 {
  1223. if len(config.Code) > 0 {
  1224. additionalCharge.MedListCodg = config.Code
  1225. }
  1226. }
  1227. }
  1228. // if json["price"] != nil || reflect.TypeOf(json["price"]).String() == "float64" {
  1229. // price := int64(json["price"].(float64))
  1230. // formatInt_price := strconv.FormatInt(price, 10)
  1231. // float_price, _ := strconv.ParseFloat(formatInt_price, 64)
  1232. // additionalCharge.Price = float_price
  1233. // }
  1234. //if json["price"] != nil || reflect.TypeOf(json["price"]).String() == "float64" {
  1235. // price := int64(json["price"].(float64))
  1236. // formatInt_price := strconv.FormatInt(price, 10)
  1237. // float_price, _ := strconv.ParseFloat(formatInt_price, 64)
  1238. // additionalCharge.Price = float_price
  1239. //}
  1240. if json["price"] != nil || reflect.TypeOf(json["price"]).String() == "string" {
  1241. price, _ := strconv.ParseFloat(json["price"].(string), 64)
  1242. additionalCharge.Price = price
  1243. }
  1244. if json["count"] != nil && reflect.TypeOf(json["count"]).String() == "string" {
  1245. count, _ := json["count"].(string)
  1246. counts, _ := strconv.ParseInt(count, 10, 64)
  1247. additionalCharge.Count = counts
  1248. }
  1249. if json["item_name"] != nil && reflect.TypeOf(json["item_name"]).String() == "string" {
  1250. item_name, _ := json["item_name"].(string)
  1251. additionalCharge.ItemName = item_name
  1252. }
  1253. return 0
  1254. }
  1255. func (c *HisApiController) setAdviceWithJSON(advice *models.HisDoctorAdviceInfo, json map[string]interface{}) int {
  1256. if json["drug_name"] == nil || reflect.TypeOf(json["drug_name"]).String() != "string" {
  1257. utils.ErrorLog("drug_name")
  1258. return enums.ErrorCodeParamWrong
  1259. }
  1260. adviceName, _ := json["drug_name"].(string)
  1261. if len(adviceName) == 0 {
  1262. utils.ErrorLog("len(advice_name) == 0")
  1263. return enums.ErrorCodeParamWrong
  1264. }
  1265. advice.AdviceName = adviceName
  1266. adviceDesc, _ := json["advice_desc"].(string)
  1267. advice.AdviceDesc = adviceDesc
  1268. if json["drug_spec"] != nil && reflect.TypeOf(json["drug_spec"]).String() == "string" {
  1269. drugSpec, _ := strconv.ParseFloat(json["drug_spec"].(string), 64)
  1270. advice.DrugSpec = drugSpec
  1271. }
  1272. if json["remark"] != nil && reflect.TypeOf(json["remark"]).String() == "string" {
  1273. remark, _ := json["remark"].(string)
  1274. advice.Remark = remark
  1275. }
  1276. if json["id"] == nil {
  1277. advice.DrugId = 0
  1278. } else {
  1279. if json["id"] != nil || reflect.TypeOf(json["id"]).String() == "float64" {
  1280. drug_id := int64(json["id"].(float64))
  1281. advice.DrugId = drug_id
  1282. }
  1283. }
  1284. if json["advice_id"] != nil && reflect.TypeOf(json["advice_id"]).String() == "float64" {
  1285. advice_id := int64(json["advice_id"].(float64))
  1286. advice.ID = advice_id
  1287. if advice.ID > 0 {
  1288. hisAdvice, err := service.GetHisDoctorAdvicesById(advice.ID)
  1289. if err == nil {
  1290. if hisAdvice.ID > 0 {
  1291. advice.ExecutionTime = hisAdvice.ExecutionTime
  1292. advice.ExecutionStaff = hisAdvice.ExecutionStaff
  1293. advice.ExecutionState = hisAdvice.ExecutionState
  1294. advice.CheckTime = hisAdvice.CheckTime
  1295. advice.Checker = hisAdvice.Checker
  1296. advice.CheckState = hisAdvice.CheckState
  1297. advice.StartTime = hisAdvice.StartTime
  1298. }
  1299. }
  1300. }
  1301. }
  1302. //
  1303. //if json["execution_time"] != nil && reflect.TypeOf(json["execution_time"]).String() == "string" {
  1304. // execution_time, _ := strconv.ParseInt(json["execution_time"].(string), 10,64)
  1305. // advice.ExecutionTime = execution_time
  1306. //}
  1307. //
  1308. //
  1309. //
  1310. //if json["execution_staff"] != nil && reflect.TypeOf(json["execution_staff"]).String() == "string" {
  1311. // execution_staff, _ := strconv.ParseInt(json["execution_staff"].(string), 10,64)
  1312. // advice.ExecutionStaff = execution_staff
  1313. //}
  1314. //
  1315. //
  1316. //
  1317. //if json["execution_state"] != nil && reflect.TypeOf(json["execution_state"]).String() == "string" {
  1318. // execution_state, _ := strconv.ParseInt(json["execution_state"].(string), 10,64)
  1319. // advice.ExecutionState = execution_state
  1320. //}
  1321. //
  1322. //
  1323. //if json["check_time"] != nil && reflect.TypeOf(json["check_time"]).String() == "string" {
  1324. // check_time, _ := strconv.ParseInt(json["check_time"].(string), 10,64)
  1325. // advice.CheckTime = check_time
  1326. //}
  1327. //
  1328. //
  1329. //if json["check_state"] != nil && reflect.TypeOf(json["check_state"]).String() == "string" {
  1330. // check_state, _ := strconv.ParseInt(json["check_state"].(string), 10,64)
  1331. // advice.CheckState = check_state
  1332. //}
  1333. //
  1334. //
  1335. //if json["checker"] != nil && reflect.TypeOf(json["checker"]).String() == "string" {
  1336. // checker, _ := strconv.ParseInt(json["checker"].(string), 10,64)
  1337. // advice.Checker = checker
  1338. //}
  1339. //
  1340. //if json["start_time"] != nil && reflect.TypeOf(json["start_time"]).String() == "string" {
  1341. // start_time, _ := strconv.ParseInt(json["start_time"].(string), 10,64)
  1342. // advice.StartTime = start_time
  1343. //}
  1344. if json["min_unit"] != nil && reflect.TypeOf(json["min_unit"]).String() == "string" {
  1345. drugSpecUnit, _ := json["min_unit"].(string)
  1346. advice.DrugSpecUnit = drugSpecUnit
  1347. }
  1348. if json["single_dose"] != nil && reflect.TypeOf(json["single_dose"]).String() == "string" {
  1349. singleDose, _ := strconv.ParseFloat(json["single_dose"].(string), 64)
  1350. advice.SingleDose = singleDose
  1351. }
  1352. if json["single_dose_unit"] != nil && reflect.TypeOf(json["single_dose_unit"]).String() == "string" {
  1353. singleDoseUnit, _ := json["single_dose_unit"].(string)
  1354. advice.SingleDoseUnit = singleDoseUnit
  1355. }
  1356. if json["prescribing_number"] != nil && reflect.TypeOf(json["prescribing_number"]).String() == "string" {
  1357. prescribingNumber, _ := strconv.ParseFloat(json["prescribing_number"].(string), 64)
  1358. advice.PrescribingNumber = prescribingNumber
  1359. }
  1360. if json["prescribing_number_unit"] != nil && reflect.TypeOf(json["prescribing_number_unit"]).String() == "string" {
  1361. prescribingNumberUnit, _ := json["prescribing_number_unit"].(string)
  1362. advice.PrescribingNumberUnit = prescribingNumberUnit
  1363. }
  1364. if json["delivery_way"] != nil && reflect.TypeOf(json["delivery_way"]).String() == "string" {
  1365. deliveryWay, _ := json["delivery_way"].(string)
  1366. advice.DeliveryWay = deliveryWay
  1367. }
  1368. if json["execution_frequency"] != nil && reflect.TypeOf(json["execution_frequency"]).String() == "string" {
  1369. executionFrequency, _ := json["execution_frequency"].(string)
  1370. advice.ExecutionFrequency = executionFrequency
  1371. }
  1372. if json["retail_price"] != nil || reflect.TypeOf(json["retail_price"]).String() == "string" {
  1373. price, _ := strconv.ParseFloat(json["retail_price"].(string), 64)
  1374. advice.Price = price
  1375. }
  1376. if json["medical_insurance_number"] != nil || reflect.TypeOf(json["medical_insurance_number"]).String() == "string" {
  1377. med_list_codg, _ := json["medical_insurance_number"].(string)
  1378. advice.MedListCodg = med_list_codg
  1379. }
  1380. if json["day"] != nil || reflect.TypeOf(json["day"]).String() == "float64" {
  1381. day := int64(json["day"].(float64))
  1382. advice.Day = day
  1383. }
  1384. return 0
  1385. }
  1386. func (c *HisApiController) setProjectWithJSON(project *models.HisPrescriptionProject, json map[string]interface{}) int {
  1387. if json["id"] != nil || reflect.TypeOf(json["id"]).String() == "float64" {
  1388. id := int64(json["id"].(float64))
  1389. project.ID = id
  1390. }
  1391. if json["project_id"] != nil || reflect.TypeOf(json["project_id"]).String() == "float64" {
  1392. project_id := int64(json["project_id"].(float64))
  1393. project.ProjectId = project_id
  1394. fmt.Println(project_id)
  1395. fmt.Println(project.ProjectId)
  1396. }
  1397. // if json["price"] != nil || reflect.TypeOf(json["price"]).String() == "float64" {
  1398. // price := int64(json["price"].(float64))
  1399. // formatInt_price := strconv.FormatInt(price, 10)
  1400. // float_price, _ := strconv.ParseFloat(formatInt_price, 64)
  1401. // project.Price = float_price
  1402. // }
  1403. if json["price"] != nil || reflect.TypeOf(json["price"]).String() == "string" {
  1404. price, _ := strconv.ParseFloat(json["price"].(string), 64)
  1405. project.Price = price
  1406. }
  1407. if json["total"] != nil && reflect.TypeOf(json["total"]).String() == "string" {
  1408. total, _ := json["total"].(string)
  1409. totals, _ := strconv.ParseInt(total, 10, 64)
  1410. project.Count = totals
  1411. }
  1412. if json["medical_code"] != nil && reflect.TypeOf(json["medical_code"]).String() == "string" {
  1413. medical_code, _ := json["medical_code"].(string)
  1414. project.MedListCodg = medical_code
  1415. }
  1416. if json["single_dose"] != nil && reflect.TypeOf(json["single_dose"]).String() == "string" {
  1417. single_dose, _ := json["single_dose"].(string)
  1418. project.SingleDose = single_dose
  1419. }
  1420. if json["delivery_way"] != nil && reflect.TypeOf(json["delivery_way"]).String() == "string" {
  1421. delivery_way, _ := json["delivery_way"].(string)
  1422. project.DeliveryWay = delivery_way
  1423. }
  1424. if json["execution_frequency"] != nil && reflect.TypeOf(json["execution_frequency"]).String() == "string" {
  1425. execution_frequency, _ := json["execution_frequency"].(string)
  1426. project.ExecutionFrequency = execution_frequency
  1427. }
  1428. if json["remark"] != nil && reflect.TypeOf(json["remark"]).String() == "string" {
  1429. remark, _ := json["remark"].(string)
  1430. project.Remark = remark
  1431. }
  1432. if json["number_days"] != nil && reflect.TypeOf(json["number_days"]).String() == "string" {
  1433. day, _ := json["number_days"].(string)
  1434. project.Day = day
  1435. }
  1436. if json["unit"] != nil && reflect.TypeOf(json["unit"]).String() == "string" {
  1437. unit, _ := json["unit"].(string)
  1438. project.Unit = unit
  1439. }
  1440. return 0
  1441. }
  1442. func (c *HisApiController) setAddtionWithJSON(additionalCharge *models.HisAdditionalCharge, json map[string]interface{}, org_id int64) int {
  1443. if json["id"] != nil || reflect.TypeOf(json["id"]).String() == "float64" {
  1444. id := int64(json["id"].(float64))
  1445. additionalCharge.ID = id
  1446. }
  1447. if json["item_id"] != nil || reflect.TypeOf(json["item_id"]).String() == "float64" {
  1448. item_id := int64(json["item_id"].(float64))
  1449. additionalCharge.ItemId = item_id
  1450. config, _ := service.GetAdditionChargeByID(org_id, item_id)
  1451. if config.ID > 0 {
  1452. if len(config.Code) > 0 {
  1453. additionalCharge.MedListCodg = config.Code
  1454. }
  1455. }
  1456. }
  1457. // if json["price"] != nil || reflect.TypeOf(json["price"]).String() == "float64" {
  1458. // price := int64(json["price"].(float64))
  1459. // formatInt_price := strconv.FormatInt(price, 10)
  1460. // float_price, _ := strconv.ParseFloat(formatInt_price, 64)
  1461. // additionalCharge.Price = float_price
  1462. // }
  1463. //if json["price"] != nil || reflect.TypeOf(json["price"]).String() == "float64" {
  1464. // price := int64(json["price"].(float64))
  1465. // formatInt_price := strconv.FormatInt(price, 10)
  1466. // float_price, _ := strconv.ParseFloat(formatInt_price, 64)
  1467. // additionalCharge.Price = float_price
  1468. //}
  1469. if json["price"] != nil || reflect.TypeOf(json["price"]).String() == "string" {
  1470. price, _ := strconv.ParseFloat(json["price"].(string), 64)
  1471. additionalCharge.Price = price
  1472. }
  1473. if json["count"] != nil && reflect.TypeOf(json["count"]).String() == "string" {
  1474. count, _ := json["count"].(string)
  1475. counts, _ := strconv.ParseInt(count, 10, 64)
  1476. additionalCharge.Count = counts
  1477. }
  1478. if json["item_name"] != nil && reflect.TypeOf(json["item_name"]).String() == "string" {
  1479. item_name, _ := json["item_name"].(string)
  1480. additionalCharge.ItemName = item_name
  1481. }
  1482. return 0
  1483. }
  1484. func (c *HisApiController) GetHisOrderList() {
  1485. page, _ := c.GetInt64("page", -1)
  1486. limit, _ := c.GetInt64("limit", -1)
  1487. start_time := c.GetString("start_time")
  1488. end_time := c.GetString("end_time")
  1489. types, _ := c.GetInt64("type", 0)
  1490. keywords := c.GetString("keywords")
  1491. timeLayout := "2006-01-02"
  1492. loc, _ := time.LoadLocation("Local")
  1493. var startTime int64
  1494. if len(start_time) > 0 {
  1495. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  1496. if err != nil {
  1497. fmt.Println(err)
  1498. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1499. return
  1500. }
  1501. startTime = theTime.Unix()
  1502. }
  1503. var endTime int64
  1504. if len(end_time) > 0 {
  1505. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  1506. if err != nil {
  1507. utils.ErrorLog(err.Error())
  1508. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1509. return
  1510. }
  1511. endTime = theTime.Unix()
  1512. }
  1513. adminUser := c.GetAdminUserInfo()
  1514. org_id := adminUser.CurrentOrgId
  1515. order, err, total := service.GetHisOrderList(org_id, page, limit, startTime, endTime, types, keywords)
  1516. if err == nil {
  1517. c.ServeSuccessJSON(map[string]interface{}{
  1518. "order": order,
  1519. "total": total,
  1520. })
  1521. } else {
  1522. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1523. return
  1524. }
  1525. }
  1526. func (c *HisApiController) GetHisOrder() {
  1527. patient_id, _ := c.GetInt64("patient_id", 0)
  1528. number := c.GetString("number")
  1529. adminInfo := c.GetAdminUserInfo()
  1530. order, err := service.GetHisOrder(adminInfo.CurrentOrgId, number, patient_id)
  1531. prescriptions, _ := service.GetHisPrescriptionThree(adminInfo.CurrentOrgId, patient_id, order.SettleAccountsDate, order.Number)
  1532. if err == nil {
  1533. c.ServeSuccessJSON(map[string]interface{}{
  1534. "order": order,
  1535. "prescription": prescriptions,
  1536. })
  1537. } else {
  1538. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1539. return
  1540. }
  1541. }
  1542. func (c *HisApiController) GetHisPrescriptionList() {
  1543. record_date := c.GetString("record_date")
  1544. keywords := c.GetString("keywords")
  1545. page, _ := c.GetInt64("page")
  1546. limit, _ := c.GetInt64("limit")
  1547. timeLayout := "2006-01-02"
  1548. loc, _ := time.LoadLocation("Local")
  1549. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_date+" 00:00:00", loc)
  1550. if err != nil {
  1551. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1552. return
  1553. }
  1554. recordDateTime := theTime.Unix()
  1555. adminInfo := c.GetAdminUserInfo()
  1556. prescriptionOrder, err, total := service.GetHisPatientPrescriptionList(adminInfo.CurrentOrgId, keywords, recordDateTime, page, limit)
  1557. //adminInfo := c.GetAdminUserInfo()
  1558. //prescriptionOrder, err := service.GetHisPrescriptionOrderList(adminInfo.CurrentOrgId)
  1559. //fmt.Println(prescriptionOrder)
  1560. if err == nil {
  1561. c.ServeSuccessJSON(map[string]interface{}{
  1562. "order": prescriptionOrder,
  1563. "total": total,
  1564. })
  1565. } else {
  1566. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1567. return
  1568. }
  1569. }
  1570. func (c *HisApiController) GetHisPrescriptionInfo() {
  1571. id, _ := c.GetInt64("id")
  1572. adminInfo := c.GetAdminUserInfo()
  1573. prescriptionOrder, err := service.GetHisPrescriptionOrderInfo(id, adminInfo.CurrentOrgId)
  1574. prescription, err := service.GetHisPrescriptionFour(adminInfo.CurrentOrgId, prescriptionOrder.PatientId, prescriptionOrder.RecordDate, prescriptionOrder.PrescriptionNumber)
  1575. if err == nil {
  1576. c.ServeSuccessJSON(map[string]interface{}{
  1577. "order": prescriptionOrder,
  1578. "prescription": prescription,
  1579. })
  1580. } else {
  1581. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1582. return
  1583. }
  1584. }
  1585. func (c *HisApiController) GetMedicalInsuranceConfig() {
  1586. adminUser := c.GetAdminUserInfo()
  1587. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  1588. c.ServeSuccessJSON(map[string]interface{}{
  1589. "config": config,
  1590. })
  1591. }
  1592. type ResultTwo struct {
  1593. ErrMsg interface{} `json:"err_msg"`
  1594. InfRefmsgid string `json:"inf_refmsgid"`
  1595. Infcode int64 `json:"infcode"`
  1596. Output struct {
  1597. Baseinfo struct {
  1598. Age float64 `json:"age"`
  1599. Brdy string `json:"brdy"`
  1600. Certno string `json:"certno"`
  1601. Gend string `json:"gend"`
  1602. Naty string `json:"naty"`
  1603. PsnCertType string `json:"psn_cert_type"`
  1604. PsnName string `json:"psn_name"`
  1605. PsnNo string `json:"psn_no"`
  1606. } `json:"baseinfo"`
  1607. Idetinfo []interface{} `json:"idetinfo"`
  1608. Iinfo []struct {
  1609. Balc int64 `json:"balc"`
  1610. CvlservFlag string `json:"cvlserv_flag"`
  1611. EmpName string `json:"emp_name"`
  1612. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  1613. Insutype string `json:"insutype"`
  1614. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  1615. PausInsuDate interface{} `json:"paus_insu_date"`
  1616. PsnInsuDate string `json:"psn_insu_date"`
  1617. PsnInsuStas string `json:"psn_insu_stas"`
  1618. PsnType string `json:"psn_type"`
  1619. } `json:"insuinfo"`
  1620. } `json:"output"`
  1621. RefmsgTime string `json:"refmsg_time"`
  1622. RespondTime string `json:"respond_time"`
  1623. Signtype interface{} `json:"signtype"`
  1624. WarnInfo interface{} `json:"warn_info"`
  1625. }
  1626. type ResultThree struct {
  1627. Cainfo interface{} `json:"cainfo"`
  1628. ErrMsg interface{} `json:"err_msg"`
  1629. InfRefmsgid string `json:"inf_refmsgid"`
  1630. Infcode int64 `json:"infcode"`
  1631. Output struct {
  1632. Data struct {
  1633. IptOtpNo string `json:"ipt_otp_no"`
  1634. MdtrtID string `json:"mdtrt_id"`
  1635. PsnNo string `json:"psn_no"`
  1636. } `json:"data"`
  1637. } `json:"output"`
  1638. RefmsgTime string `json:"refmsg_time"`
  1639. RespondTime string `json:"respond_time"`
  1640. Signtype interface{} `json:"signtype"`
  1641. WarnMsg interface{} `json:"warn_msg"`
  1642. }
  1643. type ResultFour struct {
  1644. Cainfo string `json:"cainfo"`
  1645. ErrMsg string `json:"err_msg"`
  1646. InfRefmsgid string `json:"inf_refmsgid"`
  1647. Infcode int64 `json:"infcode"`
  1648. Output struct {
  1649. Result []struct {
  1650. BasMednFlag string `json:"bas_medn_flag"`
  1651. ChldMedcFlag string `json:"chld_medc_flag"`
  1652. ChrgitmLv string `json:"chrgitm_lv"`
  1653. Cnt float64 `json:"cnt"`
  1654. DetItemFeeSumamt float64 `json:"det_item_fee_sumamt"`
  1655. DrtReimFlag string `json:"drt_reim_flag"`
  1656. FeedetlSn string `json:"feedetl_sn"`
  1657. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  1658. HiNegoDrugFlag string `json:"hi_nego_drug_flag"`
  1659. InscpScpAmt float64 `json:"inscp_scp_amt"`
  1660. ListSpItemFlag string `json:"list_sp_item_flag"`
  1661. LmtUsedFlag string `json:"lmt_used_flag"`
  1662. MedChrgitmType string `json:"med_chrgitm_type"`
  1663. Memo string `json:"memo"`
  1664. OverlmtAmt float64 `json:"overlmt_amt"`
  1665. PreselfpayAmt float64 `json:"preselfpay_amt"`
  1666. Pric float64 `json:"pric"`
  1667. PricUplmtAmt float64 `json:"pric_uplmt_amt"`
  1668. SelfpayProp float64 `json:"selfpay_prop"`
  1669. } `json:"result"`
  1670. } `json:"output"`
  1671. RefmsgTime string `json:"refmsg_time"`
  1672. RespondTime string `json:"respond_time"`
  1673. Signtype string `json:"signtype"`
  1674. WarnMsg string `json:"warn_msg"`
  1675. }
  1676. type ResultFive struct {
  1677. Insutype string `json:"insutype"`
  1678. }
  1679. type ResultSix struct {
  1680. Cainfo interface{} `json:"cainfo"`
  1681. ErrMsg interface{} `json:"err_msg"`
  1682. InfRefmsgid string `json:"inf_refmsgid"`
  1683. Infcode int64 `json:"infcode"`
  1684. Output struct {
  1685. } `json:"output"`
  1686. RefmsgTime string `json:"refmsg_time"`
  1687. RespondTime string `json:"respond_time"`
  1688. Signtype interface{} `json:"signtype"`
  1689. WarnMsg interface{} `json:"warn_msg"`
  1690. }
  1691. type ResultSeven struct {
  1692. Cainfo string `json:"cainfo"`
  1693. ErrMsg string `json:"err_msg"`
  1694. InfRefmsgid string `json:"inf_refmsgid"`
  1695. Infcode int64 `json:"infcode"`
  1696. Output struct {
  1697. Setldetail []interface{} `json:"setldetail"`
  1698. Setlinfo struct {
  1699. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  1700. AcctPay float64 `json:"acct_pay"`
  1701. ActPayDedc float64 `json:"act_pay_dedc"`
  1702. Age float64 `json:"age"`
  1703. Balc float64 `json:"balc"`
  1704. Brdy string `json:"brdy"`
  1705. Certno string `json:"certno"`
  1706. ClrOptins string `json:"clr_optins"`
  1707. ClrType string `json:"clr_type"`
  1708. ClrWay string `json:"clr_way"`
  1709. CvlservFlag string `json:"cvlserv_flag"`
  1710. CvlservPay float64 `json:"cvlserv_pay"`
  1711. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  1712. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  1713. Gend string `json:"gend"`
  1714. HifesPay float64 `json:"hifes_pay"`
  1715. HifmiPay float64 `json:"hifmi_pay"`
  1716. HifobPay float64 `json:"hifob_pay"`
  1717. HifpPay float64 `json:"hifp_pay"`
  1718. HospPartAmt float64 `json:"hosp_part_amt"`
  1719. InscpScpAmt float64 `json:"inscp_scp_amt"`
  1720. Insutype string `json:"insutype"`
  1721. MafPay float64 `json:"maf_pay"`
  1722. MdtrtCertType string `json:"mdtrt_cert_type"`
  1723. MdtrtID string `json:"mdtrt_id"`
  1724. MedType string `json:"med_type"`
  1725. MedfeeSumamt float64 `json:"medfee_sumamt"`
  1726. MedinsSetlID string `json:"medins_setl_id"`
  1727. Naty string `json:"naty"`
  1728. OthPay float64 `json:"oth_pay"`
  1729. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  1730. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  1731. PreselfpayAmt float64 `json:"preselfpay_amt"`
  1732. PsnCashPay float64 `json:"psn_cash_pay"`
  1733. PsnCertType string `json:"psn_cert_type"`
  1734. PsnName string `json:"psn_name"`
  1735. PsnNo string `json:"psn_no"`
  1736. PsnPartAmt float64 `json:"psn_part_amt"`
  1737. PsnType string `json:"psn_type"`
  1738. SetlID string `json:"setl_id"`
  1739. SetlTime string `json:"setl_time"`
  1740. } `json:"setlinfo"`
  1741. } `json:"output"`
  1742. RefmsgTime string `json:"refmsg_time"`
  1743. RespondTime string `json:"respond_time"`
  1744. Signtype interface{} `json:"signtype"`
  1745. WarnMsg interface{} `json:"warn_msg"`
  1746. }
  1747. type ResultEight struct {
  1748. Cainfo string `json:"cainfo"`
  1749. ErrMsg string `json:"err_msg"`
  1750. InfRefmsgid string `json:"inf_refmsgid"`
  1751. Infcode int64 `json:"infcode"`
  1752. Output struct {
  1753. Stmtinfo struct {
  1754. SetlOptins string `json:"setl_optins"`
  1755. StmtRslt string `json:"stmt_rslt"`
  1756. StmtRsltDscr string `json:"stmt_rslt_dscr"`
  1757. } `json:"stmtinfo"`
  1758. } `json:"output"`
  1759. RefmsgTime string `json:"refmsg_time"`
  1760. RespondTime string `json:"respond_time"`
  1761. Signtype interface{} `json:"signtype"`
  1762. WarnMsg interface{} `json:"warn_msg"`
  1763. }
  1764. type ResultNine struct {
  1765. Cainfo string `json:"cainfo"`
  1766. ErrMsg string `json:"err_msg"`
  1767. InfRefmsgid string `json:"inf_refmsgid"`
  1768. Infcode int64 `json:"infcode"`
  1769. Output struct {
  1770. FileQuryNo string `json:"file_qury_no"`
  1771. } `json:"output"`
  1772. RefmsgTime string `json:"refmsg_time"`
  1773. RespondTime string `json:"respond_time"`
  1774. Signtype interface{} `json:"signtype"`
  1775. WarnMsg interface{} `json:"warn_msg"`
  1776. }
  1777. type ResultTen struct {
  1778. Cainfo string `json:"cainfo"`
  1779. ErrMsg string `json:"err_msg"`
  1780. InfRefmsgid string `json:"inf_refmsgid"`
  1781. Infcode int64 `json:"infcode"`
  1782. Output struct {
  1783. DldEndtime string `json:"dld_endtime"`
  1784. FileQuryNo string `json:"file_qury_no"`
  1785. Filename string `json:"filename"`
  1786. } `json:"output"`
  1787. RefmsgTime string `json:"refmsg_time"`
  1788. RespondTime string `json:"respond_time"`
  1789. Signtype interface{} `json:"signtype"`
  1790. WarnMsg interface{} `json:"warn_msg"`
  1791. }
  1792. type ResultEleven struct {
  1793. Cainfo string `json:"cainfo"`
  1794. ErrMsg string `json:"err_msg"`
  1795. InfRefmsgid string `json:"inf_refmsgid"`
  1796. Infcode int64 `json:"infcode"`
  1797. Output struct {
  1798. Setlinfo struct {
  1799. FixmedinsName string `json:"fixmedins_name"`
  1800. FixmedinsCode string `json:"fixmedins_code"`
  1801. PsnNo string `json:"psn_no"`
  1802. PsnName string `json:"psn_name"`
  1803. HifobPay float64 `json:"hifob_pay"`
  1804. Gend string `json:"gend"`
  1805. Brdy string `json:"brdy"`
  1806. PsnCertType string `json:"psn_cert_type"`
  1807. PsnType string `json:"psn_type"`
  1808. EmpName string `json:"emp_name"`
  1809. Certno string `json:"certno"`
  1810. Insutype string `json:"insutype"`
  1811. MedfeeSumamt float64 `json:"medfee_sumamt"`
  1812. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  1813. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  1814. PreselfpayAmt float64 `json:"preselfpay_amt"`
  1815. InscpScpAmt float64 `json:"inscp_scp_amt"`
  1816. ActPayDedc float64 `json:"act_pay_dedc"`
  1817. HifpPay float64 `json:"hifp_pay"`
  1818. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  1819. CvlservPay float64 `json:"cvlserv_pay"`
  1820. HifesPay float64 `json:"hifes_pay"`
  1821. HifmiPay float64 `json:"hifmi_pay"`
  1822. MafPay float64 `json:"maf_pay"`
  1823. OthPay float64 `json:"oth_pay"`
  1824. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  1825. PsnPay float64 `json:"psn_pay"`
  1826. AcctPay float64 `json:"acct_pay"`
  1827. CashPayamt float64 `json:"cash_payamt"`
  1828. Balc float64 `json:"balc"`
  1829. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  1830. MedinsSetlId string `json:"medins_setl_id"`
  1831. RefdSetlFlag string `json:"refd_setl_flag"`
  1832. SetlTime string `json:"setl_time"`
  1833. MedType string `json:"med_type"`
  1834. } `json:"setlinfo"`
  1835. } `json:"output"`
  1836. RefmsgTime string `json:"refmsg_time"`
  1837. RespondTime string `json:"respond_time"`
  1838. Signtype interface{} `json:"signtype"`
  1839. WarnMsg interface{} `json:"warn_msg"`
  1840. }
  1841. type Custom struct {
  1842. DetItemFeeSumamt string
  1843. Cut string
  1844. FeedetlSn string
  1845. Price string
  1846. MedListCodg string
  1847. Type int64
  1848. AdviceId int64
  1849. ProjectId int64
  1850. ItemId int64
  1851. }
  1852. //获取个人信息----挂号-----上传就诊信息
  1853. func (c *HisApiController) GetRegisterInfo() {
  1854. id, _ := c.GetInt64("id")
  1855. record_time := c.GetString("record_time")
  1856. name := c.GetString("name")
  1857. gender, _ := c.GetInt64("gender")
  1858. age, _ := c.GetInt64("age")
  1859. birthday := c.GetString("birthday")
  1860. phone := c.GetString("phone")
  1861. medical_care, _ := c.GetInt64("medical_care")
  1862. id_card := c.GetString("id_card")
  1863. register_type, _ := c.GetInt64("register_type")
  1864. registration_fee, _ := c.GetFloat("registration_fee")
  1865. medical_expenses, _ := c.GetFloat("medical_expenses")
  1866. certificates, _ := c.GetInt64("certificates")
  1867. settlementValue, _ := c.GetInt64("settlement_value")
  1868. social_type, _ := c.GetInt64("social_type")
  1869. medical_insurance_card := c.GetString("medical_insurance_card")
  1870. id_card_type, _ := c.GetInt64("id_card_type")
  1871. timeLayout := "2006-01-02"
  1872. loc, _ := time.LoadLocation("Local")
  1873. birthdays, _ := time.ParseInLocation(timeLayout+" 15:04:05", birthday+" 00:00:00", loc)
  1874. birthUnix := birthdays.Unix()
  1875. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  1876. if err != nil {
  1877. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1878. return
  1879. }
  1880. recordDateTime := theTime.Unix()
  1881. adminInfo := c.GetAdminUserInfo()
  1882. patient, _ := service.GetPatientByID(adminInfo.CurrentOrgId, id)
  1883. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  1884. miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  1885. if patient == nil {
  1886. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  1887. return
  1888. }
  1889. if len(patient.IdCardNo) == 0 {
  1890. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeIDCartNo)
  1891. return
  1892. }
  1893. //org, _ := service.GetOrgById(adminInfo.CurrentOrgId)
  1894. config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  1895. if config.IsOpen == 1 {
  1896. api := "http://127.0.0.1:9531/" + "gdyb/one?cert_no=" + patient.IdCardNo + "&org_name=" + miConfig.OrgName + "&doctor=" + patientPrescription.Doctor + "&fixmedins_code=" + miConfig.Code + "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  1897. resp, requestErr := http.Get(api)
  1898. if requestErr != nil {
  1899. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1900. return
  1901. }
  1902. defer resp.Body.Close()
  1903. body, ioErr := ioutil.ReadAll(resp.Body)
  1904. if ioErr != nil {
  1905. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1906. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1907. return
  1908. }
  1909. var respJSON map[string]interface{}
  1910. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  1911. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1912. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1913. return
  1914. }
  1915. userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1916. userJSONBytes, _ := json.Marshal(userJSON)
  1917. var res ResultTwo
  1918. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  1919. utils.ErrorLog("解析失败:%v", err)
  1920. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1921. return
  1922. }
  1923. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  1924. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  1925. infoStr := string(Iinfos)
  1926. idetinfoStr := string(Idetinfos)
  1927. his := models.VMHisPatient{
  1928. PsnNo: res.Output.Baseinfo.PsnNo,
  1929. PsnCertType: res.Output.Baseinfo.PsnCertType,
  1930. Certno: res.Output.Baseinfo.Certno,
  1931. PsnName: res.Output.Baseinfo.PsnName,
  1932. Gend: res.Output.Baseinfo.Gend,
  1933. Naty: res.Output.Baseinfo.Naty,
  1934. Brdy: res.Output.Baseinfo.Brdy,
  1935. Age: res.Output.Baseinfo.Age,
  1936. Iinfo: infoStr,
  1937. Idetinfo: idetinfoStr,
  1938. PatientId: patient.ID,
  1939. RecordDate: theTime.Unix(),
  1940. UserOrgId: adminInfo.CurrentOrgId,
  1941. AdminUserId: adminInfo.AdminUser.Id,
  1942. IsReturn: 1,
  1943. }
  1944. fmt.Println(his)
  1945. lastPatient, _ := service.GetLastPatient(adminInfo.CurrentOrgId)
  1946. timeStr := time.Now().Format("2006-01-02")
  1947. timeArr := strings.Split(timeStr, "-")
  1948. var str = timeArr[0] + timeArr[1] + timeArr[2] + strconv.FormatInt(lastPatient.ID, 10)
  1949. hisPatient := models.HisPatient{
  1950. Number: str,
  1951. }
  1952. err = service.UpdateHisPatient(lastPatient.ID, hisPatient)
  1953. if res.Output.Iinfo == nil || len(res.Output.Iinfo) == 0 {
  1954. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterOneException)
  1955. return
  1956. }
  1957. timestamp := time.Now().Unix()
  1958. tempTime := time.Unix(timestamp, 0)
  1959. timeFormat := tempTime.Format("20060102150405")
  1960. chrgBchno := rand.Intn(100000) + 10000
  1961. ipt_otp_no := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  1962. count, _ := service.FindHisRegisterRecord(theTime.Unix(), patient.ID, adminInfo.CurrentOrgId)
  1963. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  1964. //department_id := strconv.FormatInt(department.ID, 10)
  1965. doctor_id := strconv.FormatInt(patientPrescription.DoctorId, 10)
  1966. if count <= 0 {
  1967. api := "http://127.0.0.1:9531/" + "gdyb/two?cert_no=" + patient.IdCardNo + "&insutype=" +
  1968. res.Output.Iinfo[0].Insutype + "&psn_no=" + res.Output.Baseinfo.PsnNo +
  1969. "&org_name=" + miConfig.OrgName + "&doctor=" + patientPrescription.Doctor + "&ipt_otp_no=" + ipt_otp_no +
  1970. "&dept=" + department.Name + "&fixmedins_code=" + miConfig.Code + "&dept_code=" + department.Number + "&doctor_id=" + doctor_id + "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  1971. resp, requestErr := http.Get(api)
  1972. if requestErr != nil {
  1973. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1974. return
  1975. }
  1976. defer resp.Body.Close()
  1977. body, ioErr := ioutil.ReadAll(resp.Body)
  1978. if ioErr != nil {
  1979. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1980. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1981. return
  1982. }
  1983. var respJSON map[string]interface{}
  1984. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  1985. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1986. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1987. return
  1988. }
  1989. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1990. userJSONBytes, _ := json.Marshal(respJSON)
  1991. var res ResultThree
  1992. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  1993. utils.ErrorLog("解析失败:%v", err)
  1994. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1995. return
  1996. }
  1997. if res.Infcode == -1 {
  1998. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterTwoException)
  1999. return
  2000. }
  2001. fmt.Println("000!!!!!!")
  2002. fmt.Println(res)
  2003. fmt.Println(res.Output.Data.MdtrtID)
  2004. fmt.Println(res.Output.Data.PsnNo)
  2005. fmt.Println(res.Output.Data.IptOtpNo)
  2006. his.Number = res.Output.Data.MdtrtID
  2007. his.PsnNo = res.Output.Data.PsnNo
  2008. his.IptOtpNo = res.Output.Data.IptOtpNo
  2009. his.IdCardNo = patient.IdCardNo
  2010. his.PhoneNumber = patient.Phone
  2011. his.UserOrgId = adminInfo.CurrentOrgId
  2012. his.Status = 1
  2013. his.Ctime = time.Now().Unix()
  2014. his.Mtime = time.Now().Unix()
  2015. err := service.CreateHisPatientTwo(&his)
  2016. diagnosisConfig, _ := service.FindDiagnoseById(patientPrescription.Diagnosis)
  2017. if err == nil {
  2018. api := "http://127.0.0.1:9531/" + "gdyb/four?psn_no=" + his.PsnNo +
  2019. "&mdtrt_id=" + his.Number + "&doctor=" + patientPrescription.Doctor + "&department=" + department.Name +
  2020. "&diag=" + diagnosisConfig.ClassName + "&org_name=" + miConfig.OrgName + "&med_type=" + "11" + "&doctor_id=" + strconv.FormatInt(patientPrescription.DoctorId, 10) + "&fixmedins_code=" + miConfig.Code + "&diag_code=" + diagnosisConfig.CountryCode +
  2021. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  2022. resp, requestErr := http.Get(api)
  2023. if requestErr != nil {
  2024. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2025. return
  2026. }
  2027. body, ioErr := ioutil.ReadAll(resp.Body)
  2028. if ioErr != nil {
  2029. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2030. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2031. return
  2032. }
  2033. var respJSON map[string]interface{}
  2034. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  2035. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2036. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2037. return
  2038. }
  2039. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2040. userJSONBytes, _ := json.Marshal(respJSON)
  2041. fmt.Println(respJSON)
  2042. fmt.Println(userJSONBytes)
  2043. var res ResultSix
  2044. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  2045. utils.ErrorLog("解析失败:%v", err)
  2046. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2047. return
  2048. }
  2049. if res.Infcode == -1 {
  2050. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterTwoException)
  2051. return
  2052. }
  2053. c.ServeSuccessJSON(map[string]interface{}{
  2054. "his_info": his,
  2055. })
  2056. } else {
  2057. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2058. return
  2059. }
  2060. }
  2061. } else {
  2062. timeStr := time.Now().Format("2006-01-02")
  2063. timeArr := strings.Split(timeStr, "-")
  2064. var str = timeArr[0] + timeArr[1] + timeArr[2] + strconv.FormatInt(patient.ID, 10)
  2065. his, err := service.GetHisPatientInfo(adminInfo.CurrentOrgId, patient.ID, recordDateTime)
  2066. var hisPatient models.XtHisPatient
  2067. if err == gorm.ErrRecordNotFound || his.ID == 0 {
  2068. hisPatient = models.XtHisPatient{
  2069. Name: name,
  2070. Age: age,
  2071. Gender: gender,
  2072. Birthday: birthUnix,
  2073. Phone: phone,
  2074. MedicalTreatmentType: medical_care,
  2075. IdType: certificates,
  2076. IdCardNo: id_card,
  2077. BalanceAccountsType: settlementValue,
  2078. SocialType: social_type,
  2079. MedicalInsuranceNumber: medical_insurance_card,
  2080. RegisterType: register_type,
  2081. RegisterCost: registration_fee,
  2082. TreatmentCost: medical_expenses,
  2083. AdminUserId: adminInfo.AdminUser.Id,
  2084. UserOrgId: adminInfo.CurrentOrgId,
  2085. Status: 1,
  2086. RecordDate: recordDateTime,
  2087. IsReturn: 1,
  2088. PatientId: patient.ID,
  2089. Ctime: time.Now().Unix(),
  2090. Mtime: time.Now().Unix(),
  2091. Number: str,
  2092. IdCardType: id_card_type,
  2093. }
  2094. service.CreateHisPatient(&hisPatient)
  2095. }
  2096. c.ServeSuccessJSON(map[string]interface{}{
  2097. "his_info": hisPatient,
  2098. })
  2099. }
  2100. }
  2101. //上传明细----结算
  2102. func (c *HisApiController) GetUploadInfo() {
  2103. id, _ := c.GetInt64("id")
  2104. record_time := c.GetString("record_time")
  2105. pay_way, _ := c.GetInt64("pay_way")
  2106. pay_price, _ := c.GetFloat("pay_price")
  2107. pay_card_no := c.GetString("pay_card_no")
  2108. discount_price, _ := c.GetFloat("discount_price")
  2109. preferential_price, _ := c.GetFloat("preferential_price")
  2110. reality_price, _ := c.GetFloat("reality_price")
  2111. found_price, _ := c.GetFloat("found_price")
  2112. medical_insurance_price, _ := c.GetFloat("medical_insurance_price")
  2113. private_price, _ := c.GetFloat("private_price")
  2114. timeLayout := "2006-01-02"
  2115. loc, _ := time.LoadLocation("Local")
  2116. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  2117. if err != nil {
  2118. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  2119. return
  2120. }
  2121. recordDateTime := theTime.Unix()
  2122. adminUser := c.GetAdminUserInfo()
  2123. prescriptions, _ := service.GetHisPrescription(adminUser.CurrentOrgId, id, recordDateTime)
  2124. his, _ := service.GetVMHisPatientInfo(adminUser.CurrentOrgId, id, recordDateTime)
  2125. timestamp := time.Now().Unix()
  2126. tempTime := time.Unix(timestamp, 0)
  2127. timeFormat := tempTime.Format("20060102150405")
  2128. chrgBchno := rand.Intn(100000) + 10000
  2129. chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  2130. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  2131. //org, _ := service.GetOrgById(adminUser.CurrentOrgId)
  2132. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  2133. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  2134. strconv.FormatInt(his.PatientId, 10)
  2135. client := &http.Client{}
  2136. data := make(map[string]interface{})
  2137. data["psn_no"] = his.PsnNo
  2138. data["mdtrt_id"] = his.Number
  2139. data["pre"] = prescriptions
  2140. data["chrg_bchno"] = chrg_bchno
  2141. data["org_name"] = miConfig.OrgName
  2142. data["doctor"] = patientPrescription.Doctor
  2143. data["dept"] = patientPrescription.Departments
  2144. data["fixmedins_code"] = miConfig.Code
  2145. data["dept_code"] = department.Number
  2146. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  2147. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  2148. data["secret_key"] = miConfig.SecretKey
  2149. var ids []int64
  2150. //var idsTwo []int64
  2151. //
  2152. for _, item := range prescriptions {
  2153. ids = append(ids, item.ID)
  2154. }
  2155. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  2156. if config.IsOpen == 1 { //对接了医保,走医保流程
  2157. bytesData, _ := json.Marshal(data)
  2158. req, _ := http.NewRequest("POST", "http://127.0.0.1:9531/"+"gdyb/five", bytes.NewReader(bytesData))
  2159. resp, _ := client.Do(req)
  2160. defer resp.Body.Close()
  2161. body, ioErr := ioutil.ReadAll(resp.Body)
  2162. if ioErr != nil {
  2163. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2164. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2165. return
  2166. }
  2167. var respJSON map[string]interface{}
  2168. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2169. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2170. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2171. return
  2172. }
  2173. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2174. userJSONBytes, _ := json.Marshal(respJSON)
  2175. var res ResultFour
  2176. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  2177. utils.ErrorLog("解析失败:%v", err)
  2178. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2179. return
  2180. }
  2181. if res.Infcode == 0 {
  2182. order := &models.HisOrder{
  2183. UserOrgId: adminUser.CurrentOrgId,
  2184. HisPatientId: his.ID,
  2185. PatientId: his.PatientId,
  2186. SettleAccountsDate: recordDateTime,
  2187. Ctime: time.Now().Unix(),
  2188. Mtime: time.Now().Unix(),
  2189. Status: 1,
  2190. Number: chrg_bchno,
  2191. Infcode: res.Infcode,
  2192. WarnMsg: res.WarnMsg,
  2193. Cainfo: res.Cainfo,
  2194. ErrMsg: res.ErrMsg,
  2195. RespondTime: res.RefmsgTime,
  2196. InfRefmsgid: res.InfRefmsgid,
  2197. OrderStatus: 1,
  2198. PayWay: pay_way,
  2199. PayPrice: pay_price,
  2200. PayCardNo: pay_card_no,
  2201. DiscountPrice: discount_price,
  2202. PreferentialPrice: preferential_price,
  2203. RealityPrice: reality_price,
  2204. FoundPrice: found_price,
  2205. MedicalInsurancePrice: medical_insurance_price,
  2206. PrivatePrice: private_price,
  2207. }
  2208. err = service.CreateOrder(order)
  2209. if err != nil {
  2210. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateOrderException)
  2211. return
  2212. }
  2213. for _, item := range res.Output.Result {
  2214. temp := strings.Split(item.FeedetlSn, "-")
  2215. var advice_id int64 = 0
  2216. var project_id int64 = 0
  2217. var types int64 = 0
  2218. id, _ := strconv.ParseInt(temp[2], 10, 64)
  2219. types, _ = strconv.ParseInt(temp[1], 10, 64)
  2220. if temp[1] == "1" {
  2221. advice_id = id
  2222. project_id = 0
  2223. } else if temp[1] == "2" {
  2224. advice_id = 0
  2225. project_id = id
  2226. }
  2227. info := &models.HisOrderInfo{
  2228. OrderNumber: order.Number,
  2229. FeedetlSn: item.FeedetlSn,
  2230. UploadDate: time.Now().Unix(),
  2231. AdviceId: advice_id,
  2232. DetItemFeeSumamt: item.DetItemFeeSumamt,
  2233. Cnt: item.Cnt,
  2234. Pric: float64(item.Pric),
  2235. PatientId: his.PatientId,
  2236. PricUplmtAmt: item.PricUplmtAmt,
  2237. SelfpayProp: item.SelfpayProp,
  2238. FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  2239. OverlmtAmt: item.OverlmtAmt,
  2240. PreselfpayAmt: item.PreselfpayAmt,
  2241. BasMednFlag: item.BasMednFlag,
  2242. MedChrgitmType: item.MedChrgitmType,
  2243. HiNegoDrugFlag: item.HiNegoDrugFlag,
  2244. Status: 1,
  2245. Memo: item.Memo,
  2246. Mtime: time.Now().Unix(),
  2247. InscpScpAmt: item.InscpScpAmt,
  2248. DrtReimFlag: item.DrtReimFlag,
  2249. Ctime: time.Now().Unix(),
  2250. ListSpItemFlag: item.ListSpItemFlag,
  2251. ChldMedcFlag: item.ChldMedcFlag,
  2252. LmtUsedFlag: item.LmtUsedFlag,
  2253. ChrgitmLv: item.ChrgitmLv,
  2254. UserOrgId: adminUser.CurrentOrgId,
  2255. HisPatientId: his.ID,
  2256. OrderId: order.ID,
  2257. ProjectId: project_id,
  2258. Type: types,
  2259. }
  2260. service.CreateOrderInfo(info)
  2261. }
  2262. service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  2263. service.UpDatePrescriptionInfoNumber(adminUser.CurrentOrgId, patientPrescription.PatientId, chrg_bchno, recordDateTime)
  2264. var total float64
  2265. for _, item := range prescriptions {
  2266. if item.Type == 1 { //药品
  2267. for _, subItem := range item.HisDoctorAdviceInfo {
  2268. total = total + (subItem.Price * subItem.PrescribingNumber)
  2269. }
  2270. }
  2271. if item.Type == 2 { //项目
  2272. for _, subItem := range item.HisPrescriptionProject {
  2273. total = total + (subItem.Price * float64(subItem.Count))
  2274. }
  2275. }
  2276. }
  2277. org, _ := service.GetOrgById(adminUser.CurrentOrgId)
  2278. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  2279. allTotal := fmt.Sprintf("%.2f", total)
  2280. if res.Infcode == 0 {
  2281. var rf []*ResultFive
  2282. json.Unmarshal([]byte(his.Iinfo), &rf)
  2283. psn_no := his.PsnNo
  2284. mdtrt_id := his.Number
  2285. chrg_bchno := chrg_bchno
  2286. cert_no := his.Certno
  2287. insutype := rf[0].Insutype
  2288. api := "http://127.0.0.1:9531/" + "gdyb/eight?cert_no=" + cert_no + "&insutype=" +
  2289. insutype + "&psn_no=" + psn_no + "&chrg_bchno=" + chrg_bchno + "&mdtrt_id=" + mdtrt_id +
  2290. "&total=" + allTotal + "&org_name=" + org.OrgName + "&doctor=" + patientPrescription.Doctor + "&fixmedins_code=" + miConfig.Code + "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  2291. resp, requestErr := http.Get(api)
  2292. if requestErr != nil {
  2293. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2294. return
  2295. }
  2296. defer resp.Body.Close()
  2297. body, ioErr := ioutil.ReadAll(resp.Body)
  2298. if ioErr != nil {
  2299. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2300. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2301. return
  2302. }
  2303. var respJSON map[string]interface{}
  2304. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  2305. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2306. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2307. return
  2308. }
  2309. fmt.Println(respJSON)
  2310. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2311. userJSONBytes, _ := json.Marshal(respJSON)
  2312. var res ResultSeven
  2313. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  2314. utils.ErrorLog("解析失败:%v", err)
  2315. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2316. return
  2317. }
  2318. if res.Infcode == -1 {
  2319. errlog := &models.HisOrderError{
  2320. UserOrgId: adminUser.CurrentOrgId,
  2321. Ctime: time.Now().Unix(),
  2322. Mtime: time.Now().Unix(),
  2323. Number: chrg_bchno,
  2324. ErrMsg: res.ErrMsg,
  2325. Status: 1,
  2326. PatientId: id,
  2327. RecordTime: recordDateTime,
  2328. Stage: 7,
  2329. }
  2330. service.CreateErrMsgLog(errlog)
  2331. } else {
  2332. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  2333. order.OrderStatus = 2
  2334. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  2335. order.SetlId = res.Output.Setlinfo.SetlID
  2336. order.PsnNo = res.Output.Setlinfo.PsnNo
  2337. order.PsnName = res.Output.Setlinfo.PsnName
  2338. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  2339. order.Certno = res.Output.Setlinfo.Certno
  2340. order.Gend = res.Output.Setlinfo.Gend
  2341. order.Naty = res.Output.Setlinfo.Naty
  2342. order.Age = res.Output.Setlinfo.Age
  2343. order.Insutype = res.Output.Setlinfo.Insutype
  2344. order.PsnType = res.Output.Setlinfo.PsnType
  2345. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  2346. order.SetlTime = res.Output.Setlinfo.SetlTime
  2347. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  2348. order.MedType = res.Output.Setlinfo.MedType
  2349. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  2350. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  2351. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  2352. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  2353. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  2354. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  2355. order.HifpPay = res.Output.Setlinfo.HifpPay
  2356. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  2357. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  2358. order.HifesPay = res.Output.Setlinfo.HifesPay
  2359. order.HifobPay = res.Output.Setlinfo.HifobPay
  2360. order.MafPay = res.Output.Setlinfo.MafPay
  2361. order.OthPay = res.Output.Setlinfo.OthPay
  2362. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  2363. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  2364. order.AcctPay = res.Output.Setlinfo.AcctPay
  2365. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  2366. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  2367. order.Balc = res.Output.Setlinfo.Balc
  2368. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  2369. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  2370. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  2371. order.ClrWay = res.Output.Setlinfo.ClrWay
  2372. setlDetail, _ := json.Marshal(res.Output.Setldetail)
  2373. detailStr := string(setlDetail)
  2374. order.SetlDetail = detailStr
  2375. err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  2376. err = service.UpDateOrder(order)
  2377. if err == nil {
  2378. c.ServeSuccessJSON(map[string]interface{}{
  2379. "msg": "结算成功",
  2380. })
  2381. }
  2382. }
  2383. } else {
  2384. }
  2385. } else {
  2386. }
  2387. } else {
  2388. var total float64
  2389. for _, item := range prescriptions {
  2390. if item.Type == 1 { //药品
  2391. for _, subItem := range item.HisDoctorAdviceInfo {
  2392. total = total + (subItem.Price * subItem.PrescribingNumber)
  2393. }
  2394. }
  2395. if item.Type == 2 { //项目
  2396. for _, subItem := range item.HisPrescriptionProject {
  2397. total = total + (subItem.Price * float64(subItem.Count))
  2398. }
  2399. }
  2400. for _, subItem := range item.HisAdditionalCharge {
  2401. total = total + (subItem.Price * float64(subItem.Count))
  2402. }
  2403. }
  2404. allTotal := fmt.Sprintf("%.2f", total)
  2405. totals, _ := strconv.ParseFloat(allTotal, 64)
  2406. order := &models.HisOrder{
  2407. UserOrgId: adminUser.CurrentOrgId,
  2408. HisPatientId: his.ID,
  2409. PatientId: id,
  2410. SettleAccountsDate: recordDateTime,
  2411. Ctime: time.Now().Unix(),
  2412. Mtime: time.Now().Unix(),
  2413. Status: 1,
  2414. OrderStatus: 2,
  2415. Number: chrg_bchno,
  2416. MedfeeSumamt: totals,
  2417. PayWay: pay_way,
  2418. PayPrice: pay_price,
  2419. PayCardNo: pay_card_no,
  2420. DiscountPrice: discount_price,
  2421. PreferentialPrice: preferential_price,
  2422. RealityPrice: reality_price,
  2423. FoundPrice: found_price,
  2424. MedicalInsurancePrice: medical_insurance_price,
  2425. PrivatePrice: private_price,
  2426. }
  2427. err = service.CreateOrder(order)
  2428. if err != nil {
  2429. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateOrderException)
  2430. return
  2431. }
  2432. var customs []*Custom
  2433. for _, item := range prescriptions {
  2434. if item.Type == 1 { //药品
  2435. for _, subItem := range item.HisDoctorAdviceInfo {
  2436. cus := &Custom{
  2437. AdviceId: subItem.ID,
  2438. ProjectId: 0,
  2439. DetItemFeeSumamt: fmt.Sprintf("%.2f", subItem.Price*subItem.PrescribingNumber),
  2440. Cut: fmt.Sprintf("%.2f", subItem.PrescribingNumber),
  2441. FeedetlSn: subItem.FeedetlSn,
  2442. Price: fmt.Sprintf("%.2f", subItem.Price),
  2443. MedListCodg: subItem.MedListCodg,
  2444. Type: 1,
  2445. }
  2446. customs = append(customs, cus)
  2447. }
  2448. }
  2449. if item.Type == 2 { //项目
  2450. for _, subItem := range item.HisPrescriptionProject {
  2451. cus := &Custom{
  2452. AdviceId: 0,
  2453. ProjectId: subItem.ID,
  2454. DetItemFeeSumamt: fmt.Sprintf("%.2f", subItem.Price*float64(subItem.Count)),
  2455. Cut: fmt.Sprintf("%.2f", float64(subItem.Count)),
  2456. FeedetlSn: subItem.FeedetlSn,
  2457. Price: fmt.Sprintf("%.2f", float64(subItem.Price)),
  2458. MedListCodg: subItem.MedListCodg,
  2459. Type: 2,
  2460. }
  2461. customs = append(customs, cus)
  2462. }
  2463. }
  2464. for _, item := range item.HisAdditionalCharge {
  2465. cus := &Custom{
  2466. ItemId: item.ID,
  2467. AdviceId: 0,
  2468. ProjectId: 0,
  2469. DetItemFeeSumamt: fmt.Sprintf("%.2f", item.Price),
  2470. Cut: fmt.Sprintf("%.2f", float64(item.Count)),
  2471. FeedetlSn: item.FeedetlSn,
  2472. Price: fmt.Sprintf("%.2f", float64(item.Price)),
  2473. MedListCodg: item.XtHisAddtionConfig.Code,
  2474. Type: 3,
  2475. }
  2476. customs = append(customs, cus)
  2477. }
  2478. }
  2479. for _, item := range customs {
  2480. var advice_id int64 = 0
  2481. var project_id int64 = 0
  2482. var item_id int64 = 0
  2483. var types int64 = 0
  2484. if item.Type == 1 {
  2485. advice_id = item.AdviceId
  2486. project_id = 0
  2487. item_id = 0
  2488. } else if item.Type == 2 {
  2489. advice_id = 0
  2490. item_id = 0
  2491. project_id = item.ProjectId
  2492. } else if item.Type == 3 {
  2493. advice_id = 0
  2494. item_id = item.ItemId
  2495. project_id = 0
  2496. }
  2497. detItemFeeSumamt, _ := strconv.ParseFloat(item.DetItemFeeSumamt, 32)
  2498. cut, _ := strconv.ParseFloat(item.Cut, 32)
  2499. pric, _ := strconv.ParseFloat(item.Price, 32)
  2500. info := &models.HisOrderInfo{
  2501. OrderNumber: order.Number,
  2502. UploadDate: time.Now().Unix(),
  2503. AdviceId: advice_id,
  2504. DetItemFeeSumamt: detItemFeeSumamt,
  2505. Cnt: cut,
  2506. Pric: pric,
  2507. PatientId: id,
  2508. Status: 1,
  2509. Mtime: time.Now().Unix(),
  2510. Ctime: time.Now().Unix(),
  2511. UserOrgId: adminUser.CurrentOrgId,
  2512. HisPatientId: his.ID,
  2513. OrderId: order.ID,
  2514. ProjectId: project_id,
  2515. Type: types,
  2516. ItemId: item_id,
  2517. }
  2518. service.CreateOrderInfo(info)
  2519. }
  2520. //err := service.UpDateAddtionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  2521. err = service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  2522. err = service.UpDatePrescriptionInfoNumber(adminUser.CurrentOrgId, id, chrg_bchno, recordDateTime)
  2523. err = service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  2524. if err == nil {
  2525. c.ServeSuccessJSON(map[string]interface{}{
  2526. "msg": "结算成功",
  2527. })
  2528. }
  2529. }
  2530. }
  2531. //退款
  2532. func (c *HisApiController) Refund() {
  2533. order_id, _ := c.GetInt64("order_id")
  2534. number := c.GetString("number")
  2535. adminUser := c.GetAdminUserInfo()
  2536. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  2537. if config.IsOpen == 1 { //对接了医保,走医保流程
  2538. } else {
  2539. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId)
  2540. if err == nil {
  2541. c.ServeSuccessJSON(map[string]interface{}{
  2542. "msg": "退费成功",
  2543. })
  2544. } else {
  2545. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2546. return
  2547. }
  2548. }
  2549. }
  2550. func (this *HisApiController) AdditionalCharge() {
  2551. dataBody := make(map[string]interface{}, 0)
  2552. err := json.Unmarshal(this.Ctx.Input.RequestBody, &dataBody)
  2553. fmt.Println(err)
  2554. his_patient_id := int64(dataBody["his_patient_id"].(float64))
  2555. patient_id := int64(dataBody["patient_id"].(float64))
  2556. medicineData, _ := dataBody["medicineData"].([]interface{})
  2557. adminUserInfo := this.GetAdminUserInfo()
  2558. orgId := adminUserInfo.CurrentOrgId
  2559. admin_user_id := adminUserInfo.AdminUser.Id
  2560. timeStr := time.Now().Format("2006-01-02")
  2561. timeLayout := "2006-01-02 15:04:05"
  2562. timeStringToTime, _ := utils.ParseTimeStringToTime(timeLayout, timeStr+" 00:00:00")
  2563. timenow := timeStringToTime.Unix()
  2564. var additionalCharges []*models.HisAdditionalCharge
  2565. for _, item := range medicineData {
  2566. var randNum int
  2567. randNum = rand.Intn(10000) + 1000
  2568. timestamp := time.Now().Unix()
  2569. tempTime := time.Unix(timestamp, 0)
  2570. timeFormat := tempTime.Format("20060102150405")
  2571. p_number := timeFormat + strconv.FormatInt(int64(randNum), 10) + strconv.FormatInt(int64(adminUserInfo.CurrentOrgId), 10) + strconv.FormatInt(int64(patient_id), 10)
  2572. items := item.(map[string]interface{})
  2573. money := items["price"].(string)
  2574. item_id_str := items["item_id"].(string)
  2575. name := items["name"].(string)
  2576. id_str := items["id"].(string)
  2577. moneys, _ := strconv.ParseInt(money, 10, 64)
  2578. monStr := strconv.FormatInt(moneys, 10)
  2579. monneyStr, _ := strconv.ParseFloat(monStr, 64)
  2580. item_id, _ := strconv.ParseInt(item_id_str, 10, 64)
  2581. id, _ := strconv.ParseInt(id_str, 10, 64)
  2582. additionalCharge := &models.HisAdditionalCharge{
  2583. ID: id,
  2584. HisPatientId: his_patient_id,
  2585. UserOrgId: orgId,
  2586. PatientId: patient_id,
  2587. RecordDate: timenow,
  2588. Price: monneyStr,
  2589. Status: 1,
  2590. ItemName: name,
  2591. ItemId: item_id,
  2592. AdminUserId: admin_user_id,
  2593. CreatedTime: time.Now().Unix(),
  2594. OrderStatus: 0,
  2595. PrescriptionNumber: "",
  2596. BatchNumber: "",
  2597. FeedetlSn: p_number,
  2598. }
  2599. service.CreateAdditionalCharge(additionalCharge)
  2600. additionalCharges = append(additionalCharges, additionalCharge)
  2601. }
  2602. this.ServeSuccessJSON(map[string]interface{}{
  2603. "msg": "添加成功",
  2604. "additional_charges": additionalCharges,
  2605. })
  2606. }
  2607. func (this *HisApiController) DeleteAddition() {
  2608. id, _ := this.GetInt64("id")
  2609. //TODO 需要判断是否已经结算
  2610. err := service.DelelteAddition(id, this.GetAdminUserInfo().CurrentOrgId)
  2611. if err == nil {
  2612. this.ServeSuccessJSON(map[string]interface{}{
  2613. "msg": "删除成功",
  2614. })
  2615. return
  2616. } else {
  2617. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  2618. return
  2619. }
  2620. }
  2621. func (this *HisApiController) GetAdminUsers() {
  2622. adminUser := this.GetAdminUserInfo()
  2623. doctors, _ := service.GetAllHisDoctor(adminUser.CurrentOrgId)
  2624. this.ServeSuccessJSON(map[string]interface{}{
  2625. "doctors": doctors,
  2626. })
  2627. }
  2628. func (this *DialysisApiController) GetLastOrNextHisPrescription() {
  2629. change_type, _ := this.GetInt64("type", 0)
  2630. record_date := this.GetString("record_time")
  2631. patient_id, _ := this.GetInt64("patient_id", 0)
  2632. timeLayout := "2006-01-02"
  2633. loc, _ := time.LoadLocation("Local")
  2634. theAdviceRecordTime, _ := time.ParseInLocation(timeLayout, record_date, loc)
  2635. record_time := theAdviceRecordTime.Unix()
  2636. adminUserInfo := this.GetAdminUserInfo()
  2637. prescriptions, err := service.GetHisPrescriptionByType(change_type, record_time, adminUserInfo.CurrentOrgId, patient_id)
  2638. if err == nil {
  2639. if len(prescriptions) == 0 {
  2640. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDoctorAdviceEmpty)
  2641. return
  2642. } else {
  2643. this.ServeSuccessJSON(map[string]interface{}{
  2644. "prescriptions": prescriptions,
  2645. })
  2646. return
  2647. }
  2648. } else {
  2649. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  2650. return
  2651. }
  2652. }
  2653. func (this *DialysisApiController) GetCallHisPrescription() {
  2654. patient_id, _ := this.GetInt64("patient_id", 0)
  2655. timeLayout := "2006-01-02"
  2656. loc, _ := time.LoadLocation("Local")
  2657. start_time := this.GetString("start_time")
  2658. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  2659. end_time := this.GetString("end_time")
  2660. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  2661. adminUserInfo := this.GetAdminUserInfo()
  2662. prescriptions, err := service.GetCallHisPrescriptions(startime.Unix(), endtime.Unix(), adminUserInfo.CurrentOrgId, patient_id)
  2663. if err == nil {
  2664. this.ServeSuccessJSON(map[string]interface{}{
  2665. "prescriptions": prescriptions,
  2666. })
  2667. return
  2668. } else {
  2669. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  2670. return
  2671. }
  2672. }
  2673. func (this *HisApiController) GetHisDayPrescription() {
  2674. timeLayout := "2006-01-02"
  2675. loc, _ := time.LoadLocation("Local")
  2676. start_time := this.GetString("start_time")
  2677. patient_id, _ := this.GetInt64("patient_id", 0)
  2678. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  2679. end_time := this.GetString("end_time")
  2680. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  2681. adminUserInfo := this.GetAdminUserInfo()
  2682. dayHisPrescription, err := service.GetMonthHisPrescription(adminUserInfo.CurrentOrgId, patient_id, startime.Unix(), endtime.Unix())
  2683. if err == nil {
  2684. this.ServeSuccessJSON(map[string]interface{}{
  2685. "day_prescription": dayHisPrescription,
  2686. })
  2687. return
  2688. } else {
  2689. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  2690. return
  2691. }
  2692. }
  2693. func (c *HisApiController) GetHisChargePatientList() {
  2694. record_date := c.GetString("record_date")
  2695. timeLayout := "2006-01-02"
  2696. loc, _ := time.LoadLocation("Local")
  2697. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_date+" 00:00:00", loc)
  2698. if err != nil {
  2699. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  2700. return
  2701. }
  2702. recordDateTime := theTime.Unix()
  2703. adminInfo := c.GetAdminUserInfo()
  2704. patients, _ := service.GetAllChargeHisPatientList(adminInfo.CurrentOrgId, "", recordDateTime)
  2705. //var patients []*service.Patients
  2706. //for _, item := range tempPatients{
  2707. // if len(item.HisPrescription) > 0 {
  2708. // patients = append(patients, item)
  2709. // }
  2710. //}
  2711. //patients_two, _ := service.GetChargeHisPatientListTwo(adminInfo.CurrentOrgId, "", recordDateTime)
  2712. c.ServeSuccessJSON(map[string]interface{}{
  2713. "list": patients,
  2714. //"list_two": patients_two,
  2715. })
  2716. }
  2717. func (c *HisApiController) GetHisUnRegisterPatientList() {
  2718. record_date := c.GetString("record_date")
  2719. timeLayout := "2006-01-02"
  2720. loc, _ := time.LoadLocation("Local")
  2721. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_date+" 00:00:00", loc)
  2722. if err != nil {
  2723. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  2724. return
  2725. }
  2726. recordDateTime := theTime.Unix()
  2727. adminUser := c.GetAdminUserInfo()
  2728. tempPatients, _ := service.GetHisPatientList(adminUser.CurrentOrgId, "", recordDateTime)
  2729. var patients []*service.Patients
  2730. for _, item := range tempPatients {
  2731. if item.HisPatient.ID == 0 {
  2732. patients = append(patients, item)
  2733. }
  2734. }
  2735. c.ServeSuccessJSON(map[string]interface{}{
  2736. "list": patients,
  2737. //"list_two": patients_two,
  2738. })
  2739. }
  2740. func RemoveRepeatedPatient(patient []*service.Patients) (newArr []*service.Patients) {
  2741. newArr = make([]*service.Patients, 0)
  2742. for i := 0; i < len(patient); i++ {
  2743. repeat := false
  2744. for j := i + 1; j < len(patient); j++ {
  2745. if patient[i].ID == patient[j].ID {
  2746. repeat = true
  2747. break
  2748. }
  2749. }
  2750. if !repeat {
  2751. newArr = append(newArr, patient[i])
  2752. }
  2753. }
  2754. return
  2755. }