PatientCDAIndex.java 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. package com.yihu.ehr.service.patient;
  2. import com.yihu.ehr.common.config.SysConfig;
  3. import com.yihu.ehr.model.Patient;
  4. import java.util.UUID;
  5. /**
  6. * 病人文件索引类,用于生成文件路径,不确保文件路径存在
  7. *
  8. * @author Air
  9. * @version 1.0
  10. * @created 2015.07.01 18:06
  11. */
  12. public class PatientCDAIndex {
  13. private Patient patient;
  14. public PatientCDAIndex(Patient patient) {
  15. this.patient = patient;
  16. }
  17. public String getDirectory() {
  18. String dir = SysConfig.getInstance().getTempFile();
  19. return dir + "/" + patient.getOrgCode() + "/" + patient.getOrgCode() + "-" + patient.getPatientId() + "-" + patient.getEventNo();
  20. }
  21. /**
  22. * 生成病人档案目录
  23. * orgCode-pateintId-eventNo/data
  24. *
  25. * @return
  26. */
  27. public String getDataDirectory() {
  28. return getDirectory() + "/" + IndexType.DATA;
  29. }
  30. public String createIndex(String indexType, String fileType) {
  31. UUID uuid = UUID.randomUUID();
  32. String index = uuid.toString();
  33. String dir = getDirectory() + "/" + indexType;
  34. return dir + "/" + index + fileType;
  35. }
  36. public String createDataSetIndex(String indexType, String fileType) {
  37. UUID uuid = UUID.randomUUID();
  38. String index = "dataset_index";
  39. String dir = getDirectory() + "/" + IndexType.DATA + "/" +indexType;
  40. return dir + "/" + index + fileType;
  41. }
  42. /**
  43. * 生成最终病人档案目录
  44. * data/cda
  45. * data/origin
  46. * data/standard
  47. *
  48. * @param indexType
  49. * @param fileType
  50. * @return
  51. */
  52. public String createDataIndex(String indexType, String fileType) {
  53. return createIndex(IndexType.DATA + "/" + indexType, fileType);
  54. }
  55. public class FileType {
  56. public final static String XML = ".xml";
  57. public final static String JSON = ".json";
  58. public final static String ZIP = ".zip";
  59. }
  60. public class IndexType {
  61. public final static String DATA = "data"; //病人档案数据目录
  62. public final static String CDA = "cda"; //病人cda档案目录
  63. public final static String STANDARD = "standard"; //病人标准档案目录
  64. public final static String ORIGIN = "origin"; //病人原始档案目录
  65. public final static String ZIP = "zip"; //病人压缩包目录
  66. public final static String DOCUMENT = "document";
  67. }
  68. }