Procedure

TfrmODMedNVA.Validate

Directives

Override

Module

fODMedNVA

Last Modified

7/15/2014 3:26:42 PM

Visibility

Protected

Overrides

TfrmODBase.Validate

Owner

TfrmODMedNVA

Declaration

procedure Validate(var AnErrMsg: string); override;

Calls Hierarchy


TfrmODMedNVA.Validate
 ├TfrmODMedNVA.ControlChange
 │ ├TResponses.Clear
 │ ├TResponses.Update
 │ │ ├TResponses.FindResponseByName
 │ │ └TResponses.IENForPrompt
 │ ├TfrmODMedNVA.FindCommonDrug
 │ │ ├TfrmODMedNVA.FindDoseFields
 │ │ ├SaveDrug
 │ │ └KillDrug
 │ ├TfrmODMedNVA.ConstructedDoseFields
 │ ├TfrmODMedNVA.ValueOf
 │ │ ├GetSchedule
 │ │ └GetScheduleEX
 │ ├TfrmODMedNVA.OutpatientSig
 │ │ ├TfrmODMedNVA.ValueOf...
 │ │ └TfrmODMedNVA.CheckDecimal
 │ └TResponses.GetOrderText
 │   ├TResponses.NextInstance
 │   ├TResponses.FindResponseByName
 │   ├TResponses.FormatResponse
 │   │ └TResponses.FindResponseByIEN
 │   └TResponses.AppendChildren
 │     ├TResponses.FindPromptByIEN
 │     ├TResponses.FindResponseByIEN
 │     └TResponses.FormatResponse...
 ├SetError
 ├TResponses.InstanceCount
 ├TResponses.NextInstance
 ├ValidDateTimeStr
 └FMNow

Calls

Name Declaration Comments
TfrmODMedNVA.ControlChange procedure ControlChange(Sender: TObject); -
FMNow function FMNow: TFMDateTime; -
TResponses.InstanceCount function InstanceCount(const APromptID: string): Integer; -
TResponses.NextInstance function NextInstance(const APromptID: string; LastInstance: Integer): Integer; -
SetError procedure SetError(const x: string); -
ValidDateTimeStr function ValidDateTimeStr(const AString, Flags: string): TFMDateTime; -


Source

471   procedure TfrmODMedNVA.Validate(var AnErrMsg: string);
472   var
473     i: Integer;
474     StartDate: TFMDateTime;
475   
476     procedure SetError(const x: string);
477     begin
478       if Length(AnErrMsg) > 0 then AnErrMsg := AnErrMsg + CRLF;
479       AnErrMsg := AnErrMsg + x;
480     end;
481   
482     procedure ValidateDosage(const x: string);
483     begin
484       if Length(x) = 0 then SetError(TX_NO_DOSE);
485     end;
486   
487     procedure ValidateRoute(const x: string; NeedLookup: Boolean; AnInstance: Integer);
488     var
489       RouteID, RouteAbbr: string;
490     begin
491       if (Length(x) = 0) and (not MedIsSupply(txtMed.Tag)) then SetError(TX_NO_ROUTE);
492       if (Length(x) > 0) and NeedLookup then
493       begin
494         LookupRoute(x, RouteID, RouteAbbr);
495         if RouteID = '0'
496           then SetError(TX_NF_ROUTE)
497           else Responses.Update('ROUTE', AnInstance, RouteID, RouteAbbr);
498       end;
499     end;
500   
501     procedure ValidateSchedule(const x: string; AnInstance: Integer);
502     const
503       SCH_BAD = 0;
504       SCH_NO_RTN = -1;
505     var
506       ValidLevel: Integer;
507       ARoute, ADrug: string;
508     begin
509       ARoute := ValueOfResponse(FLD_ROUTE_ID, AnInstance);
510       ADrug  := ValueOfResponse(FLD_DRUG_ID,  AnInstance);
511    {  if (Length(x) = 0) and (not FNonVADlg) then SetError(TX_NO_SCHED)
512       else if (Length(x) = 0) and FNonVADlg and ScheduleRequired(txtMed.Tag, ARoute, ADrug)
513       then SetError(TX_NO_SCHED);
514   }
515       if Length(x) > 0 then
516       begin
517         ValidLevel := ValidSchedule(x, 'O');
518         if ValidLevel = SCH_NO_RTN then
519         begin
520           if Pos('"', x) > 0                              then SetError(TX_SCH_QUOTE);
521           if Copy(x, 1, 1) = '-'                          then SetError(TX_SCH_MINUS);
522           if Pos(' ', Copy(x, Pos(' ', x) + 1, 999)) > 0  then SetError(TX_SCH_SPACE);
523           if Length(x) > 70                               then SetError(TX_SCH_LEN);
524           if (Pos('P RN', x) > 0) or (Pos('PR N', x) > 0) then SetError(TX_SCH_PRN);
525           if Pos('Q0', x) > 0                             then SetError(TX_SCH_ZERO);
526           if TrimLeft(x) <> x                             then SetError(TX_SCH_LSP);
527         end;
528         if ValidLevel = SCH_BAD then SetError(TX_SCH_NS);
529       end;
530     end;
531   
532   begin
533     inherited;
534      begin
535     AnErrMsg := '';
536     if User.NoOrdering then AnErrMsg := 'Ordering has been disabled. Press Quit';
537   
538     ControlChange(Self);                            // make sure everything is updated
539     if txtMed.Tag = 0 then SetError(TX_NO_MED);
540     if Responses.InstanceCount('INSTR') < 1 then SetError(TX_NO_DOSE);
541     i := Responses.NextInstance('INSTR', 0);
542     while i > 0 do
543     begin
544    {   if (ValueOfResponse(FLD_DRUG_ID, i) = '') then
545        begin
546         if not ContainsAlpha(Responses.IValueFor('INSTR', i)) then SetError(TX_DOSE_NUM);
547         if Length(Responses.IValueFor('INSTR', i)) > 60       then SetError(TX_DOSE_LEN);
548        end;
549       ValidateRoute(Responses.EValueFor('ROUTE', i), Responses.IValueFor('ROUTE', i) = '', i);
550       ValidateSchedule(ValueOfResponse(FLD_SCHEDULE, i), i);
551    }
552       i := Responses.NextInstance('INSTR', i);
553     //  inherited;  -  do not reject past dates - historical would not be allowed
554   
555          if calStart.Text <> '' then
556        begin
557           StartDate := ValidDateTimeStr(calStart.Text,'TS');
558           if StartDate > FMNow then SetError(TX_NO_FUTURE_DATES);
559           if StartDate < 0 then SetError(TX_BAD_DATE);
560        end;
561      end;
562     end;
563     if Pos(U, self.memComment.Text) > 0 then SetError('Comments cannot contain a "^".');
564   end;