You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

2017 lines
97 KiB

1 month ago
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Data;
  4. using System.Linq;
  5. using System.Text;
  6. using System.Threading.Tasks;
  7. using FastReport.Editor;
  8. using Report.Entity;
  9. using Report.Entity.RptEntity;
  10. using Spire.Pdf.Lists;
  11. namespace ReportLibrary
  12. {
  13. public class ConvertHelper
  14. {
  15. private const int EMPTY_VALUE = -1;
  16. public static void RemoveEmptyRows(DataSet dataSet)
  17. {
  18. foreach (DataTable table in dataSet.Tables)
  19. {
  20. for (int i = 0; i < table.Rows.Count; i++)
  21. {
  22. bool isRowEmpty = false;
  23. foreach (DataColumn column in table.Columns)
  24. {
  25. if (!string.IsNullOrEmpty(table.Rows[i][column].ToString()))
  26. {
  27. if (table.Rows[i][column].ToString().Equals("-1"))
  28. {
  29. isRowEmpty = true;
  30. break;
  31. };
  32. }
  33. }
  34. if (isRowEmpty)
  35. {
  36. table.Rows[i].Delete();
  37. }
  38. }
  39. }
  40. }
  41. private static List<piclog> ToPicTable(Dictionary<string, string> dict, string websiteUrl)
  42. {
  43. List<piclog> picList = new List<piclog>();
  44. piclog pic = new piclog();
  45. string key = "hisLog";
  46. if (dict.ContainsKey(key) == true)
  47. {
  48. var baseUri = new Uri(websiteUrl);
  49. var fullUri = new Uri(baseUri, dict[key]);
  50. pic.photo = fullUri.AbsoluteUri;
  51. }
  52. key = "firstPage";
  53. if (dict.ContainsKey(key) == true)
  54. {
  55. var baseUri = new Uri(websiteUrl);
  56. var fullUri = new Uri(baseUri, dict[key]);
  57. pic.firstPage = fullUri.AbsoluteUri;
  58. }
  59. key = "pageHeader";
  60. if (dict.ContainsKey(key) == true)
  61. {
  62. var baseUri = new Uri(websiteUrl);
  63. var fullUri = new Uri(baseUri, dict[key]);
  64. pic.pageHeader = fullUri.AbsoluteUri;
  65. }
  66. key = "pageFooter";
  67. if (dict.ContainsKey(key) == true)
  68. {
  69. var baseUri = new Uri(websiteUrl);
  70. var fullUri = new Uri(baseUri, dict[key]);
  71. pic.pageFooter = fullUri.AbsoluteUri;
  72. }
  73. key = "resultSign";
  74. if (dict.ContainsKey(key) == true)
  75. {
  76. var baseUri = new Uri(websiteUrl);
  77. var fullUri = new Uri(baseUri, dict[key]);
  78. pic.resultSign = fullUri.AbsoluteUri;
  79. }
  80. key = "orgSign";
  81. if (dict.ContainsKey(key) == true)
  82. {
  83. var baseUri = new Uri(websiteUrl);
  84. var fullUri = new Uri(baseUri, dict[key]);
  85. pic.orgSign = fullUri.AbsoluteUri;
  86. }
  87. key = "picExtOne";
  88. if (dict.ContainsKey(key) == true)
  89. {
  90. var baseUri = new Uri(websiteUrl);
  91. var fullUri = new Uri(baseUri, dict[key]);
  92. pic.picExtOne = fullUri.AbsoluteUri;
  93. }
  94. key = "picExtTwo";
  95. if (dict.ContainsKey(key) == true)
  96. {
  97. var baseUri = new Uri(websiteUrl);
  98. var fullUri = new Uri(baseUri, dict[key]);
  99. pic.picExtTwo = fullUri.AbsoluteUri;
  100. }
  101. key = "picExtThree";
  102. if (dict.ContainsKey(key) == true)
  103. {
  104. var baseUri = new Uri(websiteUrl);
  105. var fullUri = new Uri(baseUri, dict[key]);
  106. pic.picExtThree = fullUri.AbsoluteUri;
  107. }
  108. key = "picExtFour";
  109. if (dict.ContainsKey(key) == true)
  110. {
  111. var baseUri = new Uri(websiteUrl);
  112. var fullUri = new Uri(baseUri, dict[key]);
  113. pic.picExtFour = fullUri.AbsoluteUri;
  114. }
  115. key = "picExtFive";
  116. if (dict.ContainsKey(key) == true)
  117. {
  118. var baseUri = new Uri(websiteUrl);
  119. var fullUri = new Uri(baseUri, dict[key]);
  120. pic.picExtFive = fullUri.AbsoluteUri;
  121. }
  122. key = "picExtSix";
  123. if (dict.ContainsKey(key) == true)
  124. {
  125. var baseUri = new Uri(websiteUrl);
  126. var fullUri = new Uri(baseUri, dict[key]);
  127. pic.picExtSix = fullUri.AbsoluteUri;
  128. }
  129. key = "picExtSeven";
  130. if (dict.ContainsKey(key) == true)
  131. {
  132. var baseUri = new Uri(websiteUrl);
  133. var fullUri = new Uri(baseUri, dict[key]);
  134. pic.picExtSeven = fullUri.AbsoluteUri;
  135. }
  136. key = "picExtEight";
  137. if (dict.ContainsKey(key) == true)
  138. {
  139. var baseUri = new Uri(websiteUrl);
  140. var fullUri = new Uri(baseUri, dict[key]);
  141. pic.picExtEight = fullUri.AbsoluteUri;
  142. }
  143. key = "picExtNine";
  144. if (dict.ContainsKey(key) == true)
  145. {
  146. var baseUri = new Uri(websiteUrl);
  147. var fullUri = new Uri(baseUri, dict[key]);
  148. pic.picExtNine = fullUri.AbsoluteUri;
  149. }
  150. key = "picExtTen";
  151. if (dict.ContainsKey(key) == true)
  152. {
  153. var baseUri = new Uri(websiteUrl);
  154. var fullUri = new Uri(baseUri, dict[key]);
  155. pic.picExtTen = fullUri.AbsoluteUri;
  156. }
  157. picList.Add(pic);
  158. return picList;
  159. }
  160. public static async Task<DataSet> ReportHealthToDataSetAsync(string filePath, Dictionary<string, string> dict, string websiteUrl, string apiUrl,string imageUrl, bool isSaveJson = false)
  161. {
  162. Task<DataSet> task = Task.Factory.StartNew<DataSet>(() =>
  163. {
  164. string json = FileHelper.ReadAllText(filePath);
  165. Dto0005 bill = ClientConfig.DeserializeObject<Dto0005>(json);
  166. List<DictMedicalReportType> dictMedicalTypeList = new List<DictMedicalReportType>();
  167. foreach (var item in bill.medicalReportTypes)
  168. {
  169. DictMedicalReportType dictmedicalreporttype = new DictMedicalReportType()
  170. {
  171. medicalReportTypeId = item.medicalReportTypeId,
  172. medicalReportTypeName = item.medicalReportTypeName,
  173. displayOrder = item.displayOrder,
  174. };
  175. dictMedicalTypeList.Add(dictmedicalreporttype);
  176. }
  177. List<HRPatientRegister> pHealthList = new List<HRPatientRegister>();
  178. HRPatientRegister pHealth = new HRPatientRegister()
  179. {
  180. patientRegisterId = bill.patientRegisterId,
  181. isPersonal = bill.isPersonal,
  182. customerOrgName = bill.customerOrgName,
  183. departmentName = bill.departmentName,
  184. patientRegisterNo = bill.patientRegisterNo,
  185. barcodeImg = BarCodeHelper.BuildBarCode(bill.patientRegisterNo),
  186. patientNo = bill.patientNo,
  187. idNo = bill.idNo,
  188. medicalTimes = bill.medicalTimes,
  189. patientName = bill.patientName,
  190. sexName = bill.sexName,
  191. age = bill.age == null ? "" : Convert.ToString(bill.age),
  192. birthDate = bill.birthDate == null ? "" : Convert.ToDateTime(bill.birthDate).ToString("yyyy-MM-dd"),
  193. maritalStatusName = bill.maritalStatusName,
  194. nationName = bill.nationName,
  195. mobileTelephone = bill.mobileTelephone,
  196. isVip = bill.isVip,
  197. medicalStartDate = bill.medicalStartDate.Replace("T"," ").Substring(0,19),
  198. medicalTypeName = bill.medicalTypeName,
  199. personnelTypeName = bill.personnelTypeName,
  200. medicalPackageOrCustomerOrgGroupName = bill.medicalPackageOrCustomerOrgGroupName,
  201. summaryDoctorName = bill.summaryDoctorName,
  202. summaryDoctorSignUrl = bill.summaryDoctorSignUrl,
  203. summaryDate = bill.summaryDate,
  204. auditDoctorName = bill.auditDoctorName,
  205. auditDoctorSignUrl=bill.auditDoctorSignUrl,
  206. auditDate = bill.auditDate,
  207. medicalCenterId = bill.medicalCenterId,
  208. medicalCenterName = bill.medicalCenterName,
  209. medicalCenterAddress = bill.medicalCenterAddress,
  210. medicalCenterTelphone = bill.medicalCenterTelphone,
  211. };
  212. pHealthList.Add(pHealth);
  213. List<HRSumSummary> pSumList = new List<HRSumSummary>();
  214. List<HRSummaryContent> pContentList = new List<HRSummaryContent>();
  215. foreach (var item in bill.sumSummarys)
  216. {
  217. HRSumSummary hrsumsummary = new HRSumSummary()
  218. {
  219. summaryTitle = item.summaryTitle,
  220. summaryFlag = item.summaryFlag,
  221. displayOrder = item.displayOrder,
  222. };
  223. foreach (var content in item.summaryContents)
  224. {
  225. HRSummaryContent hrsummarycontent = new HRSummaryContent()
  226. {
  227. summaryTitle = item.summaryTitle,
  228. summaryContent = content.summaryContent,
  229. displayOrder = content.displayOrder,
  230. };
  231. pContentList.Add(hrsummarycontent);
  232. }
  233. pSumList.Add(hrsumsummary);
  234. }
  235. if (pSumList.Count == 0)
  236. {
  237. HRSumSummary hrsumsummary = new HRSumSummary() { displayOrder = EMPTY_VALUE };
  238. pSumList.Add(hrsumsummary);
  239. }
  240. if (pContentList.Count == 0)
  241. {
  242. HRSummaryContent hrsummarycontent = new HRSummaryContent() { displayOrder = EMPTY_VALUE };
  243. pContentList.Add(hrsummarycontent);
  244. }
  245. List<HRSuggestion> pSugList = new List<HRSuggestion>();
  246. List<HRSugMedicalInterpretation> pMedList = new List<HRSugMedicalInterpretation>();
  247. List<HRSugCommonReason> pReasonList = new List<HRSugCommonReason>();
  248. List<HRSugHealthGuidance> pGuideList = new List<HRSugHealthGuidance>();
  249. int orderNo = 0;
  250. string text = string.Empty;
  251. foreach (var item in bill.sumSuggestions)
  252. {
  253. HRSuggestion hrsuggestion = new HRSuggestion()
  254. {
  255. suggestionTitle = item.suggestionTitle,
  256. suggestionFlag = item.suggestionFlag,
  257. displayOrder = item.displayOrder,
  258. };
  259. orderNo = 0;
  260. text = "{医学解释}";
  261. var medicalInterSortList = item.medicalInterpretations.OrderBy(o => o.displayOrder).ToList();
  262. foreach (var med in medicalInterSortList)
  263. {
  264. HRSugMedicalInterpretation hrsugmedicalinterpretation = new HRSugMedicalInterpretation()
  265. {
  266. suggestionTitle = item.suggestionTitle,
  267. suggestionContent = med.suggestionContent,
  268. displayOrder = med.displayOrder,
  269. };
  270. orderNo++;
  271. pMedList.Add(hrsugmedicalinterpretation);
  272. if (medicalInterSortList.Count > 1)
  273. text += string.Format("{0}、{1}", orderNo, med.suggestionContent);
  274. else
  275. {
  276. text += string.Format("{0}", med.suggestionContent);
  277. }
  278. }
  279. if (medicalInterSortList.Count > 0) hrsuggestion.medicalText = text;
  280. orderNo = 0;
  281. text = "{常见原因}";
  282. var commonReasonSortList = item.commonReasons.OrderBy(o => o.displayOrder).ToList();
  283. foreach (var reason in commonReasonSortList)
  284. {
  285. HRSugCommonReason hrsugcommonreason = new HRSugCommonReason()
  286. {
  287. suggestionTitle = item.suggestionTitle,
  288. suggestionContent = reason.suggestionContent,
  289. displayOrder = reason.displayOrder,
  290. };
  291. orderNo++;
  292. pReasonList.Add(hrsugcommonreason);
  293. if (commonReasonSortList.Count > 1)
  294. text += string.Format("{0}、{1}", orderNo, reason.suggestionContent);
  295. else
  296. {
  297. text += string.Format("{0}", reason.suggestionContent);
  298. }
  299. }
  300. if (commonReasonSortList.Count > 0) hrsuggestion.reasonText = text;
  301. orderNo = 0;
  302. text = "{健康指导}";
  303. var healthGuidSortList = item.healthGuidances.OrderBy(o => o.displayOrder).ToList();
  304. foreach (var guide in healthGuidSortList)
  305. {
  306. HRSugHealthGuidance hrsughealthguidance = new HRSugHealthGuidance()
  307. {
  308. suggestionTitle = item.suggestionTitle,
  309. suggestionContent = guide.suggestionContent,
  310. displayOrder = guide.displayOrder,
  311. };
  312. orderNo++;
  313. pGuideList.Add(hrsughealthguidance);
  314. if (healthGuidSortList.Count > 1)
  315. text += string.Format("{0}、{1}", orderNo, guide.suggestionContent);
  316. else
  317. {
  318. text += string.Format("{0}", guide.suggestionContent);
  319. }
  320. }
  321. if (healthGuidSortList.Count > 0) hrsuggestion.guideText = text;
  322. pSugList.Add(hrsuggestion);
  323. }
  324. if (pSugList.Count == 0)
  325. {
  326. HRSuggestion hrsuggestion = new HRSuggestion() { displayOrder = EMPTY_VALUE }; ;
  327. pSugList.Add(hrsuggestion);
  328. }
  329. if (pMedList.Count == 0)
  330. {
  331. HRSugMedicalInterpretation hrsugmedicalinterpretation = new HRSugMedicalInterpretation() { displayOrder = EMPTY_VALUE };
  332. pMedList.Add(hrsugmedicalinterpretation);
  333. }
  334. if (pReasonList.Count == 0)
  335. {
  336. HRSugCommonReason hrsugcommonreason = new HRSugCommonReason() { displayOrder = EMPTY_VALUE };
  337. pReasonList.Add(hrsugcommonreason);
  338. }
  339. if (pGuideList.Count == 0)
  340. {
  341. HRSugHealthGuidance hrsughealthguidance = new HRSugHealthGuidance() { displayOrder = EMPTY_VALUE };
  342. pGuideList.Add(hrsughealthguidance);
  343. }
  344. List<RegisterCheckItemType> pItemTypeList = new List<RegisterCheckItemType>();
  345. List<RegisterCheckAsbitem> pAsbitemList = new List<RegisterCheckAsbitem>();
  346. List<RegisterCheckItem> pCheckItemList = new List<RegisterCheckItem>();
  347. List<RegisterCheckPircture> pPirctureList = new List<RegisterCheckPircture>();
  348. List<RegisterCheckSummary> pSummaryList = new List<RegisterCheckSummary>();
  349. List<DictExamItemType> dExamItemTypeList = new List<DictExamItemType>();
  350. List<DictNotExamItemType> dNotExamItemTypeList = new List<DictNotExamItemType>();
  351. List<HBsAgAsbitem> dHBsAgList = new List<HBsAgAsbitem>();
  352. List<RegisterCheckPirctureHorizontal> pPirctureListHorizontal = new List<RegisterCheckPirctureHorizontal>();
  353. string previousItemTypeId = "", previousAsbitemNames = "";
  354. int absitemOrderNo = 0;
  355. orderNo = 0;
  356. text = "";
  357. var registerCheckSortList = bill.registerChecks.OrderBy(o => o.displayOrder).ToList();
  358. foreach (var asbitem in registerCheckSortList)
  359. {
  360. if (previousItemTypeId != asbitem.itemTypeId)
  361. {
  362. ItemType type = bill.itemTypes.Where(p => (p.itemTypeId.Equals(asbitem.itemTypeId))).FirstOrDefault();
  363. if (type != null)
  364. {
  365. RegisterCheckItemType registercheckitemtype = new RegisterCheckItemType()
  366. {
  367. medicalReportTypeId = type.medicalReportTypeId,
  368. itemTypeId = type.itemTypeId,
  369. itemTypeName = type.itemTypeName,
  370. displayOrder = type.displayOrder,
  371. };
  372. if (type.medicalReportTypeId.Equals("3"))
  373. {
  374. DictExamItemType dictexamitemtype = new DictExamItemType()
  375. {
  376. medicalReportTypeId = type.medicalReportTypeId,
  377. itemTypeId = type.itemTypeId,
  378. itemTypePathCode = type.itemTypePathCode,
  379. itemTypeName = type.itemTypeName,
  380. displayOrder = type.displayOrder,
  381. };
  382. dExamItemTypeList.Add(dictexamitemtype);
  383. }
  384. else
  385. {
  386. DictNotExamItemType dictnotexamitemtype = new DictNotExamItemType()
  387. {
  388. medicalReportTypeId = type.medicalReportTypeId,
  389. itemTypeId = type.itemTypeId,
  390. itemTypePathCode = type.itemTypePathCode,
  391. itemTypeName = type.itemTypeName,
  392. displayOrder = type.displayOrder,
  393. };
  394. dNotExamItemTypeList.Add(dictnotexamitemtype);
  395. }
  396. pItemTypeList.Add(registercheckitemtype);
  397. }
  398. previousItemTypeId = asbitem.itemTypeId;
  399. }
  400. if (previousAsbitemNames != asbitem.asbitemNames)
  401. {
  402. previousAsbitemNames = asbitem.asbitemNames;
  403. absitemOrderNo++;
  404. }
  405. RegisterCheckAsbitem registercheckasbitem = new RegisterCheckAsbitem()
  406. {
  407. itemTypeId = asbitem.itemTypeId,
  408. asbitemNames = asbitem.asbitemNames,
  409. absOrderNo = absitemOrderNo,
  410. displayOrder = asbitem.displayOrder,
  411. checkDoctorName = asbitem.checkDoctorName,
  412. checkDoctorSignUrl=asbitem.checkDoctorSignUrl,
  413. checkDate = asbitem.checkDate.Replace("T"," ").Substring(0,19),
  414. auditorName = asbitem.auditorName,
  415. auditorSignUrl = asbitem.auditorSignUrl,
  416. samplerName = asbitem.samplerName,
  417. samplingTime = asbitem.samplingTime,
  418. lisSampleNo=asbitem.lisSampleNo,
  419. };
  420. if (asbitem.asbitemNames.Contains("乙肝"))
  421. {
  422. HBsAgAsbitem hb = new HBsAgAsbitem()
  423. {
  424. itemTypeId = asbitem.itemTypeId,
  425. asbitemNames = asbitem.asbitemNames,
  426. absOrderNo = absitemOrderNo,
  427. displayOrder = asbitem.displayOrder,
  428. checkDoctorName = asbitem.checkDoctorName,
  429. checkDoctorSignUrl=asbitem.checkDoctorSignUrl,
  430. checkDate = asbitem.checkDate.Replace("T", " ").Substring(0, 19),
  431. auditorName = asbitem.auditorName,
  432. auditorSignUrl = asbitem.auditorSignUrl,
  433. samplerName = asbitem.samplerName,
  434. samplingTime = asbitem.samplingTime,
  435. lisSampleNo = asbitem.lisSampleNo,
  436. };
  437. dHBsAgList.Add(hb);
  438. }
  439. foreach (var item in asbitem.items)
  440. {
  441. RegisterCheckItem registercheckitem = new RegisterCheckItem()
  442. {
  443. asbitemNames = asbitem.asbitemNames,
  444. itemId = item.itemId,
  445. itemName = item.itemName,
  446. result = item.result,
  447. referenceRangeValue = item.referenceRangeValue,
  448. criticalRangeValue = item.criticalRangeValue,
  449. unit = item.unit,
  450. reportFontColor = item.reportFontColor,
  451. reportBackgroundColor = item.reportBackgroundColor,
  452. reportPrompt = item.reportPrompt,
  453. displayOrder = item.displayOrder,
  454. };
  455. pCheckItemList.Add(registercheckitem);
  456. }
  457. foreach (var pic in asbitem.pictures)
  458. {
  459. var baseUri = new Uri(imageUrl);
  460. var fullUri = new Uri(baseUri, pic.pictureFileName);
  461. RegisterCheckPircture registercheckpircture = new RegisterCheckPircture()
  462. {
  463. asbitemNames = asbitem.asbitemNames,
  464. pictureFileName = fullUri.AbsoluteUri,
  465. pictureFileType=pic.pictureFileType,
  466. itemTypeName = pic.itemTypeName,
  467. pictureBase64 = pic.pictureBase64,
  468. displayOrder = pic.displayOrder,
  469. };
  470. pPirctureList.Add(registercheckpircture);
  471. }
  472. var grouped = pPirctureList.GroupBy(x => x.asbitemNames).ToList();
  473. foreach (var group in grouped)
  474. {
  475. var existingItem = pPirctureListHorizontal.FirstOrDefault(item => item.asbitemNames == group.Key);
  476. if (existingItem == null)
  477. {
  478. RegisterCheckPirctureHorizontal newItem = new RegisterCheckPirctureHorizontal
  479. {
  480. asbitemNames = group.Key
  481. };
  482. var pictures = group.Select(x => x.pictureFileName).Take(6).ToList();
  483. if (pictures.Count > 0) newItem.pictureHorizontalOne = pictures.ElementAtOrDefault(0);
  484. if (pictures.Count > 1) newItem.pictureHorizontalTwo = pictures.ElementAtOrDefault(1);
  485. if (pictures.Count > 2) newItem.pictureHorizontalThree = pictures.ElementAtOrDefault(2);
  486. if (pictures.Count > 3) newItem.pictureHorizontalFour = pictures.ElementAtOrDefault(3);
  487. if (pictures.Count > 4) newItem.pictureHorizontalFive = pictures.ElementAtOrDefault(4);
  488. if (pictures.Count > 5) newItem.pictureHorizontalSix = pictures.ElementAtOrDefault(5);
  489. newItem.pictureCount = pictures.Count; // 设置实际转换的行数
  490. var ext= group.Where(p => p.asbitemNames.Equals(group.Key)).FirstOrDefault();
  491. if(ext!= null)
  492. {
  493. newItem.itemTypeName = ext.itemTypeName;
  494. newItem.displayOrder = ext.displayOrder;
  495. }
  496. pPirctureListHorizontal.Add(newItem);
  497. }
  498. }
  499. orderNo = 0;
  500. text = "";
  501. var summarysSortList = asbitem.summarys.OrderBy(o => o.displayOrder).ToList();
  502. foreach (var sum in summarysSortList)
  503. {
  504. RegisterCheckSummary registerchecksummary = new RegisterCheckSummary()
  505. {
  506. asbitemNames = asbitem.asbitemNames,
  507. summary = sum.summary,
  508. displayOrder = sum.displayOrder,
  509. };
  510. orderNo++;
  511. if (summarysSortList.Count > 1)
  512. text += string.Format("{0}:{1}", orderNo, sum.summary);
  513. else
  514. {
  515. text = string.Format("{0}", sum.summary);
  516. }
  517. pSummaryList.Add(registerchecksummary);
  518. }
  519. if (summarysSortList.Count > 0) registercheckasbitem.summarysText = text;
  520. pAsbitemList.Add(registercheckasbitem);
  521. }
  522. List<CheckTarget> checkTargetOne = new List<CheckTarget>();
  523. List<CheckTarget> checkTargetTwo = new List<CheckTarget>();
  524. List<CheckTarget> checkTargetThree = new List<CheckTarget>();
  525. List<CheckTarget> checkTargetFour = new List<CheckTarget>();
  526. List<CheckTarget> checkTargetFive = new List<CheckTarget>();
  527. List<CheckTarget> checkTargetSix = new List<CheckTarget>();
  528. var groupedItem = bill.ItemContrasts.GroupBy(x => x.asbitemName).ToList();
  529. int tagIndex = 1;
  530. string itemReferenceRange = "",tempItemName;
  531. foreach (var group in groupedItem)
  532. {
  533. var targets = bill.ItemContrasts.Where(x => x.asbitemName.Equals(group.Key));
  534. foreach (var target in targets)
  535. {
  536. var groupedRange = targets.GroupBy(x => x.itemName).ToList();
  537. if (groupedRange.Count == 1)
  538. {
  539. itemReferenceRange= targets.Max(x=>x.itemReferenceRange);
  540. }
  541. if(groupedRange.Count > 1)
  542. {
  543. foreach(var item in groupedRange)
  544. {
  545. tempItemName = targets.Where(p => p.itemReferenceRange.Equals(item.Key)).FirstOrDefault().itemName;
  546. itemReferenceRange += string.Format("{0}:{1} ", tempItemName, item.Key);
  547. }
  548. }
  549. CheckTarget checkTarget = new CheckTarget()
  550. {
  551. asbitemName = target.asbitemName,
  552. itemName = target.itemName,
  553. itemReferenceRange = itemReferenceRange,
  554. itemResult = target.itemResult,
  555. medicalStartDate = target.medicalStartDate,
  556. displayOrder = 1
  557. };
  558. if (tagIndex == 1)
  559. checkTargetOne.Add(checkTarget);
  560. else if (tagIndex == 2)
  561. checkTargetTwo.Add(checkTarget);
  562. else if (tagIndex == 3)
  563. checkTargetThree.Add(checkTarget);
  564. else if (tagIndex == 4)
  565. checkTargetFour.Add(checkTarget);
  566. else if (tagIndex == 5)
  567. checkTargetFive.Add(checkTarget);
  568. else if (tagIndex == 6)
  569. checkTargetSix.Add(checkTarget);
  570. }
  571. tagIndex++;
  572. }
  573. if (checkTargetOne.Count == 0)
  574. {
  575. CheckTarget checkTarget = new CheckTarget() { displayOrder = EMPTY_VALUE }; ;
  576. checkTargetOne.Add(checkTarget);
  577. }
  578. if (checkTargetTwo.Count == 0)
  579. {
  580. CheckTarget checkTarget = new CheckTarget() { displayOrder = EMPTY_VALUE }; ;
  581. checkTargetTwo.Add(checkTarget);
  582. }
  583. if (checkTargetThree.Count == 0)
  584. {
  585. CheckTarget checkTarget = new CheckTarget() { displayOrder = EMPTY_VALUE }; ;
  586. checkTargetThree.Add(checkTarget);
  587. }
  588. if (checkTargetFour.Count == 0)
  589. {
  590. CheckTarget checkTarget = new CheckTarget() { displayOrder = EMPTY_VALUE }; ;
  591. checkTargetFour.Add(checkTarget);
  592. }
  593. if (checkTargetFive.Count == 0)
  594. {
  595. CheckTarget checkTarget = new CheckTarget() { displayOrder = EMPTY_VALUE }; ;
  596. checkTargetFive.Add(checkTarget);
  597. }
  598. if (checkTargetSix.Count == 0)
  599. {
  600. CheckTarget checkTarget = new CheckTarget() { displayOrder = EMPTY_VALUE }; ;
  601. checkTargetSix.Add(checkTarget);
  602. }
  603. if (dExamItemTypeList.Count == 0)
  604. {
  605. DictExamItemType dictexamitemtype = new DictExamItemType() { displayOrder = EMPTY_VALUE }; ;
  606. dExamItemTypeList.Add(dictexamitemtype);
  607. }
  608. if (dNotExamItemTypeList.Count == 0)
  609. {
  610. DictNotExamItemType dictnotexamitemtype = new DictNotExamItemType() { displayOrder = EMPTY_VALUE }; ;
  611. dNotExamItemTypeList.Add(dictnotexamitemtype);
  612. }
  613. if (dHBsAgList.Count == 0)
  614. {
  615. HBsAgAsbitem hb = new HBsAgAsbitem() { displayOrder = EMPTY_VALUE }; ;
  616. dHBsAgList.Add(hb);
  617. }
  618. if (pItemTypeList.Count == 0)
  619. {
  620. RegisterCheckItemType registercheckitemtype = new RegisterCheckItemType() { displayOrder = EMPTY_VALUE }; ;
  621. pItemTypeList.Add(registercheckitemtype);
  622. }
  623. if (pAsbitemList.Count == 0)
  624. {
  625. RegisterCheckAsbitem registercheckasbitem = new RegisterCheckAsbitem() { absOrderNo = EMPTY_VALUE, displayOrder = EMPTY_VALUE };
  626. pAsbitemList.Add(registercheckasbitem);
  627. }
  628. if (pCheckItemList.Count == 0)
  629. {
  630. RegisterCheckItem registercheckitem = new RegisterCheckItem() { reportFontColor = EMPTY_VALUE, reportBackgroundColor = EMPTY_VALUE, displayOrder = EMPTY_VALUE };
  631. pCheckItemList.Add(registercheckitem);
  632. }
  633. if (pPirctureList.Count == 0)
  634. {
  635. RegisterCheckPircture registercheckpircture = new RegisterCheckPircture() { displayOrder = EMPTY_VALUE };
  636. pPirctureList.Add(registercheckpircture);
  637. }
  638. if (pPirctureListHorizontal.Count == 0)
  639. {
  640. RegisterCheckPirctureHorizontal registercheckpircture = new RegisterCheckPirctureHorizontal() { displayOrder = EMPTY_VALUE };
  641. pPirctureListHorizontal.Add(registercheckpircture);
  642. }
  643. if (pSummaryList.Count == 0)
  644. {
  645. RegisterCheckSummary registerchecksummary = new RegisterCheckSummary() { displayOrder = EMPTY_VALUE };
  646. pSummaryList.Add(registerchecksummary);
  647. }
  648. Rpt0005 hrpersonhealth = new Rpt0005()
  649. {
  650. dictMedType = dictMedicalTypeList,
  651. dictExamItemType=dExamItemTypeList,
  652. dictNotExamItemType = dNotExamItemTypeList,
  653. pinfo = pHealthList,
  654. resItemType = pItemTypeList,
  655. resAsbitem = pAsbitemList,
  656. res = pCheckItemList,
  657. resPic = pPirctureList,
  658. resPicHorizontal=pPirctureListHorizontal,
  659. resSum = pSummaryList,
  660. sug = pSugList,
  661. sugReason = pReasonList,
  662. sugGuide = pGuideList,
  663. sugMeical = pMedList,
  664. summ = pSumList,
  665. summContent = pContentList,
  666. pic = ToPicTable(dict, websiteUrl),
  667. HBsAg=dHBsAgList,
  668. checkTargetOne=checkTargetOne,
  669. checkTargetTwo = checkTargetTwo,
  670. checkTargetThree = checkTargetThree,
  671. checkTargetFour = checkTargetFour,
  672. checkTargetFive = checkTargetFive,
  673. checkTargetSix = checkTargetSix,
  674. };
  675. string dataSetJson = ClientConfig.SerializeObject(hrpersonhealth);
  676. if (isSaveJson)
  677. FileHelper.WriteAllText(filePath, dataSetJson);
  678. DataSet ds = ClientConfig.DeserializeObject<DataSet>(dataSetJson);
  679. return ds;
  680. });
  681. DataSet dSet = await task;
  682. RemoveEmptyRows(dSet);
  683. return dSet;
  684. }
  685. public static async Task<DataSet> OccupationalDiseaseToDataSetAsync(string filePath, Dictionary<string, string> dict, string websiteUrl, string apiUrl,string imageUrl, bool isSaveJson = false)
  686. {
  687. Task<DataSet> task = Task.Factory.StartNew<DataSet>(() =>
  688. {
  689. string json = FileHelper.ReadAllText(filePath);
  690. Report.Entity.PeisEntity.OccupationalDisease.Dto0006 bill = ClientConfig.DeserializeObject<Report.Entity.PeisEntity.OccupationalDisease.Dto0006>(json);
  691. List<DictMedicalReportType> dictMedicalTypeList = new List<DictMedicalReportType>();
  692. foreach (var item in bill.medicalReportTypes)
  693. {
  694. DictMedicalReportType dictmedicalreporttype = new DictMedicalReportType()
  695. {
  696. medicalReportTypeId = item.medicalReportTypeId,
  697. medicalReportTypeName = item.medicalReportTypeName,
  698. displayOrder = item.displayOrder,
  699. };
  700. dictMedicalTypeList.Add(dictmedicalreporttype);
  701. }
  702. List<HRPatientRegister> pHealthList = new List<HRPatientRegister>();
  703. HRPatientRegister pHealth = new HRPatientRegister()
  704. {
  705. patientRegisterId = bill.patientRegisterId,
  706. isPersonal = bill.isPersonal,
  707. customerOrgName = bill.customerOrgName,
  708. departmentName = bill.departmentName,
  709. patientRegisterNo = bill.patientRegisterNo,
  710. barcodeImg = BarCodeHelper.BuildBarCode(bill.patientRegisterNo),
  711. patientNo = bill.patientNo,
  712. idNo = bill.idNo,
  713. medicalTimes = bill.medicalTimes,
  714. patientName = bill.patientName,
  715. sexName = bill.sexName,
  716. age = bill.age == null ? "" : Convert.ToString(bill.age),
  717. birthDate = bill.birthDate == null ? "" : Convert.ToDateTime(bill.birthDate).ToString("yyyy-MM-dd"),
  718. maritalStatusName = bill.maritalStatusName,
  719. nationName = bill.nationName,
  720. mobileTelephone = bill.mobileTelephone,
  721. isVip = bill.isVip,
  722. medicalStartDate = bill.medicalStartDate.Replace("T", " ").Substring(0, 19),
  723. medicalTypeName = bill.medicalTypeName,
  724. personnelTypeName = bill.personnelTypeName,
  725. medicalPackageOrCustomerOrgGroupName = bill.medicalPackageOrCustomerOrgGroupName,
  726. summaryDoctorName = bill.summaryDoctorName,
  727. summaryDoctorSignUrl=bill.summaryDoctorSignUrl,
  728. summaryDate = bill.summaryDate,
  729. auditDoctorName = bill.auditDoctorName,
  730. auditDoctorSignUrl=bill.auditDoctorSignUrl,
  731. auditDate = bill.auditDate,
  732. medicalCenterId = bill.medicalCenterId,
  733. medicalCenterName = bill.medicalCenterName,
  734. medicalCenterAddress = bill.medicalCenterAddress,
  735. medicalCenterTelphone = bill.medicalCenterTelphone,
  736. };
  737. pHealthList.Add(pHealth);
  738. List<PatientOccupationalDisease> pOccDisList = new List<PatientOccupationalDisease>();
  739. PatientOccupationalDisease patientoccupationaldisease = new PatientOccupationalDisease()
  740. {
  741. ocCheckTypeId = bill.patientOccupationalDisease.ocCheckTypeId,
  742. ocCheckTypeName = bill.patientOccupationalDisease.ocCheckTypeName,
  743. jobType = bill.patientOccupationalDisease.jobType,
  744. totalWorkTime = bill.patientOccupationalDisease.totalWorkTime,
  745. poisonWorkTime = bill.patientOccupationalDisease.poisonWorkTime,
  746. riskFactors = bill.patientOccupationalDisease.riskFactors,
  747. familyGeneticHistory = bill.patientOccupationalDisease.familyGeneticHistory,
  748. lastMenstrualPeriodDate = bill.patientOccupationalDisease.lastMenstrualPeriodDate,
  749. firstMenstruation = bill.patientOccupationalDisease.firstMenstruation,
  750. menstruationTimeLength = bill.patientOccupationalDisease.menstruationTimeLength,
  751. menstruationCycle = bill.patientOccupationalDisease.menstruationCycle,
  752. menstruationEndAge = bill.patientOccupationalDisease.menstruationEndAge,
  753. menstruationFlag = bill.patientOccupationalDisease.menstruationFlag,
  754. childrenNum = bill.patientOccupationalDisease.childrenNum,
  755. abortionTimes = bill.patientOccupationalDisease.abortionTimes,
  756. prematureBirthTimes = bill.patientOccupationalDisease.abortionTimes,
  757. stillbirthTimes = bill.patientOccupationalDisease.stillbirthTimes,
  758. abnormalTimes = bill.patientOccupationalDisease.abnormalTimes,
  759. smokeFlag = bill.patientOccupationalDisease.smokeFlag,
  760. smokeNum = bill.patientOccupationalDisease.smokeNum == null ? "" : Convert.ToString(bill.patientOccupationalDisease.smokeNum),
  761. smokeNumMax = bill.patientOccupationalDisease.smokeNumMax == null ? "" : Convert.ToString(bill.patientOccupationalDisease.smokeNumMax),
  762. smokeYears = bill.patientOccupationalDisease.smokeYears == null ? "" : Convert.ToString(bill.patientOccupationalDisease.smokeYears),
  763. drinkFlag = bill.patientOccupationalDisease.drinkFlag,
  764. drinkNum = bill.patientOccupationalDisease.drinkNum == null ? "" : Convert.ToString(bill.patientOccupationalDisease.drinkNum),
  765. drinkNumMax = bill.patientOccupationalDisease.drinkNumMax == null ? "" : Convert.ToString(bill.patientOccupationalDisease.drinkNumMax),
  766. drinkYears = bill.patientOccupationalDisease.drinkYears == null ? "" : Convert.ToString(bill.patientOccupationalDisease.drinkYears),
  767. other = bill.patientOccupationalDisease.other,
  768. occupationalAbnormal = bill.patientOccupationalDisease.occupationalAbnormal,
  769. noOccupationalAbnormal = bill.patientOccupationalDisease.noOccupationalAbnormal,
  770. occupationalAbSuggestion = bill.patientOccupationalDisease.occupationalAbSuggestion,
  771. noOccupAbSuggestion = bill.patientOccupationalDisease.noOccupAbSuggestion,
  772. handleSuggestion = bill.patientOccupationalDisease.handleSuggestion,
  773. OccupationalDiseaseNumber= bill.patientOccupationalDisease.OccupationalDiseaseNumber,
  774. };
  775. pOccDisList.Add(patientoccupationaldisease);
  776. List<OcCheckType> pOcCheckList = new List<OcCheckType>();
  777. foreach (var item in bill.ocCheckTypeDtos)
  778. {
  779. OcCheckType occhecktype = new OcCheckType()
  780. {
  781. ocCheckTypeId = item.ocCheckTypeId,
  782. displayName = item.displayName,
  783. simpleCode = item.simpleCode,
  784. displayOrder = item.displayOrder,
  785. };
  786. pOcCheckList.Add(occhecktype);
  787. }
  788. List<PatientOccupationalHistory> pPatOccHisList = new List<PatientOccupationalHistory>();
  789. foreach (var item in bill.patientOccupationalHistoryDtos)
  790. {
  791. PatientOccupationalHistory patientoccupationalhistory = new PatientOccupationalHistory()
  792. {
  793. org = item.org,
  794. beginDate = item.beginDate,
  795. endDate = item.endDate,
  796. workShop = item.workShop,
  797. workType = item.workType,
  798. poison = item.poison,
  799. protectiveMeasures = item.protectiveMeasures,
  800. displayOrder = item.displayOrder,
  801. };
  802. pPatOccHisList.Add(patientoccupationalhistory);
  803. }
  804. List<PatientOccupationalMedicalHistory> pPatOccMedHisList = new List<PatientOccupationalMedicalHistory>();
  805. foreach (var item in bill.patientOccupationalMedicalHistoryDtos)
  806. {
  807. PatientOccupationalMedicalHistory patientoccupationalmedicalhistory = new PatientOccupationalMedicalHistory()
  808. {
  809. occupationalDisease = item.occupationalDisease,
  810. diagnosisDate = item.diagnosisDate,
  811. diagnosisHospital = item.diagnosisHospital,
  812. isRecovery = item.isRecovery,
  813. treatmentMethods = item.treatmentMethods,
  814. displayOrder = item.displayOrder,
  815. };
  816. pPatOccMedHisList.Add(patientoccupationalmedicalhistory);
  817. }
  818. List<PatientPastMedicalHistory> pPatPastMedHisList = new List<PatientPastMedicalHistory>();
  819. foreach (var item in bill.patientPastMedicalHistoryDtos)
  820. {
  821. PatientPastMedicalHistory patientpastmedicalhistory = new PatientPastMedicalHistory()
  822. {
  823. occupationalDisease = item.occupationalDisease,
  824. diagnosisDate = item.diagnosisDate,
  825. diagnosisHospital = item.diagnosisHospital,
  826. isRecovery = item.isRecovery,
  827. treatmentMethods = item.treatmentMethods,
  828. displayOrder = item.displayOrder,
  829. };
  830. pPatPastMedHisList.Add(patientpastmedicalhistory);
  831. }
  832. List<PatientPoison> pPatPoiList = new List<PatientPoison>();
  833. foreach (var item in bill.patientPoisonDtos)
  834. {
  835. PatientPoison patientpoison = new PatientPoison()
  836. {
  837. poisonName = item.poisonName,
  838. occupationalAbnormalName = item.occupationalAbnormalName,
  839. displayOrder = item.displayOrder,
  840. };
  841. pPatPoiList.Add(patientpoison);
  842. }
  843. List<PatientSymptom> pPatSymList = new List<PatientSymptom>();
  844. foreach (var item in bill.patientSymptomDtos)
  845. {
  846. PatientSymptom patientsymptom = new PatientSymptom()
  847. {
  848. symptomName = item.symptomName,
  849. degree = item.degree,
  850. timeLength = item.timeLength,
  851. displayOrder = item.displayOrder,
  852. };
  853. pPatSymList.Add(patientsymptom);
  854. }
  855. if (pOccDisList.Count == 0)
  856. {
  857. PatientOccupationalDisease patOccDis = new PatientOccupationalDisease();
  858. pOccDisList.Add(patOccDis);
  859. }
  860. if (pOcCheckList.Count == 0)
  861. {
  862. OcCheckType patOccDis = new OcCheckType() { displayOrder = EMPTY_VALUE };
  863. pOcCheckList.Add(patOccDis);
  864. }
  865. if (pPatOccHisList.Count == 0)
  866. {
  867. PatientOccupationalHistory patOccDis = new PatientOccupationalHistory() { displayOrder = EMPTY_VALUE };
  868. pPatOccHisList.Add(patOccDis);
  869. }
  870. if (pPatOccMedHisList.Count == 0)
  871. {
  872. PatientOccupationalMedicalHistory patOccDis = new PatientOccupationalMedicalHistory() { displayOrder = EMPTY_VALUE };
  873. pPatOccMedHisList.Add(patOccDis);
  874. }
  875. if (pPatPastMedHisList.Count == 0)
  876. {
  877. PatientPastMedicalHistory patOccDis = new PatientPastMedicalHistory() { displayOrder = EMPTY_VALUE };
  878. pPatPastMedHisList.Add(patOccDis);
  879. }
  880. if (pPatPoiList.Count == 0)
  881. {
  882. PatientPoison patOccDis = new PatientPoison() { displayOrder = EMPTY_VALUE };
  883. pPatPoiList.Add(patOccDis);
  884. }
  885. if (pPatSymList.Count == 0)
  886. {
  887. PatientSymptom patOccDis = new PatientSymptom() { displayOrder = EMPTY_VALUE };
  888. pPatSymList.Add(patOccDis);
  889. }
  890. List<HRSumSummary> pSumList = new List<HRSumSummary>();
  891. List<HRSummaryContent> pContentList = new List<HRSummaryContent>();
  892. foreach (var item in bill.sumSummarys)
  893. {
  894. HRSumSummary hrsumsummary = new HRSumSummary()
  895. {
  896. summaryTitle = item.summaryTitle,
  897. summaryFlag = item.summaryFlag,
  898. displayOrder = item.displayOrder,
  899. };
  900. foreach (var content in item.summaryContents)
  901. {
  902. HRSummaryContent hrsummarycontent = new HRSummaryContent()
  903. {
  904. summaryTitle = item.summaryTitle,
  905. summaryContent = content.summaryContent,
  906. displayOrder = content.displayOrder,
  907. };
  908. pContentList.Add(hrsummarycontent);
  909. }
  910. pSumList.Add(hrsumsummary);
  911. }
  912. if (pSumList.Count == 0)
  913. {
  914. HRSumSummary hrsumsummary = new HRSumSummary() { displayOrder = EMPTY_VALUE };
  915. pSumList.Add(hrsumsummary);
  916. }
  917. if (pContentList.Count == 0)
  918. {
  919. HRSummaryContent hrsummarycontent = new HRSummaryContent() { displayOrder = EMPTY_VALUE };
  920. pContentList.Add(hrsummarycontent);
  921. }
  922. List<HRSuggestion> pSugList = new List<HRSuggestion>();
  923. List<HRSugMedicalInterpretation> pMedList = new List<HRSugMedicalInterpretation>();
  924. List<HRSugCommonReason> pReasonList = new List<HRSugCommonReason>();
  925. List<HRSugHealthGuidance> pGuideList = new List<HRSugHealthGuidance>();
  926. int orderNo = 0;
  927. string text = string.Empty;
  928. foreach (var item in bill.sumSuggestions)
  929. {
  930. HRSuggestion hrsuggestion = new HRSuggestion()
  931. {
  932. suggestionTitle = item.suggestionTitle,
  933. suggestionFlag = item.suggestionFlag,
  934. displayOrder = item.displayOrder,
  935. };
  936. orderNo = 0;
  937. text = "{医学解释}";
  938. var medicalInterSortList = item.medicalInterpretations.OrderBy(o => o.displayOrder).ToList();
  939. foreach (var med in medicalInterSortList)
  940. {
  941. HRSugMedicalInterpretation hrsugmedicalinterpretation = new HRSugMedicalInterpretation()
  942. {
  943. suggestionTitle = item.suggestionTitle,
  944. suggestionContent = med.suggestionContent,
  945. displayOrder = med.displayOrder,
  946. };
  947. orderNo++;
  948. pMedList.Add(hrsugmedicalinterpretation);
  949. if (medicalInterSortList.Count > 1)
  950. text += string.Format("{0}、{1}", orderNo, med.suggestionContent);
  951. else
  952. {
  953. text += string.Format("{0}", med.suggestionContent);
  954. }
  955. }
  956. if (medicalInterSortList.Count > 0) hrsuggestion.medicalText = text;
  957. orderNo = 0;
  958. text = "{常见原因}";
  959. var commonReasonSortList = item.commonReasons.OrderBy(o => o.displayOrder).ToList();
  960. foreach (var reason in commonReasonSortList)
  961. {
  962. HRSugCommonReason hrsugcommonreason = new HRSugCommonReason()
  963. {
  964. suggestionTitle = item.suggestionTitle,
  965. suggestionContent = reason.suggestionContent,
  966. displayOrder = reason.displayOrder,
  967. };
  968. orderNo++;
  969. pReasonList.Add(hrsugcommonreason);
  970. if (commonReasonSortList.Count > 1)
  971. text += string.Format("{0}、{1}", orderNo, reason.suggestionContent);
  972. else
  973. {
  974. text += string.Format("{0}", reason.suggestionContent);
  975. }
  976. }
  977. if (commonReasonSortList.Count > 0) hrsuggestion.reasonText = text;
  978. orderNo = 0;
  979. text = "{健康指导}";
  980. var healthGuidSortList = item.healthGuidances.OrderBy(o => o.displayOrder).ToList();
  981. foreach (var guide in healthGuidSortList)
  982. {
  983. HRSugHealthGuidance hrsughealthguidance = new HRSugHealthGuidance()
  984. {
  985. suggestionTitle = item.suggestionTitle,
  986. suggestionContent = guide.suggestionContent,
  987. displayOrder = guide.displayOrder,
  988. };
  989. orderNo++;
  990. pGuideList.Add(hrsughealthguidance);
  991. if (healthGuidSortList.Count > 1)
  992. text += string.Format("{0}、{1}", orderNo, guide.suggestionContent);
  993. else
  994. {
  995. text += string.Format("{0}", guide.suggestionContent);
  996. }
  997. }
  998. if (healthGuidSortList.Count > 0) hrsuggestion.guideText = text;
  999. pSugList.Add(hrsuggestion);
  1000. }
  1001. if (pSugList.Count == 0)
  1002. {
  1003. HRSuggestion hrsuggestion = new HRSuggestion() { displayOrder = EMPTY_VALUE }; ;
  1004. pSugList.Add(hrsuggestion);
  1005. }
  1006. if (pMedList.Count == 0)
  1007. {
  1008. HRSugMedicalInterpretation hrsugmedicalinterpretation = new HRSugMedicalInterpretation() { displayOrder = EMPTY_VALUE };
  1009. pMedList.Add(hrsugmedicalinterpretation);
  1010. }
  1011. if (pReasonList.Count == 0)
  1012. {
  1013. HRSugCommonReason hrsugcommonreason = new HRSugCommonReason() { displayOrder = EMPTY_VALUE };
  1014. pReasonList.Add(hrsugcommonreason);
  1015. }
  1016. if (pGuideList.Count == 0)
  1017. {
  1018. HRSugHealthGuidance hrsughealthguidance = new HRSugHealthGuidance() { displayOrder = EMPTY_VALUE };
  1019. pGuideList.Add(hrsughealthguidance);
  1020. }
  1021. List<RegisterCheckItemType> pItemTypeList = new List<RegisterCheckItemType>();
  1022. List<RegisterCheckAsbitem> pAsbitemList = new List<RegisterCheckAsbitem>();
  1023. List<RegisterCheckItem> pCheckItemList = new List<RegisterCheckItem>();
  1024. List<RegisterCheckPircture> pPirctureList = new List<RegisterCheckPircture>();
  1025. List<RegisterCheckSummary> pSummaryList = new List<RegisterCheckSummary>();
  1026. List<DictExamItemType> dExamItemTypeList = new List<DictExamItemType>();
  1027. List<DictNotExamItemType> dNotExamItemTypeList = new List<DictNotExamItemType>();
  1028. string previousItemTypeId = "", previousAsbitemNames = "";
  1029. int absitemOrderNo = 0;
  1030. orderNo = 0;
  1031. text = "";
  1032. var registerCheckSortList = bill.registerChecks.OrderBy(o => o.displayOrder).ToList();
  1033. foreach (var asbitem in registerCheckSortList)
  1034. {
  1035. if (previousItemTypeId != asbitem.itemTypeId)
  1036. {
  1037. Report.Entity.PeisEntity.OccupationalDisease.ItemType type = bill.itemTypes.Where(p => (p.itemTypeId.Equals(asbitem.itemTypeId))).FirstOrDefault();
  1038. if (type != null)
  1039. {
  1040. RegisterCheckItemType registercheckitemtype = new RegisterCheckItemType()
  1041. {
  1042. medicalReportTypeId = type.medicalReportTypeId,
  1043. itemTypeId = type.itemTypeId,
  1044. itemTypeName = type.itemTypeName,
  1045. displayOrder = type.displayOrder,
  1046. };
  1047. if (type.medicalReportTypeId.Equals("3"))
  1048. {
  1049. DictExamItemType dictexamitemtype = new DictExamItemType()
  1050. {
  1051. medicalReportTypeId = type.medicalReportTypeId,
  1052. itemTypeId = type.itemTypeId,
  1053. itemTypePathCode = type.itemTypePathCode,
  1054. itemTypeName = type.itemTypeName,
  1055. displayOrder = type.displayOrder,
  1056. };
  1057. dExamItemTypeList.Add(dictexamitemtype);
  1058. }
  1059. else
  1060. {
  1061. DictNotExamItemType dictnotexamitemtype = new DictNotExamItemType()
  1062. {
  1063. medicalReportTypeId = type.medicalReportTypeId,
  1064. itemTypeId = type.itemTypeId,
  1065. itemTypePathCode = type.itemTypePathCode,
  1066. itemTypeName = type.itemTypeName,
  1067. displayOrder = type.displayOrder,
  1068. };
  1069. dNotExamItemTypeList.Add(dictnotexamitemtype);
  1070. }
  1071. pItemTypeList.Add(registercheckitemtype);
  1072. }
  1073. previousItemTypeId = asbitem.itemTypeId;
  1074. }
  1075. if (previousAsbitemNames != asbitem.asbitemNames)
  1076. {
  1077. previousAsbitemNames = asbitem.asbitemNames;
  1078. absitemOrderNo++;
  1079. }
  1080. RegisterCheckAsbitem registercheckasbitem = new RegisterCheckAsbitem()
  1081. {
  1082. itemTypeId = asbitem.itemTypeId,
  1083. asbitemNames = asbitem.asbitemNames,
  1084. absOrderNo = absitemOrderNo,
  1085. displayOrder = asbitem.displayOrder,
  1086. checkDoctorName = asbitem.checkDoctorName,
  1087. checkDoctorSignUrl=asbitem.checkDoctorSignUrl,
  1088. auditorName = asbitem.auditorName,
  1089. auditorSignUrl = asbitem.auditorSignUrl,
  1090. samplerName = asbitem.samplerName,
  1091. samplingTime = asbitem.samplingTime,
  1092. checkDate = asbitem.checkDate.Replace("T", " ").Substring(0, 19),
  1093. };
  1094. foreach (var item in asbitem.items)
  1095. {
  1096. RegisterCheckItem registercheckitem = new RegisterCheckItem()
  1097. {
  1098. asbitemNames = asbitem.asbitemNames,
  1099. itemId = item.itemId,
  1100. itemName = item.itemName,
  1101. result = item.result,
  1102. referenceRangeValue = item.referenceRangeValue,
  1103. criticalRangeValue = item.criticalRangeValue,
  1104. unit = item.unit,
  1105. reportFontColor = item.reportFontColor,
  1106. reportBackgroundColor = item.reportBackgroundColor,
  1107. reportPrompt = item.reportPrompt,
  1108. displayOrder = item.displayOrder,
  1109. };
  1110. pCheckItemList.Add(registercheckitem);
  1111. }
  1112. foreach (var pic in asbitem.pictures)
  1113. {
  1114. var baseUri = new Uri(imageUrl);
  1115. var fullUri = new Uri(baseUri, pic.pictureFileName);
  1116. RegisterCheckPircture registercheckpircture = new RegisterCheckPircture()
  1117. {
  1118. asbitemNames = asbitem.asbitemNames,
  1119. pictureFileName = fullUri.AbsoluteUri,
  1120. pictureBase64 = pic.pictureBase64,
  1121. displayOrder = pic.displayOrder,
  1122. };
  1123. pPirctureList.Add(registercheckpircture);
  1124. }
  1125. orderNo = 0;
  1126. text = "";
  1127. var summarysSortList = asbitem.summarys.OrderBy(o => o.displayOrder).ToList();
  1128. foreach (var sum in summarysSortList)
  1129. {
  1130. RegisterCheckSummary registerchecksummary = new RegisterCheckSummary()
  1131. {
  1132. asbitemNames = asbitem.asbitemNames,
  1133. summary = sum.summary,
  1134. displayOrder = sum.displayOrder,
  1135. };
  1136. orderNo++;
  1137. if (summarysSortList.Count > 1)
  1138. text += string.Format("{0}:{1}", orderNo, sum.summary);
  1139. else
  1140. {
  1141. text = string.Format("{0}", sum.summary);
  1142. }
  1143. pSummaryList.Add(registerchecksummary);
  1144. }
  1145. if (summarysSortList.Count > 0) registercheckasbitem.summarysText = text;
  1146. pAsbitemList.Add(registercheckasbitem);
  1147. }
  1148. if (dExamItemTypeList.Count == 0)
  1149. {
  1150. DictExamItemType dictexamitemtype = new DictExamItemType() { displayOrder = EMPTY_VALUE }; ;
  1151. dExamItemTypeList.Add(dictexamitemtype);
  1152. }
  1153. if (dNotExamItemTypeList.Count == 0)
  1154. {
  1155. DictNotExamItemType dictnotexamitemtype = new DictNotExamItemType() { displayOrder = EMPTY_VALUE }; ;
  1156. dNotExamItemTypeList.Add(dictnotexamitemtype);
  1157. }
  1158. if (pItemTypeList.Count == 0)
  1159. {
  1160. RegisterCheckItemType registercheckitemtype = new RegisterCheckItemType() { displayOrder = EMPTY_VALUE }; ;
  1161. pItemTypeList.Add(registercheckitemtype);
  1162. }
  1163. if (pAsbitemList.Count == 0)
  1164. {
  1165. RegisterCheckAsbitem registercheckasbitem = new RegisterCheckAsbitem() { absOrderNo = EMPTY_VALUE, displayOrder = EMPTY_VALUE };
  1166. pAsbitemList.Add(registercheckasbitem);
  1167. }
  1168. if (pCheckItemList.Count == 0)
  1169. {
  1170. RegisterCheckItem registercheckitem = new RegisterCheckItem() { reportFontColor = EMPTY_VALUE, reportBackgroundColor = EMPTY_VALUE, displayOrder = EMPTY_VALUE };
  1171. pCheckItemList.Add(registercheckitem);
  1172. }
  1173. if (pPirctureList.Count == 0)
  1174. {
  1175. RegisterCheckPircture registercheckpircture = new RegisterCheckPircture() { displayOrder = EMPTY_VALUE };
  1176. pPirctureList.Add(registercheckpircture);
  1177. }
  1178. if (pSummaryList.Count == 0)
  1179. {
  1180. RegisterCheckSummary registerchecksummary = new RegisterCheckSummary() { displayOrder = EMPTY_VALUE };
  1181. pSummaryList.Add(registerchecksummary);
  1182. }
  1183. Rpt0006 hrpersonhealth = new Rpt0006()
  1184. {
  1185. dictMedType = dictMedicalTypeList,
  1186. dictExamItemType = dExamItemTypeList,
  1187. dictNotExamItemType = dNotExamItemTypeList,
  1188. pinfo = pHealthList,
  1189. resItemType = pItemTypeList,
  1190. resAsbitem = pAsbitemList,
  1191. res = pCheckItemList,
  1192. resPic = pPirctureList,
  1193. resSum = pSummaryList,
  1194. sug = pSugList,
  1195. sugReason = pReasonList,
  1196. sugGuide = pGuideList,
  1197. sugMeical = pMedList,
  1198. summ = pSumList,
  1199. summContent = pContentList,
  1200. odPat=pOccDisList,
  1201. odCheckType = pOcCheckList,
  1202. odHistory = pPatOccHisList,
  1203. odMedicHistory = pPatOccMedHisList,
  1204. odPastMedicHistory = pPatPastMedHisList,
  1205. odPoison = pPatPoiList,
  1206. odSymptom = pPatSymList,
  1207. pic = ToPicTable(dict, websiteUrl),
  1208. };
  1209. string dataSetJson = ClientConfig.SerializeObject(hrpersonhealth);
  1210. if (isSaveJson)
  1211. FileHelper.WriteAllText(filePath, dataSetJson);
  1212. DataSet ds = ClientConfig.DeserializeObject<DataSet>(dataSetJson);
  1213. return ds;
  1214. });
  1215. DataSet dSet = await task;
  1216. RemoveEmptyRows(dSet);
  1217. return dSet;
  1218. }
  1219. public static async Task<DataSet> PatientGuideToDataSetAsync(string filePath, Dictionary<string, string> dict, string websiteUrl, string apiUrl, bool isSaveJson = false)
  1220. {
  1221. Task<DataSet> task = Task.Factory.StartNew<DataSet>(() =>
  1222. {
  1223. string json = FileHelper.ReadAllText(filePath);
  1224. Dto0001 pg = ClientConfig.DeserializeObject<Dto0001>(json);
  1225. List<PatientInfo> pList = new List<PatientInfo>();
  1226. PatientInfo patientinfo = new PatientInfo()
  1227. {
  1228. patientRegisterId = pg.patientRegisterId,
  1229. patientRegisterNo = pg.patientRegisterNo,
  1230. patientName = pg.patientName,
  1231. photo = pg.photo,
  1232. barcodeImg = BarCodeHelper.BuildBarCode(pg.patientRegisterNo),
  1233. sexName = pg.sexName,
  1234. age = pg.age == null ? "" : Convert.ToString(pg.age),
  1235. hisPatientId=pg.hisPatientId,
  1236. medicalStartDate = pg.medicalStartDate,
  1237. idNo = pg.idNo,
  1238. mobileTelephone = pg.mobileTelephone,
  1239. patientNo = pg.patientNo,
  1240. medicalTimes = pg.medicalTimes,
  1241. jobCardNo = pg.jobCardNo,
  1242. medicalCardNo = pg.medicalCardNo,
  1243. customerOrgName = pg.customerOrgName,
  1244. customerOrgShortName = pg.customerOrgShortName,
  1245. departmentName = pg.departmentName,
  1246. customerOrgGroupName = pg.customerOrgGroupName,
  1247. medicalPackageName = pg.medicalPackageName,
  1248. personnelTypeName = pg.personnelTypeName,
  1249. organizationUnitId = pg.organizationUnitId,
  1250. organizationUnitName = pg.organizationUnitName,
  1251. medicalCenterAddress = pg.medicalCenterAddress,
  1252. medicalCenterTelphone = pg.medicalCenterTelphone,
  1253. medicalCenterFax = pg.medicalCenterFax,
  1254. medicalTypeName=pg.medicalTypeName,
  1255. };
  1256. pList.Add(patientinfo);
  1257. var guideSortList = pg.detail.OrderBy(o => o.displayOrder).ToList();
  1258. List<GuideInfo> guideList = new List<GuideInfo>();
  1259. List<AsbitemInfo> asbitemList = new List<AsbitemInfo>();
  1260. foreach (var item in guideSortList)
  1261. {
  1262. GuideInfo guideinfo = new GuideInfo()
  1263. {
  1264. patientRegisterId = pg.patientRegisterId,
  1265. guideName = item.guideName,
  1266. asbitemCount = item.asbitemCount,
  1267. displayOrder = item.displayOrder,
  1268. };
  1269. foreach (var asbitem in item.detail_Name)
  1270. {
  1271. AsbitemInfo asbiteminfo = new AsbitemInfo()
  1272. {
  1273. guideName = item.guideName,
  1274. asbitemName = asbitem.asbitemName,
  1275. checkRequestNo=asbitem.checkRequestNo,
  1276. asbitemGuide = asbitem.asbitemGuide,
  1277. displayOrder = asbitem.displayOrder,
  1278. };
  1279. asbitemList.Add(asbiteminfo);
  1280. }
  1281. guideList.Add(guideinfo);
  1282. }
  1283. if (guideList.Count == 0)
  1284. {
  1285. GuideInfo guideinfo = new GuideInfo() { asbitemCount = EMPTY_VALUE, displayOrder = EMPTY_VALUE };
  1286. guideList.Add(guideinfo);
  1287. }
  1288. if (asbitemList.Count == 0)
  1289. {
  1290. AsbitemInfo asbiteminfo = new AsbitemInfo() { displayOrder = EMPTY_VALUE };
  1291. asbitemList.Add(asbiteminfo);
  1292. }
  1293. Rpt0001 guidees = new Rpt0001()
  1294. {
  1295. pinfo = pList,
  1296. guide = guideList,
  1297. asbitem = asbitemList,
  1298. pic = ToPicTable(dict, websiteUrl),
  1299. };
  1300. string dataSetJson = ClientConfig.SerializeObject(guidees);
  1301. if (isSaveJson)
  1302. FileHelper.WriteAllText(filePath, dataSetJson);
  1303. DataSet ds = ClientConfig.DeserializeObject<DataSet>(dataSetJson);
  1304. return ds;
  1305. });
  1306. DataSet dSet = await task;
  1307. RemoveEmptyRows(dSet);
  1308. return dSet;
  1309. }
  1310. public static async Task<DataSet> TestRequestToDataSetAsync(string filePath, Dictionary<string, string> dict, string websiteUrl, string apiUrl, bool isSaveJson = false)
  1311. {
  1312. Task<DataSet> task = Task.Factory.StartNew<DataSet>(() =>
  1313. {
  1314. string dataSetJson = string.Empty;
  1315. string json = FileHelper.ReadAllText(filePath);
  1316. var bill = ClientConfig.DeserializeObject<Dto0002>(json);
  1317. var objStr = bill.lisRequest.ToString();
  1318. if (objStr.Contains("["))
  1319. {
  1320. var array = ClientConfig.DeserializeObject<TestRequest[]>(objStr);
  1321. List<TestRequest> testList = new List<TestRequest>();
  1322. foreach (var item in array)
  1323. {
  1324. item.barcodeImg = BarCodeHelper.BuildBarCode(item.lisRequestNo);
  1325. }
  1326. List<TestRequest> tqList=new List<TestRequest>();
  1327. tqList= array.ToList<TestRequest>();
  1328. var printArray = tqList.Where(p => p.samplePrintCount != "1").ToList();
  1329. int index=0;
  1330. foreach (var item in printArray)
  1331. {
  1332. index=0;
  1333. for (int i = 0; i < Convert.ToInt32(item.samplePrintCount)-1; i++)
  1334. {
  1335. TestRequest req = new TestRequest()
  1336. {
  1337. patientName = item.patientName,
  1338. sexName = item.sexName,
  1339. age = item.age,
  1340. sampleTypeName = item.sampleTypeName,
  1341. sampleContainerName = item.sampleContainerName,
  1342. containerColor = item.containerColor,
  1343. sampleContainerRemark = item.sampleContainerRemark,
  1344. lisRequestNo = item.lisRequestNo,
  1345. barcodeImg = new byte[] { 1 },
  1346. patientRegisterNo = item.patientRegisterNo,
  1347. asbitemNames = item.asbitemNames,
  1348. customerOrgName = item.customerOrgName,
  1349. departmentName = item.departmentName,
  1350. sampleGroupName = item.sampleGroupName,
  1351. mobileTelephone = item.mobileTelephone,
  1352. //samplePrintCount = item.samplePrintCount,
  1353. };
  1354. index = tqList.IndexOf(item);
  1355. if (index == 0)
  1356. {
  1357. tqList.Insert(0, req);
  1358. }else
  1359. {
  1360. tqList.Insert(index-1, req);
  1361. }
  1362. }
  1363. }
  1364. Rpt0002 tr = new Rpt0002()
  1365. {
  1366. testRequestes = tqList.OrderBy(p => p.sampleGroupName).ToList(),
  1367. };
  1368. dataSetJson = ClientConfig.SerializeObject(tr);
  1369. }
  1370. else
  1371. {
  1372. var obj = ClientConfig.DeserializeObject<TestRequest>(objStr);
  1373. obj.barcodeImg = BarCodeHelper.BuildBarCode(obj.lisRequestNo);
  1374. List<TestRequest> testList = new List<TestRequest>();
  1375. testList.Add(obj);
  1376. var printArray = testList.Where(p => p.samplePrintCount != "1").ToList();
  1377. int index = 0;
  1378. foreach (var item in printArray)
  1379. {
  1380. index = 0;
  1381. for (int i = 0; i < Convert.ToInt32(item.samplePrintCount) - 1; i++)
  1382. {
  1383. TestRequest req = new TestRequest()
  1384. {
  1385. patientName = item.patientName,
  1386. sexName = item.sexName,
  1387. age = item.age,
  1388. sampleTypeName = item.sampleTypeName,
  1389. sampleContainerName = item.sampleContainerName,
  1390. containerColor = item.containerColor,
  1391. sampleContainerRemark = item.sampleContainerRemark,
  1392. lisRequestNo = item.lisRequestNo,
  1393. barcodeImg = new byte[] { 1 },
  1394. patientRegisterNo = item.patientRegisterNo,
  1395. asbitemNames = item.asbitemNames,
  1396. customerOrgName = item.customerOrgName,
  1397. departmentName = item.departmentName,
  1398. sampleGroupName = item.sampleGroupName,
  1399. mobileTelephone = item.mobileTelephone,
  1400. //samplePrintCount = item.samplePrintCount,
  1401. };
  1402. index = testList.IndexOf(item);
  1403. if (index == 0)
  1404. {
  1405. testList.Insert(0, req);
  1406. }
  1407. else
  1408. {
  1409. testList.Insert(index - 1, req);
  1410. }
  1411. }
  1412. }
  1413. Rpt0002 tr = new Rpt0002()
  1414. {
  1415. testRequestes = testList,
  1416. };
  1417. dataSetJson = ClientConfig.SerializeObject(tr);
  1418. }
  1419. if (isSaveJson)
  1420. FileHelper.WriteAllText(filePath, dataSetJson);
  1421. DataSet ds = ClientConfig.DeserializeObject<DataSet>(dataSetJson);
  1422. return ds;
  1423. });
  1424. DataSet dSet = await task;
  1425. return dSet;
  1426. }
  1427. public static async Task<DataSet> ExamRequestToDataSetAsync(string filePath, Dictionary<string, string> dict, string websiteUrl, string apiUrl, bool isSaveJson = false)
  1428. {
  1429. Task<DataSet> task = Task.Factory.StartNew<DataSet>(() =>
  1430. {
  1431. string dataSetJson = string.Empty;
  1432. string json = FileHelper.ReadAllText(filePath);
  1433. var bill = ClientConfig.DeserializeObject<Dto0004>(json);
  1434. var objStr = bill.lisRequest.ToString();
  1435. if (objStr.Contains("["))
  1436. {
  1437. var array = ClientConfig.DeserializeObject<ExamRequest[]>(objStr);
  1438. List<ExamRequest> testList = new List<ExamRequest>();
  1439. foreach (var item in array)
  1440. {
  1441. item.barcodeImg = BarCodeHelper.BuildBarCode(item.checkRequestNo);
  1442. }
  1443. Rpt0004 tr = new Rpt0004()
  1444. {
  1445. exam = array.ToList<ExamRequest>(),
  1446. };
  1447. dataSetJson = ClientConfig.SerializeObject(tr);
  1448. }
  1449. else
  1450. {
  1451. var obj = ClientConfig.DeserializeObject<ExamRequest>(objStr);
  1452. obj.barcodeImg = BarCodeHelper.BuildBarCode(obj.checkRequestNo);
  1453. List<ExamRequest> testList = new List<ExamRequest>();
  1454. testList.Add(obj);
  1455. Rpt0004 tr = new Rpt0004()
  1456. {
  1457. exam = testList,
  1458. };
  1459. dataSetJson = ClientConfig.SerializeObject(tr);
  1460. }
  1461. if (isSaveJson)
  1462. FileHelper.WriteAllText(filePath, dataSetJson);
  1463. DataSet ds = ClientConfig.DeserializeObject<DataSet>(dataSetJson);
  1464. return ds;
  1465. });
  1466. DataSet dSet = await task;
  1467. return dSet;
  1468. }
  1469. public static async Task<DataSet> PayBillToDataSetAsync(string filePath, Dictionary<string, string> dict, string websiteUrl, string apiUrl, bool isSaveJson = false)
  1470. {
  1471. Task<DataSet> task = Task.Factory.StartNew<DataSet>(() =>
  1472. {
  1473. string json = FileHelper.ReadAllText(filePath);
  1474. Dto0007 bill = ClientConfig.DeserializeObject<Dto0007>(json);
  1475. List<Dto0007> pList = new List<Dto0007>();
  1476. pList.Add(bill);
  1477. Rpt0007Charge p = new Rpt0007Charge()
  1478. {
  1479. payinfo = pList,
  1480. pic = ToPicTable(dict, websiteUrl),
  1481. };
  1482. string dataSetJson = ClientConfig.SerializeObject(p);
  1483. if (isSaveJson)
  1484. FileHelper.WriteAllText(filePath, dataSetJson);
  1485. DataSet ds = ClientConfig.DeserializeObject<DataSet>(dataSetJson);
  1486. return ds;
  1487. });
  1488. DataSet dSet = await task;
  1489. return dSet;
  1490. }
  1491. public static async Task<DataSet> OccuptionDiseaseFinalToDataSetAsync(string filePath, Dictionary<string, string> dict, string websiteUrl, string apiUrl, bool isSaveJson = false)
  1492. {
  1493. Task<DataSet> task = Task.Factory.StartNew<DataSet>(() =>
  1494. {
  1495. string dataSetJson = string.Empty;
  1496. string json = FileHelper.ReadAllText(filePath);
  1497. Dto0009 odf = ClientConfig.DeserializeObject<Dto0009>(json);
  1498. List<ODFSummary> odfList = new List<ODFSummary>();
  1499. ODFSummary odfsummary = new ODFSummary()
  1500. {
  1501. customerOrgName = odf.customerOrgName,
  1502. certificateNo = odf.certificateNo,
  1503. medicalTypeName = odf.medicalTypeName,
  1504. medicalStartDate = odf.medicalStartDate,
  1505. recordNumber = odf.recordNumber,
  1506. medicalCenterName = odf.medicalCenterName,
  1507. medicalCenterAddress = odf.medicalCenterAddress,
  1508. reportDate = odf.reportDate,
  1509. medicalSumCount = odf.medicalSumCount,
  1510. whenLeavingWorkCount = odf.whenLeavingWorkCount,
  1511. onDutyCount = odf.onDutyCount,
  1512. poisonNames = odf.poisonNames,
  1513. conclusions = odf.conclusions,
  1514. jobTypes = odf.jobTypes,
  1515. };
  1516. odfList.Add(odfsummary);
  1517. List<ConclusionDetails> cdList = new List<ConclusionDetails>();
  1518. foreach (var item in odf.conclusionDetails)
  1519. {
  1520. ConclusionDetails conclusiondetails = new ConclusionDetails()
  1521. {
  1522. conclusionName = item.conclusionName,
  1523. conclusionCount = item.conclusionCount,
  1524. conclusionRatio = item.conclusionRatio,
  1525. };
  1526. cdList.Add(conclusiondetails);
  1527. }
  1528. List<AsbitemAbnormal> aaList = new List<AsbitemAbnormal>();
  1529. foreach (var item in odf.asbitemAbnormals)
  1530. {
  1531. AsbitemAbnormal asbitemabnormal = new AsbitemAbnormal()
  1532. {
  1533. abnormalAsbitemName = item.abnormalAsbitemName,
  1534. abnormalCount = item.abnormalCount,
  1535. abnormalRatio = item.abnormalRatio,
  1536. };
  1537. aaList.Add(asbitemabnormal);
  1538. }
  1539. if (cdList.Count == 0)
  1540. {
  1541. ConclusionDetails cd = new ConclusionDetails() { conclusionCount = EMPTY_VALUE };
  1542. cdList.Add(cd);
  1543. }
  1544. if (aaList.Count == 0)
  1545. {
  1546. AsbitemAbnormal aa = new AsbitemAbnormal() { abnormalCount = EMPTY_VALUE };
  1547. aaList.Add(aa);
  1548. }
  1549. Rpt0009 tr = new Rpt0009()
  1550. {
  1551. summary = odfList,
  1552. cdetail=cdList,
  1553. asbitem=aaList
  1554. };
  1555. dataSetJson = ClientConfig.SerializeObject(tr);
  1556. if (isSaveJson)
  1557. FileHelper.WriteAllText(filePath, dataSetJson);
  1558. DataSet ds = ClientConfig.DeserializeObject<DataSet>(dataSetJson);
  1559. return ds;
  1560. });
  1561. DataSet dSet = await task;
  1562. RemoveEmptyRows(dSet);
  1563. return dSet;
  1564. }
  1565. public static async Task<DataSet> OccuptionDiseaseDetailToDataSetAsync(string filePath, Dictionary<string, string> dict, string websiteUrl, string apiUrl, bool isSaveJson = false)
  1566. {
  1567. Task<DataSet> task = Task.Factory.StartNew<DataSet>(() =>
  1568. {
  1569. string dataSetJson = string.Empty;
  1570. string json = FileHelper.ReadAllText(filePath);
  1571. Dto0010 odf = ClientConfig.DeserializeObject<Dto0010>(json);
  1572. List<Rpt0010_BaseInfo> baseInfos = new List<Rpt0010_BaseInfo>();
  1573. Rpt0010_BaseInfo rpt0010_baseinfo = new Rpt0010_BaseInfo()
  1574. {
  1575. customerOrgName = odf.customerOrgName,
  1576. certificateNo = odf.certificateNo,
  1577. recordNumber = odf.recordNumber,
  1578. medicalCenterName = odf.medicalCenterName,
  1579. medicalStartDate = odf.medicalStartDate,
  1580. reportDate = odf.reportDate,
  1581. medicalResultDesc = odf.medicalResultDesc,
  1582. };
  1583. baseInfos.Add(rpt0010_baseinfo);
  1584. List<Rpt0010_OcCheckTypeName> checkTypeNames = new List<Rpt0010_OcCheckTypeName>();
  1585. if (odf.ocCheckTypeNames != null)
  1586. {
  1587. foreach (var item in odf.ocCheckTypeNames)
  1588. {
  1589. Rpt0010_OcCheckTypeName ocCheckTypeName = new Rpt0010_OcCheckTypeName()
  1590. {
  1591. typeName = item.ocCheckTypeName,
  1592. isSelected = item.isSelected,
  1593. };
  1594. checkTypeNames.Add(ocCheckTypeName);
  1595. }
  1596. }
  1597. List<Rpt0010_OtherDiseasesOrAbnormalIndividualsDetails> odoaiDetails = new List<Rpt0010_OtherDiseasesOrAbnormalIndividualsDetails>();
  1598. foreach (var item in odf.otherDiseasesOrAbnormalIndividualsDetails)
  1599. {
  1600. Rpt0010_OtherDiseasesOrAbnormalIndividualsDetails rpt0010_odoaiDetail = new Rpt0010_OtherDiseasesOrAbnormalIndividualsDetails()
  1601. {
  1602. patientRegisterNo = item.patientRegisterNo,
  1603. patientName = item.patientName,
  1604. idNo = item.idNo,
  1605. sexName = item.sexName,
  1606. age = item.age,
  1607. jobType = item.jobType,
  1608. poisonWorkTime = item.poisonWorkTime,
  1609. poisonNames = item.poisonNames,
  1610. anomalyIndex = item.anomalyIndex,
  1611. handlingSuggestions = item.handlingSuggestions,
  1612. medicalConclusion = item.medicalConclusion,
  1613. ocCheckTypeName = item.ocCheckTypeName,
  1614. medicalStartDate = item.medicalStartDate,
  1615. summaryDoctorName = item.summaryDoctorName,
  1616. displayOrder = item.displayOrder,
  1617. };
  1618. odoaiDetails.Add(rpt0010_odoaiDetail);
  1619. };
  1620. List<Rpt0010_NoAbnormalConditionsDetails> nacdmedicalResults = new List<Rpt0010_NoAbnormalConditionsDetails>();
  1621. foreach (var item in odf.noAbnormalConditionsDetails)
  1622. {
  1623. Rpt0010_NoAbnormalConditionsDetails rpt0010_nacdmedicalResult = new Rpt0010_NoAbnormalConditionsDetails()
  1624. {
  1625. patientRegisterNo = item.patientRegisterNo,
  1626. patientName = item.patientName,
  1627. idNo=item.idNo,
  1628. sexName= item.sexName,
  1629. age= item.age,
  1630. jobType = item.jobType,
  1631. poisonWorkTime = item.poisonWorkTime,
  1632. poisonNames = item.poisonNames,
  1633. anomalyIndex = item.anomalyIndex,
  1634. handlingSuggestions = item.handlingSuggestions,
  1635. medicalConclusion=item.medicalConclusion,
  1636. ocCheckTypeName=item.ocCheckTypeName,
  1637. medicalStartDate=item.medicalStartDate,
  1638. summaryDoctorName=item.summaryDoctorName,
  1639. displayOrder = item.displayOrder,
  1640. };
  1641. nacdmedicalResults.Add(rpt0010_nacdmedicalResult);
  1642. };
  1643. List<Rpt0010_MedicalResultAbnormalRate> medicalResultAbnormalRates = new List<Rpt0010_MedicalResultAbnormalRate>();
  1644. foreach (var item in odf.medicalResultAbnormalRateDetails)
  1645. {
  1646. Rpt0010_MedicalResultAbnormalRate rpt0010_medicalresultabnormalrate = new Rpt0010_MedicalResultAbnormalRate()
  1647. {
  1648. asbitemName = item.asbitemName,
  1649. abnormalRate = item.abnormalRate.ToString(),
  1650. abnormalPatientNames = item.abnormalPatientNames,
  1651. displayOrder = item.displayOrder,
  1652. };
  1653. medicalResultAbnormalRates.Add(rpt0010_medicalresultabnormalrate);
  1654. };
  1655. List<Rpt0010_MissingItems> missingItems = new List<Rpt0010_MissingItems>();
  1656. foreach (var item in odf.listOfMissingItemsDetails)
  1657. {
  1658. Rpt0010_MissingItems rpt0010_missingitems = new Rpt0010_MissingItems()
  1659. {
  1660. patientRegisterNo = item.patientRegisterNo,
  1661. patientName = item.patientName,
  1662. idNo = item.idNo,
  1663. jobType = item.jobType,
  1664. poisonWorkTime = item.poisonWorkTime,
  1665. poisonNames = item.poisonNames,
  1666. ocCheckTypeName = item.ocCheckTypeName,
  1667. sexName = item.sexName,
  1668. age = item.age,
  1669. medicalStartDate = item.medicalStartDate,
  1670. summaryDoctorName = item.summaryDoctorName,
  1671. unCheckAsbitemName = item.unCheckAsbitemName,
  1672. displayOrder = item.displayOrder,
  1673. };
  1674. missingItems.Add(rpt0010_missingitems);
  1675. };
  1676. List<Rpt0010_UninspectedPerson> uninspectedPersones = new List<Rpt0010_UninspectedPerson>();
  1677. foreach (var item in odf.uninspectedPersonnelDetails)
  1678. {
  1679. Rpt0010_UninspectedPerson rpt0010_missingitems = new Rpt0010_UninspectedPerson()
  1680. {
  1681. patientRegisterNo = item.patientRegisterNo,
  1682. patientName = item.patientName,
  1683. idNo = item.idNo,
  1684. jobType = item.jobType,
  1685. poisonWorkTime = item.poisonWorkTime,
  1686. poisonNames = item.poisonNames,
  1687. ocCheckTypeName = item.ocCheckTypeName,
  1688. sexName = item.sexName,
  1689. age = item.age,
  1690. medicalStartDate = item.medicalStartDate,
  1691. summaryDoctorName = item.summaryDoctorName,
  1692. unCheckAsbitemName = item.unCheckAsbitemName,
  1693. displayOrder = item.displayOrder,
  1694. };
  1695. uninspectedPersones.Add(rpt0010_missingitems);
  1696. };
  1697. List<Rpt0010_OcAbnormal> ocAbnormals = new List<Rpt0010_OcAbnormal>();
  1698. foreach (var item in odf.occupationalAbnormalDetails)
  1699. {
  1700. Rpt0010_OcAbnormal rpt0010_ocabnormal = new Rpt0010_OcAbnormal()
  1701. {
  1702. occupationalAbnormalName = item.occupationalAbnormalName,
  1703. occupationalAbnormalCount = item.occupationalAbnormalCount.ToString(),
  1704. occupationalAbnormalRatio = item.occupationalAbnormalRatio.ToString(),
  1705. displayOrder = item.displayOrder,
  1706. };
  1707. ocAbnormals.Add(rpt0010_ocabnormal);
  1708. };
  1709. List<Rpt0010_OcCheckType> ocCheckTypes = new List<Rpt0010_OcCheckType>();
  1710. foreach (var item in odf.ocCheckTypeDetails)
  1711. {
  1712. Rpt0010_OcCheckType rpt0010_occhecktype = new Rpt0010_OcCheckType()
  1713. {
  1714. poisonNames = item.poisonNames,
  1715. ocCheckTypeName = item.ocCheckTypeName,
  1716. checkCount = item.checkCount,
  1717. displayOrder = item.displayOrder,
  1718. };
  1719. ocCheckTypes.Add(rpt0010_occhecktype);
  1720. };
  1721. List<Rpt0010_OcContraindication> ocContraindications = new List<Rpt0010_OcContraindication>();
  1722. foreach (var item in odf.occupationalContraindicationDetails)
  1723. {
  1724. Rpt0010_OcContraindication rpt0010_occontraindication = new Rpt0010_OcContraindication()
  1725. {
  1726. patientRegisterNo = item.patientRegisterNo,
  1727. patientName = item.patientName,
  1728. idNo = item.idNo,
  1729. sexName = item.sexName,
  1730. age = item.age,
  1731. jobType = item.jobType,
  1732. poisonWorkTime = item.poisonWorkTime,
  1733. poisonNames = item.poisonNames,
  1734. anomalyIndex = item.anomalyIndex,
  1735. handlingSuggestions = item.handlingSuggestions,
  1736. medicalConclusion = item.medicalConclusion,
  1737. ocCheckTypeName = item.ocCheckTypeName,
  1738. medicalStartDate = item.medicalStartDate,
  1739. summaryDoctorName = item.summaryDoctorName,
  1740. displayOrder = item.displayOrder,
  1741. };
  1742. ocContraindications.Add(rpt0010_occontraindication);
  1743. };
  1744. List<Rpt0010_ReviewPersonnel> reviewPersonnel = new List<Rpt0010_ReviewPersonnel>();
  1745. foreach (var item in odf.reviewPersonnelDetails)
  1746. {
  1747. Rpt0010_ReviewPersonnel rpt0010_reviewpersonnel = new Rpt0010_ReviewPersonnel()
  1748. {
  1749. patientRegisterNo = item.patientRegisterNo,
  1750. patientName = item.patientName,
  1751. idNo = item.idNo,
  1752. sexName = item.sexName,
  1753. age = item.age,
  1754. jobType = item.jobType,
  1755. poisonWorkTime = item.poisonWorkTime,
  1756. poisonNames = item.poisonNames,
  1757. anomalyIndex = item.anomalyIndex,
  1758. handlingSuggestions = item.handlingSuggestions,
  1759. medicalConclusion = item.medicalConclusion,
  1760. ocCheckTypeName = item.ocCheckTypeName,
  1761. medicalStartDate = item.medicalStartDate,
  1762. summaryDoctorName = item.summaryDoctorName,
  1763. displayOrder = item.displayOrder,
  1764. };
  1765. reviewPersonnel.Add(rpt0010_reviewpersonnel);
  1766. };
  1767. List<Rpt0010_SuspectedOcDisease> suspectedOcDiseases = new List<Rpt0010_SuspectedOcDisease>();
  1768. foreach (var item in odf.suspectedOccupationalDiseaseDetails)
  1769. {
  1770. Rpt0010_SuspectedOcDisease rpt0010_suspectedocdisease = new Rpt0010_SuspectedOcDisease()
  1771. {
  1772. patientRegisterNo = item.patientRegisterNo,
  1773. patientName = item.patientName,
  1774. idNo = item.idNo,
  1775. sexName = item.sexName,
  1776. age = item.age,
  1777. jobType = item.jobType,
  1778. poisonWorkTime = item.poisonWorkTime,
  1779. poisonNames = item.poisonNames,
  1780. anomalyIndex = item.anomalyIndex,
  1781. handlingSuggestions = item.handlingSuggestions,
  1782. medicalConclusion = item.medicalConclusion,
  1783. ocCheckTypeName = item.ocCheckTypeName,
  1784. medicalStartDate = item.medicalStartDate,
  1785. summaryDoctorName = item.summaryDoctorName,
  1786. displayOrder = item.displayOrder,
  1787. };
  1788. suspectedOcDiseases.Add(rpt0010_suspectedocdisease);
  1789. };
  1790. if (checkTypeNames.Count == 0)
  1791. {
  1792. Rpt0010_OcCheckTypeName aa = new Rpt0010_OcCheckTypeName() { typeName = EMPTY_VALUE.ToString() };
  1793. checkTypeNames.Add(aa);
  1794. }
  1795. if (odoaiDetails.Count == 0)
  1796. {
  1797. Rpt0010_OtherDiseasesOrAbnormalIndividualsDetails aa = new Rpt0010_OtherDiseasesOrAbnormalIndividualsDetails();
  1798. odoaiDetails.Add(aa);
  1799. }
  1800. if (nacdmedicalResults.Count == 0)
  1801. {
  1802. Rpt0010_NoAbnormalConditionsDetails aa = new Rpt0010_NoAbnormalConditionsDetails();
  1803. nacdmedicalResults.Add(aa);
  1804. }
  1805. if (medicalResultAbnormalRates.Count == 0)
  1806. {
  1807. Rpt0010_MedicalResultAbnormalRate aa = new Rpt0010_MedicalResultAbnormalRate();
  1808. medicalResultAbnormalRates.Add(aa);
  1809. }
  1810. if (missingItems.Count == 0)
  1811. {
  1812. Rpt0010_MissingItems aa = new Rpt0010_MissingItems();
  1813. missingItems.Add(aa);
  1814. }
  1815. if (uninspectedPersones.Count == 0)
  1816. {
  1817. Rpt0010_UninspectedPerson aa = new Rpt0010_UninspectedPerson();
  1818. uninspectedPersones.Add(aa);
  1819. }
  1820. if (ocAbnormals.Count == 0)
  1821. {
  1822. Rpt0010_OcAbnormal aa = new Rpt0010_OcAbnormal();
  1823. ocAbnormals.Add(aa);
  1824. }
  1825. if (ocCheckTypes.Count == 0)
  1826. {
  1827. Rpt0010_OcCheckType aa = new Rpt0010_OcCheckType() { displayOrder = EMPTY_VALUE };
  1828. ocCheckTypes.Add(aa);
  1829. }
  1830. if (ocContraindications.Count == 0)
  1831. {
  1832. Rpt0010_OcContraindication aa = new Rpt0010_OcContraindication();
  1833. ocContraindications.Add(aa);
  1834. }
  1835. if (reviewPersonnel.Count == 0)
  1836. {
  1837. Rpt0010_ReviewPersonnel aa = new Rpt0010_ReviewPersonnel();
  1838. reviewPersonnel.Add(aa);
  1839. }
  1840. if (suspectedOcDiseases.Count == 0)
  1841. {
  1842. Rpt0010_SuspectedOcDisease aa = new Rpt0010_SuspectedOcDisease();
  1843. suspectedOcDiseases.Add(aa);
  1844. }
  1845. Rpt0010 tr = new Rpt0010()
  1846. {
  1847. baseInfo = baseInfos,
  1848. odoaiDetail = odoaiDetails,
  1849. nacdmedicalResult = nacdmedicalResults,
  1850. medicalResultAbnormalRate = medicalResultAbnormalRates,
  1851. missingItems = missingItems,
  1852. uninspectedPerson= uninspectedPersones,
  1853. ocAbnormals = ocAbnormals,
  1854. ocCheckType = ocCheckTypes,
  1855. ocContraindication = ocContraindications,
  1856. reviewPersonnel = reviewPersonnel,
  1857. suspectedOcDiseases = suspectedOcDiseases,
  1858. ocCheckTypeNames = checkTypeNames,
  1859. pic = ToPicTable(dict, websiteUrl),
  1860. };
  1861. dataSetJson = ClientConfig.SerializeObject(tr);
  1862. if (isSaveJson)
  1863. FileHelper.WriteAllText(filePath, dataSetJson);
  1864. DataSet ds = ClientConfig.DeserializeObject<DataSet>(dataSetJson);
  1865. return ds;
  1866. });
  1867. DataSet dSet = await task;
  1868. RemoveEmptyRows(dSet);
  1869. return dSet;
  1870. }
  1871. }
  1872. }