Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Write element with sequence item or nested sequence #308

Closed
ZengQingHong927 opened this issue Apr 25, 2024 · 2 comments
Closed

Write element with sequence item or nested sequence #308

ZengQingHong927 opened this issue Apr 25, 2024 · 2 comments

Comments

@ZengQingHong927
Copy link

Hey all,
I am new to the great library and being to implement a dicom application to connect to PACS. I refer to the godoc to create a dataset with sequence item. Finally, I print the dataset value and get the null. Thank you.

`
import (
"fmt"

"github.com/suyashkumar/dicom"
"github.com/suyashkumar/dicom/pkg/tag"

)

func main() {
element_1, _ := dicom.NewElement(tag.Modality, []string{"SR"})
element_2, _ := dicom.NewElement(tag.PatientName, "Alice")
element_3, _ := dicom.NewElement(tag.PatientID, "12345")
seqItem := [][]*dicom.Element{
{
element_2,
element_3,
},
}
sequenceElement, _ := dicom.NewElement(tag.ConceptNameCodeSequence, seqItem)
ds := dicom.Dataset{
Elements: []*dicom.Element{
sequenceElement,
element_1,
},
}
for _, v := range ds.Elements {
data, _ := v.Value.MarshalJSON()
fmt.Println(string(data))
}
}
`

The below is log
[[null,null]] ["SR"]

System: MacOS 14.4.1
Go Version: 1.21.1
IDE: vscode

@ZengQingHong927
Copy link
Author

I found the bug that second parameter must be slice for NewElement function.
element_2, _ := dicom.NewElement(tag.PatientName, []string{"Alice"}) element_3, _ := dicom.NewElement(tag.PatientID, []string{"12345"})

@suyashkumar
Copy link
Owner

@ZengQingHong927 sounds like you got everything working? Let me know if not and additional help needed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants