Last active
June 8, 2016 11:29
-
-
Save anjesh/7da6b8b05e9b2ca082020fb1727f2bd4 to your computer and use it in GitHub Desktop.
This joins the 3 collections (tenders, contracts, tender_items) into one single collection (release)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
To run this script, run the following command in the cli | |
# mongo localhost:27017/[dbname] map_to_ocds.js | |
*/ | |
//remove ocds_release collection | |
db.ocds_release.remove({}) | |
// var bulk = db.ocds_release.initializeUnorderedBulkOp(); | |
db.tender_items_collection.createIndex({"fkTenderDataId": 1}); | |
db.contracts_collection.createIndex({"tender.id": 1}); | |
var start = new Date().getTime(); | |
print("starting Execution") | |
db.tenders_collection.find({}).forEach(function(tender){ | |
//prepare tendor object | |
var items = [] | |
db.tender_items_collection.find({"fkTenderDataId": tender.tenderData.id}).forEach(function(item) { | |
items.push({ | |
"id": item.id, | |
"description": item.goodsName + " " + item.description, | |
"classification": { | |
"scheme": "CPV", | |
"id": item.goods.code, | |
"description": item.goods.mdValue | |
}, | |
"additionalClassifications": [], | |
"quantity": item.quantity, | |
"unit": { | |
"name": item.unitMeasure.mdValue | |
} | |
}); | |
}); | |
var procuringAgency = { | |
"identifier": { | |
"scheme": "State Registration Chambers", | |
"id": tender.stateOrg.code, | |
"legalName": tender.stateOrg.orgName, | |
"uri": "" | |
}, | |
"additionalIdentifiers": { | |
"scheme": "eTenders", | |
"id": tender.stateOrg.id, | |
"legalName": tender.stateOrg.orgName, | |
"uri": "" | |
}, | |
"name": tender.stateOrg.orgName, | |
"address": { | |
"streetAddress": tender.stateOrg.address, | |
"locality":"", | |
}, | |
"contactPoint": { | |
"name": "", | |
"email": tender.stateOrg.email, | |
"telephone": tender.stateOrg.phone, | |
"faxNumber": tender.stateOrg.fax, | |
"url": "" | |
} | |
}; | |
var tenderObj = { | |
"id": NumberLong(tender.id), | |
"title": "Tender Ref " + tender.regNumber + " Bulletin " + tender.bulletin.bulletinNumb, | |
"description": "", | |
"status": tender.tenderStatus.mdValue, | |
"procurementMethod": tender.tenderType.mdValue, | |
"items": items, | |
"minValue": {}, | |
"value": {}, | |
"procurementMethod":tender.tenderType.mdValue, | |
"procurementMethodRationale":"", | |
"awardCriteria":"", | |
"awardCriteriaDetails":"", | |
"submissionMethod": ["written"], | |
"submissionMethodDetails":"", | |
"tenderPeriod": { | |
"startDate": tender.bulletin.publDate, | |
"endDate": tender.tenderData.openDateTime | |
}, | |
"enquiryPeriod": {}, | |
"hasEnquiries": "", | |
"eligibilityCriteria": "", | |
"awardPeriod": {}, | |
"numberOfTenderers": "", | |
"tenderers": [], | |
"procuringAgency": procuringAgency, | |
"documents": [], | |
"milestones": [], | |
"amendment": {} | |
}; | |
var awardArray = []; | |
var contractArray = []; | |
db.contracts_collection.find({"tender.id": tender.id}).forEach(function(contract){ | |
var award = { | |
"id": "award-" + NumberLong(contract.id), | |
"title": "Award for " + contract.tender.tenderData.goodsDescr, | |
"description": "", | |
"status": "", | |
"date": "", | |
"value": { | |
"amount": contract.amount, | |
"currency": "mdl" | |
}, | |
"suppliers": [{ | |
"identifier": {}, | |
"additionalIdentifiers": [{ | |
"scheme": "eTenders", | |
"id": contract.participant.id, | |
"legalName": contract.participant.fullName | |
}], | |
"name": contract.participant.fullName, | |
}], | |
"items": [], | |
"contractPeriod": { | |
"startDate": contract.contractDate, | |
"endDate": contract.finalDate | |
}, | |
"documents": [], | |
"amendment": {} | |
}; | |
if(contract.goods) { | |
award["items"] = [{ | |
"id": contract.goods.id, | |
"description": "", | |
"classification": { | |
"scheme": "CPV", | |
"id": contract.goods.code, | |
"description": contract.goods.mdValue | |
}, | |
"quantity": "", | |
"unit": {} | |
}]; | |
} | |
awardArray.push(award); | |
var contract = { | |
"id": NumberLong(contract.id), | |
"awardID": award.id, | |
"title": contract.contractNumber + " " + contract.tender.tenderData.goodsDescr, | |
"description": "", | |
"status": contract.status.mdValue, | |
"period": { | |
"startDate": "", | |
"endDate": contract.finalDate | |
}, | |
"value": { | |
"amount": contract.amount, | |
"currency": "mdl" | |
}, | |
"items": {}, | |
"dateSigned": contract.contractDate, | |
"documents": [], | |
"amendment": {}, | |
"implementations": {} | |
}; | |
contractArray.push(contract); | |
}); | |
db.ocds_release.insert({ | |
"ocid": "test-ocid", | |
"date": "", | |
"id": NumberLong(tender.id), | |
"initiationType": "tender", | |
"tender": tenderObj, | |
"award": awardArray, | |
"contract": contractArray, | |
"buyer": procuringAgency, | |
"language": "md" | |
}); | |
}); | |
var end = new Date().getTime(); | |
var time = end - start; | |
print("Execution Time (seconds) ", time/1000); | |
// mongodump --db etenders --collection ocds_release |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"ocid": "", | |
"date": "", | |
"id": 1117382, | |
"initiationType": "tender", | |
"tender": { | |
"id": 1117382, | |
"title": "Tender Ref 13/00944 Bulletin 95", | |
"description": "", | |
"status": "Executarea contractului", | |
"procurementMethod": "Licitaţie publică", | |
"items": [ | |
{ | |
"id": 1138750, | |
"description": "Maladii a sistemului pulmonar Biletul de tratament pe 18 zile, alimentare de minim 3 ori pe zi, cameră dublă cu grup sanitar", | |
"classification": { | |
"scheme": "CPV", | |
"id": "66133000-1", | |
"description": "Servicii de tratament si de compensare" | |
}, | |
"additionalClassifications": [], | |
"quantity": 55, | |
"unit": { | |
"name": "Bucată" | |
} | |
}, | |
{ | |
"id": 1138751, | |
"description": "Maladii a sistemului locomotor Biletul de tratament pe 18 zile, alimentare de minim 3 ori pe zi, cameră dublă cu grup sanitar", | |
"classification": { | |
"scheme": "CPV", | |
"id": "66133000-1", | |
"description": "Servicii de tratament si de compensare" | |
}, | |
"additionalClassifications": [], | |
"quantity": 30, | |
"unit": { | |
"name": "Bucată" | |
} | |
}, | |
{ | |
"id": 1138752, | |
"description": "Maladii a sistemului gastrointestinal Biletul de tratament pe 18 zile, alimentare de minim 3 ori pe zi, cameră dublă cu grup sanitar", | |
"classification": { | |
"scheme": "CPV", | |
"id": "66133000-1", | |
"description": "Servicii de tratament si de compensare" | |
}, | |
"additionalClassifications": [], | |
"quantity": 110, | |
"unit": { | |
"name": "Bucată" | |
} | |
}, | |
{ | |
"id": 1138753, | |
"description": "Maladii a rinichilor, căilor urinare şi prostatitei Biletul de tratament pe 18 zile, alimentare de minim 3 ori pe zi, cameră dublă cu grup sanitar", | |
"classification": { | |
"scheme": "CPV", | |
"id": "66133000-1", | |
"description": "Servicii de tratament si de compensare" | |
}, | |
"additionalClassifications": [], | |
"quantity": 30, | |
"unit": { | |
"name": "Bucată" | |
} | |
} | |
], | |
"minValue": {}, | |
"value": {}, | |
"procurementMethodRationale": "", | |
"awardCriteria": "", | |
"awardCriteriaDetails": "", | |
"submissionMethod": [ | |
"written" | |
], | |
"submissionMethodDetails": "", | |
"tenderPeriod": { | |
"startDate": "03.12.2013", | |
"endDate": "13.12.2013 10:00" | |
}, | |
"enquiryPeriod": {}, | |
"hasEnquiries": "", | |
"eligibilityCriteria": "", | |
"awardPeriod": {}, | |
"numberOfTenderers": "", | |
"tenderers": [], | |
"procuringAgency": { | |
"identifier": { | |
"scheme": "State Registration Chambers", | |
"id": "1006601001229", | |
"legalName": "DEPARTAMENTUL DOTĂRI AL MINISTERULUI APĂRĂRII", | |
"uri": "" | |
}, | |
"additionalIdentifiers": { | |
"scheme": "eTenders", | |
"id": 10, | |
"legalName": "DEPARTAMENTUL DOTĂRI AL MINISTERULUI APĂRĂRII", | |
"uri": "" | |
}, | |
"name": "DEPARTAMENTUL DOTĂRI AL MINISTERULUI APĂRĂRII", | |
"address": { | |
"streetAddress": "mun. Chişinău, şos. Hînceşti 84", | |
"locality": "" | |
}, | |
"contactPoint": { | |
"name": "", | |
"email": "[email protected]", | |
"telephone": "022252071 252149 252209", | |
"faxNumber": "022252049", | |
"url": "" | |
} | |
}, | |
"documents": [], | |
"milestones": [], | |
"amendment": {} | |
}, | |
"award": [ | |
{ | |
"id": "award-1261119", | |
"title": "Award for Servicii de tratament sanatorial", | |
"description": "", | |
"status": "", | |
"date": "", | |
"value": { | |
"amount": 732500, | |
"currency": "mdl" | |
}, | |
"suppliers": [ | |
{ | |
"identifier": {}, | |
"additionalIdentifiers": [ | |
{ | |
"scheme": "eTenders", | |
"id": 1229415, | |
"legalName": "S.C. OlSt-SERVICE S.R.L." | |
} | |
], | |
"name": "S.C. OlSt-SERVICE S.R.L." | |
} | |
], | |
"items": [ | |
{ | |
"id": 52165, | |
"description": "", | |
"classification": { | |
"scheme": "CPV", | |
"id": "66133000-1", | |
"description": "Servicii de tratament si de compensare" | |
}, | |
"quantity": "", | |
"unit": {} | |
} | |
], | |
"contractPeriod": { | |
"startDate": "20.12.2013", | |
"endDate": "31.12.2014" | |
}, | |
"documents": [], | |
"amendment": {} | |
}, | |
{ | |
"id": "award-1261910", | |
"title": "Award for Servicii de tratament sanatorial", | |
"description": "", | |
"status": "", | |
"date": "", | |
"value": { | |
"amount": 484250, | |
"currency": "mdl" | |
}, | |
"suppliers": [ | |
{ | |
"identifier": {}, | |
"additionalIdentifiers": [ | |
{ | |
"scheme": "eTenders", | |
"id": 1229414, | |
"legalName": "GAMA AVIA S.R.L." | |
} | |
], | |
"name": "GAMA AVIA S.R.L." | |
} | |
], | |
"items": [ | |
{ | |
"id": 52165, | |
"description": "", | |
"classification": { | |
"scheme": "CPV", | |
"id": "66133000-1", | |
"description": "Servicii de tratament si de compensare" | |
}, | |
"quantity": "", | |
"unit": {} | |
} | |
], | |
"contractPeriod": { | |
"startDate": "20.12.2013", | |
"endDate": "31.12.2014" | |
}, | |
"documents": [], | |
"amendment": {} | |
}, | |
{ | |
"id": "award-1261911", | |
"title": "Award for Servicii de tratament sanatorial", | |
"description": "", | |
"status": "", | |
"date": "", | |
"value": { | |
"amount": 448000, | |
"currency": "mdl" | |
}, | |
"suppliers": [ | |
{ | |
"identifier": {}, | |
"additionalIdentifiers": [ | |
{ | |
"scheme": "eTenders", | |
"id": 1229413, | |
"legalName": "BALNEO-EXPRES S.R.L." | |
} | |
], | |
"name": "BALNEO-EXPRES S.R.L." | |
} | |
], | |
"items": [ | |
{ | |
"id": 52165, | |
"description": "", | |
"classification": { | |
"scheme": "CPV", | |
"id": "66133000-1", | |
"description": "Servicii de tratament si de compensare" | |
}, | |
"quantity": "", | |
"unit": {} | |
} | |
], | |
"contractPeriod": { | |
"startDate": "20.12.2013", | |
"endDate": "31.12.2014" | |
}, | |
"documents": [], | |
"amendment": {} | |
} | |
], | |
"contract": [ | |
{ | |
"id": 1261119, | |
"awardID": "award-1261119", | |
"title": "Servicii de tratament sanatorial", | |
"description": "", | |
"status": "Înregistrat(ă)", | |
"period": { | |
"startDate": "", | |
"endDate": "31.12.2014" | |
}, | |
"value": 732500, | |
"dateSigned": "20.12.2013", | |
"documents": [], | |
"amendment": [] | |
}, | |
{ | |
"id": 1261910, | |
"awardID": "award-1261910", | |
"title": "Servicii de tratament sanatorial", | |
"description": "", | |
"status": "Înregistrat(ă)", | |
"period": { | |
"startDate": "", | |
"endDate": "31.12.2014" | |
}, | |
"value": 484250, | |
"dateSigned": "20.12.2013", | |
"documents": [], | |
"amendment": [] | |
}, | |
{ | |
"id": 1261911, | |
"awardID": "award-1261911", | |
"title": "Servicii de tratament sanatorial", | |
"description": "", | |
"status": "Înregistrat(ă)", | |
"period": { | |
"startDate": "", | |
"endDate": "31.12.2014" | |
}, | |
"value": 448000, | |
"dateSigned": "20.12.2013", | |
"documents": [], | |
"amendment": [] | |
} | |
], | |
"buyer": { | |
"identifier": { | |
"scheme": "State Registration Chambers", | |
"id": "1006601001229", | |
"legalName": "DEPARTAMENTUL DOTĂRI AL MINISTERULUI APĂRĂRII", | |
"uri": "" | |
}, | |
"additionalIdentifiers": { | |
"scheme": "eTenders", | |
"id": 10, | |
"legalName": "DEPARTAMENTUL DOTĂRI AL MINISTERULUI APĂRĂRII", | |
"uri": "" | |
}, | |
"name": "DEPARTAMENTUL DOTĂRI AL MINISTERULUI APĂRĂRII", | |
"address": { | |
"streetAddress": "mun. Chişinău, şos. Hînceşti 84", | |
"locality": "" | |
}, | |
"contactPoint": { | |
"name": "", | |
"email": "[email protected]", | |
"telephone": "022252071 252149 252209", | |
"faxNumber": "022252049", | |
"url": "" | |
} | |
}, | |
"language": "md" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment