Skip to content
Snippets Groups Projects
Commit b8cdf57f authored by 丁爽's avatar 丁爽
Browse files

修改并补充病历,改变病历和药品的匹配方式

parent 2a5a2378
Branches
No related merge requests found
package com.example.bean;
public class Drugs {
private Long id;
private int id;
private String name;
private String specification;
private int number;
private String way;
private String dosage;
public Long getId() {
public int getId() {
return id;
}
public void setId(Long id) {
public void setId(int id) {
this.id = id;
}
......
......@@ -67,4 +67,17 @@ public class MedicalRecord {
public void setDrugs(List<Drugs> drugs) {
this.drugs = drugs;
}
@Override
public String toString() {
return "MedicalRecord{" +
"mid=" + mid +
", uid='" + uid + '\'' +
", did='" + did + '\'' +
", diagnose='" + diagnose + '\'' +
", symptom='" + symptom + '\'' +
", recordtime=" + recordtime +
", drugs=" + drugs +
'}';
}
}
package com.example.controller;
import com.example.bean.MedicalRecord;
import com.example.bean.Drugs;
import com.example.bean.RespBean;
import com.example.mapper.MedicalRecordMapper;
import com.example.service.MedicalRecordService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.*;
import java.util.List;
@RestController
......@@ -15,7 +14,7 @@ public class MedicalRecordController {
@Autowired
private MedicalRecordService medicalRecordService;
@PostMapping("/addMedicalRecord")
public RespBean addNewMedicalRecord(MedicalRecord medicalRecord) {
public RespBean addNewMedicalRecord(@RequestBody MedicalRecord medicalRecord) {
int result = medicalRecordService.addNewMedicalRecord(medicalRecord);
if(result == 1){
return new RespBean("success","添加成功");
......@@ -24,8 +23,18 @@ public class MedicalRecordController {
return new RespBean("error","添加失败");
}
}
@PostMapping("/addDrugs")
public RespBean addDrugs(@RequestBody Drugs drugs){
int result = medicalRecordService.addDrugs(drugs);
if(result == 1){
return new RespBean("success","添加成功");
}
else {
return new RespBean("error","添加失败");
}
}
@PostMapping("/deleteMedicalrecord")
public RespBean deleteMedicalRecord(int mid){
public RespBean deleteMedicalRecord(@RequestParam("mid") int mid){
int result = medicalRecordService.deleteMedicalRecordByMid(mid);
if(result == 1){
return new RespBean("success","删除成功");
......@@ -35,7 +44,13 @@ public class MedicalRecordController {
}
}
@PostMapping
public RespBean showSummary(String uid){
return null;
public RespBean showSummary(@RequestParam("userid") String uid){
int result = medicalRecordService.getSummaryByUid(uid);
if(result == 1){
return new RespBean("success","获取成功");
}
else{
return new RespBean("error","获取失败");
}
}
}
package com.example.mapper;
import com.example.bean.DailyReport;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import com.example.bean.Drugs;
import java.util.List;
@Mapper
public interface DrugsMapper {
int deleteDrugsByMid(int mid);
int savaDrugs(@Param("drugs") String[] drugs);
List<Long> getDrugsIdByDrugName(@Param("drugNames") String[] tagsNames);
int saveDrugstoMedicalRecord(@Param("drugIds") List<Long> drugIds,@Param("mid") int mid);
int savaDrugstoMedicalRecord(int mid);
List<Drugs> getDrugsByMid(int mid);
int addDrugs(Drugs drugs);
}
package com.example.mapper;
import com.example.bean.DailyReport;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
import com.example.bean.MedicalRecord;
import com.example.bean.Drugs;
@Mapper
public interface MedicalRecordMapper {
int addNewMedicalRecord(MedicalRecord medicalRecord);
......@@ -19,4 +21,5 @@ public interface MedicalRecordMapper {
int updateMedicalRecord(MedicalRecord medicalRecord);
int deleteMedicalRecordByMid(@Param("mid") int mid);
List<MedicalRecord> selectMedicalRecordByUserId(String userid);
}
package com.example.service;
import com.example.bean.Drugs;
import com.example.bean.MedicalRecord;
import com.example.mapper.MedicalRecordMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.example.mapper.DrugsMapper;
import java.sql.Timestamp;
import java.util.List;
......@@ -13,11 +15,30 @@ import static org.apache.ibatis.ognl.DynamicSubscript.mid;
public class MedicalRecordService {
@Autowired
private MedicalRecordMapper medicalRecordMapper;
private DrugsMapper drugsMapper;
public int addNewMedicalRecord(MedicalRecord medicalRecord) {
return medicalRecordMapper.addNewMedicalRecord(medicalRecord);
int i = medicalRecordMapper.addNewMedicalRecord(medicalRecord);
List<Drugs> drugs= medicalRecord.getDrugs();
drugsMapper.savaDrugstoMedicalRecord(medicalRecord.getMid());
return i;
}
public int addDrugs(Drugs drugs){
return drugsMapper.addDrugs(drugs);
}
private int addDrugsToMedicalRecord(int[] drugsid,int mid) {
drugsMapper.deleteDrugsByMid(mid);
for(int i=0;i<drugsid.length;i++){
int did = drugsid[i];
drugsMapper.savaDrugstoMedicalRecord(mid,did);
}
}
public int getMidByUId(String uid){
return medicalRecordMapper.getMidByUid(uid);
}
......
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.example.mapper.DrugsMapper">
<delete id="deleteDrugsByMid" parameterType="int">
delete from mrecord_drugs where mid = #{mid};
</delete>
<insert id="addDrugs" parameterType="com.example.bean.Drugs">
insert into drugs (name, specification, number, way, dosage)
values (#{name},#{specification},#{number},#{way},#{dosage});
</insert>
<insert id="saveDrugstoMedicalRecord" parameterType="int">
insert into mrecord_drugs(mid, did) VALUES (#{mid},#{did});
</insert>
</mapper>
\ No newline at end of file
......@@ -39,4 +39,7 @@
<delete id="deleteMedicalRecordByMid" parameterType="int" >
DELETE FROM medicalrecord WHERE mid = #{mid};
</delete>
<select id = "selectMedicalRecordByUid" parameterType="com.example.bean.MedicalRecord">
select *
</select>
</mapper>
\ No newline at end of file
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment