Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Flavien Groisillier
flavien-ledoc
Commits
9cff5621
Commit
9cff5621
authored
Mar 02, 2022
by
FlavienGr
Browse files
add select formulaire patient
parent
addbfd20
Changes
2
Hide whitespace changes
Inline
Side-by-side
src/app/Patient/patient-form-add/patient-form-add.component.html
View file @
9cff5621
...
...
@@ -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>
...
...
src/app/Patient/patient-form-add/patient-form-add.component.ts
View file @
9cff5621
...
...
@@ -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
.
treatment
FormGroup
());
(
this
.
form
.
get
(
'
treatments
'
)
as
FormArray
)?.
push
(
this
.
treatment
Scheme
());
}
...
...
@@ -65,7 +86,7 @@ export class PatientFormAddComponent implements OnInit {
treatmentRepeatFormGroup
():
FormGroup
{
return
this
.
fb
.
group
([]);
}
treatment
FormGroup
():
FormGroup
{
treatment
Scheme
():
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
);
})
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment