@Test public void testBuild(){ Map<String, Object> attributes = new HashMap<>(); attributes.put("value", "coded text value"); Map<String, Object> definingCode = new HashMap<>(); attributes.put("definingCode", definingCode); Map<String, Object> terminology = new HashMap<>(); definingCode.put("terminologyId", terminology); terminology.put("value", "local"); definingCode.put("codeString", "at9999"); Map<String, Object> valueMap = new HashMap<>(); valueMap.put(CompositionSerializer.TAG_VALUE, attributes); DvText codedText = DvCodedTextVBean.getInstance(valueMap); assertNotNull(codedText); }
public static DvCodedText getInstance(Map<String, Object> attributes){ Object value = attributes.get(CompositionSerializer.TAG_VALUE); if (value == null) throw new IllegalArgumentException("No value in attributes"); if (value instanceof DvCodedText) return (DvCodedText)value; if (value instanceof Map) { Map<String, Object> valueMap = (Map) value; String actualValue = (String) valueMap.get("value"); CodePhrase codePhrase; Object definingCode = valueMap.get("definingCode"); if (definingCode instanceof Map) { Map<String, Object> defCode = (Map<String, Object>) valueMap.get("definingCode"); String terminologyId = ((Map<String, String>) defCode.get("terminologyId")).get("value"); String codeString = (String) defCode.get("codeString"); codePhrase = new CodePhrase(terminologyId, codeString); } else if (definingCode instanceof CodePhrase) codePhrase = (CodePhrase)definingCode; else throw new IllegalArgumentException("Could not handle codephrase argument:"+definingCode); DvCodedText dvCodedText = new DvCodedText(actualValue, codePhrase); Object mappings = valueMap.get("mappings"); if (mappings != null && mappings instanceof List){ Map<String, Object> termMappingValueMap = new HashMap<>(); List<TermMapping> termMappings = new ArrayList<>(); for (Object termMap: (List)mappings){ termMappingValueMap.put(CompositionSerializer.TAG_VALUE, termMap); TermMapping termMapping = TermMappingVBean.getInstance(termMappingValueMap); termMappings.add(termMapping); } dvCodedText.setMappings(termMappings); } return dvCodedText; } throw new IllegalArgumentException("Could not get instance"); }
DvCodedTextVBean extends DataValueAdapter implements I_VBeanWrapper { public static DvCodedText getInstance(Map<String, Object> attributes){ Object value = attributes.get(CompositionSerializer.TAG_VALUE); if (value == null) throw new IllegalArgumentException("No value in attributes"); if (value instanceof DvCodedText) return (DvCodedText)value; if (value instanceof Map) { Map<String, Object> valueMap = (Map) value; String actualValue = (String) valueMap.get("value"); CodePhrase codePhrase; Object definingCode = valueMap.get("definingCode"); if (definingCode instanceof Map) { Map<String, Object> defCode = (Map<String, Object>) valueMap.get("definingCode"); String terminologyId = ((Map<String, String>) defCode.get("terminologyId")).get("value"); String codeString = (String) defCode.get("codeString"); codePhrase = new CodePhrase(terminologyId, codeString); } else if (definingCode instanceof CodePhrase) codePhrase = (CodePhrase)definingCode; else throw new IllegalArgumentException("Could not handle codephrase argument:"+definingCode); DvCodedText dvCodedText = new DvCodedText(actualValue, codePhrase); Object mappings = valueMap.get("mappings"); if (mappings != null && mappings instanceof List){ Map<String, Object> termMappingValueMap = new HashMap<>(); List<TermMapping> termMappings = new ArrayList<>(); for (Object termMap: (List)mappings){ termMappingValueMap.put(CompositionSerializer.TAG_VALUE, termMap); TermMapping termMapping = TermMappingVBean.getInstance(termMappingValueMap); termMappings.add(termMapping); } dvCodedText.setMappings(termMappings); } return dvCodedText; } throw new IllegalArgumentException("Could not get instance"); } }
DvCodedTextVBean extends DataValueAdapter implements I_VBeanWrapper { public static DvCodedText getInstance(Map<String, Object> attributes){ Object value = attributes.get(CompositionSerializer.TAG_VALUE); if (value == null) throw new IllegalArgumentException("No value in attributes"); if (value instanceof DvCodedText) return (DvCodedText)value; if (value instanceof Map) { Map<String, Object> valueMap = (Map) value; String actualValue = (String) valueMap.get("value"); CodePhrase codePhrase; Object definingCode = valueMap.get("definingCode"); if (definingCode instanceof Map) { Map<String, Object> defCode = (Map<String, Object>) valueMap.get("definingCode"); String terminologyId = ((Map<String, String>) defCode.get("terminologyId")).get("value"); String codeString = (String) defCode.get("codeString"); codePhrase = new CodePhrase(terminologyId, codeString); } else if (definingCode instanceof CodePhrase) codePhrase = (CodePhrase)definingCode; else throw new IllegalArgumentException("Could not handle codephrase argument:"+definingCode); DvCodedText dvCodedText = new DvCodedText(actualValue, codePhrase); Object mappings = valueMap.get("mappings"); if (mappings != null && mappings instanceof List){ Map<String, Object> termMappingValueMap = new HashMap<>(); List<TermMapping> termMappings = new ArrayList<>(); for (Object termMap: (List)mappings){ termMappingValueMap.put(CompositionSerializer.TAG_VALUE, termMap); TermMapping termMapping = TermMappingVBean.getInstance(termMappingValueMap); termMappings.add(termMapping); } dvCodedText.setMappings(termMappings); } return dvCodedText; } throw new IllegalArgumentException("Could not get instance"); } DvCodedTextVBean(DvCodedText text); }
DvCodedTextVBean extends DataValueAdapter implements I_VBeanWrapper { public static DvCodedText getInstance(Map<String, Object> attributes){ Object value = attributes.get(CompositionSerializer.TAG_VALUE); if (value == null) throw new IllegalArgumentException("No value in attributes"); if (value instanceof DvCodedText) return (DvCodedText)value; if (value instanceof Map) { Map<String, Object> valueMap = (Map) value; String actualValue = (String) valueMap.get("value"); CodePhrase codePhrase; Object definingCode = valueMap.get("definingCode"); if (definingCode instanceof Map) { Map<String, Object> defCode = (Map<String, Object>) valueMap.get("definingCode"); String terminologyId = ((Map<String, String>) defCode.get("terminologyId")).get("value"); String codeString = (String) defCode.get("codeString"); codePhrase = new CodePhrase(terminologyId, codeString); } else if (definingCode instanceof CodePhrase) codePhrase = (CodePhrase)definingCode; else throw new IllegalArgumentException("Could not handle codephrase argument:"+definingCode); DvCodedText dvCodedText = new DvCodedText(actualValue, codePhrase); Object mappings = valueMap.get("mappings"); if (mappings != null && mappings instanceof List){ Map<String, Object> termMappingValueMap = new HashMap<>(); List<TermMapping> termMappings = new ArrayList<>(); for (Object termMap: (List)mappings){ termMappingValueMap.put(CompositionSerializer.TAG_VALUE, termMap); TermMapping termMapping = TermMappingVBean.getInstance(termMappingValueMap); termMappings.add(termMapping); } dvCodedText.setMappings(termMappings); } return dvCodedText; } throw new IllegalArgumentException("Could not get instance"); } DvCodedTextVBean(DvCodedText text); @Override Map<String, Object> getFieldMap(); @Override DvCodedText parse(String value, String... defaults); static DvCodedText getInstance(Map<String, Object> attributes); static DvCodedText generate(); }
DvCodedTextVBean extends DataValueAdapter implements I_VBeanWrapper { public static DvCodedText getInstance(Map<String, Object> attributes){ Object value = attributes.get(CompositionSerializer.TAG_VALUE); if (value == null) throw new IllegalArgumentException("No value in attributes"); if (value instanceof DvCodedText) return (DvCodedText)value; if (value instanceof Map) { Map<String, Object> valueMap = (Map) value; String actualValue = (String) valueMap.get("value"); CodePhrase codePhrase; Object definingCode = valueMap.get("definingCode"); if (definingCode instanceof Map) { Map<String, Object> defCode = (Map<String, Object>) valueMap.get("definingCode"); String terminologyId = ((Map<String, String>) defCode.get("terminologyId")).get("value"); String codeString = (String) defCode.get("codeString"); codePhrase = new CodePhrase(terminologyId, codeString); } else if (definingCode instanceof CodePhrase) codePhrase = (CodePhrase)definingCode; else throw new IllegalArgumentException("Could not handle codephrase argument:"+definingCode); DvCodedText dvCodedText = new DvCodedText(actualValue, codePhrase); Object mappings = valueMap.get("mappings"); if (mappings != null && mappings instanceof List){ Map<String, Object> termMappingValueMap = new HashMap<>(); List<TermMapping> termMappings = new ArrayList<>(); for (Object termMap: (List)mappings){ termMappingValueMap.put(CompositionSerializer.TAG_VALUE, termMap); TermMapping termMapping = TermMappingVBean.getInstance(termMappingValueMap); termMappings.add(termMapping); } dvCodedText.setMappings(termMappings); } return dvCodedText; } throw new IllegalArgumentException("Could not get instance"); } DvCodedTextVBean(DvCodedText text); @Override Map<String, Object> getFieldMap(); @Override DvCodedText parse(String value, String... defaults); static DvCodedText getInstance(Map<String, Object> attributes); static DvCodedText generate();  }