Click here to Skip to main content
15,879,051 members
Articles / Programming Languages / C#

Smart Doc Assist

Rate me:
Please Sign up or sign in to vote.
5.00/5 (3 votes)
15 Oct 2012CPOL5 min read 12.5K   5   4
Ultrabook app for doctors

This article is an entry in our AppInnovation Contest. Articles in this sub-section are not required to be full articles so care should be taken when voting.

Introduction

Persona in mind while designing this application is a busy practitioner such as a Doctor. He provides consultation to his patients at various locations such as different hospitals, clinics, institutes. He does not have much time at his disposal. This app can provide him one point for managing data of his interest. Once he provides consultation for a patient at any location, the app stores that data on cloud which can be accessed later. Using this app, he can use templates of human body and sketch during consultation on his Ultrabook. He can share all this digital information with his patients. App uses the following features of Ultrabook to improve doctor’s productivity and takes the consulting experience of patients to the next level.

Feature Detail
Interactive diagram Touch aware interactive diagram with drawing tools can be used by doctors to explain in detail.
Cloud Sync App makes use of cloud ready platform to save important data securely on cloud.
Audio – Video recording App makes use of inbuilt camera and mic in ultrabook to record important things during consultation that can be reviewed later.
Data Sharing App can make use of inbuilt sharing capabilities in Ultrabook like SMS, NFC.
Location awareness Automatically saves place where patient consultation is done.
Notifications A toast message pops up when appointment exceeds allotted time.

Writing the Application

Landing page of the application provides an overview of appointments for today & tomorrow. It also shows booking status of appointments for the next week. Doctor can manage appointments from landing page of the application itself. Landing page makes use of rich UI rendering of Ultrabook to show data in a user friendly way. Double touch on available appointment slot can be used to book an appointment for patient. Once a patient is added in database, all his details will be available for re-use.

With this app, doctor does not have to keep track of time during appointment. If appointment exceeds allotted time, a toast notification pops up as a reminder.

Here is a code snippet for Toast Notification –
C#
Var templateContent = ToastContentFactory.CreateToastImageAndText01();

templateContent.TextBodyWrap.Text = "Next appointment starts in X mins";
templateContent.Image.Src = toastImageSrc;
templateContent.Image.Alt = "Patient image";

IToastNotificationContent toastContent = templateContent;
output.Text = toastContent.GetContent();

ToastNotification toast = toastContent.CreateNotification();
ToastNotificationManager.CreateToastNotifier().Show(toast);

A single touch on appointment in calendar opens consultation page for doctor. Doctor can refer to patient history from this page. He can save his comments in the notes field provided. If he needs to explain a complicated topic he can use interactive diagram for explanation. Interactive diagram would look something like this –

Image 1

Interactive diagram opens pre-loaded images of body part in full featured image editor. Interactive diagram supports various touch based events such as pinch, stretch and rotate. Pinch and stretch can zoom to specific details of diagram. Image can be rotated with two or more fingers. Changes done in image can be saved. If changes are saved, they will be specific for the patient and can be accessed in future.

Consultation page also has options of audio recording OR video recording. It can also use camera to capture images if needed. Following are some sample codes for this.

Code snippet for capturing image –
C#
try
{
	CameraCaptureUI dialog = new CameraCaptureUI();
	Size aspectRatio = new Size(16, 9);
	dialog.PhotoSettings.CroppedAspectRatio = aspectRatio;

        StorageFile file = await    dialog.CaptureFileAsync(CameraCaptureUIMode.Photo);
	if (file != null)
	{
		BitmapImage bitmapImage = new BitmapImage();
		using(IRandomAccessStream fileStream = 
              await file.OpenAsync(Windows.Storage.FileAccessMode.Read))
		{
			bitmapImage.SetSource(fileStream);
		}
		Scenario1Image.Source = bitmapImage;
		Scenario1ResetButton.Visibility = Visibility.Visible;
		photoFile = file.Path;
	}	
}
catch (Exception ex)
{
	ExceptionLogger(ex.Message);
}
Code snippet for showing captured image –
C#
StorageFile file = await StorageFile.GetFileFromPathAsync(filePath);
BitmapImage bitmapImage = new BitmapImage();

using(IRandomAccessStream fileStream = 
      await file.OpenAsync(Windows.Storage.FileAccessMode.Read))
{
	bitmapImage.SetSource(fileStream);
}

Image.Source = bitmapImage;
Code snippet for capturing video –
C#
try
{
	CameraCaptureUI dialog = new CameraCaptureUI();
	dialog.VideoSettings.Format = CameraCaptureUIVideoFormat.Mp4;

	StorageFile file = await dialog.CaptureFileAsync(CameraCaptureUIMode.Video);
	if (file != null)
	{
		IRandomAccessStream fileStream = 
             await file.OpenAsync(Windows.Storage.FileAccessMode.Read);
		Scenario2Video.SetSource(fileStream, "video/mp4");
		Scenario2ResetButton.Visibility = Visibility.Visible;
		videoFile = file.Path;
	}	
}
catch (Exception ex)
{
	ExceptionLogger(ex.Message);
} 
Code snippet for showing captured video –
C#
StorageFile file = await StorageFile.GetFileFromPathAsync(filePath);
IRandomAccessStream fileStream = await file.OpenAsync(Windows.Storage.FileAccessMode.Read);
Video.SetSource(fileStream, "video/mp4");
Code snippet for audio capture and playback –
C#
mediaCaptureMgr = new Windows.Media.Capture.MediaCapture();
var settings = new MediaCaptureInitializationSettings();
settings.StreamingCaptureMode = StreamingCaptureMode.Audio;
await mediaCaptureMgr.InitializeAsync(settings);

// start recording
var recordStorageFile = 
  await Windows.Storage.KnownFolders.VideosLibrary.CreateFileAsync(fileName);
var recordProfile = 
  Windows.Media.MediaProperties.MediaEncodingProfile.CreateM4a
  (Windows.Media.MediaProperties.AudioEncodingQuality.Auto);
await mediaCaptureMgr.StartRecordToStorageFileAsync(recordProfile, recordStorageFile);

// stop recording and preview
await mediaCaptureMgr.StopRecordAsync();
var stream = await recordStorageFile.OpenAsync(Windows.Storage.FileAccessMode.Read);
playbackElement.AutoPlay = true;
playbackElement.SetSource(stream, recordStorageFile.FileType);
playbackElement.Play();

Consultation page also provides the option to save next appointment for the patient. Doctor’s calendar on home page will automatically get updated. App will also send a reminder SMS to patient prior to the next appointment.

Here is code snippet of how app will send a SMS -
C#
// Get the default SMS device
curDevice = await SmsDevice.GetDefaultAsync();
try
{   // Create a text message                                       
	SmsTextMessage msg = new SmsTextMessage();
	msg.To = SendToText.Text;
	msg.Body = SendMessageText.Text;

	// Send the message asynchronously
	OutputStatus.Text = "Sending message ...";
	await curDevice.SendMessageAsync(msg);
	OutputStatus.Text = "Text message sent";
}
catch (Exception err)
{
	OutputStatus.Text = err.Message;
}

While consultation for patient is saved, it also automatically saves the place where this consultation was done. It can be referred to if needed in patient’s history. To make geolocation work, doctor will once save co-ordinates of all his consultation places.

Code snippet for geolocation support –
C#
 // Here is the code that can be used to save various locations 
 // where doctor provides consultancy.

Geolocator geo = new Geolocator();
Geoposition pos = await geo.GetGeopositionAsync();

textblock4.Text = "Latitude: " + pos.Coordinate.Latitude.ToString();
textblock5.Text = "Longitude: " + pos.Coordinate.Longitude.ToString(
textblock6.Text = "Accuracy: " + pos.Coordinate.Accuracy.ToString();

// Once consulting locations are saved, this is how current position 
// can be calculated and saved in patient’s consultation history record.

Dispatcher.InvokeAsync(CoreDispatcherPriority.Normal, (s, a) =>
{
	Geoposition pos = (a.Context as IPositionChangedEventArgs).Position;

	textblock1.Text = "Latitude: " + pos.Coordinate.Latitude.ToString();
	textblock2.Text = "Longitude: " + pos.Coordinate.Longitude.ToString();
	textblock3.Text = "Accuracy: " + pos.Coordinate.Accuracy.ToString();
}, this, e);

// pos status can have various values like Ready, 
// Initializing, NoData, Disabled, NotInitialized, NotAvailable.

Doctor can capture different form of electronic data during consultation. This data can be shared with patient using e-mail OR there is a new kid for sharing data – NFC. NFC can be used to share if patient also has a device that supports NFC. NFC is a new revolutionary way to share data between devices. We just need to tap devices with each other and NFC takes care of sharing data between. Those devices can of different types like a mobile and a tablet. Those devices can have different operating systems underneath, but NFC makes data sharing possible in between them. For this purpose, a new namespace Windows.Networking.Proximity is introduced in Windows. In NFC, our device can trigger the proximity event to start data sharing OR our device can start sharing data with others. We will consider the second scenario.

NFC supports 3 different modes. In this case, we will consider Peer-to-Peer Mode.

  1. Card emulation Mode: This mode allows a NFC device to work as a contact-less smart card (i.e., a credit card). This feature can be used in applications for payments, e-ticketing and so on.
  2. Peer-to-Peer Mode: This mode enables two NFC devices to exchange data using a bidirectional half duplex communication. From the point of view of the users, this mode simplifies information sharing: they just have to tap together their NFC devices with no need for any prior setup.
  3. Reader/Writer Mode: This mode allows an active NFC device to read from/write to a passive NFC tag. Typical examples are applications for smart posters.

Here is a code snippet for sharing data using NFC (Near Field Communication) –

C#
var proximityDevice = ProximityDevice.GetDefault();
if (proximityDevice != null)
{
    proximityDevice.DeviceArrived += ProximityDeviceArrived;
    proximityDevice.DeviceDeparted +=ProximityDeviceDeparted;    
    WriteMessageText("Proximity device initialized.\n");
}
else
{
    WriteMessageText("Failed to initialized proximity device.\n");
}
void PublishMessage()
{
    publishedMessageId = proximityDevice.PublishMessage
                   ("Windows.SampleMessageType", publishText);
    DisplayStatus("Message published, tap another device to transmit.", StatusOutputText);
}
void SubscribeForMessage()
{
    subscribedMessageId = proximityDevice.SubscribeForMessage
                   ("Windows.SampleMessageType", MessageReceived);
    DisplayStatus("Subscribed for proximity message, 
                    enter proximity to receive.", StatusOutputText);
}

Once device connections are established, just publish and subscribe message needs to be done, to send and receive data respectively.

Points of Interest

Ultrabook provides really exciting features like touch aware, NFC opening up new horizons for apps to be developed. And implementing them in a program is super easy.

History

  • v1.0 | Initial release | 10.15.2012

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Software Developer (Senior) PTC Software (India) Pvt Ltd.
India India
Manoj is from Pune, India. He is working on Microsoft technology stack like C#, Silverlight, SharePoint, Windows Phone.

Comments and Discussions

 
QuestionWhich flavour? Pin
Chris Maunder15-Oct-12 8:20
cofounderChris Maunder15-Oct-12 8:20 
AnswerRe: Which flavour? Pin
Manoj Attal15-Oct-12 23:11
Manoj Attal15-Oct-12 23:11 
GeneralRe: Which flavour? Pin
Chris Maunder16-Oct-12 2:28
cofounderChris Maunder16-Oct-12 2:28 
GeneralRe: Which flavour? Pin
Manoj Attal16-Oct-12 2:31
Manoj Attal16-Oct-12 2:31 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.