¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.smartor.service.impl; |
| | | |
| | | import com.google.gson.Gson; |
| | | import com.google.gson.reflect.TypeToken; |
| | | import com.ruoyi.common.core.domain.entity.SysUser; |
| | | import com.ruoyi.common.utils.StringUtils; |
| | | import com.ruoyi.common.utils.http.HttpUtils; |
| | | import com.smartor.domain.*; |
| | | import com.smartor.mapper.PatMedOuthospMapper; |
| | | import com.smartor.mapper.SysUser2Mapper; |
| | | import com.smartor.mapper.SysUserImportMapper; |
| | | import com.smartor.service.IPatArchiveService; |
| | | import com.smartor.service.IPatMedInhospService; |
| | | import com.smartor.service.IServiceSLTDHealthcareRecordService; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.apache.commons.collections4.CollectionUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.beans.factory.annotation.Value; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import java.lang.reflect.Array; |
| | | import java.lang.reflect.Type; |
| | | import java.text.ParseException; |
| | | import java.text.SimpleDateFormat; |
| | | import java.util.*; |
| | | |
| | | @Slf4j |
| | | @Service |
| | | public class ServiceSLTDHealthcareRecordServiceImpl implements IServiceSLTDHealthcareRecordService { |
| | | |
| | | private static final String DATE_FORMAT = "yyyy-MM-dd HH:mm:ss"; |
| | | private static final String APP_KEY = "ak-zUMiOWhqXiJQWPB1pCbz0pjr"; |
| | | |
| | | @Autowired |
| | | private IPatArchiveService patArchiveService; |
| | | |
| | | @Autowired |
| | | private IPatMedInhospService patMedInhospService; |
| | | |
| | | @Autowired |
| | | private PatMedOuthospMapper patMedOuthospMapper; |
| | | |
| | | @Autowired |
| | | private SysUser2Mapper sysUser2Mapper; |
| | | |
| | | @Value("${sltd_pub_path}") |
| | | private String sltdPubPath; |
| | | |
| | | @Override |
| | | public List<ServiceSLTDInhospResDTO> queryHealthcareRecordList(ServiceSLTDInhospReqVO reqVO) { |
| | | log.info("ãqueryHealthcareRecordListãå¼å§è°ç¨çç«åå¾·å¥åº·è®°å½æ¥è¯¢æ¥å£ï¼è¯·æ±åæ°ï¼{}", reqVO); |
| | | try { |
| | | Map<String, Object> requestParams = buildRequestParams(reqVO); |
| | | Map<String, String> headers = buildRequestHeaders(); |
| | | String result = HttpUtils.sendPostByHeader(sltdPubPath + "osj/hbos-thirdparty-integration/standard/common/healthcareRecord/dtcQueryHealthcareRecordList", new Gson().toJson(requestParams), headers); |
| | | log.info("ãqueryHealthcareRecordListãæ¥å£ååºç»æï¼{}", result); |
| | | |
| | | String cry = determineCry(reqVO); |
| | | return parseResponseData(result, reqVO.getHealthcareRecordTypeList().get(0), cry); |
| | | } catch (Exception e) { |
| | | log.error("ãqueryHealthcareRecordListãè°ç¨çç«åå¾·å¥åº·è®°å½æ¥è¯¢æ¥å£å¼å¸¸ï¼è¯·æ±åæ°ï¼{}", reqVO, e); |
| | | throw new RuntimeException("è°ç¨çç«åå¾·å¥åº·è®°å½æ¥è¯¢æ¥å£å¤±è´¥", e); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * ééå»é¢ç¨æ·ä¿¡æ¯ |
| | | * |
| | | * @param reqVO |
| | | * @return |
| | | */ |
| | | @Override |
| | | public Boolean queryHospUserInfoList(ServiceSLTDInhospReqVO reqVO) { |
| | | Map<String, Object> requestParams = buildRequestParams(reqVO); |
| | | Map<String, String> headers = buildRequestHeaders(); |
| | | String result = HttpUtils.sendPostByHeader(sltdPubPath + "osj/hbos-thirdparty-integration/standard/common/healthcareRecord/dtcQueryHealthcareRecordList", new Gson().toJson(requestParams), headers); |
| | | log.info("ãqueryHealthcareRecordListãæ¥å£ååºç»æï¼{}", result); |
| | | List<Map<String, Object>> dataList = getDataList(result); |
| | | for (Map<String, Object> dataItem : dataList) { |
| | | SysUser sysUser = new SysUser(); |
| | | sysUser.setUserName(getStringValue(dataItem, "accountNo")); |
| | | sysUser.setNickName(getStringValue(dataItem, "name")); |
| | | List diagnosisObjList = (List<?>) dataItem.get("qualifications"); |
| | | if (CollectionUtils.isNotEmpty(diagnosisObjList)) { |
| | | for (Object diagnosis : diagnosisObjList) { |
| | | if (diagnosis instanceof Map) { |
| | | Map<String, Object> diagnosisMap = (Map<String, Object>) diagnosis; |
| | | String professionalTitleName = getStringValue(diagnosisMap, "professionalTitleName"); |
| | | if (professionalTitleName.contains("å»å¸")) sysUser.setUserType("å»ç"); |
| | | if (professionalTitleName.contains("æ¤")) sysUser.setUserType("æ¤å£«"); |
| | | sysUser.setTitle(getStringValue(diagnosisMap, "professionalTitleName")); |
| | | } |
| | | } |
| | | } |
| | | sysUser.setDeptCode(getStringValue(dataItem, "accountNo")); |
| | | sysUser.setDeptName(getStringValue(dataItem, "personnelDeptName")); |
| | | sysUser.setPhonenumber(getStringValue(dataItem, "telephone")); |
| | | //设置æ§å« |
| | | String genderName = getStringValue(dataItem, "genderName"); |
| | | if ("ç·".equals(genderName)) sysUser.setSex("0"); |
| | | else if ("女".equals(genderName)) sysUser.setSex("1"); |
| | | else sysUser.setSex("2"); |
| | | |
| | | sysUser.setCreateTime(new Date()); |
| | | sysUser.setUpdateTime(new Date()); |
| | | sysUser.setUpdateBy("admin"); |
| | | sysUser.setCreateBy("admin"); |
| | | |
| | | sysUser2Mapper.insertUser(sysUser); |
| | | } |
| | | |
| | | return true; |
| | | } |
| | | |
| | | private String determineCry(ServiceSLTDInhospReqVO reqVO) { |
| | | if (reqVO.getHealthcareRecordTypeList().contains("FH0108.02")) { |
| | | if (reqVO.getStartHeadTime() != null && reqVO.getStartTailTime() != null) { |
| | | return "0"; |
| | | } else if (reqVO.getPreOutHospitalHeadDate() != null && reqVO.getPreOutHospitalTailDate() != null) { |
| | | return "1"; |
| | | } |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | private Map<String, Object> buildRequestParams(ServiceSLTDInhospReqVO reqVO) { |
| | | Map<String, Object> params = new HashMap<>(); |
| | | if (reqVO.getOrgId() != null) { |
| | | params.put("orgId", Long.parseLong(reqVO.getOrgId())); |
| | | } |
| | | if (reqVO.getCampusIds() != null) { |
| | | params.put("campusIds", reqVO.getCampusIds()); |
| | | } |
| | | if (reqVO.getStartHeadTime() != null) { |
| | | params.put("startHeadTime", reqVO.getStartHeadTime()); |
| | | } |
| | | if (reqVO.getStartTailTime() != null) { |
| | | params.put("startTailTime", reqVO.getStartTailTime()); |
| | | } |
| | | if (reqVO.getHealthcareRecordTypeList() != null && !reqVO.getHealthcareRecordTypeList().isEmpty()) { |
| | | params.put("healthcareRecordTypeList", reqVO.getHealthcareRecordTypeList()); |
| | | } |
| | | params.put("subjectCode", reqVO.getPatientName()); |
| | | params.put("healthcareRecordNo", reqVO.getHealthcareRecordNo()); |
| | | params.put("orgSubjectCode", reqVO.getIdCardNo()); |
| | | if (reqVO.getDeptIdList() != null && !reqVO.getDeptIdList().isEmpty()) { |
| | | params.put("deptDimensions", reqVO.getDeptIdList()); |
| | | } |
| | | params.put("serviceScopes", null); |
| | | params.put("inpatientArea", null); |
| | | params.put("status", reqVO.getStatusList() != null && !reqVO.getStatusList().isEmpty() ? reqVO.getStatusList() : null); |
| | | return params; |
| | | } |
| | | |
| | | private Map<String, String> buildRequestHeaders() { |
| | | Map<String, String> headers = new HashMap<>(); |
| | | headers.put("Content-Type", "application/json"); |
| | | headers.put("app-key", APP_KEY); |
| | | return headers; |
| | | } |
| | | |
| | | private List<ServiceSLTDInhospResDTO> parseResponseData(String result, String type, String cry) { |
| | | try { |
| | | |
| | | List<Map<String, Object>> dataList = getDataList(result); |
| | | List<ServiceSLTDInhospResDTO> resultList = new ArrayList<>(); |
| | | for (Map<String, Object> dataItem : dataList) { |
| | | resultList.add(convertToDTO(dataItem)); |
| | | } |
| | | log.info("ãparseResponseDataãæåè§£æ{}æ¡å¥åº·è®°å½æ°æ®", resultList.size()); |
| | | |
| | | processResultList(resultList, type, cry); |
| | | return resultList; |
| | | } catch (Exception e) { |
| | | log.error("ãparseResponseDataãè§£æååºæ°æ®å¼å¸¸ï¼ååºå
容ï¼{}", result, e); |
| | | throw new RuntimeException("è§£æååºæ°æ®å¤±è´¥", e); |
| | | } |
| | | } |
| | | |
| | | public List<Map<String, Object>> getDataList(String result) { |
| | | Gson gson = new Gson(); |
| | | Type mapType = new TypeToken<Map<String, Object>>() { |
| | | }.getType(); |
| | | Map<String, Object> responseMap = gson.fromJson(result, mapType); |
| | | |
| | | Number codeObj = (Number) responseMap.get("code"); |
| | | if (codeObj == null || codeObj.intValue() != 200) { |
| | | log.error("ãparseResponseDataãæ¥å£è¿å失败ï¼ååºç ï¼{}ï¼ååºå
容ï¼{}", codeObj, result); |
| | | throw new RuntimeException("æ¥å£è°ç¨å¤±è´¥ï¼ååºç ï¼" + codeObj); |
| | | } |
| | | |
| | | Object dataObj = responseMap.get("data"); |
| | | if (dataObj == null) { |
| | | log.warn("ãparseResponseDataãæ¥å£è¿åæ°æ®ä¸ºç©º"); |
| | | return new ArrayList<>(); |
| | | } |
| | | |
| | | String dataJson = gson.toJson(dataObj); |
| | | Type listType = new TypeToken<List<Map<String, Object>>>() { |
| | | }.getType(); |
| | | List<Map<String, Object>> dataList = gson.fromJson(dataJson, listType); |
| | | return dataList; |
| | | } |
| | | |
| | | private void processResultList(List<ServiceSLTDInhospResDTO> resultList, String type, String cry) { |
| | | switch (type) { |
| | | case "FH0108.01": |
| | | log.info("ãparseResponseDataãè§£æé¨è¯æ°æ®"); |
| | | outHospitalDate(resultList); |
| | | break; |
| | | case "FH0108.02": |
| | | log.info("ãparseResponseDataãè§£æä½é¢æ°æ®"); |
| | | inHospitalDate(resultList, cry); |
| | | break; |
| | | case "FH0108.03": |
| | | log.info("ãparseResponseDataãè§£ææ¥è¯æ°æ®"); |
| | | outHospitalDate(resultList); |
| | | break; |
| | | default: |
| | | log.warn("ãparseResponseDataãæªç¥çæ°æ®ç±»åï¼{}", type); |
| | | break; |
| | | } |
| | | } |
| | | |
| | | private Boolean outHospitalDate(List<ServiceSLTDInhospResDTO> resultList) { |
| | | for (ServiceSLTDInhospResDTO dto : resultList) { |
| | | PatArchive patArchive = processPatientArchive(dto); |
| | | PatMedOuthosp patMedOuthosp = buildPatMedOuthosp(dto, patArchive); |
| | | patMedOuthospMapper.insertPatMedOuthosp(patMedOuthosp); |
| | | } |
| | | return true; |
| | | } |
| | | |
| | | private PatMedOuthosp buildPatMedOuthosp(ServiceSLTDInhospResDTO dto, PatArchive patArchive) { |
| | | PatMedOuthosp patMedOuthosp = new PatMedOuthosp(); |
| | | patMedOuthosp.setOuthospno(dto.getHealthcareRecordNo()); |
| | | patMedOuthosp.setSerialnum(dto.getHealthcareRecordNo()); |
| | | patMedOuthosp.setPatid(patArchive.getId()); |
| | | patMedOuthosp.setPatname(patArchive.getName()); |
| | | patMedOuthosp.setPatno(patArchive.getPatientno()); |
| | | patMedOuthosp.setDeptcode("" + dto.getDeptId()); |
| | | patMedOuthosp.setDeptname(dto.getDeptName()); |
| | | patMedOuthosp.setDiagname(dto.getDiagnosisName()); |
| | | patMedOuthosp.setIcd10code(dto.getDiagnosisCode()); |
| | | patMedOuthosp.setDrcode("" + dto.getDoctorId()); |
| | | patMedOuthosp.setDrname(dto.getDoctorName()); |
| | | patMedOuthosp.setAdmitdate(parseDate(dto.getLastEncounterTime())); |
| | | patMedOuthosp.setSchemestatus(1L); |
| | | patMedOuthosp.setMainsuit(dto.getDiagnosisName()); |
| | | patMedOuthosp.setHpi(null); |
| | | patMedOuthosp.setCreateTime(new Date()); |
| | | return patMedOuthosp; |
| | | } |
| | | |
| | | private Date parseDate(String dateStr) { |
| | | try { |
| | | return new SimpleDateFormat(DATE_FORMAT).parse(dateStr); |
| | | } catch (ParseException e) { |
| | | log.warn("ãparseDateãè§£ææ¥æå¤±è´¥ï¼{}", dateStr, e); |
| | | return null; |
| | | } |
| | | } |
| | | |
| | | private Boolean inHospitalDate(List<ServiceSLTDInhospResDTO> resultList, String cry) { |
| | | for (ServiceSLTDInhospResDTO dto : resultList) { |
| | | PatArchive patArchive = processPatientArchive(dto); |
| | | processPatientInhospInfo(dto, patArchive, cry); |
| | | } |
| | | return true; |
| | | } |
| | | |
| | | private void processPatientInhospInfo(ServiceSLTDInhospResDTO dto, PatArchive patArchive, String cry) { |
| | | PatMedInhosp patMedInhosp = buildPatientInhospInfo(dto, patArchive, cry); |
| | | PatMedInhosp queryInhosp = new PatMedInhosp(); |
| | | queryInhosp.setPatno(patArchive.getPatientno()); |
| | | queryInhosp.setSerialnum(patMedInhosp.getSerialnum()); |
| | | List<PatMedInhosp> existingInhosps = patMedInhospService.selectPatMedInhospList(queryInhosp); |
| | | |
| | | if (CollectionUtils.isNotEmpty(existingInhosps)) { |
| | | patMedInhosp.setInhospid(existingInhosps.get(0).getInhospid()); |
| | | patMedInhospService.updatePatMedInhosp(patMedInhosp); |
| | | log.debug("ãprocessPatientInhospInfoãæ´æ°ä½é¢ä¿¡æ¯ï¼æ£è
ç¼å·ï¼{}ï¼æµæ°´å·ï¼{}", patArchive.getPatientno(), patMedInhosp.getSerialnum()); |
| | | } else { |
| | | patMedInhospService.insertPatMedInhosp(patMedInhosp); |
| | | log.debug("ãprocessPatientInhospInfoãæ°å¢ä½é¢ä¿¡æ¯ï¼æ£è
ç¼å·ï¼{}ï¼æµæ°´å·ï¼{}", patArchive.getPatientno(), patMedInhosp.getSerialnum()); |
| | | } |
| | | } |
| | | |
| | | private PatMedInhosp buildPatientInhospInfo(ServiceSLTDInhospResDTO dto, PatArchive patArchive, String cry) { |
| | | PatMedInhosp patMedInhosp = new PatMedInhosp(); |
| | | patMedInhosp.setPatid(patArchive.getId()); |
| | | patMedInhosp.setPatno(patArchive.getPatientno()); |
| | | patMedInhosp.setPatname(patArchive.getName()); |
| | | patMedInhosp.setNurseId(dto.getChiefNurseId() == null ? "" : dto.getChiefNurseId().toString()); |
| | | patMedInhosp.setNurseName(dto.getChiefNurseName()); |
| | | patMedInhosp.setSerialnum(dto.getHealthcareRecordNo()); |
| | | patMedInhosp.setFuflag("1"); |
| | | patMedInhosp.setInhospstate("0".equals(cry) ? "0" : "1"); |
| | | patMedInhosp.setHospitalcode(dto.getOrgId()); |
| | | patMedInhosp.setBedNo(dto.getBedNumber()); |
| | | patMedInhosp.setStarttime(parseDate(dto.getStartTime())); |
| | | patMedInhosp.setEndtime(parseDate(dto.getPreOutHospitalDate())); |
| | | |
| | | if ("1".equals(cry)) { |
| | | setDischargeInfo(patMedInhosp, dto); |
| | | } else { |
| | | setAdmissionInfo(patMedInhosp, dto); |
| | | } |
| | | |
| | | patMedInhosp.setDrname(dto.getDoctorName()); |
| | | patMedInhosp.setDrcode("" + dto.getDoctorId()); |
| | | patMedInhosp.setSchemestatus("0".equals(cry) ? 1L : 2L); |
| | | patMedInhosp.setDelFlag("0"); |
| | | patMedInhosp.setOrgid("1"); |
| | | return patMedInhosp; |
| | | } |
| | | |
| | | private void setDischargeInfo(PatMedInhosp patMedInhosp, ServiceSLTDInhospResDTO dto) { |
| | | patMedInhosp.setLeaveldeptcode("" + dto.getDeptId()); |
| | | patMedInhosp.setLeaveldeptname(dto.getDeptName()); |
| | | patMedInhosp.setLeavediagname(dto.getMainDischargeDiagnosis() == null ? null : dto.getMainDischargeDiagnosis().getDiagnosisDictName()); |
| | | patMedInhosp.setLeaveicd10code(dto.getMainDischargeDiagnosis() == null ? null : dto.getMainDischargeDiagnosis().getDiagnosisDictCode()); |
| | | patMedInhosp.setOutWayId(null); |
| | | patMedInhosp.setOutWayName(null); |
| | | patMedInhosp.setLeavehospitaldistrictid("" + dto.getAreaId()); |
| | | patMedInhosp.setLeavehospitaldistrictcode("" + dto.getAreaId()); |
| | | patMedInhosp.setLeavehospitaldistrictname(dto.getAreaName()); |
| | | patMedInhosp.setLeaveldeptid("" + dto.getDeptId()); |
| | | } |
| | | |
| | | private void setAdmissionInfo(PatMedInhosp patMedInhosp, ServiceSLTDInhospResDTO dto) { |
| | | patMedInhosp.setDeptcode("" + dto.getDeptId()); |
| | | patMedInhosp.setDeptname(dto.getDeptName()); |
| | | patMedInhosp.setDiagname(dto.getAdmissionDiagnosisName()); |
| | | patMedInhosp.setIcd10code(dto.getAdmissionDiagnosisCode()); |
| | | patMedInhosp.setHospitaldistrictid("" + dto.getAreaId()); |
| | | patMedInhosp.setHospitaldistrictcode("" + dto.getAreaId()); |
| | | patMedInhosp.setHospitaldistrictname(dto.getAreaName()); |
| | | } |
| | | |
| | | private PatArchive processPatientArchive(ServiceSLTDInhospResDTO dto) { |
| | | PatArchive queryArchive = new PatArchive(); |
| | | queryArchive.setIdcardno(dto.getIdCardNo().trim()); |
| | | List<PatArchive> existingArchives = patArchiveService.selectPatArchiveList(queryArchive); |
| | | |
| | | PatArchive patArchive = buildPatientArchive(dto); |
| | | |
| | | if (CollectionUtils.isEmpty(existingArchives)) { |
| | | patArchiveService.insertPatArchive(patArchive); |
| | | log.debug("ãprocessPatientArchiveãæ°å¢æ£è
æ¡£æ¡ï¼æ£è
ç¼å·ï¼{}", patArchive.getPatientno()); |
| | | } else { |
| | | patArchive.setId(existingArchives.get(0).getId()); |
| | | patArchiveService.updateArchive(patArchive); |
| | | log.debug("ãprocessPatientArchiveãæ´æ°æ£è
æ¡£æ¡ï¼æ£è
ç¼å·ï¼{}", patArchive.getPatientno()); |
| | | } |
| | | |
| | | return patArchive; |
| | | } |
| | | |
| | | private PatArchive buildPatientArchive(ServiceSLTDInhospResDTO dto) { |
| | | PatArchive patArchive = new PatArchive(); |
| | | patArchive.setPatientno(dto.getMedicalRecordNo()); |
| | | patArchive.setIdcardno(dto.getIdCardNo().trim()); |
| | | patArchive.setName(dto.getPatientName()); |
| | | patArchive.setSourcefrom(2); |
| | | patArchive.setPattype("2"); |
| | | patArchive.setSex("ç·".equals(dto.getGender()) ? 1L : 2L); |
| | | patArchive.setNation(dto.getNation()); |
| | | patArchive.setNativePlace(dto.getNativePlace()); |
| | | patArchive.setPlaceOfResidence(dto.getAddress()); |
| | | patArchive.setBirthdate(parseDate(dto.getBirthday())); |
| | | patArchive.setTelcode(dto.getPhone()); |
| | | if (CollectionUtils.isNotEmpty(dto.getResidentContactInfos())) { |
| | | patArchive.setRelativetelcode(dto.getResidentContactInfos().get(0).getTelecom()); |
| | | } |
| | | patArchive.setDelFlag("0"); |
| | | patArchive.setCreateTime(new Date()); |
| | | patArchive.setUpdateTime(new Date()); |
| | | return patArchive; |
| | | } |
| | | |
| | | private ServiceSLTDInhospResDTO convertToDTO(Map<String, Object> dataItem) { |
| | | ServiceSLTDInhospResDTO dto = new ServiceSLTDInhospResDTO(); |
| | | dto.setOrgId(getStringValue(dataItem, "orgId")); |
| | | dto.setHealthcareRecordId(getLongValue(dataItem, "healthcareRecordId")); |
| | | dto.setHealthcareRecordNo(getStringValue(dataItem, "healthcareRecordNo")); |
| | | dto.setPatientId(getLongValue(dataItem, "patientId")); |
| | | dto.setPatientName(getStringValue(dataItem, "patientName")); |
| | | dto.setPinyin(getStringValue(dataItem, "pinyin")); |
| | | dto.setNation(getStringValue(dataItem, "nation")); |
| | | dto.setIdCardNo(getStringValue(dataItem, "idCardNo")); |
| | | dto.setHealthcareRecordTimes(getIntegerValue(dataItem, "healthcareRecordTimes")); |
| | | dto.setHospitalizationNumber(getIntegerValue(dataItem, "hospitalizationNumber")); |
| | | dto.setMedicalCardId(getLongValue(dataItem, "medicalCardId")); |
| | | dto.setMedicalCardType(getStringValue(dataItem, "medicalCardType")); |
| | | dto.setMedicalCardTypeName(getStringValue(dataItem, "medicalCardTypeName")); |
| | | dto.setMedicalCardNo(getStringValue(dataItem, "medicalCardNo")); |
| | | dto.setMedicalRecordNo(getStringValue(dataItem, "medicalRecordNo")); |
| | | dto.setGender(getStringValue(dataItem, "gender")); |
| | | dto.setGenderCode(getStringValue(dataItem, "genderCode")); |
| | | dto.setAge(getStringValue(dataItem, "age")); |
| | | dto.setBirthday(getStringValue(dataItem, "birthday")); |
| | | dto.setPhone(getStringValue(dataItem, "phone")); |
| | | dto.setEducation(getStringValue(dataItem, "education")); |
| | | dto.setEducationCode(getStringValue(dataItem, "educationCode")); |
| | | dto.setNeonatal(getBooleanValue(dataItem, "neonatal")); |
| | | dto.setMarriage(getStringValue(dataItem, "marriage")); |
| | | dto.setMarriageCode(getStringValue(dataItem, "marriageCode")); |
| | | dto.setOccupationType(getStringValue(dataItem, "occupationType")); |
| | | dto.setOccupationTypeCode(getStringValue(dataItem, "occupationTypeCode")); |
| | | dto.setNativePlace(getStringValue(dataItem, "nativePlace")); |
| | | dto.setAreaId(getLongValue(dataItem, "areaId")); |
| | | dto.setAreaName(getStringValue(dataItem, "areaName")); |
| | | dto.setRoomId(getLongValue(dataItem, "roomId")); |
| | | dto.setRoomNumber(getStringValue(dataItem, "roomNumber")); |
| | | dto.setBedId(getLongValue(dataItem, "bedId")); |
| | | dto.setBedNumber(getStringValue(dataItem, "bedNumber")); |
| | | dto.setEncounterTime(getStringValue(dataItem, "encounterTime")); |
| | | dto.setStartTime(getStringValue(dataItem, "startTime")); |
| | | dto.setPreOutHospitalDate(getStringValue(dataItem, "preOutHospitalDate")); |
| | | dto.setLastEncounterTime(getStringValue(dataItem, "lastEncounterTime")); |
| | | dto.setDiagnosisCode(getStringValue(dataItem, "diagnosisCode")); |
| | | dto.setDiagnosisName(getStringValue(dataItem, "diagnosisName")); |
| | | dto.setHealthcareRecordStatus(getStringValue(dataItem, "healthcareRecordStatus")); |
| | | dto.setHealthcareType(getStringValue(dataItem, "healthcareType")); |
| | | dto.setDeptId(getLongValue(dataItem, "deptId")); |
| | | dto.setDeptName(getStringValue(dataItem, "deptName")); |
| | | dto.setDoctorId(getLongValue(dataItem, "doctorId")); |
| | | dto.setDoctorName(getStringValue(dataItem, "doctorName")); |
| | | dto.setHealthcarePeriodId(getLongValue(dataItem, "healthcarePeriodId")); |
| | | dto.setChiefNurseId(getLongValue(dataItem, "chiefNurseId")); |
| | | dto.setChiefNurseName(getStringValue(dataItem, "chiefNurseName")); |
| | | dto.setCostCategoryName(getStringValue(dataItem, "costCategoryName")); |
| | | dto.setCostCategoryCode(getStringValue(dataItem, "costCategoryCode")); |
| | | dto.setCostNatureName(getStringValue(dataItem, "costNatureName")); |
| | | dto.setCostNatureCode(getStringValue(dataItem, "costNatureCode")); |
| | | dto.setFurtherConsultationStatus(getIntegerValue(dataItem, "furtherConsultationStatus")); |
| | | |
| | | Object contactsObj = dataItem.get("residentContactInfos"); |
| | | if (contactsObj instanceof List) { |
| | | dto.setResidentContactInfos(parseContacts((List<?>) contactsObj)); |
| | | } |
| | | |
| | | Object diagnosisObj = dataItem.get("diagnosisList"); |
| | | if (diagnosisObj instanceof List) { |
| | | dto.setDiagnosisList(parseDiagnosis((List<?>) diagnosisObj)); |
| | | } |
| | | |
| | | return dto; |
| | | } |
| | | |
| | | private List<ServiceSLTDContactsResDTO> parseContacts(List<?> contactsList) { |
| | | List<ServiceSLTDContactsResDTO> contacts = new ArrayList<>(); |
| | | for (Object contactObj : contactsList) { |
| | | if (contactObj instanceof Map) { |
| | | Map<String, Object> contactMap = (Map<String, Object>) contactObj; |
| | | ServiceSLTDContactsResDTO contact = new ServiceSLTDContactsResDTO(); |
| | | contact.setName(getStringValue(contactMap, "name")); |
| | | contact.setRelationshipCode(getStringValue(contactMap, "relationshipCode")); |
| | | contact.setRelationship(getStringValue(contactMap, "relationship")); |
| | | contact.setTelecom(getStringValue(contactMap, "telecom")); |
| | | contact.setCurrentAddress(getStringValue(contactMap, "currentAddress")); |
| | | contacts.add(contact); |
| | | } |
| | | } |
| | | return contacts; |
| | | } |
| | | |
| | | private List<ServiceSLTDDiagnosisResDTO> parseDiagnosis(List<?> diagnosisList) { |
| | | List<ServiceSLTDDiagnosisResDTO> diagnosis = new ArrayList<>(); |
| | | for (Object diagnosisObj : diagnosisList) { |
| | | if (diagnosisObj instanceof Map) { |
| | | Map<String, Object> diagnosisMap = (Map<String, Object>) diagnosisObj; |
| | | ServiceSLTDDiagnosisResDTO diag = new ServiceSLTDDiagnosisResDTO(); |
| | | diag.setDiagnosisDictCode(getStringValue(diagnosisMap, "diagnosisDictCode")); |
| | | diag.setDiagnosisDictName(getStringValue(diagnosisMap, "diagnosisDictName")); |
| | | diag.setDiagnosisCategory(getStringValue(diagnosisMap, "diagnosisCategory")); |
| | | diag.setRecordType(getIntegerValue(diagnosisMap, "recordType")); |
| | | diag.setIsMainDiagnosis(getIntegerValue(diagnosisMap, "isMainDiagnosis")); |
| | | diagnosis.add(diag); |
| | | } |
| | | } |
| | | return diagnosis; |
| | | } |
| | | |
| | | private String getStringValue(Map<String, Object> map, String key) { |
| | | Object value = map.get(key); |
| | | return value != null ? value.toString() : null; |
| | | } |
| | | |
| | | private Long getLongValue(Map<String, Object> map, String key) { |
| | | Object value = map.get(key); |
| | | if (value == null) return null; |
| | | if (value instanceof Number) { |
| | | return ((Number) value).longValue(); |
| | | } |
| | | try { |
| | | return Long.parseLong(value.toString()); |
| | | } catch (NumberFormatException e) { |
| | | return null; |
| | | } |
| | | } |
| | | |
| | | private Integer getIntegerValue(Map<String, Object> map, String key) { |
| | | Object value = map.get(key); |
| | | if (value == null) return null; |
| | | if (value instanceof Number) { |
| | | return ((Number) value).intValue(); |
| | | } |
| | | try { |
| | | return Integer.parseInt(value.toString()); |
| | | } catch (NumberFormatException e) { |
| | | return null; |
| | | } |
| | | } |
| | | |
| | | private Boolean getBooleanValue(Map<String, Object> map, String key) { |
| | | Object value = map.get(key); |
| | | if (value == null) return null; |
| | | if (value instanceof Boolean) { |
| | | return (Boolean) value; |
| | | } |
| | | return Boolean.parseBoolean(value.toString()); |
| | | } |
| | | } |