Commit 9cff5621 authored by FlavienGr's avatar FlavienGr
Browse files

add select formulaire patient

parent addbfd20
......@@ -123,36 +123,40 @@
let treatment of patientTreatment()['controls'];
let empIndex = index
"
[formGroupName]="empIndex"
>
<div [formGroupName]="empIndex">
<div class="row">
<div class="col-4">
<label for="drug">Médicaments</label>
<input
class="form-control"
type="text"
formControlName="drug"
id="drug"
/>
</div>
<div class="col-4" formArrayName="repeat">
<label for="repeat">Répétition</label>
<input
class="form-control"
type="text"
formControlName="repeat"
id="repeat"
/>
</div>
<div class="col-4">
<label for="duration">Durée</label>
<input
class="form-control"
type="text"
formControlName="duration"
id="duration"
/>
</div>
<div class="row">
<div class="col-4">
<label>Médicaments</label>
<select formControlName="drug">
<option *ngFor="let drug of drugs" [ngValue]="drug.id">
{{ drug.label }}
</option>
</select>
</div>
<div class="col-4">
<label>Répétition</label>
<select formControlName="repeat">
<option
*ngFor="let repeat of repeats"
[ngValue]="repeat.id"
>
{{ repeat.label }}
</option>
</select>
</div>
<div class="col-4">
<label>Durée</label>
<select formControlName="duration">
<option
*ngFor="let duration of durations"
[ngValue]="duration.id"
>
{{ duration.label }}
</option>
</select>
</div>
</div>
</div>
......
......@@ -4,6 +4,24 @@ import { ActivatedRoute } from '@angular/router';
import { Patient } from 'src/app/models/Patient';
import { PatientsService } from 'src/app/services/patients.service';
const DRUGS = [
{ id: 1, label: 'Aspirine' },
{ id: 2, label: 'Doliprane' },
{ id: 3, label: 'Gravinalox' },
];
const REPEATS = [
{ id: 1, label: 'Matin' },
{ id: 2, label: 'Midi' },
{ id: 3, label: 'Soir' },
];
const DURATIONS = [
{ id: 1, label: '1 jour' },
{ id: 2, label: '2 jours' },
{ id: 3, label: '1 semaine' },
];
@Component({
selector: 'app-patient-form-add',
templateUrl: './patient-form-add.component.html',
......@@ -15,6 +33,9 @@ export class PatientFormAddComponent implements OnInit {
treatments: FormArray;
repeat: FormArray;
patient: Patient;
drugs = DRUGS;
repeats = REPEATS;
durations = DURATIONS;
public editable: boolean = false;
constructor(
......@@ -43,7 +64,7 @@ export class PatientFormAddComponent implements OnInit {
weight: ['', [Validators.required]],
bloodGroup: ['', [Validators.required]],
notes: ['', [Validators.required]],
treatments: this.fb.array([])
treatments: this.fb.array([this.treatmentScheme()])
});
}
getData() {
......@@ -52,7 +73,7 @@ export class PatientFormAddComponent implements OnInit {
this.patientsService.getPatientById(id).subscribe(response => {
for (let index = 0; index < response.treatments.length; index++) {
(this.form.get('treatments') as FormArray)?.push(this.treatmentFormGroup());
(this.form.get('treatments') as FormArray)?.push(this.treatmentScheme());
}
......@@ -65,7 +86,7 @@ export class PatientFormAddComponent implements OnInit {
treatmentRepeatFormGroup(): FormGroup {
return this.fb.group([]);
}
treatmentFormGroup(): FormGroup {
treatmentScheme(): FormGroup {
return this.fb.group({
drug: new FormControl(''),
repeat: this.fb.array([]),
......@@ -97,7 +118,7 @@ export class PatientFormAddComponent implements OnInit {
}
onSubmit() {
console.log(this.form.value)
this.patientsService.addPatient(this.form.value).subscribe(response => {
console.log(response);
})
......
Supports Markdown
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