Ga naar inhoud

Consultation Form

Synopsis

Form to train a patient consultation session

Route URL

#/consultation/random/:DIAG/:PERSONTYPE/:ACUTE/:SYMPTOM1/:SYMPTOM2
#/consultation/selected/:DIAG/:PERSONTYPE/:ACUTE/:SYMPTOM1/:SYMPTOM2
#/consultation/simulation/:SIMULATIONID

Old form in legacy FMX application

main.pas in the old application.

Data

Constants

```pascal; Fatconv = 0.025;

### Variables
* Same *selectedSymptoms* and *probabilities* arrays as in [expert](expert.md) form.
* Constcons : array of symtom IDs.
* *clusterdiagnoses* array of diagnoses. This contains IDs of diagnoses that match the diagnoses which have all symptoms that are present in *selectedsymptoms* and have *present* equal *true*.

### type

#### TExpandSymptom
```delphi
TExpandSymptom = record
  Symptom : TSymptom;
  Sens : Double;
  image : boolean;
  done : boolean;
end;  
TExpandSymptomArray = array of TExpandSymptom;

TCandidateSymptom = records
  Symptom: TSymptom;
  Sens : double;
end;

TDiagPower = record
  Symptom : TSymptom;
  Diagnose : TDiagnose;
  PC : Integer;
  PE : Integer;
  prev : float;
end;  
TDiagPowerArray = array of TDiagPower;

GUI

On form start, execute action Initialize

Top of form

  • Radio group (name: grpSelectData) with items:
    • name: rbAnamnese text: Anamnese
    • name: rbPhysResearch text: Fysisch onderzoek
    • name: rbAll Text: Alles
    • name: rbLab text: Laboratorium
    • name: rbImagery text: Beeldvorming
    • name: rbGeneralData text: General data On change: Execute SelectData action.

Vertical Center of form

3 columns

Column 1

  • Label (name: lblControlledArgs) text: Controlled arguments (string 555)
  • Grid (name: grdControlledArgs), 2 columns:
  • Column 1: symptom name
  • Column 2: present or not. (filled from selectedSymptoms)

Column 2

  • label: (name: lblBudgethint), text: Budget: EUR
  • label: (name: lblBudget), text: empty
  • Button: (name: btnTreshold), text: treshold (string 472) On Click: execute action HandleTreshold
  • Button: (name: btnCluster), text: cluster hypothesis (string 425) On Click: execute action ShowClusterInfo
  • Button: (name: btnGraphic), text: graphic (string 425) On Click: execute action ShowGraphic
  • Button: (name: btnLecture), text: Powertable (string 553) On Click: execute action ShowLecture

Column 3

  • Label (name: lblAvailableArgs) text: Available arguments (string 556)
  • Grid (name: grdAvailableArgs)

Bottom of form

  • Button: (name: btnRemoveLastArgumentArg), text: remove last arg (string 552) On Click: execute action RemoveLastArgument
  • Button: (name: btnPowertable), text: powertable (string 535) On Click: execute action TogglePowerTable
  • Button: (name: btnSaveConsultation), text: Save consultation (string 553) On Click: execute action SaveSimulation
  • Button: (name: btnExit), text: Stop On Click: execute action Exit

Actions

Initialize

  • Translate form
  • Set SelectedDiag to the diagnosis passed in the route URL parameters (or saved in simulation).
  • Set a string searchterm to empty string.
  • Set a boolean CostChecked equal to False;
  • Set a boolean BitmapShown to False
  • initialize a Score object of type TScore
  • initialize an array contcons of IDs
  • Initialize 2 boolean form variables :
    nonpresscanty:=False;
    nonpressplusplus:=False;
    
  • initialize empty selecteddiagnoses array with TDiagnose records..
  • Initialize empty selectedSymptoms : TSelectedSymptomArray, object has the following fields
    • symptom of type object Symptom
    • isPresent of type boolean.
  • If the route is a simulation call LoadSimulation
  • For all other routes, call InitSimulation
  • Execute Restart action
  • Execute SelectData action

InitSimulation

  • Insert route parameter PERSONTYPE in selectedsymptoms array using AddSymptom (present: true)
  • if route parameter ACUTE differs from 0, insert it in selectedsymptoms array using AddSymptom (present: true)
  • Insert route parameter SYMPTOM1 in selectedsymptoms array using AddSymptom (present: true)
  • Insert route parameter SYMPTOM2 in selectedsymptoms array using AddSymptom (present: true)
  • Set InitialSymptomCount equal to the number of symptoms in selectedsymptoms.

Restart

This section is identical to Expert.Restart

  • Clear list of selectedsymptoms: remove all elements with index >= InitialSymptomCount
  • Set datatype = dtGeneral
  • Radio button rbGeneralData is checked.
  • Initialize Probabilities array of type TProbabilityArray: For each Diagnosis with Diagnosis.PC.cont<>0, add a record with
    • Pro[1]:=Log(Diagnosis.PC.continent/Sum[Diagnosis.PC.continent])
    • All other PRO[] elements zero
    • All PL[] elements zero
  • Disable btnRemoveLastArgument
  • Clear searchterm.
  • Display selectedsymptoms in grdSymptoms
  • focus on *grdSymptoms

SelectData

  • initialize datatype value from grpSelectData radiogroup.
  • if datatype is dtAll :
    • Initialize an array displayedsynonyms containing all synonyms of all Symptoms for which the property expands is empty.
    • Set lblAvailableArgs text to (string 556):
      Available arguments
      
  • if datatype is not dtAll, set lblAvailableArgs text to (string 73):
    Diagnoses
    
  • if datatype is dtDiagnose:
    • displayedsynonyms is a list of all diagnose objects with pc[continent]>=Parameters.nurseLimit
  • if datatype is not dtDiagnose or dtAll then

    • Initialize an array displayedsynonyms containing all Symptoms for which
      • the property expand equals False
      • the ttype property matches:
        • dtAnamnese : ttype=2
        • dtImagery : ttype=5
        • dtPhysReseach : ttype=3
        • dtLab : ttype=4
  • The synonyms are are ordered on synonym.sortnr

  • Show the displayedSynonyms array in grdControllerArgs.
  • Reset the searchterm string to empty.
  • In grid grdAvailableArgs, show the array of displayedsynonyms, ordered by sortNr.lang.
  • Make btnRemoveLastArgument visible.

FilterArguments

  • if the pressed key is Enter then execute SelectArgument and exit.
  • Add pressed key to searchterm (or remove last char, depending on key)
  • if the search term is empty, show all records
  • Filter the array displayedsynonyms so that
    • Only records that contain the search term (case insensitive) are shown.
    • Sort on position of the match in the search term.
    • In grid cell, display matched substring in red.
  • Show the filtered list in grid grdSymptoms,

SelectArgument

  • Clear searchterm
  • If datatype is dtDiagnose then
  • If datatype is not dtDiagnose then
    • execute action SelectSymtom
    • Set btnPowertable caption to PowerTable

SelectDiagnose

  • let MyDiagnose equal the selected diagnose in grdAvailableArgs
  • let Symcount equal 1+ the number of elements in selectedSymptoms
  • Set local variable cutoff to MyDiagnose.cutoff
  • Set local variable Lodcutoff to Log10(Custoff/(1-CutOff))
  • Let P be the probabilities record corresponding to MyDiagnose.Id
  • Set Local Variable 'prdi to P.prob[SymCount]*
  • If MyDiagnose.Id is not in clusterdiagnoses and (prdi<-2) then
    • Show Confirmation dialog with text (string 537)
      We think it is too early to make a diagnosis: do you want me to analyze your choice ?
      
    • if the user confirms, call ShowArgTooEarly
    • exit
  • if prdi<=lodCustoff then
    • Show dialog with text (string 214 )
      This is a reasonable diagnosis, but you lack evidence at this moment.
      
    • exit
  • Create a diagPower array as in CreatePowerDiagnose using MyDiagnose
  • if the number of records in diagPower is zero,
    • if the Parameters.Level='Senior' then
      • show a message (string 532)
        Congratulations, you may rely on your diagnosis
        
      • set the selectedDiagnose to MyDiagnose
      • exit.
  • if the number of records in diagPower is nonzero,
  • let sumpe be the sum of all PE values in diagPower
  • let prdiff equal prdi - log10(sumpe)
  • if power(10, prdiff)/(1+power(10, prdidiff))<cutoff then
    • Show message (string 529)
      You reached the threshold, but it could be that some findings will lower the probability of this disease considerably. Please go on exploring the case
      
    • exit
  • if the Parameters.Level='Senior' then
    • show a message (string 532)
      Congratulations, you may rely on your diagnosis
      
    • set the selectedDiagnose to MyDiagnose
    • exit
  • Create an array AlternateDiagnoses of TDiagnose objects from probabilities array
    • For Records matching the following criteria
      • Diag.Cutoff<Parameters.treshold
      • Prob[Symcount+1]>-2
      • Diag<>MyDiagnose
  • For each record D in AlternateDiagnoses do
    • Create a diagPower array as in CreatePowerDiagnose using D
    • Get the symptom with max PC value from diagPower.
    • Get the symptom with max PE value from diagPower.
    • let MCE be the maximum of the PC and PE value.
    • if MCE>Parameters.Powerlimit then
      • Show a dialog with text: (strings 530, 531)
        You reached the threshold, but {{D.Name.Language}} has not been explored sufficiently.
        Some major arguments remain available. Please check them, and try again.
        For help, consult the powertable.
        
      • exit
  • Increase Score.DiagCorr with 1.
  • show a message (string 532)
    Congratulations, you may rely on your diagnosis
    
  • set the selectedDiagnose to MyDiagnose

CreatePowerDiagnose

  • Parameter MyDiagnose (TDiagnose)

  • Initialize an empty array Result of type TDiagPowerArray

  • Loop over Assocation records:
    • For any record A that matches the following criteria:
      • A.diagId equals MyDiagnose.id
      • A.symId is not in selectedSymptoms symptom ids.
      • A.symId is not in any symptom selectedSymptoms implies ids.
      • A.symId is not in any symptom selectedSymptoms excludes ids.
      • A.symId is not in any symptom selectedSymptoms maycause ids. (check 2 directions)
      • symptom.ttype>0
      • Calculate PC, PE, prev calculate from CalculatePCPE using the A record. PE must be >= 10
    • Add a record to Result with
      • Diagnosis the A.diagId diagnose
      • Symptom the A.symId symptom
      • PC, PE prev as calculated from CalculatePCPE using the A record.

CalculatePCPE

see calculation of same name in Expert.CalculatePCPE

SelectSymptom

  • let SelectArgument equal the selected symptom in grdAvailableArgs
  • if the SelectArgument is already in selectedSymptoms then show message (string 435)
    This argument is already in the list
    
    Exit
  • if there are more than 58 symptoms in selectedSymptoms array, show a message
    Too many arguments
    
    exit action.
  • Calculate IsExpandable:
    • if the selected symptom id is in the expands list but not in the contcons list then IsExpandable is true
    • Else IsExpandable is false
  • if IsExpandable is True then
    • if the selected symptom id is not in the contcons list then:
      • if there are more than 58 symptoms in selectedSymptoms array, show a message (string 447)
        The requested argument is an expandable. Expansion might extend the number of arguments over 60, which is not allowed.
        
        exit action.
    • Call SelectArgumentExpandable
  • if IsExpandable is False, then

SelectArgumentExpandable

  • Argument: UseSymptom symptom to use.
  • Set CostChecked to false
  • Create list of IDS expandids: all values [expands.expandSymId] for which expands.SymID equals UseSymptom.id
  • Populate an array expandSymptoms (of type TExpandSymptomArray) with objects TExpandSymptom.
    • Source for symptoms that match the following criteria:
      • associated with SelectedDiagnose
      • present in *expandids
      • not present in selectedSymptoms
    • The fields are filled as follows:
      • Symptom: The matched symptom.
      • image : true
      • done: false
      • sens : Association.Sens.Continent
  • Let symcount equal 1+Number of elements in selectedsymptoms
  • Construct an array CandidateDiagnoses of TDiagnose records:
    • Let P be each element in Probabilities array
    • if P.Prob[symcount]>-2 then add P.Diagnose to CandidateDiagnoses
    • All diagnoses from diagnosID array
  • Construct an array CandidateSymptoms of TCandidateSymptom* records:
  • loop over CandidateDiagnoses
    • Loop over associated records
      • if a association.Symptom exists in selectedSymptoms skip it.
      • if a association.Symptom exists in expandsymptoms skip it.
      • if a association.Symptom does not exist in array CandidateSymptoms add it with Association.sens.continent
      • if a association.Symptom already exists in array CandidateSymptoms (call it rec) then: if Association.sens.continent is smaller than rec.sens, set rec.sens to Association.sens.continent
  • Add all CandidateSymptoms to expandSymptoms, set done to false, image to false.
    The fields are filled as follows:

    • Symptom: The symptom field from candidatesymptom record.
    • image : false
    • done: False
    • sens : The sens field from candidatesymptom record.
  • if the array expandSymptoms is empty then

    • Increase Score.dnotIntel with 1
    • execute action ShowDiags
    • Clear search fields
    • exit action.
  • Remove each record in expandSymptoms that matches the following criteria:
    • Symptom is present in the excludes of one Of the selectedSymptoms symptoms.
    • Symptom is present in the implies of one Of the selectedSymptoms symptoms.
  • Pick a random record from the expandsymptoms and
    • if CostChecked is false and CalculateNoCost (selected symptom) returns true then exit action;
    • Set CostChecked to true.
    • Remove record from array
  • For all records in expandSymptoms set image equal to false for records that match the following:
  • Symptom.Bitmap is true
  • Symptom.ttype in [4,5]
  • For each record R in expandSymptoms that matches the following criteria:
    • R.Image=True
    • R.Done=False
    • R.Symptom is not in excludes of a record in selectedSymptoms
    • R.Symptom is not in implies of a record in selectedSymptoms
    • Call AddChild with R.Symptom
    • Set R.Done:=True
  • Add UseSymptom.ID to contcons array.
  • Call AddNotPresentExpandChildren with expandsymptoms array.
  • Call SelectData

AddChild

  • Argument: useSymptom (TSymptom)
  • If BitmapShown is False then
  • If UseSymptom.Bitmap in [1,4] and UseSymptom.ttype in [4,5] then
    • Call action ShowImage with UseSymptom and true as parameters.
    • Set BitmapShown to true
  • else show message (string 180)
    'Yes, indeed, your patient has got this argument' + *useSymptom.Name.Language*
    
  • Call AddSymptom with arguments useSymptom and true.

AddNotPresentExpandChildren

  • Argument: expandSymptoms (TExpandSymptomArray)
  • For every record ES in expandSymptoms which matches the criteria:
    • image=false
    • done=false
    • Symptom is not in excludes or implies of selectedSymptoms
      Do the following:
    • if CostChecked is false and CalculateNoCost (selected symptom) returns true then exit action;
    • Set CostChecked to true.
    • If BitmapShown is False then
      • If UseSymptom.Bitmap in [1,4] and UseSymptom.ttype in [4,5] then
        • Call action ShowImage with UseSymptom and false as parameters.
        • Set BitmapShown to true
    • show message (string 439)
       Your patient does not present this argument' + useSymptom.Name.Language
      
    • Call AddSymptom with arguments useSymptom and False.
    • Set ES.done to true.

SelectArgumentNonExpandable

  • Argument: UseSymptom symptom to use.
  • let plus=false
  • check if there exists an Association with SymId=UseSymptom.id and diagID=SelectedDiag.id*.
  • If such an association exists, then set plus to true
  • if no such association exists then construct an array of diagnoses:
    • All diagnoses in array Probabilities with last probability >-2
    • All diagnoses in selecteddiagnoses
    • if one of the associations from these diagnoses has a symId equal to UseSymptom.id then:
      • set plus to false
    • if there is no such association then
      • Increase Score.dnotIntel with 1
      • execute action ShowDiags
      • Clear search fields
      • exit action.
  • if CostChecked is false and CalculateNoCost(UseSymtom) (see CalculateNoCost returns True, then exit action.
  • Set CostChecked to true.
  • If BitmapShown is False then
  • If UseSymptom.Bitmap is true and UseSymptom.ttype in [4,5] then
    • Call action ShowImage with UseSymptom and plus as parameters.
    • Set BitmapShown to true
  • Increase Score.dIntel with 1.
  • calculate userMessage:
  • if plus is true then (string 180)
    userMessage :='Yes, indeed, your patient has got this argument' + *useSymptom.Name.Language*
    
  • if Plus is False then (string 439)
    userMessage :='Your patient does not present this argument' + *useSymptom.Name.Language*
    
  • Show UserMessage
  • Call action AddSymptom with UseSymtom and plus

AddSymptom

  • Has a parameter useSymptom
  • Has a parameter Present of type boolean.
  • if there are 58 symptoms in selectedSymptoms array, show a message
    Too many arguments
    
    exit action.
  • Determine symptom from selected row in grid grdSymptoms.
  • If the selected symptom is already in the selectedSymptoms array, show a message (string 438)
    Argument already in list
    
    exit action.
  • if the selected symptom is in the excludes of one of the symptoms of in the selectedSymptoms array, show a message:
    [mesexcl] {excl.name} [mesexc2] symptom.name [mesexc3]
    
    exit the action.
  • if the selected symptom is in the implies of one of the symptoms of in the selectedSymptoms array, show a message:
    [mesimpl] {excl.symptom.name} [mesimpl2] symptom.name
    
    exit the action.
  • add selected symptom in to selectedSymptoms array:
  • symptom equal to selected symptom.
  • isPresent equal to action parameter present
  • Display symptoms from selectedSymptoms in grdSelectedSymptoms
  • Calculate diagnosis probabilities as in CalculateProbabilities, passing the symptom and Not IsPresent as parameters .
  • Call UpdateClusterDiagnoses passing the symptom and IsPresent as parameters .
  • Execute SelectData action.
  • Show selectedSymptoms in grid grdControlledArgs.

CalculateProbabilities

Identical to Expert.CalculateProbabilities

CalculateClusterDiagnoses

  • Parameter MySymtom : TSymptom.
  • If the number of elements in selectedSymptoms is 2 or less then
  • Set clusterdiagnoses to the list of associated diagnoses from MySymtom.
  • If the number of elements in selectedSymptoms is > 2 then
  • Remove from clusterdiagnoses all diagnoses not in the list of associated diagnoses from MySymtom.

ShowImage

  • Parameter: UseSymtom a TSymptom
  • Parameter: Plus a boolean.
  • Call CalculatePictureID with useSymptom and plus, store its result in ImageID
  • If ImageID is positive then
  • Show modal form PictureForm
  • Pass ImageID to form.

CalculateNoCost

  • Parameter Symptom
  • initialize Result to false;
  • If Symptom.cost<=0 then exit function.
  • Calculate RealCost:
    RealCost:=Cost*fatConv*bef;
    
  • Calculate AvailableBudget:
    AvailableBudget:=Score.Budget*Scored.Bef*fatConv;
    
  • If AvailableBudget equals zero:
    • Show message:
      Sorry, your budget is finished
      
    • exit function
  • If AvailableBudget<RealCost then
    • Show message:
      Your budget is too low for this
      
    • exit function
  • Show Yes/No confirmation message:
    This test costs {{RealCost}}. Do you wish to use it now.
    
    (The strings before and after {{RealCost}} are 378 and 374)
  • If the user selected Yes then adapt budget:
    Score.Budget:=Score.Budget-RealCost
    
  • If the user selected No, set Result to False

HandleTreshold

  • Show Modal form CutoffInfo
  • Pass Probabilities and selectedsymptoms

RemoveLastArgument

  • set symCount equal to count of elements in selectedsymptoms
  • If the number of symptoms is equal to InitialSymtomCount then exit.
  • in Probabilities array, set pl[symCount] and prob[symcount] to zero for all records.
  • Remove the ID of the last added element from constcons.
  • Remove last added element from selectedsymptoms
  • set symCount equal to count of elements in selectedsymptoms (should be previous value -1)
  • Recreate clusterdiagnoses.
  • If the symCount is zero, then
  • Disable btnRemoveLast
  • Disable btnRestart
  • Disable btnPowertable
  • Make lblAdding invisible
  • Make lblSearchHint visible.
  • Redisplay grid grdDiagnoses, show the probability records with Prob[symCount] > -2
    • In column 1 : 100*Procent(Prob[symCount])
    • In Column 2 : Diagnose.Name.Lang order by descending Prob[symCount]
  • If the number of symptoms is equal to InitialSymtomCount then disable btnRemoveLast

TogglePowerTable

Identical to Expert.TogglePowerTable

ShowDiags

  • Set result to False
  • Show a modal dialog SelectAlternateDiagnose
  • If the SelectAlternateDiagnose dialog was exited with the OK button:

    • Increase Score.dnotIntel with 1
    • Show the DifferentialDiagnose dialog with following data:
      • Pass selectedSymptoms from this form.
      • Pass SelectedDiagnose from the SelectAlternateDiagnose dialog.
      • Let symcount be the number of elements in selectedSymptoms
      • calculate diagProbability as:

        • Let P be the TProbability record matching SelectedDiagnose.
        • calculat rawProb:

           rawprob:=Power(10,P.Prob[SymCount+1])
          

        • calculate DiagProbability:

          DiagProbability:=100*(rawprob / (1+rawprob))
          
          * Let rankValues be an array of float values. Fill it with the Prob[SymCount+1] values in probabilities array where
          Prob[SymCount+1]>DiagProbability
          
          * calculate DistinctValues: the number of distinct values in RankValues. * calculate Rank as:
          Rank:=1+DistinctValues;
          
          * Pass DiagProbability as Probability to DifferentialDiagnose

  • Clear searchtext

  • exit

Exit

  • Show confirmation dialog with text (string 488)
    Do you want to see the diagnosis ?
    
  • If the user confirms, show form ConsultationHistory
  • pass to form selecteddiagnose selectedsymptoms and the probabilities record matching selecteddiagnose
  • pass wasloaded=true to the dialog if the consultation was started with a load of a simulaton.
  • pass wasloaded=false to the dialog if the consultation was not started with a load of a simulaton.

  • If the user does not confirm,

  • if the form was not started with loading a simulation, navigate to StartConsultation:
    #/startconsultation/{{selectedDiagnose.id}}
    
  • if the form was started with loading a simulation, navigate to SelectDiagnose:
    #/selectdiagnose
    

CalculatePictureID

  • Parameter: useSymptom (TSymptom)
  • Parameter: plus (boolean)
  • Set result equal to -1
  • set imagepath string to empty string.
  • Calculate subject string:
    • if symptom 81 is in selectedSymptoms then set subject to 'adult man'
    • if symptom 136 is in selectedSymptoms then set subject to 'adult woman'
    • if symptom 110 or symptom 98 is in selectedSymptoms then set subject to 'CHILD'
    • else set subject to empty string. (should in fact not happen)
  • if plus equals true then
    • if UseSymptom.Bitmap equals 4 then find a record from list of images (ImageInfo) matching the following criteria:
      • cat equals 'clin'
      • symId equals useSymptom.id
      • diagId equals selectedDiagnose.id
      • cont equals parameters.Continent
      • age equals subject or the string 'indifferent' Set imagepath to path
    • If UseSymptom.Bitmap does not equal 4 then find a record from list of images (ImageInfo) matching the following criteria:
      • cat equals 'clin'
      • symId equals useSymptom.id
      • path differs from 'non presente': if a record is found, examine it's path field:
        • if path differs from 'differente' then:
          • set imagepath equal to path
        • else find a record from list of images (ImageInfo) matching the following criteria:
          • cat equals 'subj'
          • subj equals subject
          • if a record is found, set imagepath equal to path
  • if plus equals false then

    • find a record from list of images (ImageInfo) matching the following criteria:
      • cat equals 'neg'
      • symId equals useSymptom.id
    • if a record is found, examine its path:
      • if path is 'Random Stools NP*' then:
        • select a random record from list of images (ImageInfo) with cat 'stool'
        • set imagepath to path
      • if path is 'Rxdifferente' then
        • select a record from list of images (ImageInfo) with following criteria:
          • cat equals 'rx'
          • subj equals subject
          • path differs from 'non presente'
        • if a record is found, set imagepath equal to path
      • if path is 'TkNEGLOOP' then
        • Choose random path from one of:
          Microscopy\thick bloodsmear\Negative and Non-pathogens\Non-pathogens thick bloodsmear
          Microscopy\thick bloodsmear\Negative and Non-pathogens\Negative thick bloodsmear
          
        • set imagePath equal to the chosen path.
      • if path is 'KnotNegLoop' then
        • Choose random path from one of:
          Microscopy\Knott - nucleopore\Knott - nucleopore non-pathogen and negative\Knott - nucleopore Mansonella perstans
          Microscopy\Knott - nucleopore\Knott - nucleopore non-pathogen and negative\Knott - nucleopore negative
          
        • set imagePath equal to the chosen path.
  • if ImagePath is empty, then show a message:

    • if plus is true then show message (string 254, string 256)
      The image is not yet present at this moment, but we hope we will find one in the near future. {{useSymptom.Name}} is positive
      
    • if plus is false then show message (string 254, string 255)
      The image is not yet present at this moment, but we hope we will find one in the near future. {{useSymptom.Name}} is negative
      
    • exit the action
  • from ImagePath construct an array of records PossibleImages matching the following criteria:
  • p contains imagepath
  • if the array PossibleImages is non-empty, then pick a random image from the list which differs from Parameters.LastRandomImageId, and set Result to the ID of the chosen record.
  • save Result as Parameters.LastRandomImageId

SaveSimulation

  • Pop up a modal form to ask for a simulation name simulationName
  • if user cancels, exit action.
  • Create a TSimulation object
  • Add 5 URL parameters to the simulation
    • name: simulationName
    • diagId : DIAG
    • subjId : GENDER
    • acuteSymId : ACUTE
    • sym1Id : SYMPTOM1
    • sym2Id : SYMPTOM1
    • symptoms : copy all selectedsymptoms in this array.
  • Let MaxSimulationId equal to the Highest ID in SimulationList (load from localstorage).
  • Let NewSimulationId equal to MaxSimulationId+1
  • Add NewSimulationId to SimulationList (save to localstorage).
  • Write stringified version of TSimulation object to localstorage with name `Simulation_{{*NewSimulationID}}``

LoadSimulation

  • Load stringified version of TSimulation object to localstorage with name Simulation_{{*SimulationID}} into Simul
  • Insert Simul.subjId symptom in selectedsymptoms using AddSymptom (present: true)
  • if Simul.AcuteId is in [104, 112, 8] then insert Simul.acuteId symptom in selectedsymptoms using AddSymptom (present: true)
  • Set InitialSymptomCount to the number of elements in selectedsymptoms
  • for all elements sym in Simul.symptoms:
    • if the symptom is not in selectedsymtoms then:
      • insert the symptom in selectedsymptoms using AddSymptom (present: sym.present)

ShowClusterInfo

ShowGraphic

  • Show Graphic modal dialog using the selected symptoms and probabilities:
  • probabilities
  • selectedsymptoms.

ShowLecture

  • Save form state
  • Navigate to route
    #/lecture/return/consultation
    

ShowArgTooEarly

  • Argument aDiagnose (TDiagnose)
  • Let symCount equal the number of symptoms +1
  • Let P be the probabilities record corresponding with aDiagnose
  • Let prdi equal Prob.Pro[SymCount]
  • Let Pct equal 100 * Procent(prdi)
  • Let rank equal 1+ (the number of distinct values in probabilities with Pro[SymCount] larger than prdi).
  • Show DifferentialDiagnose form with
  • SelectedSymptoms
  • aDiagnose
  • rank
  • pct