Skip to content

Commit

Permalink
Merge pull request #3 from dfleming9/feature/upgrade-to-schema-v6
Browse files Browse the repository at this point in the history
Add support for v6 schema
  • Loading branch information
dionmcm authored Sep 30, 2024
2 parents a0bd428 + 9a8e62c commit 5558d3d
Show file tree
Hide file tree
Showing 7 changed files with 229 additions and 197 deletions.
45 changes: 45 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# Compiled class file
*.class

# Log file
*.log

# BlueJ files
*.ctxt

# Mobile Tools for Java (J2ME)
.mtj.tmp/

# Package Files #
*.jar
*.war
*.nar
*.ear
*.zip
*.tar.gz
*.rar

# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
hs_err_pid*
replay_pid*

# maven
/target/

# output
/output/**

# upload
/upload/**

# mac crud
.DS_Store

# vscode
.vscode

# secrets
*.secret.properties

# excel outputs
*.xlsx
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

<groupId>au.csiro</groupId>
<artifactId>labcodeset-fhir-transform</artifactId>
<version>1.0.1</version>
<version>1.1.0</version>
<packaging>jar</packaging>

<name>Nederlandse Labcodeset XML to FHIR Terminology Transforms</name>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@
import org.hl7.fhir.r4.model.MetadataResource;
import org.hl7.fhir.r4.model.Resource;
import org.hl7.fhir.r4.model.ValueSet;

import au.csiro.fhir.transform.xml.nl.labcodeset.LabConcept;
import au.csiro.fhir.transform.xml.nl.labcodeset.LabConcept.Materials.Material;
import au.csiro.fhir.transform.xml.nl.labcodeset.MaterialDefinition;
import au.csiro.fhir.transform.xml.nl.labcodeset.Publication;
import au.csiro.fhir.transform.xml.nl.labcodeset.UnitDefinition;
Expand Down Expand Up @@ -56,7 +59,7 @@ public class LabcodesetResourceGenerator {
private Publication pub;
private File outputDir;
private String labcodesetVersion;
private Map<String, MaterialDefinition> materialMap = new HashMap<>();
private Map<String, Material> materialMap = new HashMap<>();
private Map<String, UnitDefinition> unitMap = new HashMap<>();

private TerminologyClient terminologyClient;
Expand Down Expand Up @@ -93,8 +96,10 @@ public LabcodesetResourceGenerator(File labcodesetFile, File outputDir, String l

this.labcodesetVersion = pub.getEffectiveDate().split("-")[0];

for (MaterialDefinition material : pub.getMaterials().getMaterial()) {
materialMap.put(material.getId(), material);
for (LabConcept concept : pub.getLabConcepts().getLabConcept()) {
for (Material material : concept.getMaterials().getMaterial()) {
materialMap.put(material.getCode(), material);
}
}

for (UnitDefinition unit : pub.getUnits().getUnit()) {
Expand Down Expand Up @@ -150,7 +155,7 @@ private void generateMaterialResources(Bundle bundle) {
}

private void generateUcumResources(Bundle bundle) {
UcumResourceGenerator ucumResourceGenerator = new UcumResourceGenerator(labcodesetVersion, loincVersion, unitMap, materialMap);
UcumResourceGenerator ucumResourceGenerator = new UcumResourceGenerator(labcodesetVersion, loincVersion, unitMap);

CodeSystem ucumCodeSystem = ucumResourceGenerator.createUcumCodeSystem(pub);
outputResource(ucumCodeSystem, UCUM_CS_FILENAME);
Expand All @@ -165,7 +170,7 @@ private void generateUcumResources(Bundle bundle) {

private void generateLoincResources(Bundle bundle) {
LoincResourceGenerator loincResourceGenerator =
new LoincResourceGenerator(labcodesetVersion, loincVersion, terminologyClient, unitMap, materialMap);
new LoincResourceGenerator(labcodesetVersion, loincVersion, terminologyClient, unitMap);

CodeSystem loincSupplement = loincResourceGenerator.createLoincCodeSystemSupplement(pub);
bundle.addEntry().setResource(loincSupplement);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,6 @@
import au.csiro.fhir.transform.xml.nl.labcodeset.LabConcept.Units;
import au.csiro.fhir.transform.xml.nl.labcodeset.LoincAxis;
import au.csiro.fhir.transform.xml.nl.labcodeset.LoincConcept;
import au.csiro.fhir.transform.xml.nl.labcodeset.MaterialDefinition;
import au.csiro.fhir.transform.xml.nl.labcodeset.MaterialOrMethodStatus;
import au.csiro.fhir.transform.xml.nl.labcodeset.Publication;
import au.csiro.fhir.transform.xml.nl.labcodeset.UnitDefinition;
import au.csiro.fhir.transforms.utility.Constants;
Expand Down Expand Up @@ -73,23 +71,20 @@ public class LoincResourceGenerator {
private String loincVersion;
private TerminologyClient terminologyClient;
private Map<String, UnitDefinition> unitMap;
private Map<String, MaterialDefinition> materialsMap;

/**
* @param labcodesetVersion version of the Labcodeset being transformed
* @param loincVersion LOINC version the Labcodeset file should be used with
* @param terminologyClient {@link TerminologyClient} that can be used to lookup details of LOINC
* codes
* @param unitMap Map of the unit references and their details in the Labcodeset file
* @param materialsMap Map of the materials references and their details in the Labcodeset file
*/
public LoincResourceGenerator(String labcodesetVersion, String loincVersion, TerminologyClient terminologyClient,
Map<String, UnitDefinition> unitMap, Map<String, MaterialDefinition> materialsMap) {
Map<String, UnitDefinition> unitMap) {
this.labcodesetVersion = labcodesetVersion;
this.loincVersion = loincVersion;
this.terminologyClient = terminologyClient;
this.unitMap = unitMap;
this.materialsMap = materialsMap;
}

/**
Expand Down Expand Up @@ -163,20 +158,9 @@ private void setUnitProperties(Units units, ConceptDefinitionComponent concept)
private void setMaterialProperties(Materials materials, ConceptDefinitionComponent concept) {
if (materials != null && materials.getMaterial() != null) {
for (Material material : materials.getMaterial()) {
if (material.getStatus() != null && !material.getStatus().equals(MaterialOrMethodStatus.ACTIVE)) {
System.err.println("All materials should be active, yet material " + material.getRef() + " on code " + concept.getCode() + " is "
+ material.getStatus());
}

MaterialDefinition materialDefinition = materialsMap.get(material.getRef());

if (materialDefinition != null) {
concept.addProperty(new ConceptPropertyComponent(new CodeType(LABCODESET_MATERIAL_PROPERTY),
new Coding(Constants.SCT_CS_URI, materialDefinition.getCode().toString(),
terminologyClient.getSnomedDisplay(materialDefinition.getCode().toString(), materialDefinition.getDisplayName()))));
} else {
System.err.println("Could not find material for reference " + material.getRef() + " - omitting this property!");
}
concept.addProperty(new ConceptPropertyComponent(new CodeType(LABCODESET_MATERIAL_PROPERTY),
new Coding(Constants.SCT_CS_URI, material.getCode().toString(),
terminologyClient.getSnomedDisplay(material.getCode().toString(), material.getDisplayName()))));
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@
import org.hl7.fhir.r4.model.ValueSet.ValueSetComposeComponent;
import au.csiro.fhir.transform.xml.nl.labcodeset.LabConcept;
import au.csiro.fhir.transform.xml.nl.labcodeset.LabConcept.Materials.Material;
import au.csiro.fhir.transform.xml.nl.labcodeset.MaterialDefinition;
import au.csiro.fhir.transform.xml.nl.labcodeset.MaterialOrMethodStatus;
import au.csiro.fhir.transform.xml.nl.labcodeset.Publication;
import au.csiro.fhir.transforms.utility.Constants;
import au.csiro.fhir.transforms.utility.TerminologyClient;
Expand All @@ -43,7 +41,7 @@ public class MaterialsResourceGenerator {
private String labcodesetVersion;
private String loincVersion;
private TerminologyClient terminologyClient;
private Map<String, MaterialDefinition> materialsMap;
private Map<String, Material> materialsMap;

/**
* @param labcodesetVersion version of the Labcodeset being transformed
Expand All @@ -53,7 +51,7 @@ public class MaterialsResourceGenerator {
* @param materialsMap Map of the materials references and their details in the Labcodeset file
*/
public MaterialsResourceGenerator(String labcodesetVersion, String loincVersion, TerminologyClient terminologyClient,
Map<String, MaterialDefinition> materialsMap) {
Map<String, Material> materialsMap) {
this.labcodesetVersion = labcodesetVersion;
this.loincVersion = loincVersion;
this.terminologyClient = terminologyClient;
Expand All @@ -70,7 +68,7 @@ public ValueSet createMaterialsValueSet(Publication pub) {
ValueSet valueSet = new ValueSet();
String identifier = "Labconcepts-materials-" + labcodesetVersion;
valueSet.setId(identifier);
valueSet.setName(identifier).setVersion(labcodesetVersion).setTitle(LABCODESET_MATERIALS_VS_TITLE).setStatus(PublicationStatus.DRAFT)
valueSet.setName(identifier).setVersion(labcodesetVersion).setTitle(LABCODESET_MATERIALS_VS_TITLE).setStatus(PublicationStatus.ACTIVE)
.setUrl(LABCODESET_MATERIALS_VS_URI).setDescription(LABCODESET_MATERIALS_VS_DESCRIPTION).setExperimental(false)
.setPublisher(Constants.LABCODESET_RESOURCE_PUBLISHER).setCopyright(Constants.LABCODESET_RESOURCE_COPYRIGHT)
.setLanguage(Constants.DUTCH_LANGUAGE_CODE);
Expand All @@ -82,11 +80,8 @@ public ValueSet createMaterialsValueSet(Publication pub) {
conceptSet.setSystem(Constants.SCT_CS_URI);
conceptSet.setVersion(Constants.NL_SCT_EDITION);

for (MaterialDefinition material : pub.getMaterials().getMaterial()) {
if (material.getStatus() != null && !material.getStatus().equals(MaterialOrMethodStatus.ACTIVE)) {
System.err.println("All materials should be active, yet material " + material.getCode() + " is " + material.getStatus());
}

for (Map.Entry<String, Material> entry : materialsMap.entrySet()) {
Material material = entry.getValue();
ConceptReferenceComponent con = new ConceptReferenceComponent();

con.setCode(material.getCode().toString());
Expand Down Expand Up @@ -128,11 +123,6 @@ public ConceptMap createMaterialsConceptMap(Publication pub) {

if (labConcept.getMaterials() != null) {
for (Material material : labConcept.getMaterials().getMaterial()) {
if (material.getStatus() != null && !material.getStatus().equals(MaterialOrMethodStatus.ACTIVE)) {
System.err.println("All materials should be active, yet material " + material.getRef() + " on code "
+ labConcept.getLoincConcept().getLoincNum() + " is " + material.getStatus());
}

SourceElementComponent element = new SourceElementComponent();
element.setCode(labConcept.getLoincConcept().getLoincNum());
if (labConcept.getLoincConcept().getTranslation() != null
Expand All @@ -143,7 +133,7 @@ public ConceptMap createMaterialsConceptMap(Publication pub) {
}

TargetElementComponent targetElement = new TargetElementComponent();
MaterialDefinition cachedMaterial = materialsMap.get(material.getRef());
Material cachedMaterial = materialsMap.get(material.getCode());
targetElement.setCode(cachedMaterial.getCode().toString());
targetElement.setDisplay(terminologyClient.getSnomedDisplay(targetElement.getCode(), cachedMaterial.getDisplayName()));
targetElement.setEquivalence(ConceptMapEquivalence.RELATEDTO);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
import org.hl7.fhir.r4.model.ValueSet.ValueSetComposeComponent;
import au.csiro.fhir.transform.xml.nl.labcodeset.LabConcept;
import au.csiro.fhir.transform.xml.nl.labcodeset.LabConcept.Units;
import au.csiro.fhir.transform.xml.nl.labcodeset.MaterialDefinition;
import au.csiro.fhir.transform.xml.nl.labcodeset.Publication;
import au.csiro.fhir.transform.xml.nl.labcodeset.UnitDefinition;
import au.csiro.fhir.transforms.utility.Constants;
Expand Down Expand Up @@ -56,10 +55,8 @@ public class UcumResourceGenerator {
* @param terminologyClient {@link TerminologyClient} that can be used to lookup details of LOINC
* codes
* @param unitMap Map of the unit references and their details in the Labcodeset file
* @param materialsMap Map of the materials references and their details in the Labcodeset file
*/
public UcumResourceGenerator(String labcodesetVersion, String loincVersion, Map<String, UnitDefinition> unitMap,
Map<String, MaterialDefinition> materialsMap) {
public UcumResourceGenerator(String labcodesetVersion, String loincVersion, Map<String, UnitDefinition> unitMap) {
this.labcodesetVersion = labcodesetVersion;
this.loincVersion = loincVersion;
this.unitMap = unitMap;
Expand Down
Loading

0 comments on commit 5558d3d

Please sign in to comment.