bl_service.go 48KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989
  1. package service
  2. import (
  3. "IC/models"
  4. "IC/utils"
  5. "fmt"
  6. "github.com/jinzhu/gorm"
  7. "strconv"
  8. "strings"
  9. "time"
  10. )
  11. type HisOrder struct {
  12. ID int64 `gorm:"column:id" json:"id" form:"id"`
  13. UserOrgId int64 `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
  14. HisPatientId int64 `gorm:"column:his_patient_id" json:"his_patient_id" form:"his_patient_id"`
  15. SettleAccountsDate int64 `gorm:"column:settle_accounts_date" json:"settle_accounts_date" form:"settle_accounts_date"`
  16. Ctime int64 `gorm:"column:ctime" json:"ctime" form:"ctime"`
  17. Mtime int64 `gorm:"column:mtime" json:"mtime" form:"mtime"`
  18. Status int64 `gorm:"column:status" json:"status" form:"status"`
  19. Number string `gorm:"column:number" json:"number" form:"number"`
  20. PatientId int64 `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
  21. OrderStatus int64 `gorm:"column:order_status" json:"order_status" form:"order_status"`
  22. MdtrtId string `gorm:"column:mdtrt_id" json:"mdtrt_id" form:"mdtrt_id"`
  23. XtHisPatient XtHisPatient `gorm:"ForeignKey:MdtrtId;AssociationForeignKey:Number" json:"his_patient"`
  24. }
  25. func (HisOrder) TableName() string {
  26. return "his_order"
  27. }
  28. type XtHisPatient struct {
  29. ID int64 `gorm:"column:id" json:"id" form:"id"`
  30. BalanceAccountsType int64 `gorm:"column:balance_accounts_type" json:"balance_accounts_type" form:"balance_accounts_type"`
  31. MedicalInsuranceNumber string `gorm:"column:medical_insurance_number" json:"medical_insurance_number" form:"medical_insurance_number"`
  32. Name string `gorm:"column:name" json:"name" form:"name"`
  33. Gender int64 `gorm:"column:gender" json:"gender" form:"gender"`
  34. IdType int64 `gorm:"column:id_type" json:"id_type" form:"id_type"`
  35. MedicalTreatmentType int64 `gorm:"column:medical_treatment_type" json:"medical_treatment_type" form:"medical_treatment_type"`
  36. Birthday int64 `gorm:"column:birthday" json:"birthday" form:"birthday"`
  37. RecordDate int64 `gorm:"column:record_date" json:"record_date" form:"record_date"`
  38. Age int64 `gorm:"column:age" json:"age" form:"age"`
  39. PhoneNumber string `gorm:"column:phone_number" json:"phone_number" form:"phone_number"`
  40. IdCardNo string `gorm:"column:id_card_no" json:"id_card_no" form:"id_card_no"`
  41. RegisterType int64 `gorm:"column:register_type" json:"register_type" form:"register_type"`
  42. AdminUserId int64 `gorm:"column:admin_user_id" json:"admin_user_id" form:"admin_user_id"`
  43. Departments int64 `gorm:"column:departments" json:"departments" form:"departments"`
  44. IsNeedCostOfProduction int64 `gorm:"column:is_need_cost_of_production" json:"is_need_cost_of_production" form:"is_need_cost_of_production"`
  45. RegisterCost float64 `gorm:"column:register_cost" json:"register_cost" form:"register_cost"`
  46. TreatmentCost float64 `gorm:"column:treatment_cost" json:"treatment_cost" form:"treatment_cost"`
  47. CostOfProduction float64 `gorm:"column:cost_of_production" json:"cost_of_production" form:"cost_of_production"`
  48. Total float64 `gorm:"column:total" json:"total" form:"total"`
  49. UserOrgId int64 `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
  50. Status int64 `gorm:"column:status" json:"status" form:"status"`
  51. Ctime int64 `gorm:"column:ctime" json:"ctime" form:"ctime"`
  52. Mtime int64 `gorm:"column:mtime" json:"mtime" form:"mtime"`
  53. PatientId int64 `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
  54. Number string `gorm:"column:number" json:"number" form:"number"`
  55. Doctor int64 `gorm:"column:doctor" json:"doctor" form:"doctor"`
  56. IsReturn int64 `gorm:"column:is_return" json:"is_return" form:"is_return"`
  57. Phone string `gorm:"column:phone" json:"phone" form:"phone"`
  58. SocialType int64 `gorm:"column:social_type" json:"social_type" form:"social_type"`
  59. IdCardType int64 `gorm:"column:id_card_type" json:"id_card_type" form:"id_card_type"`
  60. PType string `gorm:"column:p_type" json:"p_type" form:"p_type"`
  61. Diagnosis string `gorm:"column:diagnosis" json:"diagnosis" form:"diagnosis"`
  62. SickType int64 `gorm:"column:sick_type" json:"sick_type" form:"sick_type"`
  63. }
  64. func (XtHisPatient) TableName() string {
  65. return "his_patient"
  66. }
  67. type HisPrescription struct {
  68. ID int64 `gorm:"column:id" json:"id" form:"id"`
  69. UserOrgId int64 `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
  70. RecordDate int64 `gorm:"column:record_date" json:"record_date" form:"record_date"`
  71. PatientId int64 `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
  72. HisPatientId int64 `gorm:"column:his_patient_id" json:"his_patient_id" form:"his_patient_id"`
  73. Status int64 `gorm:"column:status" json:"status" form:"status"`
  74. Ctime int64 `gorm:"column:ctime" json:"ctime" form:"ctime"`
  75. Mtime int64 `gorm:"column:mtime" json:"mtime" form:"mtime"`
  76. Number string `gorm:"column:number" json:"number" form:"number"`
  77. Type int64 `gorm:"column:type" json:"type" form:"type"`
  78. Doctor string `gorm:"column:doctor" json:"doctor" form:"doctor"`
  79. Creator int64 `gorm:"column:creator" json:"creator" form:"creator"`
  80. Modifier int64 `gorm:"column:modifier" json:"modifier" form:"modifier"`
  81. OrderStatus int64 `gorm:"column:order_status" json:"order_status" form:"order_status"`
  82. PreTime int64 `gorm:"column:pre_time" json:"pre_time" form:"pre_time"`
  83. BatchNumber string `gorm:"column:batch_number" json:"batch_number" form:"batch_number"`
  84. PrescriptionNumber string `gorm:"column:prescription_number" json:"prescription_number" form:"prescription_number"`
  85. HisOrder HisOrder `gorm:"ForeignKey:Number;AssociationForeignKey:BatchNumber" json:"order"`
  86. Total string `gorm:"-" json:"total" form:"total"`
  87. PType int64 `gorm:"column:p_type" json:"p_type" form:"p_type"`
  88. MedType string `gorm:"column:med_type" json:"med_type" form:"med_type"`
  89. }
  90. func (HisPrescription) TableName() string {
  91. return "his_prescription"
  92. }
  93. type CmSample struct {
  94. HospitalBarcode string `gorm:"column:hospital_barcode" json:"hospital_barcode" form:"hospital_barcode"`
  95. Hospsamplenumber string `gorm:"column:hospsamplenumber" json:"hospsamplenumber" form:"hospsamplenumber"`
  96. Pno string `gorm:"column:pno" json:"pno" form:"pno"`
  97. Ptype string `gorm:"column:ptype" json:"ptype" form:"ptype"`
  98. Bedno string `gorm:"column:bedno" json:"bedno" form:"bedno"`
  99. Pname string `gorm:"column:pname" json:"pname" form:"pname"`
  100. Psex string `gorm:"column:psex" json:"psex" form:"psex"`
  101. Page string `gorm:"column:page" json:"page" form:"page"`
  102. Pageunit string `gorm:"column:pageunit" json:"pageunit" form:"pageunit"`
  103. Ptel string `gorm:"column:ptel" json:"ptel" form:"ptel"`
  104. Stature string `gorm:"column:stature" json:"stature" form:"stature"`
  105. Avoirdupois string `gorm:"column:avoirdupois" json:"avoirdupois" form:"avoirdupois"`
  106. Gravweek string `gorm:"column:gravweek" json:"gravweek" form:"gravweek"`
  107. Collectiongravday string `gorm:"column:collectiongravday" json:"collectiongravday" form:"collectiongravday"`
  108. Birthday time.Time `gorm:"column:birthday" json:"birthday" form:"birthday"`
  109. Departname string `gorm:"column:departname" json:"departname" form:"departname"`
  110. Docname string `gorm:"column:docname" json:"docname" form:"docname"`
  111. Doctortel string `gorm:"column:doctortel" json:"doctortel" form:"doctortel"`
  112. Diagnosis string `gorm:"column:diagnosis" json:"diagnosis" form:"diagnosis"`
  113. Stype string `gorm:"column:stype" json:"stype" form:"stype"`
  114. Samstate string `gorm:"column:samstate" json:"samstate" form:"samstate"`
  115. Desccode string `gorm:"column:desccode" json:"desccode" form:"desccode"`
  116. Descr string `gorm:"column:descr" json:"descr" form:"descr"`
  117. Sampletime time.Time `gorm:"column:sampletime" json:"sampletime" form:"sampletime"`
  118. Senddate time.Time `gorm:"column:senddate" json:"senddate" form:"senddate"`
  119. Remark string `gorm:"column:remark" json:"remark" form:"remark"`
  120. Idcard string `gorm:"column:idcard" json:"idcard" form:"idcard"`
  121. CardClass string `gorm:"column:cardclass" json:"cardclass" form:"cardclass"`
  122. }
  123. func (CmSample) TableName() string {
  124. return "cm_sample"
  125. }
  126. type CmLisitems struct {
  127. ItemCode string `gorm:"column:item_code" json:"item_code" form:"item_code"`
  128. ItemName string `gorm:"column:item_name" json:"item_name" form:"item_name"`
  129. Testmethod string `gorm:"column:testmethod" json:"testmethod" form:"testmethod"`
  130. Iscompound string `gorm:"column:iscmpound" json:"iscmpound" form:"iscmpound"`
  131. DepartmentName string `gorm:"column:department_name" json:"department_name" form:"department_name"`
  132. }
  133. func (CmLisitems) TableName() string {
  134. return "v_cm_listtems"
  135. }
  136. type HisLabelPrintInfo struct {
  137. ID int64 `gorm:"column:id" json:"id" form:"id"`
  138. PatientId int64 `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
  139. Number string `gorm:"column:number" json:"number" form:"number"`
  140. Ctime int64 `gorm:"column:ctime" json:"ctime" form:"ctime"`
  141. Mtime int64 `gorm:"column:mtime" json:"mtime" form:"mtime"`
  142. DoctorId int64 `gorm:"column:doctor_id" json:"doctor_id" form:"doctor_id"`
  143. Status int64 `gorm:"column:status" json:"status" form:"status"`
  144. ProjectName string `gorm:"column:project_name" json:"project_name" form:"project_name"`
  145. ProjectId int64 `gorm:"column:project_id" json:"project_id" form:"project_id"`
  146. IsPrint int64 `gorm:"column:is_print" json:"is_print" form:"is_print"`
  147. RecordDate int64 `gorm:"column:record_date" json:"record_date" form:"record_date"`
  148. ItemId int64 `gorm:"column:item_id" json:"item_id" form:"item_id"`
  149. PProjectId int64 `gorm:"column:p_project_id" json:"p_project_id" form:"p_project_id"`
  150. UserOrgId int64 `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
  151. DoctorName string `gorm:"column:doctor_name" json:"doctor_name" form:"doctor_name"`
  152. PatientName string `gorm:"column:patient_name" json:"patient_name" form:"patient_name"`
  153. FeedetlSn string `gorm:"column:feedetl_sn" json:"feedetl_sn" form:"feedetl_sn"`
  154. PrescriptionId int64 `gorm:"column:prescription_id" json:"prescription_id" form:"prescription_id"`
  155. HisPrescriptionProject HisPrescriptionProject `gorm:"ForeignKey:ID;AssociationForeignKey:PProjectId" json:"project"`
  156. }
  157. func (HisLabelPrintInfo) TableName() string {
  158. return "his_label_print_info"
  159. }
  160. type LisSyncProcessStatusInfo struct {
  161. ID int64 `gorm:"column:id" json:"id" form:"id"`
  162. Ctime int64 `gorm:"column:ctime" json:"ctime" form:"ctime"`
  163. Mtime int64 `gorm:"column:mtime" json:"mtime" form:"mtime"`
  164. Status int64 `gorm:"column:status" json:"status" form:"status"`
  165. LastId int64 `gorm:"column:last_id" json:"last_id" form:"last_id"`
  166. OrgId int64 `gorm:"column:org_id" json:"org_id" form:"org_id"`
  167. IsInsert int64 `gorm:"column:is_insert" json:"is_insert" form:"is_insert"`
  168. IsResult int64 `gorm:"column:is_result" json:"is_result" form:"is_result"`
  169. ResultDate int64 `gorm:"column:result_date" json:"result_date" form:"result_date"`
  170. }
  171. func (LisSyncProcessStatusInfo) TableName() string {
  172. return "lis_sync_process_status_info"
  173. }
  174. type CmResult struct {
  175. Barcode string `gorm:"column:barcode" json:"barcode" form:"barcode"`
  176. Itemcode string `gorm:"column:itemcode" json:"itemcode" form:"itemcode"`
  177. Itemname string `gorm:"column:itemname" json:"itemname" form:"itemname"`
  178. Unit string `gorm:"column:unit" json:"unit" form:"unit"`
  179. Result string `gorm:"column:result" json:"result" form:"result"`
  180. Refrange string `gorm:"column:refrange" json:"refrange" form:"refrange"`
  181. Ts string `gorm:"column:ts" json:"ts" form:"ts"`
  182. Jyys string `gorm:"column:jyys" json:"jyys" form:"jyys"`
  183. Shys string `gorm:"column:shys" json:"shys" form:"shys"`
  184. Hycode string `gorm:"column:hycode" json:"hycode" form:"hycode"`
  185. Reptype string `gorm:"column:reptype" json:"reptype" form:"reptype"`
  186. TJH string `gorm:"column:tjh" json:"tjh" form:"tjh"`
  187. Repdate time.Time `gorm:"column:repdate" json:"repdate" form:"repdate"`
  188. Groupname string `gorm:"column:groupname" json:"groupname" form:"groupname"`
  189. Groupcode string `gorm:"column:groupcode" json:"groupcode" form:"groupcode"`
  190. Brkb string `gorm:"column:brkb" json:"brkb" form:"brkb"`
  191. Mic string `gorm:"column:mic" json:"mic" form:"mic"`
  192. Yjjy string `gorm:"column:yjjy" json:"yjjy" form:"yjjy"`
  193. Name string `gorm:"column:name" json:"name" form:"name"`
  194. }
  195. func (CmResult) TableName() string {
  196. return "v_cm_result"
  197. }
  198. type LisSyncResultStatusInfo struct {
  199. ID int64 `gorm:"column:id" json:"id" form:"id"`
  200. Ctime int64 `gorm:"column:ctime" json:"ctime" form:"ctime"`
  201. Mtime int64 `gorm:"column:mtime" json:"mtime" form:"mtime"`
  202. Status int64 `gorm:"column:status" json:"status" form:"status"`
  203. LastId int64 `gorm:"column:last_id" json:"last_id" form:"last_id"`
  204. OrgId int64 `gorm:"column:org_id" json:"org_id" form:"org_id"`
  205. IsResult int64 `gorm:"column:is_result" json:"is_result" form:"is_result"`
  206. ResultDate int64 `gorm:"column:result_date" json:"result_date" form:"result_date"`
  207. }
  208. func (LisSyncResultStatusInfo) TableName() string {
  209. return "lis_sync_result_status_info"
  210. }
  211. func GetLastSyncRecord(org_id int64) (record LisSyncProcessStatusInfo, err error) {
  212. err = readMiddleDb.Model(&LisSyncProcessStatusInfo{}).Where("org_id = ? AND status = 1", org_id).Last(&record).Error
  213. return
  214. }
  215. func GetLastSyncResultRecord(org_id int64) (record LisSyncResultStatusInfo, err error) {
  216. err = readDb.Model(&LisSyncResultStatusInfo{}).Where("org_id = ? AND status = 1", org_id).Last(&record).Error
  217. return
  218. }
  219. func GetResultRecord() (record []CmResult, err error) {
  220. err = dataBase.Model(&CmResult{}).Order("barcode asc").Limit(1).Find(&record).Error
  221. return
  222. }
  223. func GetResultRecordByID(id int64) (record []CmResult, err error) {
  224. err = readDb.Model(&CmResult{}).Where("barcode > ?", id).Order("barcode asc").Find(&record).Error
  225. return
  226. }
  227. func GetSaveResultRecord(record LisSyncResultStatusInfo) (err error) {
  228. err = dataBase.Save(record).Error
  229. return
  230. }
  231. func GetLisDataById(org_id int64, last_id int64) (list []*HisLabelPrintInfo, err error) {
  232. //err = readDb.Model(&HisLabelPrintInfo{}).Where("id > ? AND user_org_id = ? AND status = 1", last_id, org_id).Find(&list).Error
  233. err = readDb.Model(&HisLabelPrintInfo{}).Preload("HisPrescriptionProject", func(db *gorm.DB) *gorm.DB {
  234. return db.Preload("HisPrescription", func(db *gorm.DB) *gorm.DB {
  235. return db.Preload("HisOrder", func(db *gorm.DB) *gorm.DB {
  236. return db.Preload("XtHisPatient", func(db *gorm.DB) *gorm.DB {
  237. return db.Where("status = 1")
  238. }).Where("status = 1")
  239. }).Where("status = 1")
  240. }).Where("status = 1")
  241. }).Where("id > ? AND user_org_id = ? AND status = 1", last_id, org_id).Limit(100).Find(&list).Error
  242. return
  243. }
  244. func GetAllLisData(org_id int64) (list []*HisLabelPrintInfo, err error) {
  245. err = readDb.Model(&HisLabelPrintInfo{}).Preload("HisPrescriptionProject", func(db *gorm.DB) *gorm.DB {
  246. return db.Preload("HisPrescription", func(db *gorm.DB) *gorm.DB {
  247. return db.Preload("HisOrder", func(db *gorm.DB) *gorm.DB {
  248. return db.Preload("XtHisPatient", func(db *gorm.DB) *gorm.DB {
  249. return db.Where("status = 1")
  250. }).Where("status = 1")
  251. }).Where("status = 1")
  252. }).Where("status = 1")
  253. }).Where("user_org_id = ? AND status = 1", org_id).Limit(100).Find(&list).Error
  254. return
  255. }
  256. func GetAllLisResultData(org_id int64) (list []*CmResult, err error) {
  257. err = readDb.Model(&CmResult{}).Where("user_org_id = ? AND status = 1 ", org_id).Find(&list).Error
  258. return
  259. }
  260. func GetLisResultDataByRecord(org_id int64) (list []*CmResult, err error) {
  261. err = readDb.Model(&CmResult{}).Where("user_org_id = ? AND status = 1", org_id).Find(&list).Error
  262. return
  263. }
  264. //插入中间件逻辑
  265. func GetDataInsertDB(org_id int64) {
  266. record, _ := GetLastSyncRecord(org_id)
  267. if record.ID == 0 {
  268. var cms_arr []CmSample
  269. list, _ := GetAllLisData(org_id)
  270. //插入中间库中
  271. for _, item := range list {
  272. fmt.Println(item.HisPrescriptionProject)
  273. if item.ItemId > 0 {
  274. var cms CmSample
  275. cms.HospitalBarcode = strconv.FormatInt(item.ID, 10)
  276. cms.Pno = item.HisPrescriptionProject.HisPrescription.HisOrder.MdtrtId
  277. cms.Ptype = "门诊"
  278. cms.Pname = item.HisPrescriptionProject.HisPrescription.HisOrder.XtHisPatient.Name
  279. if item.HisPrescriptionProject.HisPrescription.HisOrder.XtHisPatient.Gender == 1 {
  280. cms.Psex = "男"
  281. } else if item.HisPrescriptionProject.HisPrescription.HisOrder.XtHisPatient.Gender == 2 {
  282. cms.Psex = "女"
  283. }
  284. cms.Page = strconv.FormatInt(item.HisPrescriptionProject.HisPrescription.HisOrder.XtHisPatient.Age, 10)
  285. cms.Pageunit = "岁"
  286. cms.Departname = "肾病学专业"
  287. role, _ := GetAdminUserInfoByID(org_id, item.HisPrescriptionProject.HisPrescription.HisOrder.XtHisPatient.Doctor)
  288. cms.Docname = role.UserName
  289. diagnosis_ids := strings.Split(item.HisPrescriptionProject.HisPrescription.HisOrder.XtHisPatient.Diagnosis, ",")
  290. //var config []*models.HisXtDiagnoseConfig
  291. var name string
  292. for _, item := range diagnosis_ids {
  293. id, _ := strconv.ParseInt(item, 10, 64)
  294. diagnosisConfig, _ := FindDiagnoseById(id)
  295. if len(name) == 0 {
  296. name = diagnosisConfig.ClassName
  297. } else {
  298. name = name + "," + diagnosisConfig.ClassName
  299. }
  300. }
  301. cms.Diagnosis = name
  302. cms.Stype = ""
  303. cms.Samstate = ""
  304. cms.Desccode = strconv.FormatInt(item.ID, 10)
  305. cms.Descr = item.ProjectName
  306. data, _ := strconv.ParseInt(strconv.FormatInt(item.Ctime, 10), 10, 64)
  307. datatime := time.Unix(data/1000, 0)
  308. cms.Sampletime = datatime
  309. cms.Senddate = time.Now()
  310. cms_arr = append(cms_arr, cms)
  311. } else {
  312. var cms CmSample
  313. cms.HospitalBarcode = strconv.FormatInt(item.ID, 10)
  314. cms.Pno = item.HisPrescriptionProject.HisPrescription.HisOrder.MdtrtId
  315. cms.Ptype = "门诊"
  316. cms.Pname = item.HisPrescriptionProject.HisPrescription.HisOrder.XtHisPatient.Name
  317. if item.HisPrescriptionProject.HisPrescription.HisOrder.XtHisPatient.Gender == 1 {
  318. cms.Psex = "男"
  319. } else if item.HisPrescriptionProject.HisPrescription.HisOrder.XtHisPatient.Gender == 2 {
  320. cms.Psex = "女"
  321. }
  322. cms.Page = strconv.FormatInt(item.HisPrescriptionProject.HisPrescription.HisOrder.XtHisPatient.Age, 10)
  323. cms.Pageunit = "岁"
  324. cms.Departname = "肾病学专业"
  325. role, _ := GetAdminUserInfoByID(org_id, item.HisPrescriptionProject.HisPrescription.HisOrder.XtHisPatient.Doctor)
  326. cms.Docname = role.UserName
  327. diagnosis_ids := strings.Split(item.HisPrescriptionProject.HisPrescription.HisOrder.XtHisPatient.Diagnosis, ",")
  328. //var config []*models.HisXtDiagnoseConfig
  329. var name string
  330. for _, item := range diagnosis_ids {
  331. id, _ := strconv.ParseInt(item, 10, 64)
  332. diagnosisConfig, _ := FindDiagnoseById(id)
  333. if len(name) == 0 {
  334. name = diagnosisConfig.ClassName
  335. } else {
  336. name = name + "," + diagnosisConfig.ClassName
  337. }
  338. }
  339. cms.Diagnosis = name
  340. cms.Stype = ""
  341. cms.Samstate = ""
  342. cms.Desccode = strconv.FormatInt(item.ID, 10)
  343. cms.Descr = item.ProjectName
  344. tm := time.Unix(item.Ctime, 0)
  345. //data, _ := strconv.ParseInt(strconv.FormatInt(item.Ctime, 10), 10, 64)
  346. //datatime := time.Unix(data/1000, 0)
  347. cms.Sampletime = tm
  348. cms.Senddate = time.Now()
  349. cms_arr = append(cms_arr, cms)
  350. }
  351. }
  352. //插入到中间库
  353. for _, item := range cms_arr {
  354. if len(item.Pno) > 0 {
  355. blDb.Save(item)
  356. }
  357. }
  358. //插入一条插入中间库记录数据
  359. var info LisSyncProcessStatusInfo
  360. info.Ctime = time.Now().Unix()
  361. info.Status = 1
  362. info.Mtime = time.Now().Unix()
  363. info.OrgId = org_id
  364. info.IsInsert = 1
  365. info.IsResult = 0
  366. info.LastId = list[len(list)-1].ID
  367. info.ResultDate = 0
  368. writeMiddleDb.Save(&info)
  369. } else {
  370. var cms_arr []CmSample
  371. if record.LastId != 0 {
  372. list, _ := GetLisDataById(org_id, record.LastId)
  373. //插入中间库中
  374. for _, item := range list {
  375. if item.ItemId > 0 {
  376. fmt.Println()
  377. //teams, _ := GetProjectTeamList(org_id, item.ItemId, item.PrescriptionId)
  378. //for _, subItem := range teams {
  379. var cms CmSample
  380. cms.HospitalBarcode = strconv.FormatInt(item.ID, 10)
  381. //cms.Hospsamplenumber = strconv.FormatInt(item.ID, 10)
  382. cms.Pno = item.HisPrescriptionProject.HisPrescription.HisOrder.MdtrtId
  383. cms.Ptype = "门诊"
  384. cms.Pname = item.HisPrescriptionProject.HisPrescription.HisOrder.XtHisPatient.Name
  385. if item.HisPrescriptionProject.HisPrescription.HisOrder.XtHisPatient.Gender == 1 {
  386. cms.Psex = "男"
  387. } else if item.HisPrescriptionProject.HisPrescription.HisOrder.XtHisPatient.Gender == 2 {
  388. cms.Psex = "女"
  389. }
  390. cms.Page = strconv.FormatInt(item.HisPrescriptionProject.HisPrescription.HisOrder.XtHisPatient.Age, 10)
  391. cms.Pageunit = "岁"
  392. cms.Departname = "肾病学专业"
  393. role, _ := GetAdminUserInfoByID(org_id, item.HisPrescriptionProject.HisPrescription.HisOrder.XtHisPatient.Doctor)
  394. cms.Docname = role.UserName
  395. diagnosis_ids := strings.Split(item.HisPrescriptionProject.HisPrescription.HisOrder.XtHisPatient.Diagnosis, ",")
  396. //var config []*models.HisXtDiagnoseConfig
  397. var name string
  398. for _, item := range diagnosis_ids {
  399. id, _ := strconv.ParseInt(item, 10, 64)
  400. diagnosisConfig, _ := FindDiagnoseById(id)
  401. if len(name) == 0 {
  402. name = diagnosisConfig.ClassName
  403. } else {
  404. name = name + "," + diagnosisConfig.ClassName
  405. }
  406. }
  407. cms.Diagnosis = name
  408. cms.Stype = ""
  409. cms.Samstate = ""
  410. cms.Desccode = strconv.FormatInt(item.ID, 10)
  411. cms.Descr = item.ProjectName
  412. //data, _ := strconv.ParseInt(strconv.FormatInt(item.Ctime, 10), 10, 64)
  413. //datatime := time.Unix(data/1000, 0)
  414. //cms.Sampletime = datatime
  415. tm := time.Unix(item.Ctime, 0)
  416. cms.Sampletime = tm
  417. cms.Senddate = time.Now()
  418. cms_arr = append(cms_arr, cms)
  419. } else {
  420. var cms CmSample
  421. cms.HospitalBarcode = strconv.FormatInt(item.ID, 10)
  422. //cms.Hospsamplenumber = strconv.FormatInt(item.ID, 10)
  423. cms.Pno = item.HisPrescriptionProject.HisPrescription.HisOrder.MdtrtId
  424. cms.Ptype = "门诊"
  425. cms.Pname = item.HisPrescriptionProject.HisPrescription.HisOrder.XtHisPatient.Name
  426. if item.HisPrescriptionProject.HisPrescription.HisOrder.XtHisPatient.Gender == 1 {
  427. cms.Psex = "男"
  428. } else if item.HisPrescriptionProject.HisPrescription.HisOrder.XtHisPatient.Gender == 2 {
  429. cms.Psex = "女"
  430. }
  431. cms.Page = strconv.FormatInt(item.HisPrescriptionProject.HisPrescription.HisOrder.XtHisPatient.Age, 10)
  432. cms.Pageunit = "岁"
  433. cms.Departname = "肾病学专业"
  434. role, _ := GetAdminUserInfoByID(org_id, item.HisPrescriptionProject.HisPrescription.HisOrder.XtHisPatient.Doctor)
  435. cms.Docname = role.UserName
  436. diagnosis_ids := strings.Split(item.HisPrescriptionProject.HisPrescription.HisOrder.XtHisPatient.Diagnosis, ",")
  437. var name string
  438. for _, item := range diagnosis_ids {
  439. id, _ := strconv.ParseInt(item, 10, 64)
  440. diagnosisConfig, _ := FindDiagnoseById(id)
  441. if len(name) == 0 {
  442. name = diagnosisConfig.ClassName
  443. } else {
  444. name = name + "," + diagnosisConfig.ClassName
  445. }
  446. }
  447. cms.Diagnosis = name
  448. cms.Stype = ""
  449. cms.Samstate = ""
  450. cms.Desccode = strconv.FormatInt(item.ID, 10)
  451. cms.Descr = item.ProjectName
  452. tm := time.Unix(item.Ctime, 0)
  453. cms.Sampletime = tm
  454. cms.Senddate = time.Now()
  455. cms_arr = append(cms_arr, cms)
  456. }
  457. }
  458. //插入一条插入中间库记录数据
  459. for _, item := range cms_arr {
  460. if len(item.Pno) > 0 {
  461. blDb.Save(item)
  462. }
  463. }
  464. //插入一条插入中间库记录数据
  465. var info LisSyncProcessStatusInfo
  466. info.Ctime = time.Now().Unix()
  467. info.Status = 1
  468. info.Mtime = time.Now().Unix()
  469. info.OrgId = org_id
  470. info.IsInsert = 1
  471. info.IsResult = 0
  472. info.LastId = list[len(list)-1].ID
  473. info.ResultDate = 0
  474. writeMiddleDb.Save(&info)
  475. }
  476. }
  477. }
  478. //获取lis返回检验检查结果数据
  479. func GetResultDataInsertDB(org_id int64) (result []*CmResult) {
  480. record, _ := GetLastSyncResultRecord(org_id)
  481. if record.ID == 0 {
  482. list, err := GetResultRecord()
  483. if err == nil {
  484. fmt.Println(list)
  485. //插入到系统检验检查数据
  486. for _, item := range list {
  487. fmt.Println(item)
  488. project_id := int64(0)
  489. if len("180") > 0 {
  490. project_id, _ = GetBljhProjectID(org_id, item.Groupname)
  491. } else {
  492. continue
  493. }
  494. printInfo, _ := GetHisLabelPrintInfoById("180")
  495. item_id, _ := GetBlItemID(org_id, item.Groupname, item.Itemname, project_id)
  496. tx := writeMiddleDb.Begin()
  497. var inspection models.MiddleInspection
  498. var inspection_reference models.MiddleInspectionReference
  499. recordDateStr := ""
  500. inspect_date := item.Repdate.Format("2006-01-02 15:04")
  501. if item.Repdate.Unix() == 0 {
  502. recordDateStr = time.Now().Format("2006-01-02 15:04")
  503. } else {
  504. recordDateStr = inspect_date
  505. }
  506. date, _ := utils.ParseTimeStringToTime("2006-01-02 15:04", recordDateStr)
  507. record_date, _ := utils.ParseTimeStringToTime("2006-01-02", date.Format("2006-01-02"))
  508. var total int
  509. var RangeOptions string
  510. var RangeMin string
  511. var RangeMax string
  512. // 判断检查类型
  513. var ItemType int
  514. if strings.Contains(item.Refrange, "-") {
  515. ItemType = 1
  516. } else {
  517. ItemType = 2
  518. }
  519. if ItemType == 1 {
  520. Range := strings.Split(item.Refrange, "-")
  521. RangeMin = Range[0]
  522. RangeMax = Range[1]
  523. } else {
  524. RangeOptions = item.Refrange
  525. }
  526. err = readMiddleDb.Model(&models.MiddleInspectionReference{}).Where("org_id = ? and project_id = ? and item_id = ? and status = 1", org_id, project_id, item_id).Find(&inspection_reference).Count(&total).Error
  527. if inspection_reference.ID > 0 {
  528. ItemType = inspection_reference.RangeType
  529. }
  530. if total <= 0 {
  531. inspection_reference.OrgId = org_id
  532. inspection_reference.ProjectName = item.Groupname
  533. inspection_reference.Project = item.Groupname
  534. inspection_reference.ProjectId = project_id
  535. inspection_reference.ItemName = item.Itemname
  536. inspection_reference.ItemNameAddition = item.Barcode
  537. inspection_reference.ItemId = item_id
  538. inspection_reference.RangeType = ItemType
  539. inspection_reference.RangeMin = RangeMin
  540. inspection_reference.RangeMax = RangeMax
  541. inspection_reference.RangeOptions = RangeOptions
  542. inspection_reference.Unit = item.Unit
  543. inspection_reference.Status = 1
  544. inspection_reference.CreatedTime = time.Now().Unix()
  545. inspection_reference.UpdatedTime = time.Now().Unix()
  546. inspection_reference.InspectDate = inspect_date
  547. inspection_reference.UTime = inspect_date
  548. err = tx.Model(&models.MiddleInspectionReference{}).Create(&inspection_reference).Error
  549. if err != nil {
  550. tx.Rollback()
  551. }
  552. }
  553. var itotal int
  554. err = readMiddleDb.Model(&models.MiddleInspection{}).Where("org_id = ? and project_id = ? and item_id = ? and record_date = ? and patient_id = ? and status = 1", org_id, project_id, item_id, record_date, printInfo.PatientId).Find(&inspection).Count(&itotal).Error
  555. if itotal <= 0 {
  556. //item.Result = strings.Replace(item.Result, "&gt;", ">", -1)
  557. //item.Result = strings.Replace(item.Result, "&lt;", "<", -1)
  558. inspection.PatientId = printInfo.PatientId
  559. inspection.OrgId = org_id
  560. inspection.ProjectId = project_id
  561. inspection.ItemName = inspection_reference.ItemName
  562. inspection.ProjectName = inspection_reference.ProjectName
  563. inspection.InspectType = ItemType
  564. inspection.ItemId = item_id
  565. inspection.InspectValue = item.Result
  566. inspection.InspectDate = inspect_date
  567. inspection.RecordDate = record_date.Unix()
  568. inspection.Status = 1
  569. inspection.CreatedTime = time.Now().Unix()
  570. inspection.UpdatedTime = time.Now().Unix()
  571. inspection.UTime = inspect_date
  572. inspection.HisUserId = strconv.FormatInt(printInfo.PatientId, 10)
  573. err = tx.Model(&models.MiddleInspection{}).Create(&inspection).Error
  574. if err != nil {
  575. tx.Rollback()
  576. }
  577. }
  578. tx.Commit()
  579. }
  580. //插入一条查询检验检查结果记录状态数据
  581. var info LisSyncResultStatusInfo
  582. info.Ctime = time.Now().Unix()
  583. info.Status = 1
  584. info.Mtime = time.Now().Unix()
  585. info.OrgId = org_id
  586. info.IsResult = 1
  587. code, _ := strconv.ParseInt(list[0].Barcode, 10, 64)
  588. info.LastId = code
  589. info.ResultDate = time.Now().Unix()
  590. writeMiddleDb.Save(&info)
  591. //
  592. }
  593. } else {
  594. if record.LastId != 0 {
  595. fmt.Println("~~~~~~~~")
  596. list, err := GetResultRecord()
  597. fmt.Println(list)
  598. //插入中间库中
  599. //插入一条插入中间库记录数据
  600. if err == nil {
  601. //插入到系统检验检查数据
  602. for _, item := range list {
  603. project_id := int64(0)
  604. if len("180") > 0 {
  605. project_id, _ = GetBljhProjectID(org_id, item.Groupname)
  606. } else {
  607. continue
  608. }
  609. printInfo, _ := GetHisLabelPrintInfoById("180")
  610. item_id, _ := GetBlItemID(org_id, item.Groupname, item.Itemname, project_id)
  611. tx := writeMiddleDb.Begin()
  612. var inspection models.MiddleInspection
  613. var inspection_reference models.MiddleInspectionReference
  614. recordDateStr := ""
  615. inspect_date := item.Repdate.Format("2006-01-02 15:04")
  616. if item.Repdate.Unix() == 0 {
  617. recordDateStr = time.Now().Format("2006-01-02 15:04")
  618. } else {
  619. recordDateStr = inspect_date
  620. }
  621. date, _ := utils.ParseTimeStringToTime("2006-01-02 15:04", recordDateStr)
  622. record_date, _ := utils.ParseTimeStringToTime("2006-01-02", date.Format("2006-01-02"))
  623. var total int
  624. var RangeOptions string
  625. var RangeMin string
  626. var RangeMax string
  627. // 判断检查类型
  628. var ItemType int
  629. if strings.Contains(item.Refrange, "-") {
  630. ItemType = 1
  631. } else {
  632. ItemType = 2
  633. }
  634. if ItemType == 1 {
  635. Range := strings.Split(item.Refrange, "-")
  636. RangeMin = Range[0]
  637. RangeMax = Range[1]
  638. } else {
  639. RangeOptions = item.Refrange
  640. }
  641. err = readMiddleDb.Model(&models.MiddleInspectionReference{}).Where("org_id = ? and project_id = ? and item_id = ? and status = 1", org_id, project_id, item_id).Find(&inspection_reference).Count(&total).Error
  642. if inspection_reference.ID > 0 {
  643. ItemType = inspection_reference.RangeType
  644. }
  645. if total <= 0 {
  646. inspection_reference.OrgId = org_id
  647. inspection_reference.ProjectName = item.Groupname
  648. inspection_reference.Project = item.Groupname
  649. inspection_reference.ProjectId = project_id
  650. inspection_reference.ItemName = item.Itemname
  651. inspection_reference.ItemNameAddition = item.Barcode
  652. inspection_reference.ItemId = item_id
  653. inspection_reference.RangeType = ItemType
  654. inspection_reference.RangeMin = RangeMin
  655. inspection_reference.RangeMax = RangeMax
  656. inspection_reference.RangeOptions = RangeOptions
  657. inspection_reference.Unit = item.Unit
  658. inspection_reference.Status = 1
  659. inspection_reference.CreatedTime = time.Now().Unix()
  660. inspection_reference.UpdatedTime = time.Now().Unix()
  661. inspection_reference.InspectDate = inspect_date
  662. inspection_reference.UTime = inspect_date
  663. err = tx.Model(&models.MiddleInspectionReference{}).Create(&inspection_reference).Error
  664. if err != nil {
  665. tx.Rollback()
  666. }
  667. }
  668. var itotal int
  669. err = readMiddleDb.Model(&models.MiddleInspection{}).Where("org_id = ? and project_id = ? and item_id = ? and record_date = ? and patient_id = ? and status = 1", org_id, project_id, item_id, record_date, printInfo.PatientId).Find(&inspection).Count(&itotal).Error
  670. if itotal <= 0 {
  671. inspection.PatientId = printInfo.PatientId
  672. inspection.OrgId = org_id
  673. inspection.ProjectId = project_id
  674. inspection.ItemName = inspection_reference.ItemName
  675. inspection.ProjectName = inspection_reference.ProjectName
  676. inspection.InspectType = ItemType
  677. inspection.ItemId = item_id
  678. inspection.InspectValue = item.Result
  679. inspection.InspectDate = inspect_date
  680. inspection.RecordDate = record_date.Unix()
  681. inspection.Status = 1
  682. inspection.CreatedTime = time.Now().Unix()
  683. inspection.UpdatedTime = time.Now().Unix()
  684. inspection.UTime = inspect_date
  685. inspection.HisUserId = strconv.FormatInt(printInfo.PatientId, 10)
  686. err = tx.Model(&models.MiddleInspection{}).Create(&inspection).Error
  687. if err != nil {
  688. tx.Rollback()
  689. }
  690. }
  691. tx.Commit()
  692. }
  693. //插入一条查询检验检查结果记录状态数据
  694. var info LisSyncResultStatusInfo
  695. info.Ctime = time.Now().Unix()
  696. info.Status = 1
  697. info.Mtime = time.Now().Unix()
  698. info.OrgId = org_id
  699. info.IsResult = 1
  700. code, _ := strconv.ParseInt(list[0].Barcode, 10, 64)
  701. info.LastId = code
  702. info.ResultDate = time.Now().Unix()
  703. writeMiddleDb.Save(&info)
  704. }
  705. }
  706. }
  707. return
  708. }
  709. func GetAdminUserInfoByID(org_id int64, admin_user_id int64) (role UserAdminRole, err error) {
  710. err = readUserDb.Model(&UserAdminRole{}).Where("org_id = ? AND status = 1 AND admin_user_id = ?", org_id, admin_user_id).First(&role).Error
  711. return
  712. }
  713. type UserAdminRole struct {
  714. ID int64 `gorm:"column:id" json:"id" form:"id"`
  715. AdminUserId int64 `gorm:"column:admin_user_id" json:"admin_user_id" form:"admin_user_id"`
  716. OrgId int64 `gorm:"column:org_id" json:"org_id" form:"org_id"`
  717. AppId int64 `gorm:"column:app_id" json:"app_id" form:"app_id"`
  718. RoleId int64 `gorm:"column:role_id" json:"role_id" form:"role_id"`
  719. UserName string `gorm:"column:user_name" json:"user_name" form:"user_name"`
  720. Avatar string `gorm:"column:avatar" json:"avatar" form:"avatar"`
  721. UserType int64 `gorm:"column:user_type" json:"user_type" form:"user_type"`
  722. UserTitle int64 `gorm:"column:user_title" json:"user_title" form:"user_title"`
  723. Intro string `gorm:"column:intro" json:"intro" form:"intro"`
  724. Status int64 `gorm:"column:status" json:"status" form:"status"`
  725. Ctime int64 `gorm:"column:ctime" json:"ctime" form:"ctime"`
  726. Mtime int64 `gorm:"column:mtime" json:"mtime" form:"mtime"`
  727. UserTitleName string `gorm:"column:user_title_name" json:"user_title_name" form:"user_title_name"`
  728. RoleIds string `gorm:"column:role_ids" json:"role_ids" form:"role_ids"`
  729. Message string `gorm:"column:message" json:"message" form:"message"`
  730. Sex int64 `gorm:"column:sex" json:"sex" form:"sex"`
  731. Birthday int64 `gorm:"column:birthday" json:"birthday" form:"birthday"`
  732. Sort int64 `gorm:"column:sort" json:"sort" form:"sort"`
  733. IsSort int64 `gorm:"column:is_sort" json:"is_sort" form:"is_sort"`
  734. Department string `gorm:"column:department" json:"department" form:"department"`
  735. DepartmentId int64 `gorm:"column:department_id" json:"department_id" form:"department_id"`
  736. Age int64 `gorm:"column:age" json:"age" form:"age"`
  737. Nation string `gorm:"column:nation" json:"nation" form:"nation"`
  738. CardType int64 `gorm:"column:card_type" json:"card_type" form:"card_type"`
  739. IdCard string `gorm:"column:id_card" json:"id_card" form:"id_card"`
  740. Education int64 `gorm:"column:education" json:"education" form:"education"`
  741. StudyMajorName string `gorm:"column:study_major_name" json:"study_major_name" form:"study_major_name"`
  742. WorkMajorName string `gorm:"column:work_major_name" json:"work_major_name" form:"work_major_name"`
  743. RoleType int64 `gorm:"column:role_type" json:"role_type" form:"role_type"`
  744. MedicalCode string `gorm:"column:medical_code" json:"medical_code" form:"medical_code"`
  745. DoctorCode string `gorm:"column:doctor_code" json:"doctor_code" form:"doctor_code"`
  746. Licensing int64 `gorm:"column:licensing" json:"licensing" form:"licensing"`
  747. JobNumber string `gorm:"column:job_number" json:"job_number" form:"job_number"`
  748. PrescriptionQualificationIdentification int64 `gorm:"column:prescription_qualification_identification" json:"prescription_qualification_identification" form:"prescription_qualification_identification"`
  749. IdentificationOutpatients int64 `gorm:"column:identification_outpatients" json:"identification_outpatients" form:"identification_outpatients"`
  750. StartTime int64 `gorm:"column:start_time" json:"start_time" form:"start_time"`
  751. MedicalRangeCode int64 `gorm:"column:medical_range_code" json:"medical_range_code" form:"medical_range_code"`
  752. MedicalLevel int64 `gorm:"column:medical_level" json:"medical_level" form:"medical_level"`
  753. MedicalTypeJob int64 `gorm:"column:medical_type_job" json:"medical_type_job" form:"medical_type_job"`
  754. PharmacistRegistrationNumber string `gorm:"column:pharmacist_registration_number" json:"pharmacist_registration_number" form:"pharmacist_registration_number"`
  755. DoctorRangeCode int64 `gorm:"column:doctor_range_code" json:"doctor_range_code" form:"doctor_range_code"`
  756. DoctorLevel int64 `gorm:"column:doctor_level" json:"doctor_level" form:"doctor_level"`
  757. DoctorTypeJob int64 `gorm:"column:doctor_type_job" json:"doctor_type_job" form:"doctor_type_job"`
  758. DoctorNumber string `gorm:"column:doctor_number" json:"doctor_number" form:"doctor_number"`
  759. OutpatientIllnessCategory string `gorm:"column:outpatient_illness_category" json:"outpatient_illness_category" form:"outpatient_illness_category"`
  760. IsActive int64 `gorm:"column:is_active" json:"is_active" form:"is_active"`
  761. ActiveStatus int64 `gorm:"column:active_status" json:"active_status" form:"active_status"`
  762. }
  763. func (UserAdminRole) TableName() string {
  764. return "sgj_user_admin_role"
  765. }
  766. func FindDiagnoseById(id int64) (*HisXtDiagnoseConfig, error) {
  767. dealer := &HisXtDiagnoseConfig{}
  768. err := readDb.Model(&HisXtDiagnoseConfig{}).Where("id = ? AND status = 1", id).First(&dealer).Error
  769. return dealer, err
  770. }
  771. type HisXtDiagnoseConfig struct {
  772. ID int64 `gorm:"column:id" json:"id" form:"id"`
  773. ClassName string `gorm:"column:class_name" json:"class_name" form:"class_name"`
  774. Pinyin string `gorm:"column:pinyin" json:"pinyin" form:"pinyin"`
  775. Wubi string `gorm:"column:wubi" json:"wubi" form:"wubi"`
  776. ContentCode string `gorm:"column:content_code" json:"content_code" form:"content_code"`
  777. CountryCode string `gorm:"column:country_code" json:"country_code" form:"country_code"`
  778. CountryContentName string `gorm:"column:country_content_name" json:"country_content_name" form:"country_content_name"`
  779. Remark string `gorm:"column:remark" json:"remark" form:"remark"`
  780. UserOrgId int64 `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
  781. Status int64 `gorm:"column:status" json:"status" form:"status"`
  782. Ctime int64 `gorm:"column:ctime" json:"ctime" form:"ctime"`
  783. Mtime int64 `gorm:"column:mtime" json:"mtime" form:"mtime"`
  784. }
  785. func (HisXtDiagnoseConfig) TableName() string {
  786. return "his_xt_diagnose_config"
  787. }
  788. type VMHisProjectTeam struct {
  789. ID int64 `gorm:"column:id" json:"id" form:"id"`
  790. ProjectTeam string `gorm:"column:project_team" json:"project_team" form:"project_team"`
  791. Price float64 `gorm:"column:price" json:"price" form:"price"`
  792. Pinyin string `gorm:"column:pinyin" json:"pinyin" form:"pinyin"`
  793. Wubi string `gorm:"column:wubi" json:"wubi" form:"wubi"`
  794. TubeColor int64 `gorm:"column:tube_color" json:"tube_color" form:"tube_color"`
  795. TeamType int64 `gorm:"column:team_type" json:"team_type" form:"team_type"`
  796. Remark string `gorm:"column:remark" json:"remark" form:"remark"`
  797. UserOrgId int64 `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
  798. Status int64 `gorm:"column:status" json:"status" form:"status"`
  799. CreatedTime int64 `gorm:"column:created_time" json:"created_time" form:"created_time"`
  800. UpdatedTime int64 `gorm:"column:updated_time" json:"updated_time" form:"updated_time"`
  801. ProjectId string `gorm:"column:project_id" json:"project_id" form:"project_id"`
  802. VMItemProjectList []*VMItemProjectList `gorm:"-" json:"list" form:"list"`
  803. ItemId string `gorm:"column:item_id" json:"item_id" form:"item_id"`
  804. }
  805. func (VMHisProjectTeam) TableName() string {
  806. return "xt_his_project_team"
  807. }
  808. type VMItemProjectList struct {
  809. ID int64 `gorm:"column:id" json:"id" form:"id"`
  810. Number int64 `gorm:"column:number" json:"number" form:"number"`
  811. UserOrgId int64 `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
  812. ProjectId int64 `gorm:"column:project_id" json:"project_id" form:"project_id"`
  813. Status int64 `gorm:"column:status" json:"status" form:"status"`
  814. CreatedTime int64 `gorm:"column:created_time" json:"created_time" form:"created_time"`
  815. UpdatedTime int64 `gorm:"column:updated_time" json:"updated_time" form:"updated_time"`
  816. TeamId int64 `gorm:"column:team_id" json:"team_id" form:"team_id"`
  817. Type int64 `gorm:"column:type" json:"type" form:"type"`
  818. VMHisProject VMHisProject `gorm:"ForeignKey:ID;AssociationForeignKey:ProjectId" json:"project"`
  819. }
  820. func (VMItemProjectList) TableName() string {
  821. return "xt_his_project_list"
  822. }
  823. type VMHisProject struct {
  824. ID int64 `gorm:"column:id" json:"id" form:"id"`
  825. ProjectName string `gorm:"column:project_name" json:"project_name" form:"project_name"`
  826. Price float64 `gorm:"column:price" json:"price" form:"price"`
  827. Unit string `gorm:"column:unit" json:"unit" form:"unit"`
  828. CostClassify int64 `gorm:"column:cost_classify" json:"cost_classify" form:"cost_classify"`
  829. StatisticalClassification int64 `gorm:"column:statistical_classification" json:"statistical_classification" form:"statistical_classification"`
  830. UserOrgId int64 `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
  831. Status int64 `gorm:"column:status" json:"status" form:"status"`
  832. SingleDose string `gorm:"column:single_dose" json:"single_dose" form:"single_dose"`
  833. ExecutionFrequency string `gorm:"column:execution_frequency" json:"execution_frequency" form:"execution_frequency"`
  834. DeliveryWay string `gorm:"column:delivery_way" json:"delivery_way" form:"delivery_way"`
  835. NumberDays string `gorm:"column:number_days" json:"number_days" form:"number_days"`
  836. MedicalCode string `gorm:"column:medical_code" json:"medical_code" form:"medical_code"`
  837. }
  838. func (VMHisProject) TableName() string {
  839. return "xt_his_project"
  840. }
  841. type HisPrescriptionProject struct {
  842. ID int64 `gorm:"column:id" json:"id" form:"id"`
  843. ProjectId int64 `gorm:"column:project_id" json:"project_id" form:"project_id"`
  844. Price float64 `gorm:"column:price" json:"price" form:"price"`
  845. UserOrgId int64 `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
  846. Status int64 `gorm:"column:status" json:"status" form:"status"`
  847. Ctime int64 `gorm:"column:ctime" json:"ctime" form:"ctime"`
  848. Mtime int64 `gorm:"column:mtime" json:"mtime" form:"mtime"`
  849. PatientId int64 `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
  850. HisPatientId int64 `gorm:"column:his_patient_id" json:"his_patient_id" form:"his_patient_id"`
  851. RecordDate int64 `gorm:"column:record_date" json:"record_date" form:"record_date"`
  852. PrescriptionId int64 `gorm:"column:prescription_id" json:"prescription_id" form:"prescription_id"`
  853. Count int64 `gorm:"column:count" json:"count" form:"count"`
  854. FeedetlSn string `gorm:"column:feedetl_sn" json:"feedetl_sn" form:"feedetl_sn"`
  855. MedListCodg string `gorm:"column:med_list_codg" json:"med_list_codg" form:"med_list_codg"`
  856. SingleDose string `gorm:"column:single_dose" json:"single_dose" form:"single_dose"`
  857. DeliveryWay string `gorm:"column:delivery_way" json:"delivery_way" form:"delivery_way"`
  858. ExecutionFrequency string `gorm:"column:execution_frequency" json:"execution_frequency" form:"execution_frequency"`
  859. Day string `gorm:"column:day" json:"day" form:"day"`
  860. VMHisProject VMHisProject `gorm:"ForeignKey:ProjectId;AssociationForeignKey:ID" json:"project"`
  861. Remark string `gorm:"column:remark" json:"remark" form:"remark"`
  862. Unit string `gorm:"column:unit" json:"unit" form:"unit"`
  863. Type int64 `gorm:"column:type" json:"type" form:"type"`
  864. Doctor int64 `gorm:"column:doctor" json:"doctor" form:"doctor"`
  865. ExecutionTime int64 `gorm:"column:execution_time" json:"execution_time" form:"execution_time"`
  866. ExecutionStaff int64 `gorm:"column:execution_staff" json:"execution_staff" form:"execution_staff"`
  867. ExecutionState int64 `gorm:"column:execution_state" json:"execution_state" form:"execution_state"`
  868. CheckTime int64 `gorm:"column:check_time" json:"check_time" form:"check_time"`
  869. CheckState int64 `gorm:"column:check_state" json:"check_state" form:"check_state"`
  870. Checker int64 `gorm:"column:checker" json:"checker" form:"checker"`
  871. StartTime int64 `gorm:"column:start_time" json:"start_time" form:"start_time"`
  872. TeamId int64 `gorm:"column:team_id" json:"team_id" form:"team_id"`
  873. FrequencyType int64 `gorm:"column:frequency_type" json:"frequency_type" form:"frequency_type"`
  874. DayCount int64 `gorm:"column:day_count" json:"day_count" form:"day_count"`
  875. WeekDay string `gorm:"column:week_day" json:"week_day" form:"week_day"`
  876. HisPrescription HisPrescription `gorm:"ForeignKey:ID;AssociationForeignKey:PrescriptionId" json:"his_prescription"`
  877. }
  878. func (HisPrescriptionProject) TableName() string {
  879. return "his_prescription_project"
  880. }
  881. func GetProjectTeamList(orgid int64, id int64, p_id int64) (project []*HisPrescriptionProject, err error) {
  882. err = readDb.Model(&HisPrescriptionProject{}).Where("user_org_id = ? AND status = 1 AND team_id = ? AND prescription_id = ?", orgid, id, p_id).Find(&project).Error
  883. return
  884. }
  885. func GetHisLabelPrintInfoById(id string) (info HisLabelPrintInfo, err error) {
  886. err = readDb.Model(&HisLabelPrintInfo{}).Where("id = ?", id).First(&info).Error
  887. return
  888. }