Ejemplo n.º 1
0
        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);
        }
Ejemplo n.º 2
0
        private string ReadTag(ushort group, ushort element)
        {
            gdcm.Tag tag = new gdcm.Tag(group, element);

            if (group == 0x2)
            {
                gdcm.FileMetaInformation fileMetaInfo = this.file.GetHeader();

                if (fileMetaInfo.FindDataElement(tag))
                    return fileMetaInfo.GetDataElement(tag).GetValue().toString();
                else
                    return string.Empty;
            }
            else
            {
                gdcm.DataSet dataSet = this.file.GetDataSet();

                if (dataSet.FindDataElement(tag))
                    return dataSet.GetDataElement(tag).GetValue().toString();
                else
                    return string.Empty;
            }
        }
Ejemplo n.º 3
0
        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);
        }