In the end we decided not to use HealthVault but we did learn a lot. Here are some items we learned.
Off Line connections
One of the hardest concepts to learn is the concept of online and offline connections. Maybe it was just us but we had a difficult time learning this concept. I am not going into the specifics however it all depends on how items are authorized with your appid and what information you are trying to get. Make sure in your appid that you have both Offline and Online item types checked before you try to access the objects and you will save yourself a lot of headaches. This of course is done at healthvault.com under the application configuration center.
We had patients authorize our apps and then did everything offline. This meant we gained a few pieces of information from the persons HealthVault record and stored them in our database. We than accessed that record when we needed the record.
We wrote a little function to return the HealthRecordAccessor you need this to access the patients record here is ours
protected HealthRecordAccessor GetOffLineAccessor()
{
patientObj = patientHandler.GetaPatientObj(lblpi.Text);
OfflineWebApplicationConnection offlineConn = new OfflineWebApplicationConnection(patientObj.Personid);
offlineConn.Authenticate();
HealthRecordAccessor offlineAccessor = new HealthRecordAccessor(offlineConn, patientObj.Recordguid);
return offlineAccessor;
}
Let me go over this code real quick
-PatientObj is an object with the patient info
-OfflineWebApplicationConnection this is the HealthVault offline connection instance important
-HealthRecordAccessor HealthVault Record Accessor you need this
Notice we passed the info we had stored in the database through the PatientObj
So now I am going to add some medication to the patients record
Medication hvMedication = new Medication();
GeneralMeasurement generalMeasurement = new GeneralMeasurement();
generalMeasurement.Display = txtDose.Text + "mg";
hvMedication.Strength = generalMeasurement;
Microsoft.Health.ItemTypes.CodableValue codedValue = new CodableValue(txtMedication.Text);
hvMedication.Name = codedValue;
generalMeasurement = new GeneralMeasurement();
generalMeasurement.Display = times;
hvMedication.Frequency = generalMeasurement;
AddMedicationToHV(hvMedication);
Lets go over this code real quick it is simple
Medication is a HealthVault object representing medications.
GeneralMeasurements - notice this you do this a lot in HealthVault you attempt to standardize a "coding" although we never figured out where the standard came from
Again for strength
Notice how you add the codedValue to the Medication object?
Then we add the medication object to HealthVault lets look at that code
HealthRecordAccessor accessor = new HealthRecordAccessor(HealthVaultConnectionManager.CreateConnection(patientObj.Applicationpatientid, patientObj.Personid), patientObj.Recordguid);
accessor.NewItem(medication);
return true;
Ok I skipped a few steps, but this is the gist.
I create a new HealthRecordAccessor and HealthVaultConnectionManage grab my record info from my patientobj and add a new item
How do I delete the medication?
HealthRecordAccessor accessor = new HealthRecordAccessor(HealthVaultConnectionManager.CreateConnection(patientObj.Applicationpatientid, patientObj.Personid), patientObj.Recordguid);
HealthRecordFilter filter = new HealthRecordFilter(key.Id,Medication.TypeId);
HealthRecordItem item = accessor.GetItem(key.Id);
accessor.RemoveItem(item.Key);
return true;
Using the save items only using the method .Removeitem and the item.key
One last item and this one drove me crazy, if you want to place a file on HealthVault and then find the file again how do you do it? Seems easy?
We did it this way
First we added the file
string extensionName = "somename";
HealthRecordItemExtension healthRecordItemExtension = new HealthRecordItemExtension(extensionName);
file.CommonData.Extensions.Add(healthRecordItemExtension);
//add the XML
XPathNavigator navigator = healthRecordItemExtension.ExtensionData.CreateNavigator();
navigator.InnerXml = @"<extension source=""" + extensionName + @"""><consultid>" + consultid + "</consultid></extension>";
HealthRecordAccessor accessor = new HealthRecordAccessor(HealthVaultConnectionManager.CreateConnection(patientObj.Applicationpatientid, patientObj.Personid), patientObj.Recordguid);
accessor.NewItem(file);
return true;
-You have to create an extension name and a unique number for the file
So how to find it?
HealthRecordSearcher searcher = offlineAccessor.CreateSearcher();
HealthRecordFilter filter = new HealthRecordFilter(Microsoft.Health.ItemTypes.File.TypeId);
filter.View.Sections = HealthRecordItemSections.All;
searcher.Filters.Add(filter);
HealthRecordItemCollection files = searcher.GetMatchingItems()[0];
make sure you check for nulls
foreach (var item in files)
{
if (item.Key != null)
{
fileGenObj.Key = item.Key.Id;
}
foreach (HealthRecordItemExtension extension in item.CommonData.Extensions)
{
if (extension.Source == "your file name") //
{
if (string.IsNullOrEmpty(recFile))
{
foreach (Microsoft.Health.ItemTypes.File file in files)
{
if (file.Name == filename)
{
//should be the same
byte[] array = file.Content;
read your file here
}
}
}
}
}
}
-I took some stuff out that was specific to our code
-This is .Net and >net does not like nulls check for nulls often
-Check for nulls often
Hopefully I will make a longer more complete post later. However I wanted to make a post before we completely moved away from HealthVault.
Jeff
No comments:
Post a Comment