FHIR Chat · gofsh gotchas - watch out for file name clobbering · shorthand

Stream: shorthand

Topic: gofsh gotchas - watch out for file name clobbering


view this post on Zulip Hank Lenzi (Dec 20 2021 at 14:23):

I just bumped into this issue, and I thought it might be worth writing a note for the gofsh newbie (me included):
When one does a
gofsh . -o <DIRECTORY>
In the ouptut directory (specified with "-o"), gofsh will create a directory
tree
<DIRECTORY>/fsh/input
Then, it will separate codesystems and valueset in /different/ directories.
This has practical consequences: it will create two directories:
/valuesets /codesystems
Here's the gotcha: they will have two files with the /same name/

input/fsh/valuesets on  master 
❯ cat Raça-Cor.fsh 
ValueSet: Raça-Cor
Id: br-core-valueset-patient-raceethnicity-race
Description: "Códigos para representação de raça/cor no Brasil."

* ^meta.lastUpdated = "2020-03-12T13:25:39.619+00:00"
* ^language = #pt-BR
* ^url = "http://www.saude.gov.br/fhir/r4/ValueSet/BRRacaCor-1.0"
* ^version = "1.0"
* ^status = #active
* ^experimental = false
* ^publisher = "Ministério da Saúde do Brasil"
* ^immutable = false
* include codes from system $BRRacaCor

❯ cd ../codesystems/

input/fsh/codesystems on  master 
❯ cat Raça-Cor.fsh 
CodeSystem: Raça-Cor
Id: br-core-codesystem-patient-raceethnicity-race
Description: "Códigos para representação de raça/cor."

* ^meta.lastUpdated = "2020-03-11T18:20:19.538+00:00"
* ^language = #pt-BR
* ^url = "http://www.saude.gov.br/fhir/r4/CodeSystem/BRRacaCor"
* ^version = "201701A"
* ^status = #active
* ^experimental = false
* ^publisher = "Ministério da Saúde do Brasil"
* ^content = #complete
* #01 "Branca"
* #02 "Preta"
* #03 "Parda"
* #04 "Amarela"
* #05 "Indígena"

What is the problem with that? It's that you must fuse those 2 directories into
a single one (input/fsh/resources/) so that you can use sushi and the IG publisher.
When you move those files, one will clobber the other, as they will have the _same_
name (as above: "Raça-Cor.fsh"). So, be careful.

view this post on Zulip Mareike Przysucha (Dec 20 2021 at 15:00):

I don't see the problem right now. I also had files with the same name in different folders, yet sushi made it correct. Do you have a description of unwanted behaviour in sushi?

view this post on Zulip Chris Moesel (Dec 20 2021 at 19:55):

I agree with @Mareike Przysucha. You shouldn't have to move those files into a shared folder. You can keep the input folder (and subfolders) exactly as GoFSH creates it.

view this post on Zulip Chris Moesel (Dec 20 2021 at 19:55):

Also note that if you prefer that GoFSH output it a different way, GoFSH supports a few different output "styles": https://fshschool.org/docs/gofsh/running/#style

view this post on Zulip Hank Lenzi (Dec 21 2021 at 13:51):

You've misunderstood. This is not about sushi. This is about gofsh creating two files with the same name. When you move those into sushir /resources, file name clobbering occurs (in the case you want to keep you codesystems and valuesets in the same file). I hope I've made myself clear now.

view this post on Zulip Hank Lenzi (Dec 21 2021 at 14:00):

You take two different JSON files with different names (one for codesystem the othe for vaueset), pass them through gofsh, the output will be two files with the same name.
❯ cat codesystem-br-core-address-line-streettype.json
{
"resourceType": "CodeSystem",
"id": "br-core-codesystem-streettype",
"meta": {
"lastUpdated": "2020-04-02T13:03:21.687+00:00"
},
"language": "pt-BR",
"url": "http://www.saude.gov.br/fhir/r4/CodeSystem/BRTipoLogradouro",
"version": "201701A",
"name": "Tipo_de_Logradouro",
"status": "active",
"experimental": false,
"date": "2020-04-02T13:03:18.6480245+00:00",
"publisher": "Ministério da Saúde do Brasil",
"description": "Classificação os tipos de logradouros existentes para uso em endereços estruturados.",
"content": "complete",
"concept": [
{
"code": "008",
"display": "Avenida"
},
{
"code": "081",
"display": "Rua"
}
]
}❯ cat valueset-br-core-address-line-streettype.json
{
"resourceType": "ValueSet",
"id": "br-core-valueset-address-line-streettype",
"meta": {
"lastUpdated": "2020-03-12T14:50:48.259+00:00"
},
"language": "pt-BR",
"url": "http://www.saude.gov.br/fhir/r4/ValueSet/BRTipoLogradouro-1.0",
"version": "1.0",
"name": "Tipo_de_Logradouro",
"status": "active",
"experimental": false,
"date": "2020-03-12T14:50:47.8940392+00:00",
"publisher": "Ministério da Saúde do Brasil",
"description": "Classifica o tipo de logradouro.",
"immutable": false,
"compose": {
"include": [
{
"system": "http://www.saude.gov.br/fhir/r4/CodeSystem/BRTipoLogradouro",
"version": "*"
}
]
}
}

The output:

❯ cat Tipo_de_Logradouro.fsh
ValueSet: Tipo_de_Logradouro
Id: br-core-valueset-address-line-streettype
Description: "Classifica o tipo de logradouro."

input/fsh/codesystems on  master [!?]
❯ cat Tipo_de_Logradouro.fsh
CodeSystem: Tipo_de_Logradouro
Id: br-core-codesystem-streettype
Description: "Classificação os tipos de logradouros existentes para uso em endereços estruturados."

  • ^meta.lastUpdated = "2020-04-02T13:03:21.687+00:00"
  • ^language = #pt-BR
  • ^url = "http://www.saude.gov.br/fhir/r4/CodeSystem/BRTipoLogradouro"
  • ^version = "201701A"
  • ^status = #active
  • ^experimental = false
  • ^date = "2020-04-02T13:03:18.6480245+00:00"
  • ^publisher = "Ministério da Saúde do Brasil"
  • ^content = #complete
  • #008 "Avenida"
  • #081 "Rua"

Two files with the same name, from two files, with different names.

view this post on Zulip Hank Lenzi (Dec 21 2021 at 14:01):

You take two different JSON files with different names (one for codesystem the othe for vaueset), pass them through gofsh, the output will be two files with the same name.
❯ cat codesystem-br-core-address-line-streettype.json
{
"resourceType": "CodeSystem",
"id": "br-core-codesystem-streettype",
"meta": {
"lastUpdated": "2020-04-02T13:03:21.687+00:00"
},
"language": "pt-BR",
"url": "http://www.saude.gov.br/fhir/r4/CodeSystem/BRTipoLogradouro",
"version": "201701A",
"name": "Tipo_de_Logradouro",
"status": "active",
"experimental": false,
"date": "2020-04-02T13:03:18.6480245+00:00",
"publisher": "Ministério da Saúde do Brasil",
"description": "Classificação os tipos de logradouros existentes para uso em endereços estruturados.",
"content": "complete",
"concept": [
{
"code": "008",
"display": "Avenida"
},
{
"code": "081",
"display": "Rua"
}
]
}❯ cat valueset-br-core-address-line-streettype.json
{
"resourceType": "ValueSet",
"id": "br-core-valueset-address-line-streettype",
"meta": {
"lastUpdated": "2020-03-12T14:50:48.259+00:00"
},
"language": "pt-BR",
"url": "http://www.saude.gov.br/fhir/r4/ValueSet/BRTipoLogradouro-1.0",
"version": "1.0",
"name": "Tipo_de_Logradouro",
"status": "active",
"experimental": false,
"date": "2020-03-12T14:50:47.8940392+00:00",
"publisher": "Ministério da Saúde do Brasil",
"description": "Classifica o tipo de logradouro.",
"immutable": false,
"compose": {
"include": [
{
"system": "http://www.saude.gov.br/fhir/r4/CodeSystem/BRTipoLogradouro",
"version": "*"
}
]
}
}

The output:

❯ cat Tipo_de_Logradouro.fsh
ValueSet: Tipo_de_Logradouro
Id: br-core-valueset-address-line-streettype
Description: "Classifica o tipo de logradouro."

input/fsh/codesystems on  master [!?]
❯ cat Tipo_de_Logradouro.fsh
CodeSystem: Tipo_de_Logradouro
Id: br-core-codesystem-streettype
Description: "Classificação os tipos de logradouros existentes para uso em endereços estruturados."

  • ^meta.lastUpdated = "2020-04-02T13:03:21.687+00:00"
  • ^language = #pt-BR
  • ^url = "http://www.saude.gov.br/fhir/r4/CodeSystem/BRTipoLogradouro"
  • ^version = "201701A"
  • ^status = #active
  • ^experimental = false
  • ^date = "2020-04-02T13:03:18.6480245+00:00"
  • ^publisher = "Ministério da Saúde do Brasil"
  • ^content = #complete
  • #008 "Avenida"
  • #081 "Rua"

Two files with the same name, from two files, with different names.

view this post on Zulip Hank Lenzi (Dec 21 2021 at 14:02):

Sorry, I don't know what I did in Zulip, I double-posted. I apologize for that.

view this post on Zulip Chris Moesel (Dec 21 2021 at 14:20):

OK. GoFSH uses the name of the entity as the file name. Since your CS and VS have the same name (i.e., the name property in the original JSON), then they result in FSH files with the same name. Since GoFSH puts them in different folders, there is no clash there.

You can keep them in separate folders in a SUSHI project (just like GoFSH produces them). But if you want to move them so they are in the same folder, you will need to rename at least one of the files. Renaming files is safe; it should not affect the output. Since GoFSH is intended to be a one-time operation, you'll just need to do this that one time (and, again, that's only if you choose to move all your files into the same folder).

view this post on Zulip Hank Lenzi (Dec 21 2021 at 14:36):

Well, I suppose gofsh was meant, indeed, to be a one-time operation. But then you create something, put it out to the World, and users like me start using it a little bit differently. The way we're using is to reverse-engineer a buggy "BR-Core" with the much more readable FSH syntax. FSH is the future of FHIR information modelling (there's no doubt in my mind), and we're resolute on learning it. Hence, our process of shoving everything in /resource so we can navigate the file tree easily.
I see the issue with "name". I didn't create those and I try no to deviate to much from the original source.
This is a minor issue. Thanks for the answers. It wasn't really clear to me that gofsh used name of the entity (eventually, I got that from debugging my error logs).
I would, however, warn about this somewhere in the documentation.

view this post on Zulip Chris Moesel (Dec 21 2021 at 14:43):

Thanks, @Hank Lenzi. It's always fun and interesting to see our stuff used in new and interesting ways! Depending on how buggy BR-Core is, GoFSH might still stumble around a little. It does expect the input to follow the FHIR spec to at least some degree!

If you haven't already, I would encourage you to try playing with the different output styles. Maybe you'll see something you like better. We'll also consider adding a new style that does a file-per-definition but dumps them all into the same folder. In the case, we'd probably prefix them w/ the type (So, ValueSet-SomeName, CodeSystem-SomeName, etc.).

view this post on Zulip Chris Moesel (Dec 21 2021 at 14:45):

It's GoFSH#169 if you'd like to track it (although I cannot guarantee if/when we'll get to it).


Last updated: Apr 12 2022 at 19:14 UTC