DHIS2 API get dataset instead of individual data elements - dhis-2

I'm already able to fetch json back from the API related to DATA ELEMENTS.
I'd like to get DATA SET results instead (containing all DATA ELEMENTS that are part of this particular DATA SET)
Thanks!

To fetch dataSets you can use /api/dataSets.json or /api/dataSets.json?fields=dataSetElements[dataSet].
You can find more information on the Web API documentation.

To fetch data elements that are assigned to a particular dataSet you query for the dataSetElements:
In the example of the dataSet ART monthly summary (lyLU2wR22tC):
/api/dataSets/lyLU2wR22tC?fields=id,name,dataSetElements[dataElement[id,name]]
or as a specific play.dhis2.org link:
https://play.dhis2.org/2.35.1/api/dataSets/lyLU2wR22tC?fields=id,name,dataSetElements[dataElement[id,name]]
would return:
<dataSet xmlns="http://dhis2.org/schema/dxf/2.0" name="ART monthly summary" id="lyLU2wR22tC">
<dataSetElements>
<dataSetElement>
<dataElement name="ART entry point: No PMTCT" id="kVOiLDV4OC6"/>
</dataSetElement>
<dataSetElement>
<dataElement name="New on ABC 300mg + ddI 200mg + LPV/r 133.3/33.3mg" id="la1f7sqY9sb"/>
</dataSetElement>
<dataSetElement>
<dataElement name="Shift to d4T 30mg + 3TC 150mg + EFV 600mg" id="qUY0i7PnaLS"/>
</dataSetElement>
<dataSetElement>
<dataElement name="Prev. month on NVP + AZT + 3TC 10mg/ml (2mg/kg) + 10mg/ml + 10mg/ml for 7 days" id="CUVDjGzRmmU"/>
</dataSetElement>
...
</dataSet>

Please use this API for fetching all data elements of a dataset :
/api/33/dataValueSets

Related

Retrieve data from HugeClob in oracle

I have one Table, in this table stored data as xml on HugeClob. In this xml I have several data. I want retrieve this data with SQL query. I add 3 xml example.
// First
<xml-fragment>
<sdr:OCAC>
<op:operation>Sale</op:operation>
<op:ID>100</op:ID>
<op:payload>
<op:Tea>
</op:Tea>
</op:payload>
</sdr:OCAC>
</xml-fragment>
// Second
<xml-fragment>
<sdr:OCAC>
<op:operation>Sale</op:operation>
<op:ID>101</op:ID>
<op:payload>
<op:Cofe>
</op:Cofe>
</op:payload>
</sdr:OCAC>
</xml-fragment>
// Third
<xml-fragment>
<sdr:OCAC>
<op:operation>Sale</op:operation>
<op:ID>102</op:ID>
<op:payload>
<op:Juice>
</op:Juice>
</op:payload>
</sdr:OCAC>
</xml-fragment>
I want shown query result as attached image. I'm so sorry for my english.
Tea's price is 1.50
Cofe's price is 2.50
Juice's price is 3.00

How to make summary table of with respect to data in tables in access

This site is really good and I have got many help from u all.. So thank u for your help.
Now I have doubt. I have 3 tables called b1,b2,b3 in access having the same field but different data.
I want to make summary of the data in it in single table, like in b1 there is cable1 with 4m length, and in b3 there is cable1 with 8 m length..so in summary it should show cable 1 with 8+4 m length.
Any idea how to do it? Does union query help in this situation?
Purely based on your descriptioin and with no detail of your tables I would assume you are looking for something like this:
SELECT [CableType],
convert(nvarchar(5),B1.[Length]) + 'm +' + convert(nvarchar(5),B2.[Length])
+ 'm +' + convert(nvarchar(5),B3.[Length]) + 'm' as [Length]
FROM [B1]
join [B2] on [B1].[ID] = [B2].[ID]
join [B3] on [B1].[ID] = [B3].[ID]
I guess you have a column which holds the "Cable 1" description somewhere, also assuming you have an identifying column of some kind and your Lengths are stored as a number of some kind. This example would assume you always populate all 3 tables.

Filling 2 records inside of a rowset

I am trying to find out how to fill two seperate records in one rowset to be published to integration broker. I am filling both rowsets seperatly (RS1 for the Level 1 of record Names and RS for the Level 0 record of Person)
&RS1 = CreateRowset(Record.NAMES);
&RS1.Fill("Where emplid=:1 and name_type=:2", &emplid, &nameType);
&RS = CreateRowset(Record.PERSON, &RS1);
&RS.Fill("Where emplid=:1", &emplid);
I have also tried to use this after the above code and the NAMES record didnt show up into the rowset
&RS1.CopyTo(&RS, Record.NAMES, Record.PERSON);
The problem is that when I look at &RS after this runs, the Names record in &RS does not contain any of the name information from &RS1, but the person record is populated. Could anybody help me on how to get this name record in &RS populated with the data from &RS1?
The issue with your code is that &RS1 is really just used to determine the structure of &RS. The actual instantiated rowset is not part of &RS. In the code below note where I get the NAMES rowset for a specific row and assign it to &RS1, then I fill it.
Local Rowset &RS, &RS1;
&RS1 = CreateRowset(Record.NAMES);
&RS = CreateRowset(Record.PERSON, &RS1);
&RS.Fill("Where emplid=:1", &emplid);
&RS1 = &RS(1).GetRowset(Scroll.NAMES);
&RS1.Fill("Where emplid=:1 and name_type=:2", &emplid, &nameType);

Best Table Structure Design for Dynamic SQL statement

I am looking for the best table structure to create a dynamic SQL statement like this below (which is not dynamic yet). I have to choose between
joined tables
a single row with all columns with the content comma-delimted which I then will parse
one large table with multiple rows per Cost Centre Activity Code
or anything else
In this example the key which all link to is: 'NSEA8102' which is a Cost Centre Activity code
SELECT
#pDate,
#pDate,
'NSEA8102', --Cost Centre Activity Code
ccg.tCCGroup,
SUM(logs.tTripHours) AS tTriphours,
'Actual EMV Hours Worked - ' + DATENAME(MONTH,#pDATE) + ' ' + CAST(YEAR(#pDate) AS CHAR(4))
FROM dbo.tblEMV_Logsheet AS logs INNER JOIN
dbo.tblLookup_EMVEquipment AS ccg ON logs.tEquipmentKey = ccg.tEquipmentKey
WHERE tDate BETWEEN #BMonth and #EMonth
AND (logs.tAreaCode in ('MINEE', 'SERVICE'))
AND (logs.tEventCode LIKE 'RASSTEEPS')
AND logs.tSourceLocationCode = 'STEEPS'
AND logs.tDestinationLocationCode = 'ERASSTSP'
AND (ccg.tCCGroup IN ('FADT', 'FPC800', 'FWA800'))
AND ccg.tValid = 1
GROUP BY ccg.tCCGroup
Any suggestion would be welcome. Thanks

MDX - Drill down in a hierarchy to the last level having the member caption containing "#"

I have a UserHierarchy, and when the member caption of the current level contains a "#" in the name, is resembles a particular user type. The UserHierarchy, contains up to 5 levels.
I would like to display drilled down data, but only for these particular user types, hence only those captions which have "#". I would also want to aggregate the children's data.
Is there a simple way in MDX to accomplish this?
Example :
#User1 €2
---#User2 €6
---------User4 €9
---------User5 €4
---#User3 €2
---------User6 €4
---------User7 €4
I would like to display figures, for themselves and children like this. To understand, I included where the figures were obtained from :
#User1 €2
---#User2 €19 (Obtained from : €6 + €9 + €4)
---#User3 €10 (Obtained from : €2 + €4 + €4)
select [Measures].[Internet Sales Amount] on columns,
non empty(
distinct(
descendants({[Product].[Category].children}) *
{filter([Product].[Subcategory].members,
instr([Product].[Subcategory].currentmember.member_caption, 'T') = 1)
}
* descendants({[Product].[Product].children})
)
)
on rows from cube
Result with detailed info:
"Second result:
Here i have deleted the row:
* descendants({[Product].[Product].children})
I think that´s what you want since it shows the totals of the children.
You need to exchange the 'T' for your '#' then also the dimension names and what you want to show as a measure.