Hello, I have a set of data that is initially pushed to the response as true. However, before submitting the form, I need to change some options so that I receive a false response. In order to do this, I must remove a specific item from the array.
TS:
onChangeMedication(value, rowData) {
let exe = this.exeTypeNumber(value);
this.medicationTableValue.map(details => {
let medicationObj = { ...medicationFields };
if (details.code === rowData.code) {
if (value != '17587') {
let params = { PatientId: this.userId, ExeType: exe, TableId: 'medication', Param1: rowData.name, Param2: rowData.date ? new DatePipe('en').transform(rowData.date, 'yyyy-MM-dd HH:mm:ss') : null, Param3: null }
this.emrservice.ccdRecord(params)
.subscribe((res) => {
this.validStatus(res.Body.Data, rowData);
if (res.Body.Data) {
this.exportCCDSuperObj.medication.push(medicationObj);
}
});
}
};
});
}
This function will return a API response of true or false.
validStatus(data, rowData) {
this.isValidItems = data
if (!this.isValidItems) {
rowData.showNoStatus = true;
rowData.showYesStatus = false;
this.isDisabled = false;
} if (this.isValidItems) {
rowData.showYesStatus = true;
rowData.showNoStatus = false;
this.isDisabled = true;
}
}
HTML:
<td>
<select (change)="onChangeMedication($event.target.value,rowData)" [value]="defaultValue">
<option value=''>Select Record</option>
<option *ngFor="let sType of validType" [value]='sType.Id'>{{sType.Description}}</option>
</select>
</td>
<i class="fa fa-times" aria-hidden="true" *ngIf="rowData.showNoStatus"></i>
<i class="fas fa-check" *ngIf="rowData.showYesStatus"></i>