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

Adl conv correct atcode numbering #582

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import com.nedap.archie.aom.utils.AOMUtils;
import com.nedap.archie.aom.utils.NodeIdUtil;
import com.nedap.archie.base.Cardinality;
import com.nedap.archie.definitions.AdlCodeDefinitions;
import com.nedap.archie.paths.PathSegment;
import com.nedap.archie.query.APathQuery;
import com.nedap.archie.rminfo.MetaModels;
Expand Down Expand Up @@ -471,7 +472,22 @@ public static String convertCode(String oldCode, String newCodePrefix) {
return oldCode;
}
nodeIdUtil.setPrefix(newCodePrefix); //will automatically strip the leading zeroes due to integer-parsing
if(!oldCode.startsWith("at0.") && !oldCode.startsWith("ac0.")) {

/**
* Conversion rules:
* ADL1.4 code ADL2 code
* non-specialised node-identifying code at000N idN+1
* non-specialised value code at000N atN
* non-specialised value-set code ac000N acN+1
* any redefined code in specialised archetype at000N.x.y.z modify root part as above
* any new code in a specialised archetype at0.x, ac0.1.x etc. don't modify
*
* This preserves the value codes from ADL1.4 to ADL2, with the only difference being zero-filling of the
* top-level codes, i.e. codes like at0015 -> at15
* id-code and ac-codes are incremented by one, because in the old system they (unfortunately) started
* from 0, which clashes with the ADL2 system where '0' in a code means no code defined at this level.
*/
if(!oldCode.startsWith("at0.") && !oldCode.startsWith("ac0.") && !newCodePrefix.equals(AdlCodeDefinitions.VALUE_CODE_LEADER)) {
//a bit tricky, since the root of an archetype starts with at0000.0, but that's different from this I guess
nodeIdUtil.getCodes().set(0, nodeIdUtil.getCodes().get(0) + 1); //increment with 1, old is 0-based
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import com.nedap.archie.antlr.errors.ANTLRParserErrors;
import com.nedap.archie.aom.Archetype;
import com.nedap.archie.archetypevalidator.ValidationResult;
import com.nedap.archie.definitions.AdlCodeDefinitions;
import com.nedap.archie.diff.Differentiator;
import com.nedap.archie.flattener.Flattener;
import com.nedap.archie.flattener.InMemoryFullArchetypeRepository;
Expand All @@ -20,7 +21,7 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.io.InputStream;
import java.io.*;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.LinkedHashMap;
Expand Down Expand Up @@ -77,8 +78,10 @@ public void testRiskFamilyhistory() throws Exception {
if(conversionResult.getException() != null) {
logger.error("exception in converter for archetype id " + conversionResult.getArchetypeId(), conversionResult.getException());
}

// if we have a result, we'll write it out to the resources area
if (conversionResult.getArchetype() != null) {
// System.out.println(ADLArchetypeSerializer.serialize(conversionResult.getArchetype()));
writeConvertedArchetype (conversionResult);
} else {
logger.warn("archetype null: " + conversionResult.getArchetypeId());
}
Expand Down Expand Up @@ -120,11 +123,12 @@ public void parseLots() throws Exception {
}
ADL2ConversionResultList converted = new ADL14Converter(BuiltinReferenceModels.getMetaModels(), conversionConfiguration)
.convert(archetypes);
for(ADL2ConversionResult result:converted.getConversionResults()) {
if(result.getArchetype() != null) {// && result.getArchetype().getParentArchetypeId() != null) {
for(ADL2ConversionResult conversionResult:converted.getConversionResults()) {
if(conversionResult.getArchetype() != null) {// && result.getArchetype().getParentArchetypeId() != null) {
// System.out.println(ADLArchetypeSerializer.serialize(result.getArchetype()));
writeConvertedArchetype (conversionResult);
} else {
logger.warn("archetype null: " + result.getArchetypeId());
logger.warn("archetype null: " + conversionResult.getArchetypeId());
}
}

Expand Down Expand Up @@ -217,5 +221,23 @@ private Archetype parse(Map<String, Exception> exceptions, Map<String, ANTLRPars
return null;
}

File adl4convertedDir = new File("src/test/resources/adl14converted");
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Apart from the variable name needing to be adl14ConvertedDir - why write all these files, and why commit them all?

if committed, needs a clear marking to which ADL 2 version these are converted in the directory structure.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I included the generated files because you can run a conversion (with or without source code changes) and see in the Git diffs if the conversion changed anything compared to the previous run.

I had not originally envisaged that there would need to be two variants of the at-code conversion, since the SEC seems to agree on the mapping method within which at000N codes are not renumbered in the upgrade to ADL2 codes. But of course the Nedap system actually contains ADL2 archetypes converted from ADL1.4 archetypes, with the previous rule, i.e. 'add one to all codes'.

How we call these various conversions is a question for SEC, so I'll post there. But I agree that we probably need two output directories to distinguish the two forms of code conversion.


private void writeConvertedArchetype (ADL2ConversionResult conversionResult) {
File opFile;
String opFileName = conversionResult.getArchetypeId() + ".adls";
try {
opFile = new File (adl4convertedDir, opFileName);
if (!opFile.exists()) {
opFile.createNewFile();
}
FileWriter outputFileWriter = new FileWriter(opFile);
outputFileWriter.write(ADLArchetypeSerializer.serialize(conversionResult.getArchetype()));
outputFileWriter.close();
}
catch (IOException e) {
System.out.println("Failed to create " + opFileName);
e.printStackTrace();
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,135 @@
archetype (adl_version=2.0.6; rm_release=1.1.0; generated; uid=5c4b8ea6-4c9c-4c8f-9c37-b95e0a5e0aff; build_uid=4d801686-8c5f-4d96-b62b-9dcaf4008936)
openEHR-DEMOGRAPHIC-ADDRESS.address-provider.v0.0.1-alpha

specialize
openEHR-DEMOGRAPHIC-ADDRESS.address.v0

language
original_language = <[ISO_639-1::en]>
translations = <
["ko"] = <
language = <[ISO_639-1::ko]>
author = <
["name"] = <"Seung-Jong Yu">
["organisation"] = <"NOUSCO Co., Ltd.">
>
accreditation = <"Certified Board of Family Medicine in South Korea">
>
["pt-br"] = <
language = <[ISO_639-1::pt-br]>
author = <
["name"] = <"Sergio Miranda Freire">
["organisation"] = <"Universidade do Estado do Rio de Janeiro - UERJ">
["email"] = <"[email protected]">
>
>
>

description
original_author = <
["name"] = <"Sergio Miranda Freire & Rigoleta Dutra Mediano Dias">
["organisation"] = <"Universidade do Estado do Rio de Janeiro - UERJ">
["email"] = <"[email protected]">
["date"] = <"2009-05-22">
>
original_namespace = <"org.openehr">
original_publisher = <"openEHR Foundation">
other_contributors = <"Rigoleta Dutra, Ministry of Defense, Brazil (openEHR Editor)", "Sergio Freire, State University of Rio de Janeiro, Brazil (openEHR Editor)", "Sebastian Garde, Ocean Informatics, Germany (Editor)", "Omer Hotomaroglu, Turkey (Editor)", "Heather Leslie, Ocean Informatics, Australia (Editor)", "Ian McNicoll, freshEHR Clinical Informatics, United Kingdom (openEHR Editor)">
lifecycle_state = <"in_development">
custodian_namespace = <"org.openehr">
custodian_organisation = <"openEHR Foundation">
licence = <"This work is licensed under the Creative Commons Attribution-ShareAlike 3.0 License. To view a copy of this license, visit http://creativecommons.org/licenses/by-sa/3.0/.">
references = <
["1"] = <"ISO/DTS 27527:2007(E) - Provider Identification - Draft Technnical Specification - International Organization for Standardization">
>
other_details = <
["MD5-CAM-1.0.1"] = <"7B288FEED37BD006D14048650C371F58">
>
details = <
["ko"] = <
language = <[ISO_639-1::ko]>
purpose = <"ISO 22220 표준에 기반한 진료제공자 주소에 대한 데이터의 표현. 이 주소는 지리학적 위치를 나타나면 여러 방식으로 사용할 수 있음 : 거주지 주소, 우편 주소 등.">
keywords = <"*인적정보 서비스(ko)", "*진료제공자 주소(ko)", "*지리적 주소(ko)">
use = <"진료제공자 주소에 대한 등록하는 인적정보 서비스에서 사용됨.">
misuse = <"이 archetype은 이메일 주소, IP 주소, 전화, 팩스 그리고 페이져를 위해 사용될 수 없음. 그러한 아이템들을 위해서는 electronic_communication archetype를 사용.">
copyright = <"© openEHR Foundation">
>
["pt-br"] = <
language = <[ISO_639-1::pt-br]>
purpose = <"Representação dos detalhes do endereço de um prestador de assistência à saúde. Este endereço representa uma localização geográfica que pode ser utilizada para diversos fins: consultório, endereço postal, etc.">
keywords = <"serviço demográfico", "endereço de um prestador de assistência à saúde", "localização geográfica.">
use = <"Usado em serviços demográficos para registrar os detalhes de um endereço de um prestador de assistência à saúde.">
misuse = <"Este arquétipo não deve ser usado para endereços de correio eletrônico, endereços IP, endereços de computador, telefone, fax e pager. Para estes itens, use o arquétipo electronic_communication.">
copyright = <"© openEHR Foundation">
>
["en"] = <
language = <[ISO_639-1::en]>
purpose = <"Representation of data about a healthcare provider address, based on ISO standards. This address represents a geographic location which can be used in several ways: business address, postal address, etc.">
keywords = <"demographic service", "healthcare provider address", "geographic location">
use = <"Used in demographic services to register data about a healthcare provider address.">
misuse = <"This archetype can not used for email address, IP address, computer address, telephone, fax and pager. For these items use the electronic_communication archetype.">
copyright = <"© openEHR Foundation">
>
>

definition
ADDRESS[id1.1] matches { -- Healthcare provider address
/details[id2]/items matches {
ELEMENT[id0.2] occurrences matches {0..1} matches { -- Communication privacy
value matches {
DV_BOOLEAN[id0.9000]
}
}
ELEMENT[id0.3] matches { -- Healthcare provider identifier
value matches {
DV_TEXT[id0.9001]
}
}
}
}

terminology
term_definitions = <
["ko"] = <
["id1.1"] = <
text = <"진료제공자 주소">
description = <"ISO 표준에 기반한 진료제공자 주소.">
>
["id0.3"] = <
text = <"진료제공자 식별자">
description = <"이 통신 메커니즘을 액세스할지도 모르는 진료자 제공자의 식별자.">
>
["id0.2"] = <
text = <"통신 보안">
description = <"이 통신 메커니즘이 특정 진료제공자 외에는 공개적으로 표시되지 않는다는 것을 나타냄.">
>
>
["pt-br"] = <
["id1.1"] = <
text = <"Endereço de um Prestador de Assistência à Saúde">
description = <"Endereço Postal de um Prestador de Assistência à Saúde.">
>
["id0.3"] = <
text = <"Identificador do prestador">
description = <"Identificador de um prestador que pode acessar este meio de comunicação.">
>
["id0.2"] = <
text = <"Indicador de privacidade">
description = <"Indica quando um mecanismo de comunicação não é para ser exibido abertamente, exceto para organizações específicas.">
>
>
["en"] = <
["id1.1"] = <
text = <"Healthcare provider address">
description = <"Healthcare provider address, based on ISO standards.">
>
["id0.3"] = <
text = <"Healthcare provider identifier">
description = <"Identifier of a healthcare provider who may access this communication mechanism.">
>
["id0.2"] = <
text = <"Communication privacy">
description = <"Indicates that this communication mechanism is not to be openly displayed, except to specific providers.">
>
>
>
Loading