예제 #1
0
    public static int Main(string[] argv)
    {
        string file1 = argv[0];
        string file2 = argv[1];

        gdcm.Reader r = new gdcm.Reader();
        r.SetFileName(file1);
        if (!r.Read())
        {
            return(1);
        }

        gdcm.File    f  = r.GetFile();
        gdcm.DataSet ds = f.GetDataSet();
        // tsis = gdcm.Tag(0x0008,0x2112) # SourceImageSequence

        // Create a dataelement
        gdcm.DataElement de  = new gdcm.DataElement(new gdcm.Tag(0x0010, 0x2180));
        string           occ = "Occupation";

        de.SetByteValue(StrToByteArray(occ), new gdcm.VL((uint)occ.Length));
        de.SetVR(new gdcm.VR(gdcm.VR.VRType.SH));

        // Create an item
        gdcm.Item it = new gdcm.Item();
        it.SetVLToUndefined();  // Needed to not popup error message
        //it.InsertDataElement(de)
        gdcm.DataSet nds = it.GetNestedDataSet();
        nds.Insert(de);

        // Create a Sequence
        gdcm.SmartPtrSQ sq = gdcm.SequenceOfItems.New();
        sq.SetLengthToUndefined();
        sq.AddItem(it);

        // Insert sequence into data set
        gdcm.DataElement des = new gdcm.DataElement(new gdcm.Tag(0x0400, 0x0550));
        des.SetVR(new gdcm.VR(gdcm.VR.VRType.SQ));
        des.SetValue(sq.__ref__());
        des.SetVLToUndefined();

        ds.Insert(des);

        gdcm.Writer w = new gdcm.Writer();
        w.SetFile(f);
        w.SetFileName(file2);
        if (!w.Write())
        {
            return(1);
        }

        return(0);
    }
예제 #2
0
파일: NewSequence.cs 프로젝트: hsorby/gdcm
    public static int Main(string[] argv)
    {
        string file1 = argv[0];
        string file2 = argv[1];

        gdcm.Reader r = new gdcm.Reader();
        r.SetFileName( file1 );
        if ( ! r.Read() )
          {
          return 1;
          }

        gdcm.File f = r.GetFile();
        gdcm.DataSet ds = f.GetDataSet();
        // tsis = gdcm.Tag(0x0008,0x2112) # SourceImageSequence

        // Create a dataelement
        gdcm.DataElement de = new gdcm.DataElement(new gdcm.Tag(0x0010, 0x2180));
        string occ = "Occupation";
        de.SetByteValue( StrToByteArray(occ), new gdcm.VL((uint)occ.Length));
        de.SetVR(new gdcm.VR(gdcm.VR.VRType.SH));

        // Create an item
        gdcm.Item it = new gdcm.Item();
        it.SetVLToUndefined();      // Needed to not popup error message
        //it.InsertDataElement(de)
        gdcm.DataSet nds = it.GetNestedDataSet();
        nds.Insert(de);

        // Create a Sequence
        gdcm.SmartPtrSQ sq = gdcm.SequenceOfItems.New();
        sq.SetLengthToUndefined();
        sq.AddItem(it);

        // Insert sequence into data set
        gdcm.DataElement des = new gdcm.DataElement(new gdcm.Tag(0x0400,0x0550));
        des.SetVR(new gdcm.VR(gdcm.VR.VRType.SQ));
        des.SetValue(sq.__ref__());
        des.SetVLToUndefined();

        ds.Insert(des);

        gdcm.Writer w = new gdcm.Writer();
        w.SetFile( f );
        w.SetFileName( file2 );
        if ( !w.Write() )
          return 1;

        return 0;
    }
예제 #3
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);
        }
예제 #4
0
        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);
            }
        }
예제 #5
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);
        }