public List <string> GetImages(string patientId) { var images = new List <string>(); string resultString = string.Empty; gdcm.ERootType typ = gdcm.ERootType.ePatientRootType; gdcm.EQueryLevel poziom = gdcm.EQueryLevel.ePatient; gdcm.KeyValuePairArrayType klucze = new gdcm.KeyValuePairArrayType(); gdcm.KeyValuePairType klucz1 = new gdcm.KeyValuePairType(new gdcm.Tag(0x0010, 0x0020), patientId); klucze.Add(klucz1); gdcm.BaseRootQuery zapytanie = gdcm.CompositeNetworkFunctions.ConstructQuery(typ, poziom, klucze, true); string odebrane = System.IO.Path.Combine(".", "odebrane"); if (!System.IO.Directory.Exists(odebrane)) { System.IO.Directory.CreateDirectory(odebrane); } string dane = System.IO.Path.Combine(odebrane, System.IO.Path.GetRandomFileName()); System.IO.Directory.CreateDirectory(dane); bool stan = gdcm.CompositeNetworkFunctions.CMove(this.pacsConfiguration.ipPACS, this.pacsConfiguration.portPACS, zapytanie, this.pacsConfiguration.portMove, this.pacsConfiguration.myAET, this.pacsConfiguration.callAET, dane); List <string> pliki = new List <string>(System.IO.Directory.EnumerateFiles(dane)); foreach (string plik in pliki) { gdcm.PixmapReader reader = new gdcm.PixmapReader(); reader.SetFileName(plik); if (!reader.Read()) { // do not remove!!!! continue; } gdcm.Bitmap bmjpeg2000 = BitmapCoder.pxmap2jpeg2000(reader.GetPixmap()); Bitmap[] X = BitmapCoder.gdcmBitmap2Bitmap(bmjpeg2000); for (int i = 0; i < X.Length; i++) { string name = String.Format("{0}_warstwa{1}.jpg", plik, i); X[i].Save(name); images.Add(name); } } return(images); }
public List <string> GetPatients() { var patients = new List <string>(); gdcm.ERootType typ = gdcm.ERootType.ePatientRootType; gdcm.EQueryLevel poziom = gdcm.EQueryLevel.ePatient; gdcm.KeyValuePairArrayType klucze = new gdcm.KeyValuePairArrayType(); gdcm.Tag tag = new gdcm.Tag(0x0010, 0x0010); gdcm.KeyValuePairType klucz1 = new gdcm.KeyValuePairType(tag, "*"); klucze.Add(klucz1); klucze.Add(new gdcm.KeyValuePairType(new gdcm.Tag(0x0010, 0x0020), "")); gdcm.BaseRootQuery zapytanie = gdcm.CompositeNetworkFunctions.ConstructQuery(typ, poziom, klucze); // sprawdź, czy zapytanie spełnia kryteria if (!zapytanie.ValidateQuery()) { return(null); } // kontener na wyniki gdcm.DataSetArrayType wynik = new gdcm.DataSetArrayType(); bool stan = gdcm.CompositeNetworkFunctions.CFind( this.pacsConfiguration.ipPACS, this.pacsConfiguration.portPACS, zapytanie, wynik, this.pacsConfiguration.myAET, this.pacsConfiguration.callAET); // sprawdź stan if (!stan) { return(null); } // pokaż wyniki foreach (gdcm.DataSet x in wynik) { // jeden element pary klucz-wartość gdcm.DataElement de = x.GetDataElement(new gdcm.Tag(0x0010, 0x0020)); // konkretnie 10,20 = PATIENT_ID gdcm.Value val = de.GetValue(); string str = val.toString(); patients.Add(str); } return(patients); }
private void OnRefresh(object obj) { PatientList.Clear(); // typ wyszukiwania (rozpoczynamy od pacjenta) gdcm.ERootType typ = gdcm.ERootType.ePatientRootType; // do jakiego poziomu wyszukujemy gdcm.EQueryLevel poziom = gdcm.EQueryLevel.ePatient; // zobacz inne // klucze (filtrowanie lub okreœlenie, które dane s¹ potrzebne) gdcm.KeyValuePairArrayType klucze = new gdcm.KeyValuePairArrayType(); //gdcm.Tag tag = new gdcm.Tag(0x0010, 0x0010); gdcm.KeyValuePairType klucz1 = new gdcm.KeyValuePairType(new gdcm.Tag(0x0010, 0x0010), "*"); klucze.Add(klucz1); klucze.Add(new gdcm.KeyValuePairType(new gdcm.Tag(0x0010, 0x0020), "")); // skonstruuj zapytanie gdcm.BaseRootQuery zapytanie = gdcm.CompositeNetworkFunctions.ConstructQuery(typ, poziom, klucze); // sprawdŸ, czy zapytanie spe³nia kryteria if (!zapytanie.ValidateQuery()) { State = "B³êdne zapytanie"; return; } // wykonaj zapytanie gdcm.DataSetArrayType wynik = new gdcm.DataSetArrayType(); bool stan = gdcm.CompositeNetworkFunctions.CFind(IP, ushort.Parse(Port), zapytanie, wynik, AET, "ARCHIWUM"); // sprawdŸ stan if (!stan) { State = "Nie dzia³a"; return; } // poka¿ wyniki foreach (gdcm.DataSet x in wynik) { // jeden element pary klucz-wartoœæ gdcm.DataElement de = x.GetDataElement(new gdcm.Tag(0x0010, 0x0020)); // konkretnie 10,20 = PATIENT_ID // dostêp jako string gdcm.Value val = de.GetValue(); // pobierz wartoœæ dla wskazanego klucza... string str = val.toString(); // ...jako napis PatientList.Add(str); } }
public static List <string> GetPatients(string ip, ushort port, string aet, string call) { gdcm.ERootType type = gdcm.ERootType.ePatientRootType; gdcm.EQueryLevel level = gdcm.EQueryLevel.ePatient; gdcm.KeyValuePairArrayType keys = new gdcm.KeyValuePairArrayType(); gdcm.KeyValuePairType key = new gdcm.KeyValuePairType(new gdcm.Tag(0x0010, 0x0010), "*"); keys.Add(key); gdcm.BaseRootQuery query = gdcm.CompositeNetworkFunctions.ConstructQuery(type, level, keys); gdcm.DataSetArrayType dataArray = new gdcm.DataSetArrayType(); //bool status = gdcm.CompositeNetworkFunctions.CFind(ip, port, query, dataArray, aet, call); foreach (gdcm.DataSet x in dataArray) { patientList.Add(x.GetDataElement(new gdcm.Tag(0x0010, 0x0010)).GetValue().toString()); } return(patientList); }
private void OnGetImages(object obj) { ImageList.Clear(); // typ wyszukiwania (rozpoczynamy od pacjenta) gdcm.ERootType typ = gdcm.ERootType.ePatientRootType; // do jakiego poziomu wyszukujemy gdcm.EQueryLevel poziom = gdcm.EQueryLevel.ePatient; // zobacz inne // klucze (filtrowanie lub okreœlenie, które dane s¹ potrzebne) gdcm.KeyValuePairArrayType klucze = new gdcm.KeyValuePairArrayType(); if (SelectedPatient == null) { State = "Wybierz pacjenta"; return; } gdcm.KeyValuePairType klucz1 = new gdcm.KeyValuePairType(new gdcm.Tag(0x0010, 0x0020), SelectedPatient); // NIE WOLNO TU STOSOWAC *; tutaj PatientID="01" klucze.Add(klucz1); // skonstruuj zapytanie gdcm.BaseRootQuery zapytanie = gdcm.CompositeNetworkFunctions.ConstructQuery(typ, poziom, klucze, true); // sprawdŸ, czy zapytanie spe³nia kryteria if (!zapytanie.ValidateQuery()) { State = "MOVE b³êdne zapytanie!"; return; } // przygotuj katalog na wyniki String odebrane = System.IO.Path.Combine(".", "odebrane"); // podkatalog odebrane w bie¿¹cym katalogu if (!System.IO.Directory.Exists(odebrane)) // jeœli nie istnieje { System.IO.Directory.CreateDirectory(odebrane); // utwórz go } String dane = System.IO.Path.Combine(odebrane, System.IO.Path.GetRandomFileName()); // wygeneruj losow¹ nazwê podkatalogu System.IO.Directory.CreateDirectory(dane); // i go utwórz // wykonaj zapytanie - pobierz do katalogu jak w zmiennej 'dane' bool stan = gdcm.CompositeNetworkFunctions.CMove(IP, ushort.Parse(Port), zapytanie, portMove, AET, aec, dane); // sprawdŸ stan if (!stan) { State = "MOVE nie dzia³a!"; return; } List <string> pliki = new List <string>(System.IO.Directory.EnumerateFiles(dane)); foreach (String plik in pliki) { // MOVE + konwersja // przeczytaj pixele gdcm.PixmapReader reader = new gdcm.PixmapReader(); reader.SetFileName(plik); if (!reader.Read()) { // najpewniej nie jest to obraz continue; } // przekonwertuj na "znany format" gdcm.Bitmap bmjpeg2000 = pxmap2jpeg2000(reader.GetPixmap()); // przekonwertuj na .NET bitmapê Bitmap[] X = gdcmBitmap2Bitmap(bmjpeg2000); // zapisz for (int i = 0; i < X.Length; i++) { String name = String.Format("{0}_warstwa{1}.jpg", plik, i); X[i].Save(name); ImageList.Add(name); } } }
public static string Find() { string resultString = ""; //FIND // typ wyszukiwania (rozpoczynamy od pacjenta) gdcm.ERootType typ = gdcm.ERootType.ePatientRootType; // do jakiego poziomu wyszukujemy gdcm.EQueryLevel poziom = gdcm.EQueryLevel.ePatient; // zobacz tez inne // klucze (filtrowanie lub określenie, które dane są potrzebne) gdcm.KeyValuePairArrayType klucze = new gdcm.KeyValuePairArrayType(); gdcm.Tag tag = new gdcm.Tag(0x0010, 0x0010); // 10,10 == PATIENT_NAME gdcm.KeyValuePairType klucz1 = new gdcm.KeyValuePairType(tag, "*"); // * == dowolne imię klucze.Add(klucz1); klucze.Add(new gdcm.KeyValuePairType(new gdcm.Tag(0x0010, 0x0020), "")); // zwrotnie oczekujemy wypełnionego 10,20 czyli PATIENT_ID // skonstruuj zapytanie gdcm.BaseRootQuery zapytanie = gdcm.CompositeNetworkFunctions.ConstructQuery(typ, poziom, klucze); // sprawdź, czy zapytanie spełnia kryteria if (!zapytanie.ValidateQuery()) { return("FIND błędne zapytanie!"); } // kontener na wyniki gdcm.DataSetArrayType wynik = new gdcm.DataSetArrayType(); // wykonaj zapytanie bool stan = gdcm.CompositeNetworkFunctions.CFind(ipPACS, portPACS, zapytanie, wynik, myAET, callAET); // sprawdź stan if (!stan) { return("FIND nie działa!"); } resultString += "FIND działa."; // pokaż wyniki foreach (gdcm.DataSet x in wynik) { resultString += x.toString(); // cała odpowiedź jako wielolinijkowy napis // UWAGA: toString() vs ToString() !!! // + DOSTEP DO METADANYCH //for (var iter = x.Begin(); iter != x.End(); ++iter) { } // brak wrapowania iteratorów... // jeden element pary klucz-wartość gdcm.DataElement de = x.GetDataElement(new gdcm.Tag(0x0010, 0x0020)); // konkretnie 10,20 = PATIENT_ID // dostęp jako string gdcm.Value val = de.GetValue(); // pobierz wartość dla wskazanego klucza... string str = val.toString(); // ...jako napis resultString += "ID Pacjenta: " + str; // dostęp jako tablica bajtów gdcm.ByteValue bval = de.GetByteValue(); // pobierz jako daną binarną byte[] buff = new byte[bval.GetLength().GetValueLength()]; // przygotuj tablicę bajtów bval.GetBuffer(buff, (uint)buff.Length); // skopiuj zawartość // a co z tym dalej zrobić to już inna kwestia... //Console.WriteLine(); } return(resultString); }
public static string Move() { string resultString = string.Empty; // typ wyszukiwania (rozpoczynamy od pacjenta) gdcm.ERootType typ = gdcm.ERootType.ePatientRootType; // do jakiego poziomu wyszukujemy gdcm.EQueryLevel poziom = gdcm.EQueryLevel.ePatient; // zobacz inne // klucze (filtrowanie lub określenie, które dane są potrzebne) gdcm.KeyValuePairArrayType klucze = new gdcm.KeyValuePairArrayType(); gdcm.KeyValuePairType klucz1 = new gdcm.KeyValuePairType(new gdcm.Tag(0x0010, 0x0020), "01"); // NIE WOLNO TU STOSOWAC *; tutaj PatientID="01" klucze.Add(klucz1); // skonstruuj zapytanie gdcm.BaseRootQuery zapytanie = gdcm.CompositeNetworkFunctions.ConstructQuery(typ, poziom, klucze, gdcm.EQueryType.eMove); // sprawdź, czy zapytanie spełnia kryteria if (!zapytanie.ValidateQuery()) { return("MOVE błędne zapytanie!"); } // przygotuj katalog na wyniki string odebrane = System.IO.Path.Combine(".", "odebrane"); // podkatalog odebrane w bieżącym katalogu if (!System.IO.Directory.Exists(odebrane)) // jeśli nie istnieje { System.IO.Directory.CreateDirectory(odebrane); // utwórz go } string dane = System.IO.Path.Combine(odebrane, System.IO.Path.GetRandomFileName()); // wygeneruj losową nazwę podkatalogu System.IO.Directory.CreateDirectory(dane); // i go utwórz // wykonaj zapytanie - pobierz do katalogu jak w zmiennej 'dane' bool stan = gdcm.CompositeNetworkFunctions.CMove(ipPACS, portPACS, zapytanie, portMove, myAET, callAET, dane); // sprawdź stan if (!stan) { return("MOVE nie działa!"); } resultString += "MOVE działa."; List <string> pliki = new List <string>(System.IO.Directory.EnumerateFiles(dane)); foreach (string plik in pliki) { resultString += "pobrano: {0}" + plik; // MOVE + konwersja // przeczytaj pixele gdcm.PixmapReader reader = new gdcm.PixmapReader(); reader.SetFileName(plik); if (!reader.Read()) { // najpewniej nie jest to obraz resultString += "pomijam: {0}" + plik; continue; } // przekonwertuj na "znany format" gdcm.Bitmap bmjpeg2000 = BitmapCoder.pxmap2jpeg2000(reader.GetPixmap()); // przekonwertuj na .NET bitmapę Bitmap[] X = BitmapCoder.gdcmBitmap2Bitmap(bmjpeg2000); // zapisz for (int i = 0; i < X.Length; i++) { string name = String.Format("{0}_warstwa{1}.jpg", plik, i); X[i].Save(name); resultString += "konwersja do: {0}" + name; } } return(resultString); }