Medico - Medicine Class Format

From GaProgMan's Wiki
Jump to: navigation, search

This page represents the medicine class format of the medico project. For an in-depth description of the other parts of medico, please see the medico design document pages.

Class Design

The Medicine Class Format will be the ubiquitous file format used with medico. Instances of this class will be used to set up alarms and notifications. The following is a language agnostic version of the class format (for a C-like language)

public class Medication {

  public int MedicationId;
  public string HumanReadableName;
  public string MedicalName;

  public int PerscribedDosage; // in mg, most likely
  public int TimeBetweenDoses; // in minutes

  public int MaximumNumberOfDoses;

  public Time InitialDoseTime;

  // contains a list of calculated times
  public Time[] CalculatedDoseTime;
  // times are moved from the above into here, once actioned
  public Time[] ActionedDoseTimes;

  public DateTime MedicationAddedDate;
  public DateTime MedicationNoLongerActiveDate;
  
  public bool MedicationActive;

  public string Notes; 
}

This is likely to change as planning continues and flaws are found. For instance, a separate class for Calculated/Actioned times can be added which may look like this:

public class CalculatedTime {

  public int CalculatedTimeId;
  public int MedicationId;

  public Time CalculatedTimeValue;

  public bool HasBeenActioned;
  public Time? TimeActioned;

  public string Notes;
}

This would lead to greater granularity in creating and actioning times, and storing them with auditing data into the database.

XML Schema

One of the valid formats for the Medicine Class to be serialised into is XML. The following is a copy of the schema for the Medicine Class Format:

<?xml version="1.0" encoding="UTF-8" ?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
  
  <annotation>
    <documentation xml:lang="en">
      Initial design for Medico XML schema. This schema will be used to
      validate the serialised objects as they are written to XML and the
      de-serialised objects read from XML.
    </documentation>

  <xs:elememt name="medication">
    <xs:complexType>
      <xs:sequence>

        <xs:element name="medicationActive" type="xs:string"
              maxOccurs="1" minOccurs="1">
          <xs:annotation id="medication.medicationActive">
            <xs:documentation xml:lang="en">
              Whether the medication should be listed as being
              actively taken. If this is set to false, then no
              alarms will be created for this medication.
              Developer note: This shouldn't be a free text value
              in the finally version. The final version should be
              an xs:boolean representing whether the medication
              is active.
            </xs:documentation>
          </xs:annotation>
        </xs:element>

        <xs:element name="readableName" type="xs:string"
              maxOccurs="1" minOccurs="1">
          <xs:annotation id="medication.readableName">
            <xs:documentation xml:lang="en">
              The human readable name of the medication.
              Developer note: Perhaps there should be some input
              checking to ensure that nothing can be passed to
              the database/filestore backend which could be harm-
              ful?
            </xs:documentation>
          </xs:annotation>
        </xs:element>

        <xs:element name="medicalName" type="xs:string"
              maxOccurs="1" minOccurs="1">
          <xs:annotation id="medication.medicalName">
            <xs:documentation xml:lang="en">
              The medical readable name of the medication. Useful
              for identifying the medication by the name on the
              packaging.
              Developer note: Perhaps there should be some input
              checking to ensure that nothing can be passed to
              the database/filestore backend which could be harm-
              ful?
            </xs:documentation>
          </xs:annotation>
        </xs:element>

        <xs:element name="prescribedDosage" type="xs:string"
              maxOccurs="1" minOccurs="1">
          <xs:annotation id="medication.prescribedDosage">
            <xs:documentation xml:lang="en">
              The prescribed dosage for the medication. Initially,
              this will be a free text value.
              Developer note: This shouldn't be a free text value
              in the finally version. The final version should be
              an integer representing the mg per dosage
            </xs:documentation>
          </xs:annotation>
        </xs:element>

        <xs:element name="timeBetweenDoses" type="xs:string"
              maxOccurs="1" minOccurs="1">
          <xs:annotation id="medication.timeBetweenDoses">
            <xs:documentation xml:lang="en">
              The time (in minutes) between each dosage; will be
              used to set appropriate alarms
              Initially, this will be a free text value.
              Developer note: As with prescribedDosage, this shouldn't be
              free text once released. The final version should
              be an integer representing the number of minutes
              between dosages (perhaps the UI should have an
              enumerated multiplier [hours] ? )
            </xs:documentation>
          </xs:annotation>
        </xs:element>

        <xs:element name="maximumDosages" type="xs:string"
              maxOccurs="1" minOccurs="1">
          <xs:annotation id="medication.maximumDosages">
            <xs:documentation xml:lang="en">
              The maximum number of doses the user is permitted
              to take. This will be used to set the correct numb-
              er of alarms.
              Initially, this will be a free text value.
              Developer note: This shouldn't be a free text value
              in the finally version. The final version should be
              an integer representing maximum number of times that
              the user is permitted to take the medication.
            </xs:documentation>
          </xs:annotation>
        </xs:element>

        <xs:element name="initialDoseTime" type="xs:string"
              maxOccurs="1" minOccurs="1">
          <xs:annotation id="medication.initialDoseTime">
            <xs:documentation xml:lang="en">
              The time of the first dose for each day. This will
              be used as to set the first alarm, and to base the
              rest of the alarm times on.
              Initially, this will be a free text value.
              Developer note: This will not be a free text value
              in the finally version. The final version will be
              of xs:time type.
            </xs:documentation>
          </xs:annotation>
        </xs:element>

        <xs:element name="plannedDosagesTimes" type="xs:string"
              maxOccurs="1" minOccurs="1">
          <xs:annotation id="medication.plannedDosagesTimes">
            <xs:documentation xml:lang="en">
              The calculated dosage times (based on the initial
              dose time, maximum number of dosages and time bet-
              ween dosages). This shall be a comma separated list
              of strings which represent time value.
              Initially, this will be a free text value.
              Developer note: The value here should be checked
              before being used, and if there is an issue, then
              it should not be used.
            </xs:documentation>
          </xs:annotation>
        </xs:element>

        <xs:element name="actionedDosageTimes" type="xs:string"
              maxOccurs="1" minOccurs="1">
          <xs:annotation id="medication.actionedDosageTimes">
            <xs:documentation xml:lang="en">
              As protection against application crashes, the med-
              ications which the user marks as having been taken
              are added to this comma separated list. This list
              contains times of all medications which have been
              taken. When ever an alarm is dismissed, this list
              is updated and written to database/filestore.
              Initially, this will be a free text value.
              Developer note: The value here should be checked
              before being used, and if there is an issue, then
              it should not be used.
            </xs:documentation>
          </xs:annotation>
        </xs:element>

        <xs:element name="medicationAddedDate" type="xs:string"
              maxOccurs="1" minOccurs="1" >
          <xs:annotation id="medication.medicationAddedDate">
            <xs:documentation xml:lang="en">
              The date when this medication was added. This will
              be used to keep track of how many doses the user
              has taken during the life time of the prescription.
              Developer note: This will not be a free text value
              in the finally version. The final version will be
              of xs:date type.
            </xs:documentation>
          </xs:annotation>
        </xs:element>

        <xs:element name="medicationNoLongerActiveDate" type="xs:string"
              maxOccurs="1" minOccurs="1" >
          <xs:annotation id="medication.medicationNoLongerActiveDate">
            <xs:documentation xml:lang="en">
              The date when this medication was set to no longer
              active. This will be usful in the full version of
              the application for logging all prescribed medicat-
              ion that has been trialed and taken during a course
              of treatment.
              Developer note: This will not be a free text value
              in the finally version. The final version will be
              of xs:date type.
            </xs:documentation>
          </xs:annotation>
        </xs:element>

        <xs:element name="notes" type="xs:string"
              maxOccurs="1" minOccurs="1" >
          <xs:annotation id="medication.notes">
            <xs:documentation xml:lang="en">
              Any notes that the user would like to attach to the
              medication.
              Developer note: Perhaps there should be some input
              checking to ensure that nothing can be passed to
              the database/filestore backend which could be harm-
              ful?
            </xs:documentation>
          </xs:annotation>
        </xs:element>

      </xs:sequence>
    </xs:complexType>
  </xs:elememt>

</xs:schema>

JSON Schema