Commit ebd950d2c1c05d0a889a7e187427788546ae0d5e

Authored by liquanyu
1 parent 231172bf0e

孕妇建档

Showing 1 changed file with 331 additions and 0 deletions

platform-operate-api/src/main/java/com/lyms/platform/operate/web/facade/BookbuildingFacade.java View file @ ebd950d
  1 +package com.lyms.platform.operate.web.facade;
  2 +
  3 +import com.lyms.platform.biz.service.BasicConfigService;
  4 +import com.lyms.platform.common.enums.YnEnums;
  5 +import com.lyms.platform.common.result.BaseListResponse;
  6 +import com.lyms.platform.common.utils.SystemConfig;
  7 +import com.lyms.platform.operate.web.request.BookbuildingQueryRequest;
  8 +import com.lyms.platform.operate.web.result.BasicConfigResult;
  9 +import com.lyms.platform.operate.web.result.BookbuildingRecordResult;
  10 +import com.lyms.platform.operate.web.result.PregnantInfoResult;
  11 +import com.lyms.platform.pojo.BasicConfig;
  12 +import com.lyms.platform.query.BasicConfigQuery;
  13 +import com.lyms.platform.query.PatientsQuery;
  14 +import org.springframework.beans.factory.annotation.Autowired;
  15 +import org.springframework.stereotype.Component;
  16 +
  17 +import com.lyms.platform.biz.service.YunBookbuildingService;
  18 +import com.lyms.platform.common.constants.ErrorCodeConstants;
  19 +import com.lyms.platform.common.result.BaseObjectResponse;
  20 +import com.lyms.platform.common.utils.DateUtil;
  21 +import com.lyms.platform.operate.web.request.YunBookbuildingAddRequest;
  22 +import com.lyms.platform.pojo.Patients;
  23 +
  24 +import java.util.ArrayList;
  25 +import java.util.HashMap;
  26 +import java.util.List;
  27 +import java.util.Map;
  28 +
  29 +/**
  30 + *
  31 + */
  32 +@Component
  33 +public class BookbuildingFacade {
  34 +
  35 + @Autowired
  36 + private YunBookbuildingService yunBookbuildingService;
  37 +
  38 + @Autowired
  39 + private BasicConfigService basicConfigService;
  40 +
  41 +
  42 + /**
  43 + * 添加孕妇建档
  44 + * @param yunRequest
  45 + * @return
  46 + */
  47 + public BaseObjectResponse addPregnantBookbuilding(
  48 + YunBookbuildingAddRequest yunRequest) {
  49 + Patients patient = getPatientsData(yunRequest);
  50 +
  51 + Patients p = yunBookbuildingService.addPregnantBookbuilding(patient);
  52 + BaseObjectResponse br = new BaseObjectResponse();
  53 + if (p == null || p.getId() == null)
  54 + {
  55 + br.setErrorcode(ErrorCodeConstants.SYSTEM_ERROR);
  56 + br.setErrormsg("失败");
  57 +
  58 + }
  59 + br.setErrorcode(ErrorCodeConstants.SUCCESS);
  60 + br.setErrormsg("成功");
  61 + br.setData(p.getId());
  62 + return br;
  63 +
  64 + }
  65 +
  66 + /**
  67 + * 更新孕妇信息
  68 + * @param id
  69 + * @param yunRequest
  70 + */
  71 + public void updatePregnantById(String id, YunBookbuildingAddRequest yunRequest) {
  72 +
  73 + Patients patient = getPatientsData(yunRequest);
  74 + yunBookbuildingService.updatePregnant(patient, id);
  75 + }
  76 +
  77 + /**
  78 + * 查询孕妇建档记录
  79 + * @param bookbuildingQueryRequest
  80 + * @return
  81 + */
  82 + public BaseListResponse queryPregnantBuildRecord(BookbuildingQueryRequest bookbuildingQueryRequest) {
  83 +
  84 + PatientsQuery patientsQuery = new PatientsQuery();
  85 + patientsQuery.setCardNo(bookbuildingQueryRequest.getIdCard());
  86 + patientsQuery.setYn(YnEnums.YES.getId());
  87 + patientsQuery.setVcCardNo(bookbuildingQueryRequest.getVcCardNo());
  88 +
  89 + List<Map<String,List>> list = new ArrayList<>();
  90 +
  91 + List<Patients> patients = yunBookbuildingService.queryPregnantWithQuery(patientsQuery);
  92 +
  93 + List<BookbuildingRecordResult> results = new ArrayList<>();
  94 + for(Patients pat : patients)
  95 + {
  96 + if (pat != null)
  97 + {
  98 + BookbuildingRecordResult result = new BookbuildingRecordResult();
  99 + result.setBookbuildHospital(pat.getHospitalId());
  100 + result.setBookbuildDate(DateUtil.getyyyy_MM_dd(pat.getBookbuildingDate()));
  101 + result.setId(pat.getId());
  102 + results.add(result);
  103 + }
  104 +
  105 + }
  106 +
  107 + Map<String,List> mapProvince = new HashMap<>();
  108 +// //省
  109 +// List<BasicConfigResult> provincesResults = getBaseicConfigByParentId(SystemConfig.CHINA_BASIC_ID);
  110 +// mapProvince.put("provinces",provincesResults);
  111 +
  112 + //证件类型
  113 + List<BasicConfigResult> pcerteTypeResult = getBaseicConfigByParentId(SystemConfig.CERTE_TYPE_ID);
  114 + mapProvince.put("certeType",pcerteTypeResult);
  115 +
  116 + //国籍
  117 + List<BasicConfigResult> countiryResults = getBaseicConfigByParentId(SystemConfig.COUNTRY_TYPE_ID);
  118 + mapProvince.put("country",countiryResults);
  119 +
  120 + // 民族
  121 + List<BasicConfigResult> nationResults = getBaseicConfigByParentId(SystemConfig.NATION_TYPE_ID);
  122 + mapProvince.put("nation",nationResults);
  123 +
  124 + // 职业类别
  125 + List<BasicConfigResult> professionTypeResults = getBaseicConfigByParentId(SystemConfig.PROFESSION_TYPE_ID);
  126 + mapProvince.put("professionType",professionTypeResults);
  127 +
  128 + list.add(mapProvince);
  129 +
  130 +
  131 + Map<String,List> mapData = new HashMap<>();
  132 + mapData.put("data",results);
  133 + list.add(mapData);
  134 +
  135 + BaseListResponse listResponse = new BaseListResponse();
  136 + listResponse.setData(list);
  137 + listResponse.setErrorcode(ErrorCodeConstants.SUCCESS);
  138 + listResponse.setErrormsg("成功");
  139 + return listResponse;
  140 + }
  141 +
  142 + /**
  143 + * 查询基础数据通过parentId
  144 + * @param parentId
  145 + * @return
  146 + */
  147 + private List<BasicConfigResult> getBaseicConfigByParentId(String parentId)
  148 + {
  149 + BasicConfigQuery basicConfigQuery = new BasicConfigQuery();
  150 + basicConfigQuery.setNeed("1");
  151 + basicConfigQuery.setYn(YnEnums.YES.getId());
  152 + basicConfigQuery.setParentId(parentId);
  153 + List<BasicConfig> datas = basicConfigService.queryBasicConfig(basicConfigQuery);
  154 + List<BasicConfigResult> provincesResults = new ArrayList<>();
  155 + if (datas != null)
  156 + {
  157 + for(BasicConfig data : datas)
  158 + {
  159 + BasicConfigResult br = new BasicConfigResult();
  160 + br.setId(data.getId());
  161 + br.setCode(data.getCode());
  162 + br.setEnable(data.getEnable());
  163 + br.setName(data.getName());
  164 + br.setParentId(data.getParentId());
  165 + provincesResults.add(br);
  166 + }
  167 +
  168 + }
  169 + return provincesResults;
  170 + }
  171 +
  172 +
  173 + /**
  174 + * 准备修改和添加的孕妇建档数据
  175 + * @param yunRequest
  176 + * @return
  177 + */
  178 + private Patients getPatientsData(YunBookbuildingAddRequest yunRequest)
  179 + {
  180 + Patients patient = new Patients();
  181 + patient.setUsername(yunRequest.getPregnantName());
  182 +
  183 + patient.setPcerteTypeId(yunRequest.getPregnantCertificateTypeId());
  184 +
  185 + patient.setCardNo(yunRequest.getPregnantCertificateNum());
  186 +
  187 + patient.setPcountryId(yunRequest.getPregnantCountryId());
  188 + patient.setPnationId(yunRequest.getPregnantNationId());
  189 + patient.setBirth(DateUtil.parseYMD(yunRequest.getBirthday()));
  190 +
  191 + patient.setPcensusTypeId(yunRequest.getPregnantCensusTypeId());
  192 +
  193 + patient.setPliveTypeId(yunRequest.getPregnantLiveTypeId());
  194 +
  195 + patient.setPprofessionTypeId(yunRequest.getPregnantProfessionTypeId());
  196 +
  197 + patient.setPhone(yunRequest.getPregnantPhone());
  198 +
  199 + patient.setPworkUnit(yunRequest.getPregnantWorkUnit());
  200 +
  201 + //孕妇户籍地址
  202 + patient.setAddressRegister(yunRequest.getPregnantCensusAddr());
  203 + patient.setProvinceRegisterId(yunRequest.getPregnantCensusProvinceId());
  204 + patient.setCityRegisterId(yunRequest.getPregnantCensusCityId());
  205 + patient.setAreaRegisterId(yunRequest.getPregnantCensusAreaId());
  206 + patient.setStreetRegisterId(yunRequest.getPregnantCensusStreetId());
  207 +
  208 + //孕妇居住地
  209 + patient.setAddress(yunRequest.getPregnantLiveAddr());
  210 + patient.setProvinceId(yunRequest.getPregnantLiveProvinceId());
  211 + patient.setCityId(yunRequest.getPregnantLiveCityId());
  212 + patient.setAreaId(yunRequest.getPregnantLiveAreaId());
  213 + patient.setStreetId(yunRequest.getPregnantLiveStreetId());
  214 +
  215 + //孕妇产后修养地
  216 + patient.setAddressPostRest(yunRequest.getChildbirthAddr());
  217 + patient.setProvincePostRestId(yunRequest.getChildbirthProvinceId());
  218 + patient.setCityPostRestId(yunRequest.getChildbirthCityId());
  219 + patient.setAreaPostRestId(yunRequest.getChildbirthAreaId());
  220 + patient.setStreetPostRestId(yunRequest.getChildbirthStreetId());
  221 +
  222 + //丈夫信息
  223 + patient.setHusbandName(yunRequest.getHusbandName());
  224 + patient.setHcertificateTypeId(yunRequest.getHusbandCertificateTypeId());
  225 + patient.setHcertificateNum(yunRequest.getHusbandCertificateNum());
  226 + patient.setHusbandPhone(yunRequest.getHusbandPhone());
  227 + patient.setHcountryId(yunRequest.getHusbandCountryId());
  228 + patient.setHnationId(yunRequest.getHusbandNationId());
  229 + patient.setHprofessionTypeId(yunRequest.getHusbandProfessionTypeId());
  230 + patient.setHworkUnit(yunRequest.getHusbandWorkUnit());
  231 + patient.setHaddressRegister(yunRequest.getHusbandAddressRegister());
  232 + patient.setHprovinceRegisterId(yunRequest.getHusbandProvinceRegisterId());
  233 + patient.setHcityRegisterId(yunRequest.getHusbandCityRegisterId());
  234 + patient.setHareaRegisterId(yunRequest.getHusbandAreaRegisterId());
  235 + patient.setHstreetRegisterId(yunRequest.getHusbandStreetRegisterId());
  236 +
  237 + patient.setLastMenses(DateUtil.parseYMD(yunRequest.getLastMenstrualPeriod()));
  238 + patient.setDueDate(DateUtil.parseYMD(yunRequest.getDueDate()));
  239 + patient.setFileCode(yunRequest.getFileCode());
  240 + patient.setBookbuildingDoctor(yunRequest.getBookbuildingDoctor());
  241 + patient.setBookbuildingDate(DateUtil.parseYMD(yunRequest.getBookbuildingDate()));
  242 + patient.setServiceType(yunRequest.getServiceType());
  243 + patient.setVcCardNo(yunRequest.getVcCardNo());
  244 + patient.setHospitalId(yunRequest.getHospitalId());
  245 + patient.setYn(YnEnums.YES.getId());
  246 + return patient;
  247 + }
  248 +
  249 + /**
  250 + * 查询孕妇建档详细
  251 + * @param id
  252 + * @return
  253 + */
  254 + public BaseObjectResponse queryPregnantBuildById(String id) {
  255 +
  256 + PatientsQuery patientsQuery = new PatientsQuery();
  257 + patientsQuery.setId(id);
  258 + patientsQuery.setYn(YnEnums.YES.getId());
  259 + PregnantInfoResult result = new PregnantInfoResult();
  260 + List<Patients> patients = yunBookbuildingService.queryPregnantWithQuery(patientsQuery);
  261 + if (patients != null && patients.size() > 0)
  262 + {
  263 + Patients p = patients.get(0);
  264 + result.setId(p.getId());
  265 + /**********孕妇基本信息***************/
  266 + result.setPregnantName(p.getUsername());
  267 + result.setPregnantCertificateTypeId(p.getPcerteTypeId());
  268 + result.setPregnantCertificateNum(p.getCardNo());
  269 + result.setPregnantCountryId(p.getPcountryId());
  270 + result.setPregnantNationId(p.getPnationId());
  271 + result.setBirthday(DateUtil.getyyyy_MM_dd(p.getBirth()));
  272 + result.setPregnantCensusTypeId(p.getPcensusTypeId());
  273 + result.setPregnantLiveTypeId(p.getPliveTypeId());
  274 + result.setPregnantProfessionTypeId(p.getPprofessionTypeId());
  275 +
  276 + /**********孕妇联系方式***************/
  277 + result.setPregnantPhone(p.getPhone());
  278 + result.setPregnantWorkUnit(p.getPworkUnit());
  279 +
  280 + result.setPregnantCensusProvinceId(p.getProvinceRegisterId());
  281 + result.setPregnantCensusCityId(p.getCityRegisterId());
  282 + result.setPregnantCensusAreaId(p.getAreaRegisterId());
  283 + result.setPregnantCensusStreetId(p.getStreetRegisterId());
  284 + result.setPregnantCensusAddr(p.getAddressRegister());
  285 +
  286 + result.setPregnantLiveProvinceId(p.getProvinceId());
  287 + result.setPregnantLiveCityId(p.getCityId());
  288 + result.setPregnantLiveAreaId(p.getAreaId());
  289 + result.setPregnantLiveStreetId(p.getStreetId());
  290 + result.setPregnantLiveAddr(p.getAddress());
  291 +
  292 +
  293 + result.setChildbirthAddr(p.getAddressPostRest());
  294 + result.setChildbirthProvinceId(p.getProvincePostRestId());
  295 + result.setChildbirthCityId(p.getCityPostRestId());
  296 + result.setChildbirthAreaId(p.getAreaPostRestId());
  297 + result.setChildbirthStreetId(p.getStreetPostRestId());
  298 +
  299 + /****************丈夫信息**************/
  300 + result.setHusbandName(p.getHusbandName());
  301 + result.setHusbandPhone(p.getHusbandPhone());
  302 +
  303 + result.setHusbandCertificateTypeId(p.getHcertificateTypeId());
  304 + result.setHusbandCertificateNum(p.getHcertificateNum());
  305 + result.setHusbandCountryId(p.getHcountryId());
  306 + result.setHusbandNationId(p.getHnationId());
  307 + result.setHusbandProfessionTypeId(p.getHprofessionTypeId());
  308 + result.setHusbandWorkUnit(p.getHworkUnit());
  309 +
  310 + result.setHusbandAddressRegister(p.getHaddressRegister());
  311 + result.setHusbandProvinceRegisterId(p.getHprovinceRegisterId());
  312 + result.setHusbandCityRegisterId(p.getHcityRegisterId());
  313 + result.setHusbandAreaRegisterId(p.getHareaRegisterId());
  314 + result.setHusbandStreetRegisterId(p.getHstreetRegisterId());
  315 +
  316 + //院内信息
  317 + result.setLastMenstrualPeriod(DateUtil.getyyyy_MM_dd(p.getLastMenses()));
  318 + result.setDueDate(DateUtil.getyyyy_MM_dd(p.getDueDate()));
  319 + result.setFileCode(p.getFileCode());
  320 + result.setVcCardNo(p.getVcCardNo());
  321 + result.setBookbuildingDoctor(p.getBookbuildingDoctor());
  322 + result.setBookbuildingDate(DateUtil.getyyyy_MM_dd(p.getBookbuildingDate()));
  323 + result.setServiceType(p.getServiceType());
  324 + }
  325 + BaseObjectResponse objectResponse = new BaseObjectResponse();
  326 + objectResponse.setData(result);
  327 + objectResponse.setErrorcode(ErrorCodeConstants.SUCCESS);
  328 + objectResponse.setErrormsg("成功");
  329 + return objectResponse;
  330 + }
  331 +}