patientemrs.js 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. 'use strict';
  2. const Controller = require('egg').Controller;
  3. // 患者病历
  4. class PatientEmrsController extends Controller {
  5. constructor(ctx) {
  6. super(ctx);
  7. this.service = this.ctx.service.patient;
  8. }
  9. // GET LIST
  10. async index() {
  11. const { patientid } = this.ctx.params;
  12. const res = await this.service.fetch({ id: patientid }, { emrs: '+emrs' });
  13. this.ctx.ok({ data: res.emrs });
  14. }
  15. // POST
  16. async create() {
  17. const { patientid } = this.ctx.params;
  18. await this.service.createEmr({ patientid }, this.ctx.request.body);
  19. this.ctx.ok({ msg: 'created' });
  20. }
  21. // GET /{id}
  22. async fetch() {
  23. const { patientid, emrid } = this.ctx.params;
  24. const res = await this.service.fetchEmr({ patientid, emrid });
  25. this.ctx.ok({ data: res });
  26. }
  27. // POST /{id}
  28. async update() {
  29. const { patientid, id } = this.ctx.params;
  30. await this.service.updateEmr({ patientid, id }, this.ctx.request.body);
  31. this.ctx.ok({ msg: 'accepted' });
  32. }
  33. // DELETE /{id}
  34. async destroy() {
  35. const { patientid, id } = this.ctx.params;
  36. await this.service.deleteEmr({ patientid, id });
  37. this.ctx.ok({ msg: 'deleted' });
  38. }
  39. }
  40. module.exports = PatientEmrsController;