コード例 #1
0
 @RequestMapping(value = "/medicalRecord/add", method = RequestMethod.POST)
 @ResponseBody
 public Boolean addMedicalRecord(
     @RequestParam(value = "codes[]", required = false) String[] codes,
     @RequestParam Integer patientId,
     @RequestParam String domain) {
   if (codes == null || codes.length == 0) {
     throw new AjaxBadRequest("Please select codes for add");
   }
   User patient = userService.getByPrimaryKey(patientId);
   for (String entryStr : codes) {
     String[] entry = entryStr.split(Constants.HYPHEN);
     DictionaryEntry dictionaryEntry =
         new DictionaryEntry(entry[0], entry[1], Domain.valueOf(domain));
     if (entry.length < 3) {
       throw new AjaxBadRequest("Date can't be empty");
     }
     String dateStr = entry[2];
     if (dateStr.trim().isEmpty()) {
       throw new AjaxBadRequest("Date can't be empty");
     }
     Date date;
     try {
       date = new SimpleDateFormat("mm/dd/yyyy").parse(dateStr);
     } catch (ParseException e) {
       throw new AjaxBadRequest("Date format error");
     }
     String value = entry.length == 4 && !entry[3].trim().isEmpty() ? entry[3] : null;
     patient
         .getMedicalRecords()
         .add(new MedicalRecord(patientId, Domain.valueOf(domain), dictionaryEntry, date, value));
   }
   userService.update(patient);
   return true;
 }
コード例 #2
0
 @RequestMapping("/dictionaryEntry/domain/{domain}")
 @ResponseBody
 public List<DictionaryEntry> dictionaryEntriesByDomain(@PathVariable String domain) {
   List<DictionaryEntry> result = dictionaryEntryService.findAllByDomain(Domain.valueOf(domain));
   return result;
 }