fix bug in NpmPackage loader
This commit is contained in:
parent
9b04cff812
commit
0dfc060665
|
@ -58,6 +58,7 @@ import ca.uhn.fhir.model.api.annotation.Child;
|
|||
import ca.uhn.fhir.model.api.annotation.DatatypeDef;
|
||||
import ca.uhn.fhir.model.api.annotation.Description;
|
||||
import org.hl7.fhir.instance.model.api.ICompositeType;
|
||||
import org.hl7.fhir.dstu2.model.Coding;
|
||||
import org.hl7.fhir.exceptions.FHIRException;
|
||||
import org.hl7.fhir.utilities.Utilities;
|
||||
/**
|
||||
|
@ -252,6 +253,25 @@ public class CodeableConcept extends Type implements ICompositeType {
|
|||
;
|
||||
}
|
||||
|
||||
// added from java-adornments.txt:
|
||||
|
||||
public boolean hasCoding(String system, String code) {
|
||||
for (Coding c : getCoding()) {
|
||||
if (system.equals(c.getSystem()) && code.equals(c.getCode()))
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public CodeableConcept(Coding code) {
|
||||
super();
|
||||
addCoding(code);
|
||||
}
|
||||
|
||||
|
||||
|
||||
// end addition
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -952,6 +952,7 @@ public class Mimic14Importer {
|
|||
bnd.setType(BundleType.COLLECTION);
|
||||
csv.readHeaders();
|
||||
int t = 0;
|
||||
Set<String> rell = new HashSet<>();
|
||||
while (csv.line()) {
|
||||
Encounter enc = new Encounter();
|
||||
t++;
|
||||
|
@ -970,16 +971,35 @@ public class Mimic14Importer {
|
|||
}
|
||||
// ignore insurance
|
||||
if (csv.has("language")) {
|
||||
String lang = ini.getStringProperty("language", csv.cell("language"));
|
||||
if (lang == null) {
|
||||
System.out.println("Unknown language: "+csv.cell("language"));
|
||||
} else {
|
||||
pat.getCommunication().clear();
|
||||
pat.addCommunication().getLanguage().setText(csv.cell("language"));
|
||||
pat.addCommunication().getLanguage().addCoding(iniCodeToCoding(lang, "urn:ietf:bcp:47", "language", csv.cell("language")));
|
||||
}
|
||||
}
|
||||
|
||||
if (csv.has("religion")) {
|
||||
String religion = ini.getStringProperty("religion", csv.cell("religion"));
|
||||
if (religion == null) {
|
||||
if (!rell.contains(csv.cell("religion"))) {
|
||||
System.out.println("unknown religion "+csv.cell("religion"));
|
||||
}
|
||||
rell.add(csv.cell("religion"));
|
||||
} else {
|
||||
ToolingExtensions.removeExtension(pat, "http://hl7.org/fhir/StructureDefinition/patient-religion");
|
||||
pat.addExtension().setUrl("http://hl7.org/fhir/StructureDefinition/patient-religion").setValue(new CodeableConcept().setText(csv.cell("religion")));
|
||||
pat.addExtension().setUrl("http://hl7.org/fhir/StructureDefinition/patient-religion").setValue(new CodeableConcept(iniCodeToCoding(religion, null, "religion", csv.cell("religion"))));
|
||||
}
|
||||
}
|
||||
if (csv.has("marital_status")) {
|
||||
String ms = ini.getStringProperty("marital-status", csv.cell("marital_status"));
|
||||
if (ms == null) {
|
||||
System.out.println("Unknown marital-status: "+csv.cell("marital_status"));
|
||||
} else {
|
||||
pat.getMaritalStatus().getCoding().clear();
|
||||
pat.getMaritalStatus().addCoding().setSystem("http://mimic.physionet.org/fhir/MaritalStatus").setCode(csv.cell("marital_status"));
|
||||
pat.getMaritalStatus().addCoding(iniCodeToCoding(ms, null, "marital-status", csv.cell("marital_status")));
|
||||
}
|
||||
}
|
||||
if (csv.has("ethnicity")) {
|
||||
ToolingExtensions.removeExtension(pat, "http://hl7.org/fhir/us/core/StructureDefinition/us-core-ethnicity");
|
||||
|
@ -999,6 +1019,25 @@ public class Mimic14Importer {
|
|||
return bnd;
|
||||
}
|
||||
|
||||
private Coding iniCodeToCoding(String code, String defSystem, String context, String value) {
|
||||
Coding res = new Coding();
|
||||
if (code.contains("#")) {
|
||||
res.setSystem(code.substring(0, code.indexOf("#")).trim());
|
||||
code = code.substring(code.indexOf("#")+1);
|
||||
} else if (defSystem == null) {
|
||||
throw new Error("Code for "+value+" in section ["+context+"] does not contain a system, and a system is required");
|
||||
} else {
|
||||
res.setSystem(defSystem);
|
||||
}
|
||||
if (code.contains(": ")) {
|
||||
res.setCode(code.substring(0, code.indexOf(":")));
|
||||
res.setDisplay(code.substring(code.indexOf(":")+1).trim());
|
||||
} else {
|
||||
res.setCode(code.trim());
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
private Bundle processPatients(String src) throws FileNotFoundException, IOException {
|
||||
System.out.print("Processing Patients... ");
|
||||
CSVReader csv = new CSVReader(new FileInputStream(src));
|
||||
|
|
|
@ -192,7 +192,7 @@ public class NpmPackage {
|
|||
try {
|
||||
res.readIndexFile((JsonObject) JsonTrackingParser.parseJson(new String(res.content.get("package/.index.json"))));
|
||||
} catch (Exception e) {
|
||||
TextFile.bytesToFile(res.content.get("package/.index.json"), "c:\\temp\\.index.json");
|
||||
TextFile.bytesToFile(res.content.get("package/.index.json"), Utilities.path("[tmp]", ".index.json"));
|
||||
throw new IOException("Error parsing package/.index.json: "+e.getMessage(), e);
|
||||
}
|
||||
return res;
|
||||
|
|
Loading…
Reference in New Issue