View Javadoc
1   package ca.uhn.fhir.jpa.term.loinc;
2   
3   /*-
4    * #%L
5    * HAPI FHIR JPA Server
6    * %%
7    * Copyright (C) 2014 - 2018 University Health Network
8    * %%
9    * Licensed under the Apache License, Version 2.0 (the "License");
10   * you may not use this file except in compliance with the License.
11   * You may obtain a copy of the License at
12   * 
13   *      http://www.apache.org/licenses/LICENSE-2.0
14   * 
15   * Unless required by applicable law or agreed to in writing, software
16   * distributed under the License is distributed on an "AS IS" BASIS,
17   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18   * See the License for the specific language governing permissions and
19   * limitations under the License.
20   * #L%
21   */
22  
23  import ca.uhn.fhir.jpa.entity.TermConcept;
24  import ca.uhn.fhir.jpa.term.IHapiTerminologyLoaderSvc;
25  import ca.uhn.fhir.jpa.term.IRecordHandler;
26  import org.apache.commons.csv.CSVRecord;
27  import org.hl7.fhir.r4.model.ConceptMap;
28  import org.hl7.fhir.r4.model.Enumerations;
29  import org.hl7.fhir.r4.model.ValueSet;
30  
31  import java.util.List;
32  import java.util.Map;
33  import java.util.Properties;
34  
35  import static org.apache.commons.lang3.StringUtils.trim;
36  
37  public class LoincIeeeMedicalDeviceCodeHandler extends BaseLoincHandler implements IRecordHandler {
38  
39  	public static final String LOINC_IEEE_CM_ID = "LOINC-IEEE-MEDICAL-DEVICE-CM";
40  	public static final String LOINC_IEEE_CM_URI = "http://loinc.org/cm/loinc-to-ieee-device-codes";
41  	public static final String LOINC_IEEE_CM_NAME = "LOINC/IEEE Device Code Mappings";
42  	private static final String CM_COPYRIGHT = "This content from LOINC® is copyright © 1995 Regenstrief Institute, Inc. and the LOINC Committee, and available at no cost under the license at https://loinc.org/license/. The LOINC/IEEE Medical Device Code Mapping Table contains content from IEEE (http://ieee.org), copyright © 2017 IEEE.";
43  
44  	/**
45  	 * Constructor
46  	 */
47  	public LoincIeeeMedicalDeviceCodeHandler(Map<String, TermConcept> theCode2concept, List<ValueSet> theValueSets, List<ConceptMap> theConceptMaps, Properties theUploadProperties) {
48  		super(theCode2concept, theValueSets, theConceptMaps, theUploadProperties);
49  	}
50  
51  	@Override
52  	public void accept(CSVRecord theRecord) {
53  
54  		String loincNumber = trim(theRecord.get("LOINC_NUM"));
55  		String longCommonName = trim(theRecord.get("LOINC_LONG_COMMON_NAME"));
56  		String ieeeCode = trim(theRecord.get("IEEE_CF_CODE10"));
57  		String ieeeDisplayName = trim(theRecord.get("IEEE_REFID"));
58  
59  		// LOINC Part -> IEEE 11073:10101 Mappings
60  		String sourceCodeSystemUri = IHapiTerminologyLoaderSvc.LOINC_URI;
61  		String targetCodeSystemUri = IHapiTerminologyLoaderSvc.IEEE_11073_10101_URI;
62  		addConceptMapEntry(
63  			new ConceptMapping()
64  				.setConceptMapId(LOINC_IEEE_CM_ID)
65  				.setConceptMapUri(LOINC_IEEE_CM_URI)
66  				.setConceptMapName(LOINC_IEEE_CM_NAME)
67  				.setSourceCodeSystem(sourceCodeSystemUri)
68  				.setSourceCode(loincNumber)
69  				.setSourceDisplay(longCommonName)
70  				.setTargetCodeSystem(targetCodeSystemUri)
71  				.setTargetCode(ieeeCode)
72  				.setTargetDisplay(ieeeDisplayName)
73  				.setEquivalence(Enumerations.ConceptMapEquivalence.EQUAL),
74  			CM_COPYRIGHT);
75  
76  	}
77  
78  
79  }