Click here to Skip to main content
15,886,258 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I want to transfer the information of patients included (Id,Name,Age,tel) from doctor1 to doctor2
each doctor have an Id also.

To more clarify:
-I designed a gridview to show the information of patients.
-I added to this gridview colum contain checkbox to determine those patients I will transfer to other doctor.
-Finally there is checklist to choose the name of the doctor that will accept the patients and button to do the transfer.

Any one can help me how can I programmatically solving this problem?

I am using c#

Thank you
Posted
Updated 9-Apr-11 6:01am
v2
Comments
Henry Minute 9-Apr-11 12:05pm    
Without knowing the precise details of your data store, this is almost impossible to answer.

What DBMS (if any) are you using?
What is the schema?
etc......................

Also you keep mentioning 'gridview', does this mean that this is an ASP.NET application? If so please add the appropriate tags to the question.
dedoooo 9-Apr-11 12:30pm    
I am using Sql server database provided by visuial stdiuo

The schema of the data base as following

First table 1(For patients ) has:

(ID,name ,Age,tel )

Second table (for doctors)has:
(Id ,name,tel)


I want to only hint how can I transfer the patients and thier information

Finally, Yes I used asp,net application

I am begginer so,sorry for more details

Did you means (tags) my code in asp.net?

Thank you

You obviously need some table to associate the patients and doctors

Doctor_Patient
INT Doctor_ID
INT Patient_ID

Unless there can be only one doc associated with the patient, which in that case consider adding a foreign key to patient table from the doctors table

Patient
ID, name, age, tel, Doctor_ID

When you want another doctor to be associated with the patient

UPDATE Doctor_Patient
SET Doctor_ID = New_Doc_ID
WHERE Patient_ID = ???

Or

UPDATE Patient
SET Doctor_ID = NewDoc_ID
WHERE Patient_ID = ???

Obviously there are more checks and balances that need to be done, but this is the essential process for it
 
Share this answer
 
Comments
BobJanova 11-Apr-11 10:53am    
From the way the OP is worded I think this is a 'registered doctor' system where a patient can only have one doctor, so I'd add the column to Patient.
dedoooo 11-Apr-11 16:48pm    
this OP give me good idea how can start
but if I have list of Id's can I using the sql statment?
thanks
[no name] 11-Apr-11 18:12pm    
What do you mean a list if IDs?

UPDATE Patient
Set Doctor_ID = New_Doctor_ID
WHERE Patient_ID IN (1,2,3,4,5)
dedoooo 13-Apr-11 1:24am    
I mean I have an array of Id for the patient,how can I update the array?
A party is an "abstraction" for partys, not the one you vent to last night, but hopefully several parties where present.

A person is a party, and so is an organization. In my capacity as a developer I could be said to have a role as a developer, and when I get sick and visit the doctor I have a role as a patient. When one doctor stops being my doctor, his role as my doctor ends, but that does not alter the fact that he has been my doctor - something that may prove to be information of impotance should complications arise from previous cases. As I change doctors a new person gets the role as my doctor.

Here is something similar, and more comprehensive, to the design I'm outlining:
Picture of a similar model[^]

A Universal Data Model For Relationship Development[^]

In a "real" design we could have entities for PartyType, Party, RelationShipType, RelationShipRoleAssignment, RelationShip ,ContactMechanismType, ContactMechanism, CaseType, Case, and many more. As a person I would have several contactmechanisms assigned to me, and as this information usually changes over time, they too should have FromTime/ThroughTime fields.

In a medical system I would be part of a relationship between the medical facility and me in my role as patient, and medical personel enters and leaves that relationship in their various roles working on cases. If I worked as a doctor at our medical facility, I could sometimes have the role as patient too - but I should not be able to have the role as my own doctor.

General very simplified structure for dealing with interactions between parties, like for instance doctors and patients - but hopefully enough to get my drift. It's a very simplified subset of the model proposed by Len Silverston.
SQL
CREATE SCHEMA [Party]
GO

CREATE SCHEMA [Case]
GO


/* What kind of party? a formal party like a person or an organization, or an informal party like a group or department? */
CREATE TABLE [Party].[PartyType]
(
  [Id] bigint NOT NULL,
  [Name] nvarchar(255) NOT NULL,
  [Extends] bigint,
  [Abstract] bit NOT NULL,
  [Description] nvarchar(2028),

  CONSTRAINT PK_PartyType PRIMARY KEY([Id]),
  CONSTRAINT FK_PartyType_Extends_To_PartyType_Id FOREIGN KEY([Extends]) REFERENCES [Party].[PartyType]([Id]),
  CONSTRAINT UNQ_PartyType_Name UNIQUE(Name)
)
GO

CREATE TABLE [Party].[Party]
(
  [Id] bigint IDENTITY NOT NULL,
  [Type] bigint NOT NULL,

  CONSTRAINT PK_Party PRIMARY KEY(Id),
  CONSTRAINT FK_Party_Type_To_PartyType_Id FOREIGN KEY([Type]) REFERENCES [Party].[PartyType]([Id])
)
GO

CREATE TABLE [Party].[Organization]
(
  [Id] bigint NOT NULL,

  CONSTRAINT PK_Organization PRIMARY KEY(Id),
  CONSTRAINT FK_Organization_Id_To_Party_Id FOREIGN KEY([Id]) REFERENCES [Party].[Party]([Id])
)
GO

CREATE TABLE [Party].[Person]
(
  [Id] bigint NOT NULL,

  CONSTRAINT PK_Person PRIMARY KEY(Id),
  CONSTRAINT FK_Person_Id_To_Party_Id FOREIGN KEY([Id]) REFERENCES [Party].[Party]([Id])
)
GO

CREATE TABLE [Party].[Unit]
(
  [Id] bigint NOT NULL,

  CONSTRAINT PK_Unit PRIMARY KEY(Id),
  CONSTRAINT FK_Unit_Id_To_Party_Id FOREIGN KEY([Id]) REFERENCES [Party].[Party]([Id])
)
GO

/* A party may play any number of roles - like doctor or patient - at any time */
CREATE TABLE [Party].[PartyRoleType]
(
  [Id] bigint NOT NULL,
  [Name] nvarchar(255) NOT NULL,
  [Extends] bigint,
  [Abstract] bit NOT NULL,
  [Description] nvarchar(2028),
  [ValidForPartyType] bigint NOT NULL DEFAULT 1,

  CONSTRAINT PK_PartyRoleType PRIMARY KEY([Id]),
  CONSTRAINT FK_PartyRoleType_Extends_To_PartyRoleType_Id FOREIGN KEY([Extends]) REFERENCES [Party].[PartyRoleType]([Id]),
  CONSTRAINT FK_PartyRoleType_ValidForPartyType_To_PartyType_Id FOREIGN KEY([ValidForPartyType]) REFERENCES [Party].[PartyType]([Id]),
  CONSTRAINT UNQ_PartyRoleType_Name UNIQUE(Name)
)
GO

/* For a period of time party plays a role as patient, doctor, etc. */
CREATE TABLE [Party].[PartyRole]
(
  [Id] bigint IDENTITY NOT NULL,
  [Type] bigint NOT NULL,
  [Party] bigint NOT NULL,
  [FromTime] datetime2 NOT NULL,
  [ThroughTime] datetime2,

  CONSTRAINT PK_PartyRole PRIMARY KEY(Id),
  CONSTRAINT FK_PartyRole_Type_To_PartyRoleType_Id FOREIGN KEY([Type]) REFERENCES [Party].[PartyRoleType]([Id]),
  CONSTRAINT FK_PartyRole_Party_To_Party_Id FOREIGN KEY([Party]) REFERENCES [Party].[Party]([Id])
)
GO


CREATE TABLE [Case].[CaseType]
(
  [Id] bigint NOT NULL,
  [Name] nvarchar(255) NOT NULL,
  [Extends] bigint,
  [Abstract] bit NOT NULL,
  [Description] nvarchar(2028),

  CONSTRAINT PK_CaseType PRIMARY KEY([Id]),
  CONSTRAINT FK_CaseType_Extends_To_CaseType_Id FOREIGN KEY([Extends]) REFERENCES [Case].[CaseType]([Id]),
  CONSTRAINT UNQ_CaseType_Name UNIQUE(Name)
)
GO


CREATE TABLE [Case].[Case]
(
  [Id] bigint IDENTITY NOT NULL,
  [Type] bigint NOT NULL,

  CONSTRAINT PK_Case PRIMARY KEY(Id),
  CONSTRAINT FK_Case_Type_To_CaseType_Id FOREIGN KEY([Type]) REFERENCES [Case].[CaseType]([Id])
)
GO

/* "extends" [Party].[PartyRole] to allow a party to play a role in a case */
CREATE TABLE [Party].[PartyToCaseRole]
(
  [Id] bigint NOT NULL,
  [Case] bigint NOT NULL,
  
  CONSTRAINT PK_PartyToCaseRole PRIMARY KEY(Id),
  CONSTRAINT FK_PartyToCaseRole_To_PartyRole_Id FOREIGN KEY([Id]) REFERENCES [Party].[PartyRole]([Id])
  CONSTRAINT FK_PartyToCaseRole_To_Case_Id FOREIGN KEY([Id]) REFERENCES [Case].[Case]([Id])
)
GO


The above is quite simplified, but I still hope it will point you in the right direction. Information about names, adresses, contact mechanisms and so on are temporal in nature and should be factored into separate tables to allow you to track changes - NOT OVERWRITE THEM!!

When a doctor stops having a role as a doctor you set the ThroughTime, when a doctor starts being a doctor you set the FromTime.

While designing the tables, it's a good idea to keep in mind that you may eventually wish to map them to something outside the db - perhaps c#.

The follwing outlines something that could form the basis for a suitable structure:
C#
 public abstract class Identified
 {
  public long Id {get;set;}
 } 

 public abstract class Named : Identified
 {
  public string Name { get; set; }
 }

 public abstract class abstract Type : Named
 {
  public long? Extends {get;set;} 
  public bool Abstract {get;set;}
  public string Description {get;set;}
 }

 class PartyType : Type
 {
 }

 public abstract class Party : Identified
 {
  public PartyType {get;set;}  
  
  List<partyrole> Roles {get;}

 }

 public abstract class FormalParty : Party
 {
 }

 public abstract class InformalParty : Party
 {
 }

 public abstract class Person : FormalParty 
 {
 }
 
 public abstract class Oragnization : FormalParty
 {
 }

 public class Unit : InformalParty
 {
 }

 
 public class PartyRoleType : Type
 {
 }

 public class PartyRole : Identified
 {
  public PartyRoleType {get;set;}
  public Party Party {get;set;}
  public DateTime FromTime {get;set;}
  public DateTime ThroughTime {get;set;}
 }
 

 public class CaseType : Type
 {
 }

 public class Case : Identified
 {
  CaseType CaseType {get;set;} 
 }

 
 public class PartyCaseRole : PartyRole
 {
  Case Case {get;set;}
 }

</partyrole>


I hope the outline for a possible c# implmentation helps to clarify some of the database design.

Obviously this doesn't come close to an actual design for a "real" system, it doesn't even satisfy the brief desciption i gave at the top - but I hope it serves to illustrate some "real-world" "problems" and how you may design you system to cope with them - specifically that most things are temporal in nature - needs FromTime/ThroughTime functionality.

If you work your way through the implications of this design, you'll end up with a database structure that initially will seem quite, even very :), complicated. The good thing is that it will usually be quite easy to work with, as you have a structure that is capable of dealing with real scenarios through simple mechanisms.

Regards
Espen Harlinn
 
Share this answer
 
v4
Comments
Sergey Alexandrovich Kryukov 9-Apr-11 23:00pm    
Impressive effort, my 5.
--SA
Sergey Alexandrovich Kryukov 9-Apr-11 23:00pm    
OP commented:

Espen Harlinn

thank you for your help

my problem not in design the database

But it is how can moving the patients to the new doctor

I mean that for example ( put the patients info in the array)

or any idea that can give a hint to start with programming.

I need just steps to solve my problem

Thanks for all
[no name] 9-Apr-11 23:40pm    
A lot of information that did not answer the question and may have done more to confuse
Espen Harlinn 10-Apr-11 5:43am    
Well, I've tried to clarify things - condensing several books worth of info into a simple answer was perhaps a bit too ambitious.

In real life it’s not uncommon that we have to spend a serious amount of time reeducating development resources. Naturally courses on database development focus on database design, but the structures you work on is a far cry from what’s required in the real world. This quite often leads to poor designs – I guess you may have noticed that many “Business Intelligence” solutions suffer from a bad case of amnesia :)

You’re right in that I’m not providing a direct answer to OPs’ question; I’m trying to make him think in terms of real world requirements. I’m not even providing a full design based on the “architecture” I outline at the top.

If OP had spent enough time on architecture and design we probably would not have seen this quitestion as the solution would then be quite obvious.
Espen Harlinn 10-Apr-11 14:20pm    
Hi Mark - how on earth do I get rid of the 1 vote?
<pre lang="sql">UPDATE Patient
SET Doctor_ID = NewDoc_ID
WHERE Patient_ID = ???</pre>

Thank you

but I have qustion

you means in qustion mark the Id of new doctor right?

but in my project there is no specifc Id

In other word, the user can not access the code in every transfer that want to do to put the new Id

How can programmly say : "When the user choose the name of the docor form checklist and click the button "transfer" the whole information about the patients that I selected by check box

I hope that understand me

thank you
 
Share this answer
 
Comments
[no name] 9-Apr-11 23:48pm    
First of all, you should add a comment to the answer if you have a question about it not add an answer yourself.

No the ??? represents the ID of the PATIENT you are updating. Notice the Patient_ID = ???. Why would you compare this with the doctor ID?

The ID should be the value of the checkbox item and you should not be relying on names as you appear to be.
Espen Harlinn

thank you for your help

my problem not in design the database

But it is how can moving the patients to the new doctor

I mean that for example ( put the patients info in the array)

or any idea that can give a hint to start with programming.

I need just steps to solve my problem

Thanks for all
 
Share this answer
 
Comments
Espen Harlinn 9-Apr-11 15:13pm    
basically one partys' role as a doctor ends while another partys' role as a doctor begins
Just keep one Combobox next to patients info and get the Doctor's Names in the Combobox and just select the Doctors name in front of the Patients name and after editing save the data to the database.
 
Share this answer
 

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900