procedure TRxPayForm.ItemCDSBeforePost(DataSet: TDataSet);
var income_name_type ,xincome:string;
begin
if dataset.fieldbyname('icode').asstring <> '' then
begin
dataset.fieldbyname('income_name').asstring := '';
if FxItemCDS.findkey([dataset.fieldbyname('icode').asstring]) then
if trim(FxItemCds.fieldbyname('income').asstring) <> '' then
dataset.fieldbyname('income_name').asstring :=
FxItemCds.fieldbyname('income').asstring;
income_name_type := '';
xincome := dataset.fieldbyname('income_name').asstring;
if xincome='' then
xincome := FFirstDrugIncome;
if not FNoMedicationHistoryCheck then
if OldVisitRxCDS.active then
// if dataset.fieldbyname('income_name'). <> '' then
if pos(xincome, FAllDrugIncome) > 0 then
begin
if OldVisitRxCDS.locate('icode', vararrayof([dataset.fieldbyname('icode').asstring]),
[]) then
begin
if (oldvisitrxcds.fieldbyname('drugusage').asstring =
itemcds.fieldbyname('drugusage').asstring) then
begin
if (oldvisitrxcds.fieldbyname('qty').asinteger =
dataset.fieldbyname('qty').asinteger) then
begin
income_name_type := 'ยาตัวเดิม';
end
else
begin
if (oldvisitrxcds.fieldbyname('qty').asinteger <
dataset.fieldbyname('qty').asinteger) then
income_name_type := 'ยาเดิม เพิ่มจำนวน'
else
income_name_type :=
'ยาเดิม ลดจำนวน';
end;
end else
begin
income_name_type := 'ยาเดิม เปลี่ยนวิธีใช้';
end;
end
else
begin
income_name_type := 'ยาสั่งใช้ตัวใหม่';
end;
end;