none
Problem creating new Medication Record RRS feed

  • Question

  • using Microsoft.Health;  
    using Microsoft.Health.ItemTypes;  
    using Microsoft.Health.Web;  
     
    using System;  
    using System.Data;  
    using System.Configuration;  
    using System.Collections.ObjectModel;  
    using System.Collections.Generic;  
     
    using System.Web;  
    using System.Web.Security;  
    using System.Web.UI;  
    using System.Web.UI.WebControls;  
    using System.Web.UI.WebControls.WebParts;  
    using System.Web.UI.HtmlControls;  
    public partial class hvMeds : HealthServicePage  
    {  
        Meds meds = new Meds();  
     
        protected void Page_Load(object sender, EventArgs e)  
        {  
            if ((Meds)Session["meds"] != null) {  
                meds = (Meds)Session["meds"];  
                sendData();  
            }  
        }  
     
        protected void sendData() {  
            MedicationOld hvMeds = new MedicationOld();  
            //Medication hvMeds = new Medication();  
            ApproximateDateTime approxStart = new ApproximateDateTime(meds.Start.ToString());  
            ApproximateDateTime approxEnd = new ApproximateDateTime(meds.End.ToString());  
            double doseValue = Convert.ToDouble(meds.Dose);   
            hvMeds.Name = meds.Name;  
            hvMeds.DatePrescribed = approxStart;  
            hvMeds.DateDiscontinued = approxEnd;  
            hvMeds.DoseValue.ExactDose = doseValue;  
            PersonInfo.SelectedRecord.NewItem(hvMeds);  
        }  
     

    Aside from Medications being replaced by MedicationOld...there must be a problem with the above code, I am redirected to the HV login page as I expect and then returned to my application with no errors...yet no Medication record is added. 

    How can I tell what is going on?

     

    Tuesday, January 13, 2009 8:18 PM

Answers

  •  Ah. We have failed in communicating a very important piece of information to you.

    All new and modified types are contained in the Microsoft.Health.ItemTypes.dll, so you will need to add that one to your project to see the new medication type.

    Sorry about that.
    • Marked as answer by PyroPenguin Wednesday, January 21, 2009 2:00 PM
    Friday, January 16, 2009 6:28 PM
  • The Name is required, so you will need to put something there.  I would suggest something that best fits your scenario - if it's a doctor on staff, perhaps something like "Staff Doctor"...

    • Marked as answer by Eric Gunnerson Tuesday, January 20, 2009 4:40 PM
    Monday, January 19, 2009 9:09 PM

All replies

  • The code looks like it should work, and you indicate that you aren't getting an error.

    How are you checking whether the item is added?

    Wednesday, January 14, 2009 1:26 AM
  • I am signing into my test account at HealthVault Development and Test Environment.
    When I access my test client, there is no activity for either that day or type.  I have another section of my test code that adds allergies and I have no problems with that code.

    Is there a minimum data set needed for a new record?  I have not played with the redirect keys much, is there a way to see if I am getting a return code from HV?

    Thanks for the help...
    Wednesday, January 14, 2009 1:07 PM
  • What happens if the code that you use to add a medication does a query right afterwards to see if it made it into the record?
    Wednesday, January 14, 2009 6:53 PM
  • protected void sendData() {   
            MedicationOld hvMeds = new MedicationOld();   
            double doseValue = Convert.ToDouble(meds.Dose);    
            hvMeds.DoseValue.ExactDose = doseValue;   
            PersonInfo.SelectedRecord.NewItem(hvMeds);   
    Initially I was getting a NULL reference when I attempted to query the meds.  Then I noticed something odd...if I went to my test page a 2nd time and attempted to send the same meds record, I got an UnhandledNULLException when assigned the doseValue variable to DoseValue.ExactDose.

    I commented out that line and was able to create a partial meds record.  The variable doseValue did indeed hold an integer so I am not sure what when wrong.  I guess I need to keep playing around with MedicationOld to figure out what I need to use for my app.

    However if I go to https://account.healthvault-ppe.com/default.aspx I get this message when I can see the new record and see the med name...but when I attempt to view the details of the record, I get this message:
    Unable to show data
    We're sorry. HealthVault is currently unable to display the detailed data for this item. However, the data is stored in HealthVault and is available for use in the HealthVault-enabled application you used to create it.

    • Edited by PyroPenguin Wednesday, January 14, 2009 8:00 PM additional information
    Wednesday, January 14, 2009 7:55 PM
  • Let me ask a different questions...because maybe I was setting the wrong data.  When I manually create a new MEDS record, this is the default data that you can see on the test server:
    • Name - MedicationOld.Name String
    • Generic Name - <could not find>
    • Dose - MedicationOld.DoseValue, DoseValue appears to be a double, but I am not completely sure & MedicationOld.DoseUnit CodableValue
    • Strength - MedicationOld.StrengthValue int? & MedicaionOld.StrengthUnit CodableValue
    • Frequency - MedicationOld.Frequency String
    • Indication - MedicationOld.Indication String
    • Date Started - Medication.DatePrescribed ApproximateDateTime, although I am not sure I can cast it like this...
      new ApproximateDateTime(datatimeVar.ToString());
    • Prescribed By - <could not find>

    Given the above, how to I set the DoseValue it casting a double doesn't seem to work or throw an error?
    Also, how do I go from a DateTime variable to an ApproximateDateTimevariable if the above cast doesn't work or throw an error?


    Wednesday, January 14, 2009 8:46 PM
  • Is there a particular reason that you are using MedicationOld rather than medication? Our recommendation is that applications always use the highest version of a type when possible.

    You are having trouble with DoseValue because DoseValue is a class, so you have to write:

    hvMeds.DoseValue = new DoseValue(doseValue);

    As for the partial data, that may be a problem in our data transforms. If you could tell me exactly what data you put in to get the partial record, I can look into it.

    Thursday, January 15, 2009 5:29 PM
  • I am currently using MedicationOld because it is my only option.  I downloaded and installed the SDK on 01/12.  Since then my original references to Medication.something have been invalid and I can only use MedicationOld.something.  The versions of Microsoft.Health.dll and Microsoft.Health.Web.dll are both 0.13.1864.3516.  Am I on an incorrect version of the SDK?

    Thanks for the catch on DoseValue...I was stuck at DoseValue.ExactDose versus Double and missed the obvious.
    As for what I am trying to upload...Just Name, DatePrescribed, DateDiscontinued and DoseValue.

    I would send a screenshot, but I am not sure how to attach it to a forum posting.
    Thursday, January 15, 2009 8:36 PM
  • We did change some things when we updated medication, which will require you to change some of your code. I think that you'll find that the way that the new medication type works is a fair bit better than the old one. If you have specific questions about how to map your code to use the new one, I'd be happy to help.
    Friday, January 16, 2009 12:52 AM
  • For starters, what is the type that I should use?  According to the Object Browser with C# these are the available types that seem to be related to medication/drugs in some manner:
    AsthmaInhaler
    AsthmaInhalerUse
    DailyMedicationUsage
    Immunization
    InsulinInjection
    InsulinInjectionMeasurement
    InsulinInjectionUse
    MedicationOld

    There is no Medication or Prescription type that I can see.
    Friday, January 16, 2009 4:06 PM
  •  Ah. We have failed in communicating a very important piece of information to you.

    All new and modified types are contained in the Microsoft.Health.ItemTypes.dll, so you will need to add that one to your project to see the new medication type.

    Sorry about that.
    • Marked as answer by PyroPenguin Wednesday, January 21, 2009 2:00 PM
    Friday, January 16, 2009 6:28 PM
  • What a difference that made!  With a little playing I was able to upload a Medication record into HealthVault...
    Thank you Eric!

    I do have a 1 question about the types...what is the purpose of ApproximateDateTime and why can't we cast a DateTime into it?  The only way I got it to work seems a little kludgy...hopefully I did it wrong.  Is this the way to get a DateTime into an ApproximateDateTim?
    Int32 intYear = new Int32(); 
    Int32 intMonth = new Int32(); 
    Int32 intDay = new Int32(); 
    Int32 intDose = new Int32(); 
    intYear = Convert.ToInt32(meds.Start.ToString("yyyy")); 
    intMonth = Convert.ToInt32(meds.Start.ToString("MM")); 
    intDay = Convert.ToInt32(meds.Start.ToString("dd")); 
    ApproximateDate approxStartDt = new ApproximateDate(intYear, intMonth, intDay); 
    ApproximateDateTime approxStart = new ApproximateDateTime(approxStartDt); 
    hvMeds.DateStarted = approxStart

    Friday, January 16, 2009 9:05 PM
  • Glad that that worked for you.

    The purpose of ApproximateDateTime is to support cases where there isn't full information but there is still useful information. For example, using that you can capture the fact that somebody had a heart attack about 5 years ago.

    I ran into the same issue WRT approximate date time and not having an easy way to put a DateTime into it just this week. We will fix it in a future release. For now, here's what I write:


            ApproximateDateTime exerciseDataTimeApprox =
                new ApproximateDateTime(
                    new ApproximateDate(exerciseDateTime.Year, exerciseDateTime.Month, exerciseDateTime.Day),
                    new ApproximateTime(exerciseDateTime.Hour, exerciseDateTime.Minute, exerciseDateTime.Second));

    Friday, January 16, 2009 10:30 PM
  • Thanks for all your help...I am almost done with what I need for Medications.  However I might have a problem with my medication dataset that I am sending to HealthVault...I have the name of the Agency that prescribed the medication but not always the name of the doctor that made the prescription.
    It appears to get the agency name in, I need to create a PersonItem Class for the Prescription Class.  However I get a runtime error because I am not setting the name  before creating/updating the contact item.

    Is there a way to set Medication.Prescription.PrescribedBy.Organization without setting Medication.Prescription.PrescribedBy.Name?
    Will I need to set sometype of dummy value?
    Saturday, January 17, 2009 3:21 PM
  • The Name is required, so you will need to put something there.  I would suggest something that best fits your scenario - if it's a doctor on staff, perhaps something like "Staff Doctor"...

    • Marked as answer by Eric Gunnerson Tuesday, January 20, 2009 4:40 PM
    Monday, January 19, 2009 9:09 PM
  • Thanks again Eric, I was able to successfully summit my medication data into HealthVault.

    Wednesday, January 21, 2009 2:01 PM