Skip to content

Commit 1c7ae33

Browse files
committed
New DbSchema
1 parent 95d359e commit 1c7ae33

17 files changed

Lines changed: 1059 additions & 10 deletions

Controllers/LastOpenedDocumentsController.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ public LastOpenedDocument GetLastOpenedDocument(int lastOpenedDocumentId)
3636
return _context.LastOpenedDocuments.Single(l => l.LastOpenedDocumentId == lastOpenedDocumentId);
3737
}
3838

39+
//TODO: REMAKE
40+
3941
[HttpPut("[action]/{lastOpenedDocumentId}")]
4042
public IActionResult UpdateDocument(int lastOpenedDocumentId, [FromBody] LastOpenedDocument lastOpenedDocument)
4143
{
@@ -53,7 +55,7 @@ public IActionResult UpdateDocument(int lastOpenedDocumentId, [FromBody] LastOpe
5355

5456
document.LastOpenedTime = lastOpenedDocument.LastOpenedTime;
5557
document.Patient = lastOpenedDocument.Patient;
56-
document.ModelJson = lastOpenedDocument.ModelJson;
58+
//document.ModelJson = lastOpenedDocument.ModelJson;
5759

5860
_context.LastOpenedDocuments.Update(document);
5961
_context.SaveChanges();

Data/MedHelpContext.cs

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,26 @@ public MedHelpContext(DbContextOptions<MedHelpContext> options) : base(options)
1616
public DbSet<LastOpenedDocument> LastOpenedDocuments { get; set; }
1717
public DbSet<Template> Templates { get; set; }
1818
public DbSet<Medicine> Medicines { get; set; }
19+
public DbSet<Complaint> Complaints { get; set; }
20+
public DbSet<FormModel> FormModels { get; set; }
21+
22+
protected override void OnModelCreating(ModelBuilder modelBuilder)
23+
{
24+
modelBuilder.Entity<ComplaintFormModel>()
25+
.HasKey(t => new { t.ComplaintId, t.FormModelId});
26+
27+
modelBuilder.Entity<MedicineFormModel>()
28+
.HasKey(t => new {t.MedicineId, t.FormModelId});
29+
modelBuilder.Entity<FormModel>()
30+
.HasOne(t => t.Template)
31+
.WithOne(f => f.FormModel)
32+
.HasForeignKey<Template>(f => f.FormModelId);
33+
34+
modelBuilder.Entity<FormModel>()
35+
.HasOne(t => t.LastOpenedDocument)
36+
.WithOne(f => f.FormModel)
37+
.HasForeignKey<LastOpenedDocument>(f => f.FormModelId)
38+
.OnDelete(DeleteBehavior.Restrict);
39+
}
1940
}
2041
}

Data/SeedData.cs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,26 +27,29 @@ public static void Initialize(IServiceProvider serviceProvider)
2727

2828
};
2929
context.Medicines.AddRange(medicines.Select(m => new Medicine{MedicineName = m}));
30-
30+
31+
3132
var templates = new[]{
3233
new Template
3334
{
3435
Name = "Справка о приеме",
3536
SchemeJson = @"{""fields"":[{""type"":""submit"",""buttonText"":""Сохранить""},{""type"":""input"",""inputType"":""text"",""model"":""patientName"",""label"":""ФИО пацента"",""placeholder"":""Введите сюда имя пациента""},{""type"":""dateTimePicker"",""label"":""Дата рождения пациента"",""model"":""patientBirthday"",""dateTimePickerOptions"":{""format"":""YYYY-MM-DD""}},{""type"":""dateTimePicker"",""label"":""Дата посещения"",""model"":""visitDay"",""dateTimePickerOptions"":{""format"":""YYYY-MM-DD""}},{""type"":""input"",""inputType"":""text"",""model"":""speciality"",""label"":""Специальность""},{""type"":""input"",""inputType"":""text"",""model"":""doctorName"",""label"":""Имя доктора""},{""type"":""textArea"",""model"":""complaints"",""label"":""Жалобы"",""rows"":5},{""type"":""textArea"",""model"":""anammnesis"",""label"":""Анамнез"",""rows"":5},{""type"":""textArea"",""model"":""recommended"",""label"":""Рекомендации"",""rows"":5},{""type"":""vueMultiSelect"",""label"":""Лекарства"",""placeholder"":""Пожалуйста, выберите лекарства"",""values"":[],""selectOptions"":{""multiple"":true,""hideselected"":true,""multiSelect"":true,""closeOnSelect"":true,""showLabels"":false,""searchable"":true,""taggable"":true,""limit"":10}},{""type"":""submit"",""buttonText"":""Сохранить""}]}",
36-
ModelJson = @"{""patientName"":"""",""patientBirthday"":""2017-12-10T23:29:08.947Z"",""visitDay"":""2017-12-10T23:29:08.947Z"",""medicines"":""[]"",""speciality"":"""",""doctorName"":"""",""complaints"":"""",""anammnesis"":"""",""recommended"":""""}",
37+
FormModel = new FormModel(),
3738
Description = "Самая обычная справка о приеме какая только может быть",
3839
ImagePath = "https://doc-rf.com/templates/SYNERGY-CP1251/images/sprav/ych/doc.jpg"
3940
},
4041
new Template
4142
{
4243
Name = "Направление на анализы",
4344
//Description = "Куда сказано, туда и иди",
45+
FormModel = new FormModel(),
4446
Description = "Без анализов тут не обойтись",
4547
ImagePath = "http://mediaspravka.ru/photos/15_1.jpg"
4648
},
4749
new Template
4850
{
4951
Name = "Направление к другому врачу",
52+
FormModel = new FormModel(),
5053
//Description = "Ну, в этой ситуации я как бы уже это... Мои полномочия уже как бы всё... Окончены!",
5154
Description = "Такого я ещё не видел. Пусть мои коллеги посмотрят",
5255
ImagePath = "https://i.imgur.com/AoSVPpc.png"

Migrations/20171212031619_ExplicitFormModel.Designer.cs

Lines changed: 192 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)