mlhim-specs-dev team mailing list archive
-
mlhim-specs-dev team
-
Mailing list archive
-
Message #00731
[Branch ~cdd-dev/cdd/trunk] Rev 257: Updated xls2ccd.py to build 2.4.0 CCDs, added mlhim2RM.py
------------------------------------------------------------
revno: 257
committer: Timothy W. Cook <timothywayne.cook@xxxxxxxxx>
branch nick: cdd
timestamp: Sat 2012-09-15 19:10:45 -0300
message:
Updated xls2ccd.py to build 2.4.0 CCDs, added mlhim2RM.py
removed:
src/xls2ccd/Demography_NCI_Standard_Template 06_29_2012.xls
src/xls2ccd/Laboratory Test_Results_NCI Standard_Template08_15_2012.xls
src/xls2ccd/PET Patient Prep_NCI Standard_Template_08_29_2012.xls
src/xls2ccd/Physical Examination_NCI Standard_Template 08_03_2012.xls
added:
src/xls2ccd/examples/
src/xls2ccd/examples/Demography/
src/xls2ccd/examples/Demography/Demography_NCI_Standard_Template 06_29_2012.xls
src/xls2ccd/examples/Demography/MLHIM_Std_Template-NCI-Demographics.xls
src/xls2ccd/examples/Laboratory Test Results.zip
src/xls2ccd/examples/MLHIM_Std_Template/
src/xls2ccd/examples/MLHIM_Std_Template/.~lock.MLHIM_Std_Template-xls2ccd.xls#
src/xls2ccd/examples/MLHIM_Std_Template/MLHIM_Std_Template-xls2ccd.xls
src/xls2ccd/examples/PET Patient Prep/
src/xls2ccd/examples/PET Patient Prep/PET Patient Prep_NCI Standard_Template_08_29_2012.xls
src/xls2ccd/examples/Physical Exam/
src/xls2ccd/examples/Physical Exam/Physical Examination_NCI Standard_Template 08_03_2012.xls
src/xls2ccd/mlhim2RM.py
modified:
src/xls2ccd/xls2ccd.py
--
lp:cdd
https://code.launchpad.net/~cdd-dev/cdd/trunk
Your team MLHIM Specifications Developers is subscribed to branch lp:cdd.
To unsubscribe from this branch go to https://code.launchpad.net/~cdd-dev/cdd/trunk/+edit-subscription
=== removed file 'src/xls2ccd/Demography_NCI_Standard_Template 06_29_2012.xls'
Binary files src/xls2ccd/Demography_NCI_Standard_Template 06_29_2012.xls 2012-08-31 00:54:47 +0000 and src/xls2ccd/Demography_NCI_Standard_Template 06_29_2012.xls 1970-01-01 00:00:00 +0000 differ
=== removed file 'src/xls2ccd/Laboratory Test_Results_NCI Standard_Template08_15_2012.xls'
Binary files src/xls2ccd/Laboratory Test_Results_NCI Standard_Template08_15_2012.xls 2012-08-31 00:54:47 +0000 and src/xls2ccd/Laboratory Test_Results_NCI Standard_Template08_15_2012.xls 1970-01-01 00:00:00 +0000 differ
=== removed file 'src/xls2ccd/PET Patient Prep_NCI Standard_Template_08_29_2012.xls'
Binary files src/xls2ccd/PET Patient Prep_NCI Standard_Template_08_29_2012.xls 2012-08-31 00:54:47 +0000 and src/xls2ccd/PET Patient Prep_NCI Standard_Template_08_29_2012.xls 1970-01-01 00:00:00 +0000 differ
=== removed file 'src/xls2ccd/Physical Examination_NCI Standard_Template 08_03_2012.xls'
Binary files src/xls2ccd/Physical Examination_NCI Standard_Template 08_03_2012.xls 2012-08-31 00:54:47 +0000 and src/xls2ccd/Physical Examination_NCI Standard_Template 08_03_2012.xls 1970-01-01 00:00:00 +0000 differ
=== added directory 'src/xls2ccd/examples'
=== added directory 'src/xls2ccd/examples/Demography'
=== added file 'src/xls2ccd/examples/Demography/Demography_NCI_Standard_Template 06_29_2012.xls'
Binary files src/xls2ccd/examples/Demography/Demography_NCI_Standard_Template 06_29_2012.xls 1970-01-01 00:00:00 +0000 and src/xls2ccd/examples/Demography/Demography_NCI_Standard_Template 06_29_2012.xls 2012-09-15 22:10:45 +0000 differ
=== added file 'src/xls2ccd/examples/Demography/MLHIM_Std_Template-NCI-Demographics.xls'
Binary files src/xls2ccd/examples/Demography/MLHIM_Std_Template-NCI-Demographics.xls 1970-01-01 00:00:00 +0000 and src/xls2ccd/examples/Demography/MLHIM_Std_Template-NCI-Demographics.xls 2012-09-15 22:10:45 +0000 differ
=== added file 'src/xls2ccd/examples/Laboratory Test Results.zip'
Binary files src/xls2ccd/examples/Laboratory Test Results.zip 1970-01-01 00:00:00 +0000 and src/xls2ccd/examples/Laboratory Test Results.zip 2012-09-15 22:10:45 +0000 differ
=== added directory 'src/xls2ccd/examples/MLHIM_Std_Template'
=== added file 'src/xls2ccd/examples/MLHIM_Std_Template/.~lock.MLHIM_Std_Template-xls2ccd.xls#'
--- src/xls2ccd/examples/MLHIM_Std_Template/.~lock.MLHIM_Std_Template-xls2ccd.xls# 1970-01-01 00:00:00 +0000
+++ src/xls2ccd/examples/MLHIM_Std_Template/.~lock.MLHIM_Std_Template-xls2ccd.xls# 2012-09-15 22:10:45 +0000
@@ -0,0 +1,1 @@
+Tim Cook,tim,tim-Inspiron-1525,15.09.2012 18:17,file:///home/tim/.config/libreoffice/3;
\ No newline at end of file
=== added file 'src/xls2ccd/examples/MLHIM_Std_Template/MLHIM_Std_Template-xls2ccd.xls'
Binary files src/xls2ccd/examples/MLHIM_Std_Template/MLHIM_Std_Template-xls2ccd.xls 1970-01-01 00:00:00 +0000 and src/xls2ccd/examples/MLHIM_Std_Template/MLHIM_Std_Template-xls2ccd.xls 2012-09-15 22:10:45 +0000 differ
=== added directory 'src/xls2ccd/examples/PET Patient Prep'
=== added file 'src/xls2ccd/examples/PET Patient Prep/PET Patient Prep_NCI Standard_Template_08_29_2012.xls'
Binary files src/xls2ccd/examples/PET Patient Prep/PET Patient Prep_NCI Standard_Template_08_29_2012.xls 1970-01-01 00:00:00 +0000 and src/xls2ccd/examples/PET Patient Prep/PET Patient Prep_NCI Standard_Template_08_29_2012.xls 2012-09-15 22:10:45 +0000 differ
=== added directory 'src/xls2ccd/examples/Physical Exam'
=== added file 'src/xls2ccd/examples/Physical Exam/Physical Examination_NCI Standard_Template 08_03_2012.xls'
Binary files src/xls2ccd/examples/Physical Exam/Physical Examination_NCI Standard_Template 08_03_2012.xls 1970-01-01 00:00:00 +0000 and src/xls2ccd/examples/Physical Exam/Physical Examination_NCI Standard_Template 08_03_2012.xls 2012-09-15 22:10:45 +0000 differ
=== added file 'src/xls2ccd/mlhim2RM.py'
--- src/xls2ccd/mlhim2RM.py 1970-01-01 00:00:00 +0000
+++ src/xls2ccd/mlhim2RM.py 2012-09-15 22:10:45 +0000
@@ -0,0 +1,194 @@
+#!/usr/bin/python
+# -*- coding: utf-8 -*-
+
+"""
+This map provides the CCD tool developers with RM information to structure the contents of a CCD.
+Returns: (complexTypes,elements)
+
+"complexTypes" is the dictionary with keys that are the xs:complexType names in the schema. The 'value' associated with each key is a list
+constructued as follows:
+[<abstract> 'true' | 'false', <base>, <mode> 'extension' | 'restriction', [elements] list of element names, [<assert>] list of assertions, <documentation string>]
+
+"elements" is the dictionary with keys that are the xs:element names in the schema. The 'value' associated with each key is a list
+constructued as follows:
+[<maxOccurs>, <minOccurs>,<type>, <fixed>,<default>, [<enumeration>] list of enumeration values, <documentation string>]
+"""
+
+
+def get_map():
+
+ complexTypes = {}
+ complexTypes["AdminEntryType"] = ["false","","extension",[],[],"docs"]
+ complexTypes["ASKRType"] = ["false","","extension",[],[],"docs"]
+ complexTypes["ASKUType"] = ["false","","extension",[],[],"docs"]
+ complexTypes["AttestationType"] = ["false","","extension",[],[],"docs"]
+ complexTypes["CareEntryType"] = ["false","","extension",[],[],"docs"]
+ complexTypes["CCDType"] = ["false","","extension",[],[],"docs"]
+ complexTypes["ClusterType"] = ["false","","extension",[],[],"docs"]
+ complexTypes["DefinitionType"] = ["false","","extension",[],[],"docs"]
+ complexTypes["DemographicEntryType"] = ["false","","extension",[],[],"docs"]
+ complexTypes["DERType"] = ["false","","extension",[],[],"docs"]
+ complexTypes["DvAnyType"] = ["false","","extension",[],[],"docs"]
+ complexTypes["DvBooleanType"] = ["false","","extension",[],[],"docs"]
+ complexTypes["DvCodedStringType"] = ["false","","extension",[],[],"docs"]
+ complexTypes["DvCountType"] = ["false","","extension",[],[],"docs"]
+ complexTypes["DvDateType"] = ["false","","extension",[],[],"docs"]
+ complexTypes["DvDateTimeType"] = ["false","","extension",[],[],"docs"]
+ complexTypes["DvDayType"] = ["false","","extension",[],[],"docs"]
+ complexTypes["DvDurationType"] = ["false","","extension",[],[],"docs"]
+ complexTypes["DvEncapsulatedType"] = ["false","","extension",[],[],"docs"]
+ complexTypes["DvIdentifierType"] = ["false","","extension",[],[],"docs"]
+ complexTypes["DvIntervalType"] = ["false","","extension",[],[],"docs"]
+ complexTypes["DvMediaType"] = ["false","","extension",[],[],"docs"]
+ complexTypes["DvMonthType"] = ["false","","extension",[],[],"docs"]
+ complexTypes["DvMonthDayType"] = ["false","","extension",[],[],"docs"]
+ complexTypes["DvOrderedType"] = ["false","","extension",[],[],"docs"]
+ complexTypes["DvOrdinalType"] = ["false","","extension",[],[],"docs"]
+ complexTypes["DvParsableType"] = ["false","","extension",[],[],"docs"]
+ complexTypes["DvQuantifiedType"] = ["false","","extension",[],[],"docs"]
+ complexTypes["DvQuantityType"] = ["false","","extension",[],[],"docs"]
+ complexTypes["DvQuantity-units"] = ["false","","extension",[],[],"docs"]
+ complexTypes["DvRatioType"] = ["false","","extension",[],[],"docs"]
+ complexTypes["DvStringType"] = ["false","","extension",[],[],"docs"]
+ complexTypes["DvTemporalType"] = ["false","","extension",[],[],"docs"]
+ complexTypes["DvTimeType"] = ["false","","extension",[],[],"docs"]
+ complexTypes["DvURIType"] = ["false","","extension",[],[],"docs"]
+ complexTypes["DvYearType"] = ["false","","extension",[],[],"docs"]
+ complexTypes["DvYearMonthType"] = ["false","","extension",[],[],"docs"]
+ complexTypes["ElementType"] = ["false","","extension",[],[],"docs"]
+ complexTypes["EntryType"] = ["false","","extension",[],[],"docs"]
+ complexTypes["ExceptionalValueType"] = ["false","","extension",[],[],"docs"]
+ complexTypes["FeederAuditType"] = ["false","","extension",[],[],"docs"]
+ complexTypes["FeederAuditDetailsType"] = ["false","","extension",[],[],"docs"]
+ complexTypes["INVType"] = ["false","","extension",[],[],"docs"]
+ complexTypes["ItemType"] = ["false","","extension",[],[],"docs"]
+ complexTypes["LocatableType"] = ["false","","extension",[],[],"docs"]
+ complexTypes["MSKType"] = ["false","","extension",[],[],"docs"]
+ complexTypes["NAType"] = ["false","","extension",[],[],"docs"]
+ complexTypes["NASKType"] = ["false","","extension",[],[],"docs"]
+ complexTypes["NAVType"] = ["false","","extension",[],[],"docs"]
+ complexTypes["NIType"] = ["false","","extension",[],[],"docs"]
+ complexTypes["NINFType"] = ["false","","extension",[],[],"docs"]
+ complexTypes["OTHType"] = ["false","","extension",[],[],"docs"]
+ complexTypes["ParticipationType"] = ["false","","extension",[],[],"docs"]
+ complexTypes["PartyIdentifiedType"] = ["false","","extension",[],[],"docs"]
+ complexTypes["PartyProxyType"] = ["false","","extension",[],[],"docs"]
+ complexTypes["PartySelfType"] = ["false","","extension",[],[],"docs"]
+ complexTypes["PINFType"] = ["false","","extension",[],[],"docs"]
+ complexTypes["QSType"] = ["false","","extension",[],[],"docs"]
+ complexTypes["ReferenceRangeType"] = ["false","","extension",[],[],"docs"]
+ complexTypes["SlotType"] = ["false","","extension",[],[],"docs"]
+ complexTypes["TRCType"] = ["false","","extension",[],[],"docs"]
+ complexTypes["UNCType"] = ["false","","extension",[],[],"docs"]
+ complexTypes["UNKType"] = ["false","","extension",[],[],"docs"]
+
+
+ elements = {}
+ elements["AdminEntry"] = ["unbounded","0","xs:string","","",[],"docs"]
+ elements["ASKR"] = ["unbounded","0","xs:string","","",[],"docs"]
+ elements["ASKU"] = ["unbounded","0","xs:string","","",[],"docs"]
+ elements["attestation"] = ["unbounded","0","xs:string","","",[],"docs"]
+ elements["Attestation"] = ["unbounded","0","xs:string","","",[],"docs"]
+ elements["attested-view"] = ["unbounded","0","xs:string","","",[],"docs"]
+ elements["CareEntry"] = ["unbounded","0","xs:string","","",[],"docs"]
+ elements["CCD"] = ["unbounded","0","xs:string","","",[],"docs"]
+ elements["Cluster"] = ["unbounded","0","xs:string","","",[],"docs"]
+ elements["committer"] = ["unbounded","0","xs:string","","",[],"docs"]
+ elements["data-range"] = ["unbounded","0","xs:string","","",[],"docs"]
+ elements["definition"] = ["unbounded","0","xs:string","","",[],"docs"]
+ elements["Definition"] = ["unbounded","0","xs:string","","",[],"docs"]
+ elements["DemographicEntry"] = ["unbounded","0","xs:string","","",[],"docs"]
+ elements["DER"] = ["unbounded","0","xs:string","","",[],"docs"]
+ elements["details"] = ["unbounded","0","xs:string","","",[],"docs"]
+ elements["DvAny"] = ["unbounded","0","xs:string","","",[],"docs"]
+ elements["DvBoolean"] = ["unbounded","0","xs:string","","",[],"docs"]
+ elements["DvCodedString"] = ["unbounded","0","xs:string","","",[],"docs"]
+ elements["DvCount"] = ["unbounded","0","xs:string","","",[],"docs"]
+ elements["DvDate"] = ["unbounded","0","xs:string","","",[],"docs"]
+ elements["DvDateTime"] = ["unbounded","0","xs:string","","",[],"docs"]
+ elements["DvDay"] = ["unbounded","0","xs:string","","",[],"docs"]
+ elements["DvDuration"] = ["unbounded","0","xs:string","","",[],"docs"]
+ elements["DvEncapsulated"] = ["unbounded","0","xs:string","","",[],"docs"]
+ elements["DvIdentifier"] = ["unbounded","0","xs:string","","",[],"docs"]
+ elements["DvInterval"] = ["unbounded","0","xs:string","","",[],"docs"]
+ elements["DvMedia"] = ["unbounded","0","xs:string","","",[],"docs"]
+ elements["DvMonth"] = ["unbounded","0","xs:string","","",[],"docs"]
+ elements["DvMonthDay"] = ["unbounded","0","xs:string","","",[],"docs"]
+ elements["DvOrdered"] = ["unbounded","0","xs:string","","",[],"docs"]
+ elements["DvOrdinal"] = ["unbounded","0","xs:string","","",[],"docs"]
+ elements["DvParsable"] = ["unbounded","0","xs:string","","",[],"docs"]
+ elements["DvQuantified"] = ["unbounded","0","xs:string","","",[],"docs"]
+ elements["DvQuantity"] = ["unbounded","0","xs:string","","",[],"docs"]
+ elements["DvQuantity-units"] = ["unbounded","0","xs:string","","",[],"docs"]
+ elements["DvRatio"] = ["unbounded","0","xs:string","","",[],"docs"]
+ elements["DvString"] = ["unbounded","0","xs:string","","",[],"docs"]
+ elements["DvTemporal"] = ["unbounded","0","xs:string","","",[],"docs"]
+ elements["DvTime"] = ["unbounded","0","xs:string","","",[],"docs"]
+ elements["DvURI"] = ["unbounded","0","xs:string","","",[],"docs"]
+ elements["DvYear"] = ["unbounded","0","xs:string","","",[],"docs"]
+ elements["DvYearMonth"] = ["unbounded","0","xs:string","","",[],"docs"]
+ elements["Element"] = ["unbounded","0","xs:string","","",[],"docs"]
+ elements["Element-dv"] = ["unbounded","0","xs:string","","",[],"docs"]
+ elements["end-time"] = ["unbounded","0","xs:string","","",[],"docs"]
+ elements["Entry"] = ["unbounded","0","xs:string","","",[],"docs"]
+ elements["entry-data"] = ["unbounded","0","xs:string","","",[],"docs"]
+ elements["entry-provider"] = ["unbounded","0","xs:string","","",[],"docs"]
+ elements["entry-subject"] = ["unbounded","0","xs:string","","",[],"docs"]
+ elements["ExceptionalValue"] = ["unbounded","0","xs:string","","",[],"docs"]
+ elements["external-ref"] = ["unbounded","0","xs:string","","",[],"docs"]
+ elements["FeederAudit"] = ["unbounded","0","xs:string","","",[],"docs"]
+ elements["feeder-audit"] = ["unbounded","0","xs:string","","",[],"docs"]
+ elements["FeederAuditDetails"] = ["unbounded","0","xs:string","","",[],"docs"]
+ elements["feeder-system-audit"] = ["unbounded","0","xs:string","","",[],"docs"]
+ elements["feeder-system-ids"] = ["unbounded","0","xs:string","","",[],"docs"]
+ elements["function"] = ["unbounded","0","xs:string","","",[],"docs"]
+ elements["INV"] = ["unbounded","0","xs:string","","",[],"docs"]
+ elements["Item"] = ["unbounded","0","xs:string","","",[],"docs"]
+ elements["items"] = ["unbounded","0","xs:string","","",[],"docs"]
+ elements["links"] = ["unbounded","0","xs:string","","",[],"docs"]
+ elements["Locatable"] = ["unbounded","0","xs:string","","",[],"docs"]
+ elements["location"] = ["unbounded","0","xs:string","","",[],"docs"]
+ elements["lower"] = ["unbounded","0","xs:string","","",[],"docs"]
+ elements["mode"] = ["unbounded","0","xs:string","","",[],"docs"]
+ elements["MSK"] = ["unbounded","0","xs:string","","",[],"docs"]
+ elements["NA"] = ["unbounded","0","xs:string","","",[],"docs"]
+ elements["NASK"] = ["unbounded","0","xs:string","","",[],"docs"]
+ elements["NAV"] = ["unbounded","0","xs:string","","",[],"docs"]
+ elements["NI"] = ["unbounded","0","xs:string","","",[],"docs"]
+ elements["NINF"] = ["unbounded","0","xs:string","","",[],"docs"]
+ elements["normal-range"] = ["unbounded","0","xs:string","","",[],"docs"]
+ elements["original-content"] = ["unbounded","0","xs:string","","",[],"docs"]
+ elements["originating-system-audit"] = ["unbounded","0","xs:string","","",[],"docs"]
+ elements["originating-system-ids"] = ["unbounded","0","xs:string","","",[],"docs"]
+ elements["OTH"] = ["unbounded","0","xs:string","","",[],"docs"]
+ elements["other-participations"] = ["unbounded","0","xs:string","","",[],"docs"]
+ elements["other-reference-ranges"] = ["unbounded","0","xs:string","","",[],"docs"]
+ elements["Participation"] = ["unbounded","0","xs:string","","",[],"docs"]
+ elements["PartyIdentified"] = ["unbounded","0","xs:string","","",[],"docs"]
+ elements["PartyProxy"] = ["unbounded","0","xs:string","","",[],"docs"]
+ elements["PartySelf"] = ["unbounded","0","xs:string","","",[],"docs"]
+ elements["performer"] = ["unbounded","0","xs:string","","",[],"docs"]
+ elements["PINF"] = ["unbounded","0","xs:string","","",[],"docs"]
+ elements["proof"] = ["unbounded","0","xs:string","","",[],"docs"]
+ elements["protocol-id"] = ["unbounded","0","xs:string","","",[],"docs"]
+ elements["provider"] = ["unbounded","0","xs:string","","",[],"docs"]
+ elements["QS"] = ["unbounded","0","xs:string","","",[],"docs"]
+ elements["reason"] = ["unbounded","0","xs:string","","",[],"docs"]
+ elements["ReferenceRange"] = ["unbounded","0","xs:string","","",[],"docs"]
+ elements["Slot"] = ["unbounded","0","xs:string","","",[],"docs"]
+ elements["SlotData"] = ["unbounded","0","xs:string","","",[],"docs"]
+ elements["slot-data"] = ["unbounded","0","xs:string","","",[],"docs"]
+ elements["start-time"] = ["unbounded","0","xs:string","","",[],"docs"]
+ elements["subject"] = ["unbounded","0","xs:string","","",[],"docs"]
+ elements["system-id"] = ["unbounded","0","xs:string","","",[],"docs"]
+ elements["time-commited"] = ["unbounded","0","xs:string","","",[],"docs"]
+ elements["time-stamp"] = ["unbounded","0","xs:string","","",[],"docs"]
+ elements["TRC"] = ["unbounded","0","xs:string","","",[],"docs"]
+ elements["UNC"] = ["unbounded","0","xs:string","","",[],"docs"]
+ elements["UNK"] = ["unbounded","0","xs:string","","",[],"docs"]
+ elements["upper"] = ["unbounded","0","xs:string","","",[],"docs"]
+ elements["workflow-id"] = ["unbounded","0","xs:string","","",[],"docs"]
+
+ return (complexTypes,elements)
+
+
=== modified file 'src/xls2ccd/xls2ccd.py'
--- src/xls2ccd/xls2ccd.py 2012-09-14 14:58:51 +0000
+++ src/xls2ccd/xls2ccd.py 2012-09-15 22:10:45 +0000
@@ -16,6 +16,8 @@
import time
from xlrd import open_workbook
+from mlhim2RM import get_map
+
try:
xlsfile = sys.argv[1]
except:
@@ -32,73 +34,93 @@
ccd_catalog = open('ccd_catalog.txt', 'a')
ccd_catalog.write('\n====== Appended: ' + str("%d-%d-%d %d:%d" % (n.tm_year, n.tm_mon, n.tm_mday, n.tm_hour, n.tm_min)) +' ======\n')
-
-for s in wb.sheets():
- #print 'Sheet:',s.name
- #print 'Cols.: ',s.ncols
- #print 'Rows: ', s.nrows
- for row in range(s.nrows):
- values = []
- for col in range(s.ncols):
- values.append(s.cell(row,col).value)
- if values[0]:
- currkey = values[0]
- ccd_dict[currkey] = [values[0],values[1],values[2],values[3],values[4],values[5],values[6],values[7]]
- elif currkey:
- if values[8]:
- ccd_dict[currkey].append((values[8],values[9],values[10]))
+complexTypes = get_map()[0].keys()
+elements = get_map()[1].keys()
+
+xsd = ".xsd"
+
+s = wb.sheet_by_name("Data")
+print 'Sheet:',s.name
+print 'Cols.: ',s.ncols
+print 'Rows: ', s.nrows
+for row in range(1,s.nrows):
+ values = []
+ for col in range(s.ncols):
+ values.append(s.cell(row,col).value)
+ if values[9]: #title
+ currkey = values[9]
+ ccd_dict[currkey] = [values[0],values[1],values[2],values[3],values[4],values[5],values[6],values[7],values[8],values[9],values[10],values[11],values[12],values[13],values[14],values[15],values[16]]
+ elif currkey:
+ if values[17]:
+ ccd_dict[currkey].append((values[17],values[18],values[19]))
for k in ccd_dict.keys():
size = len(ccd_dict[k])
- #print "Title: "+ccd_dict[k][0]
- #print "Description: "+ccd_dict[k][1]
- #print "Public ID: "+ccd_dict[k][2]
- #print "CDE Version: "+ccd_dict[k][3]
- #print ": "+ccd_dict[k][4]
- #print "Datatype: "+ccd_dict[k][5]
- #print "UOM: "+ccd_dict[k][6]
- #print "Format: "+ccd_dict[k][7]
- #if size > 8:
- #for n in range(8,size):
+ #print ccd_dict[k]
+ #print "Title: "+ccd_dict[k][9]
+ #print "Description: "+ccd_dict[k][10]
+ #print ccd_dict[k][11]
+ #print ccd_dict[k][12]
+ #print ": "+ccd_dict[k][13]
+ #print "Datatype: "+ccd_dict[k][14]
+ #print "UOM: "+ccd_dict[k][15]
+ #print "Format: "+ccd_dict[k][16]
+ #if size > 17:
+ #for n in range(17,size):
#print "Enumeration: ", ccd_dict[k][n]
#print '\n===========================================\n'
#ccd setup
ccd_id = "ccd-"+str(uuid.uuid4())
- if ccd_dict[k][5] not in ("CHARACTER","ALPHANUMERIC"):
- ccd_id = "R"+ccd_id
+
+ #Display Format Hint
+ if not ccd_dict[k][16]:
+ ccd_dict[k][16] = " Not Defined"
+
+ # Is the datatype a valid MLHIM Type?
+ if ccd_dict[k][14] not in complexTypes:
+ ccd_id = "UnknownType-"+ccd_id
ccdct = "ct-"+str(uuid.uuid4())
- ect = "ct-"+str(uuid.uuid4())
- dct = "ct-"+str(uuid.uuid4())
+
+ #MLHIM ElementType
+ e_id = str(uuid.uuid4())
+ ect = "ct-"+ e_id # complexType
+ e_el = "el-"+ e_id # element
+
+ #MLHIM DataType
+ d_id = str(uuid.uuid4())
+ dct = "ct-"+ d_id # complexType
+ d_el = "el-"+ d_id # element
+
schema = ccd_id + ".xsd"
#/ccd setup
- title = ccd_dict[k][0]
+ title = ccd_dict[k][9]
print ""
print "Generating: "+ title +" -- CCD ID = " + ccd_id
- print ccd_dict[k][5]
- ccd_catalog.write('{0:<40}'.format(title) + ccd_id +'\n')
- description = ccd_dict[k][1] + "\n" +" CDE Version: "+ccd_dict[k][3] + "\n" + " Datatype: "+ccd_dict[k][5] + "\n"+ " UOM: "+ccd_dict[k][6] + "\n" + " Format: "+ccd_dict[k][7] + "\n"
+ print ccd_dict[k][14]
+ ccd_catalog.write('{0:.<40}'.format(title) + ccd_id +'\n')
+ description = ccd_dict[k][10] + "\n" +" Version: "+ccd_dict[k][12] + "\n" + " Datatype: "+ccd_dict[k][14] + "\n"+ " UOM: "+ccd_dict[k][15] + "\n" + " Format: "+ccd_dict[k][16] + "\n" + " Generated by MLHIM xls2ccd.py\n"
date = str(now)
- creator = "Generated by MLHIM xls2ccd.py"
+ creator = """+ccd_dict[k][0]+'" <' + ccd_dict[k][1] + '>'
contributor = ""
- language = ("en-US")
- publisher = ("INCT-MACC MLHIM Lab")
- subject = ccd_dict[k][0]
- source = ("NCI CDE Public ID: "+ccd_dict[k][2])
- rights = ("CC-BY")
- relation = ("None")
- coverage = ("Global")
+ language = ccd_dict[k][5]
+ publisher = ccd_dict[k][4]
+ subject = ccd_dict[k][9]
+ source = ccd_dict[k][11]
+ rights = ccd_dict[k][6]
+ relation = ccd_dict[k][7]
+ coverage = ccd_dict[k][8]
resource_type = "MLHIM Concept Constraint Definition (CCD)"
resource_format = "text/xml"
identifier = ccd_id
- data_name = title.replace("'",''')
- dt = ccd_dict[k][5]
-
- xsd = open(schema,'w')
-
- xsd.write("""<?xml version="1.0" encoding="UTF-8"?>
+ data_name = title.replace('&', '&').replace('<', '<').replace('>', '>').replace("'", ''').replace('"', '"')
+ dt = ccd_dict[k][14]
+
+ xsd_file = open(schema,'w')
+
+ xsd_file.write("""<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:mlhim2="http://www.mlhim.org/xmls/mlhim2/2_4_0"
elementFormDefault="qualified"
@@ -110,11 +132,11 @@
<xs:appinfo>
""")
- xsd.write("""
+ xsd_file.write("""
<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:dc= "http://purl.org/dc/elements/1.1/">
- <rdf:Description rdf:about="http://www.hkcr.net/ccd/""" + ccd_id + """">
+ <rdf:Description rdf:about="http://www.hkcr.net/ccd/""" + schema + """">
<dc:title>"""+title+"""</dc:title>
<dc:creator>"""+creator+"""</dc:creator>
<dc:contributor>"""+contributor+"""</dc:contributor>
@@ -125,7 +147,7 @@
<dc:coverage>"""+coverage+"""</dc:coverage>
<dc:type>"""+resource_type+"""</dc:type>
<dc:identifier>"""+identifier+"""</dc:identifier>
- <dc:description>"""+description+"""</dc:description>
+ <dc:description>"""+description+""" </dc:description>
<dc:publisher>"""+publisher+"""</dc:publisher>
<dc:date>"""+date+"""</dc:date>
<dc:format>"""+resource_format+"""</dc:format>
@@ -143,92 +165,118 @@
<xs:complexContent>
<xs:restriction base="mlhim2:CCDType">
<xs:sequence>
- <xs:element name="definition" minOccurs="1" maxOccurs="1" type="mlhim2:"""+ect+""""/>
+ <xs:element minOccurs="1" maxOccurs="1" ref="mlhim2:"""+e_el+""""/>
</xs:sequence>
</xs:restriction>
</xs:complexContent>
</xs:complexType>
+ <xs:element name='"""+e_el+"""' substitutionGroup="mlhim2:definition" type='mlhim2:"""+ect+"""'/>
<xs:complexType name='"""+ect+"""'>
<xs:complexContent>
<xs:restriction base="mlhim2:ElementType">
<xs:sequence>
- <xs:element name="Element_dv" minOccurs="1" maxOccurs="1" type="mlhim2:"""+dct+""""/>
+ <xs:element minOccurs="1" maxOccurs="1" ref="mlhim2:"""+d_el+""""/>
</xs:sequence>
</xs:restriction>
</xs:complexContent>
</xs:complexType>
- """)
-
-
- if dt == "DATE":
- xsd.write("""
+
+ <xs:element name='"""+d_el+"""' substitutionGroup="mlhim2:Element-dv" type='mlhim2:"""+dct+"""'/>""")
+
+
+ if dt == "DvDateType":
+ xsd_file.write("""
<xs:complexType name='"""+dct+"""'>
<xs:complexContent>
<xs:restriction base="mlhim2:DvDateType">
<xs:sequence>
- <xs:element name="data_name" minOccurs="1" maxOccurs="1" type="xs:string" fixed='"""+data_name+"""'/>
- <xs:element name="DvDate_dv" minOccurs="1" maxOccurs="1" type="xs:date"/>
+ <xs:element name="data-name" minOccurs="1" maxOccurs="1" type="xs:string" fixed='"""+data_name+"""'/>
+ <xs:element name="DvDate-dv" minOccurs="1" maxOccurs="1" type="xs:date">
+ <xs:annotation>
+ <xs:documentation>
+ Display Format: """ + ccd_dict[k][16] + """
+ </xs:documentation>
+ </xs:annotation>
+ </xs:element>
</xs:sequence>
</xs:restriction>
</xs:complexContent>
</xs:complexType>
""")
- elif dt == "TIME":
- xsd.write("""
+ elif dt == "DvTimeType":
+ xsd_file.write("""
<xs:complexType name='"""+dct+"""'>
<xs:complexContent>
<xs:restriction base="mlhim2:DvTimeType">
<xs:sequence>
- <xs:element name="data_name" minOccurs="1" maxOccurs="1" type="xs:string" fixed='"""+data_name+"""'/>
- <xs:element name="DvTime_dv" minOccurs="1" maxOccurs="1" type="xs:time"/>
+ <xs:element name="data-name" minOccurs="1" maxOccurs="1" type="xs:string" fixed='"""+data_name+"""'/>
+ <xs:element name="DvTime-dv" minOccurs="1" maxOccurs="1" type="xs:time">
+ <xs:annotation>
+ <xs:documentation>
+ Display Format: """ +ccd_dict[k][16] + """
+ </xs:documentation>
+ </xs:annotation>
+ </xs:element>
</xs:sequence>
</xs:restriction>
</xs:complexContent>
</xs:complexType>
""")
- elif dt == "NUMBER":
- xsd.write("""
+ elif dt == "DvCountType":
+ xsd_file.write("""
<xs:complexType name='"""+dct+"""'>
<xs:complexContent>
- <xs:restriction base="mlhim2:DvCountType"> <!-- This will require a DvCount, DvQuantity or other numeric type. Add elements inside the sequence, below data_name, as required. -->
+ <xs:restriction base="mlhim2:DvCountType">
<xs:sequence>
- <xs:element name="data_name" minOccurs="1" maxOccurs="1" type="xs:string" fixed='"""+data_name+"""'/>
+ <xs:element name="data-name" minOccurs="1" maxOccurs="1" type="xs:string" fixed='"""+data_name+"""'/>
<xs:element name="magnitude" minOccurs="1" maxOccurs="1" type="xs:decimal"/>
- <xs:element name="error" minOccurs="1" maxOccurs="1" type="xs:int"/>
- <xs:element maxOccurs="1" minOccurs="1" name="DvCount_units" type="xs:string"/>
+ <xs:element name="error" default="0" minOccurs="1" maxOccurs="1" type="xs:int"/>
+ <xs:element name="accuracy" default="0" minOccurs="1" maxOccurs="1" type="xs:int"/>
+ <xs:element maxOccurs="1" minOccurs="1" name="DvCount-units" type="xs:string">
+ <xs:annotation>
+ <xs:documentation>
+ Display Format: """ +ccd_dict[k][16] + """
+ </xs:documentation>
+ </xs:annotation>
+ </xs:element>
</xs:sequence>
</xs:restriction>
</xs:complexContent>
</xs:complexType>
""")
- elif len(ccd_dict[k]) > 8:
- xsd.write("""
+ elif len(ccd_dict[k]) > 17:
+ xsd_file.write("""
<xs:complexType name='"""+dct+"""'>
<xs:complexContent>
<xs:restriction base="mlhim2:DvStringType">
<xs:sequence>
- <xs:element name="data_name" minOccurs="1" maxOccurs="1" type="xs:string" fixed='"""+data_name+"""'/>
- <xs:element name="DvString_dv" minOccurs="1" maxOccurs="1">
+ <xs:element name="data-name" minOccurs="1" maxOccurs="1" type="xs:string" fixed='"""+data_name+"""'/>
+ <xs:element name="DvString-dv" minOccurs="1" maxOccurs="1">
+ <xs:annotation>
+ <xs:documentation>
+ Display Format: """ +ccd_dict[k][16] + """
+ </xs:documentation>
+ </xs:annotation>
<xs:simpleType>
<xs:restriction base="xs:string">
""")
- for n in range(8, len(ccd_dict[k])):
- enum = (ccd_dict[k][n][0]).replace("'",'')
- adoc = (ccd_dict[k][n][1]).replace("'",'') + " : " + (ccd_dict[k][n][2]).replace("'",'')
- xsd.write(""" <xs:enumeration value='"""+enum+"""'>
+ for n in range(17, len(ccd_dict[k])):
+ enum = (ccd_dict[k][n][0]).replace('&', '&').replace('<', '<').replace('>', '>').replace("'", ''').replace('"', '"')
+ adoc = (ccd_dict[k][n][1]).replace('&', '&').replace('<', '<').replace('>', '>').replace("'", ''').replace('"', '"')
+ adoc += " : " + (ccd_dict[k][n][2]).replace('&', '&').replace('<', '<').replace('>', '>').replace("'", ''').replace('"', '"')
+ adoc.replace("&","&")
+ xsd_file.write(""" <xs:enumeration value='"""+enum+"""'>
<xs:annotation>
<xs:documentation>
""" + adoc + """
</xs:documentation>
</xs:annotation>
- </xs:enumeration>
- """)
- xsd.write("""
- </xs:restriction>
+ </xs:enumeration>\n""")
+ xsd_file.write(""" </xs:restriction>
</xs:simpleType>
</xs:element>
</xs:sequence>
@@ -240,23 +288,29 @@
else:
- xsd.write("""
+ xsd_file.write("""
<xs:complexType name='"""+dct+"""'>
<xs:complexContent>
<xs:restriction base="mlhim2:DvStringType">
<xs:sequence>
- <xs:element name="data_name" minOccurs="1" maxOccurs="1" type="xs:string" fixed='"""+data_name+"""'/>
- <xs:element name="DvString_dv" minOccurs="1" maxOccurs="1" type="xs:string"/>
+ <xs:element name="data-name" minOccurs="1" maxOccurs="1" type="xs:string" fixed='"""+data_name+"""'/>
+ <xs:element name="DvString-dv" minOccurs="1" maxOccurs="1" type="xs:string">
+ <xs:annotation>
+ <xs:documentation>
+ Display Format: """ +ccd_dict[k][16] + """
+ </xs:documentation>
+ </xs:annotation>
+ </xs:element>
</xs:sequence>
</xs:restriction>
</xs:complexContent>
</xs:complexType>
""")
- xsd.write("""
+ xsd_file.write("""
</xs:schema>""")
- xsd.close()
+ xsd_file.close()
print "\nDone.\n"
ccd_catalog.close()