Assistance in how to Query an Record and Update the same record using Ruby on Rails

I am a newbie to RoR
I have this problem which I will represent in psuedocode - it
describes the allocation of a randomisation number to a patient
participating in a clinical trial at a particular hospital site.

  1. User (Doctor) logs on on with username: JBLOGGS
  2. Based on his username - system returns him a dropdownlist of
    SITE_ID’s that he has access to (previously set up in a database table
    eg. USER_SITES (SITE_ID, USERNAME) -
  3. User selects a site available to him. eg 90001
  4. User enters INITIALS of patient
  5. User press SUBMITT button
  6. The system will get the next available RANDOMISATION record
    (retrieved in ascending order of the RAND_SEQ number) which has a
    unique RAND_NUMBER and DRUG_KIT_NUMBER.
  7. The inputed INITIALS will be updated in RANDOMISATION record,
    similarly the CREATED_BY and CREATED_DATE fields
  8. System returns a screen containing USERNAME, SITE_ID, INITIALS,
    RAND_NUMBER, DRUG_KIT_NUMBER to the User - this information will be
    recorded in patient notes on another system.

Assumptions:

  1. If the SITE_ID and INITIALS field if not null - then the
    RANDOMISATION record is used already and not available.

TABLE STRUCTURES:

USER_SITES (SITE_ID, USERNAME);

RANDOMISATION (RAND_SEQ, RAND_NUMBER, DRUG_KIT_NUMBER, SITE_ID,
INITIALS, CREATED_BY, CREATED_DATE);

If anyone can assist me in anyway - I would be most grateful.

Kind Regards from DownUnder (New Zealand)
Mervyn

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs