Procedure

PutNewOrder

Module

rODBase

Last Modified

7/15/2014 3:26:42 PM

Scope

Interfaced

Declaration

procedure PutNewOrder(var AnOrder: TOrder; ConstructOrder: TConstructOrder; OrderSource: string);

Calls Hierarchy


PutNewOrder
 ├SetupORDIALOG
 └SetOrderFields
   ├TOrder.Clear
   ├SeqOfDGroup
   │ └LoadDGroupMap
   └TopNameOfDGroup
     └LoadDGroupMap

Called-By Hierarchy


                                                   PutNewOrder
                                        TResponses.SaveOrder┘ 
                                      TfrmODBase.ValidSave┘   
                               TfrmODBase.cmdAcceptClick┤     
                                   ActivateOrderDialog┘ │     
                           TfrmRemDlg.btnFinishClick┤   │     
           TfrmConsults.mnuActNewConsultRequestClick┤   │     
                   TfrmConsults.cmdNewConsultClick┘ │   │     
                TfrmConsults.mnuActNewProcedureClick┤   │     
                      TfrmConsults.cmdNewProcClick┘ │   │     
                                        ChangeOrders┤   │     
                      TfrmOrders.mnuActChangeClick┤ │   │     
                        TfrmMeds.mnuActChangeClick┘ │   │     
                                     ChangeOrdersEvt┤   │     
                                          CopyOrders┤   │     
                        TfrmOrders.mnuActCopyClick┤ │   │     
                          TfrmMeds.mnuActCopyClick┤ │   │     
                           TfrmODActive.btnOKClick┘ │   │     
                                      TransferOrders┤   │     
                        TfrmOrders.mnuActCopyClick┤ │   │     
                          TfrmMeds.mnuActCopyClick┤ │   │     
                           TfrmODActive.btnOKClick┘ │   │     
                            TfrmOrders.lstWriteClick┤   │     
               TfrmOrders.PlaceOrderForDefaultDialog┤   │     
                  TfrmOrders.DisplayDefaultDlgList┤ │   │     
                       TfrmOrders.ResetOrderPage┘ │ │   │     
               TfrmOrders.btnDelayedOrderClick┘   │ │   │     
                                 DisplayEvntDialog┤ │   │     
                             SetDelayEventForMed┘ │ │   │     
                      TfrmMeds.mnuActCopyClick┘   │ │   │     
                                 DisplayEvntDialog┤ │   │     
                                  SetViewForCopy┘ │ │   │     
                    TfrmOrders.mnuActCopyClick┘   │ │   │     
                                 DisplayEvntDialog┘ │   │     
                                ExecuteChangeEvt┘   │   │     
                 TfrmOrders.mnuActChgEvntClick┘     │   │     
                             TfrmMeds.mnuActNewClick┤   │     
                           TfrmOMNavA.ActivateDialog┤   │     
                         TfrmOMNavA.grdMenuKeyDown┤ │   │     
                         TfrmOMNavA.grdMenuMouseUp┘ │   │     
                                TfrmOMSet.DoNextItem┘   │     
                              TfrmOMSet.InsertList┤     │     
                               ActivateOrderList┘ │     │     
                     TfrmRemDlg.btnFinishClick┤   │     │     
                             ActivateOrderHTML┤   │     │     
                    TfrmOrders.lstWriteClick┤ │   │     │     
    TfrmOrders.PlaceOrderForDefaultDialog...┘ │   │     │     
                              ActivateOrderSet┤   │     │     
                   TfrmRemDlg.btnFinishClick┤ │   │     │     
TfrmConsults.mnuActNewConsultRequestClick...┤ │   │     │     
     TfrmConsults.mnuActNewProcedureClick...┤ │   │     │     
                    TfrmOrders.lstWriteClick┤ │   │     │     
    TfrmOrders.PlaceOrderForDefaultDialog...┤ │   │     │     
                     TfrmMeds.mnuActNewClick┤ │   │     │     
                TfrmOMNavA.ActivateDialog...┤ │   │     │     
                     TfrmOMSet.DoNextItem...┘ │   │     │     
                       TfrmOMNavA.DoSelectList┘   │     │     
                     TfrmOMNavA.grdMenuKeyUp┤     │     │     
                   TfrmOMNavA.grdMenuMouseUp┘     │     │     
                                        SkipToNext┤     │     
                         TfrmOMSet.DoNextItem...┘ │     │     
                            TfrmOMSet.UMDelayEvent┘     │     
                               TfrmODBase.FormCloseQuery┤     
                                     TfrmODBase.TabClose┤     
                            TfrmODAllergy.cmdAcceptClick┘     

Calls

Name Declaration Comments
SetOrderFields procedure SetOrderFields(AnOrder: TOrder; const x, y, z: string); -
SetupORDIALOG procedure SetupORDIALOG(AParam: TParamRecord; ResponseList: TList; IsIV: boolean = False); -

Called-By

Name Declaration Comments
TResponses.SaveOrder procedure SaveOrder(var AnOrder: TOrder; DlgIEN: Integer; IsIMOOrder: boolean = False); -


Source

446   procedure PutNewOrder(var AnOrder: TOrder; ConstructOrder: TConstructOrder; OrderSource: string);
447   var
448     i, inc, len, numLoop, remain: Integer;
449     ocStr, tmpStr, x, y, z: string;
450   begin
451     with RPCBrokerV do
452     begin
453       ClearParameters := True;
454       RemoteProcedure := 'ORWDX SAVE';
455       Param[0].PType := literal;
456       Param[0].Value := Patient.DFN;  //*DFN*
457       Param[1].PType := literal;
458       Param[1].Value := IntToStr(Encounter.Provider);
459       Param[2].PType := literal;
460       (*if loc > 0 then Param[2].Value := IntToStr(Loc)
461       else Param[2].Value := IntToStr(Encounter.Location);*)
462       Param[2].Value := IntToStr(Encounter.Location);
463       Param[3].PType := literal;
464       Param[3].Value := ConstructOrder.DialogName;
465       Param[4].PType := literal;
466       Param[4].Value := IntToStr(ConstructOrder.DGroup);
467       Param[5].PType := literal;
468       Param[5].Value := IntToStr(ConstructOrder.OrderItem);
469       Param[6].PType := literal;
470       Param[6].Value := AnOrder.EditOf;        // null if new order, otherwise ORIFN of original
471       if (ConstructOrder.DGroup = IVDisp) or (ConstructOrder.DialogName = 'PSJI OR PAT FLUID OE') then
472         SetupORDIALOG(Param[7], ConstructOrder.ResponseList, True)
473       else
474         SetupORDIALOG(Param[7], ConstructOrder.ResponseList);
475       if Length(ConstructOrder.LeadText)  > 0
476         then Param[7].Mult['"ORLEAD"']  := ConstructOrder.LeadText;
477       if Length(ConstructOrder.TrailText) > 0
478         then Param[7].Mult['"ORTRAIL"'] := ConstructOrder.TrailText;
479       Param[7].Mult['"ORCHECK"'] := IntToStr(ConstructOrder.OCList.Count);
480       with ConstructOrder do for i := 0 to OCList.Count - 1 do
481       begin
482         // put quotes around everything to prevent broker from choking
483         y := '"ORCHECK","' + Piece(OCList[i], U, 1) + '","' + Piece(OCList[i], U, 3) +
484           '","' + IntToStr(i+1) + '"';
485         //Param[7].Mult[y] := Pieces(OCList[i], U, 2, 4);
486         OCStr :=  Pieces(OCList[i], U, 2, 4);
487         len := Length(OCStr);
488         if len > 255 then
489           begin
490             numLoop := len div 255;
491             remain := len mod 255;
492             inc := 0;
493             while inc <= numLoop do
494               begin
495                 tmpStr := Copy(OCStr, 1, 255);
496                 OCStr := Copy(OCStr, 256, Length(OcStr));
497                 Param[7].Mult[y + ',' + InttoStr(inc)] := tmpStr;
498                 inc := inc +1;
499               end;
500             if remain > 0 then  Param[7].Mult[y + ',' + inttoStr(inc)] := OCStr;
501   
502           end
503         else
504          Param[7].Mult[y] := OCStr;
505       end;
506       if ConstructOrder.DelayEvent in ['A','D','T','M','O'] then
507         Param[7].Mult['"OREVENT"'] := ConstructOrder.PTEventPtr;
508       if ConstructOrder.LogTime > 0
509         then Param[7].Mult['"ORSLOG"'] := FloatToStr(ConstructOrder.LogTime);
510       Param[7].Mult['"ORTS"'] := IntToStr(Patient.Specialty);  // pass in treating specialty for ORTS
511       Param[8].PType := literal;
512       Param[8].Value := ConstructOrder.DigSig;
513       if Constructorder.IsIMODialog then
514       begin
515         Param[9].PType := literal;                       //IMO
516         Param[9].Value := FloatToStr(Encounter.DateTime);
517       end else
518       begin
519         Param[9].PType := literal;                       //IMO
520         Param[9].Value := '';
521       end;
522       Param[10].PType := literal;
523       Param[10].Value := OrderSource;
524       Param[11].PType := literal;
525       Param[11].Value := IntToStr(Constructorder.IsEventDefaultOR);
526   
527       CallBroker;
528       if Results.Count = 0 then Exit;          // error creating order
529       x := Results[0];
530       Results.Delete(0);
531       y := '';
532   
533       while (Results.Count > 0) and (CharAt(Results[0], 1) <> '~') and (CharAt(Results[0], 1) <> '|') do
534         begin
535           y := y + Copy(Results[0], 2, Length(Results[0])) + CRLF;
536           Results.Delete(0);
537         end;
538       if Length(y) > 0 then y := Copy(y, 1, Length(y) - 2);  // take off last CRLF
539       z := '';
540       if (Results.Count > 0) and (Results[0] = '|') then
541         begin
542           Results.Delete(0);
543           while (Results.Count > 0) and (CharAt(Results[0], 1) <> '~') and (CharAt(Results[0], 1) <> '|') do
544             begin
545               z := z + Copy(Results[0], 2, Length(Results[0]));
546               Results.Delete(0);
547             end;
548         end;
549       SetOrderFields(AnOrder, x, y, z);
550     end;
551   end;