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.

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