示例#1
0
def hypertensionFlupViewSet(xmlData):  #高血压随访新增
    parser = XMLParser()
    specialNo = getAttributeFromXML(xmlData, "specialNo")
    item_name = {0: ["hypertensionFlup"]}
    xmlData = addNodeToXML(xmlData, "hypertensionFlup", "businessKey",
                           str(uuid.uuid1()))
    xmlData = addNodeToXML(xmlData, "hypertensionFlup", "healthFileNumber",
                           specialNo)

    xmlData = delNodeFromXML(xmlData, "hypertensionFlup", "personId")

    print(xmlData)
    seriData = parser.get_seri(xmlData, item_name)
    print seriData
    print '**API: Create a new record. 11111'

    dataSeri = TbhypertensionflupSeri(data=seriData,
                                      many=True,
                                      context=seriData)
    print dataSeri
    if dataSeri.is_valid():
        print "AAAAAAAAAAAAAAAA"
        dataSeri.save()
        print "AAAAAAAAAAAAAAAABBBBBBBBBBBBBBBBBB"
    else:
        print "**API ERROR(hypertensionFlup): Data is not valid."
    return ''
示例#2
0
def diabetesSpecialViewSet(xmlData):  #糖尿病专项新增
    parser = XMLParser()
    item_name = {0: ["diabetesSpecial"]}
    seriData = parser.get_seri(xmlData, item_name)
    print '**API: Create a new record.'
    dataSeri = TbdiabetesSpecialSeri(data=seriData,
                                     many=True,
                                     context=seriData)
    print dataSeri
    if dataSeri.is_valid():
        dataSeri.save()
    else:
        print "**API ERROR(diabetesSpecialViewSet): Data is not valid."
    return ''
示例#3
0
def hypertensionSpecialViewSet(xmlData):
    parser = XMLParser()
    item_name = {0: ["hypertensionSpecial"]}
    seriData = parser.get_seri(xmlData, item_name)
    print seriData
    print '**API: Create a new record.'
    dataSeri = TbhypertensionspecialSeri(data=seriData,
                                         many=True,
                                         context=seriData)
    print dataSeri
    if dataSeri.is_valid():
        dataSeri.save()
    else:
        print "**API ERROR(hypertensionSpecial): Data is not valid."
    return ''
示例#4
0
def healthMeasureViewSet(xmlData):
    #     data = YTJMeasure.objects.filter(ID=1)
    #     dataSeri = YTJMeasureSeri(data, many=True)
    #     print dataSeri.data

    parser = XMLParser()
    item_name = {0: ["jkcl"]}
    jsonData = healthMeasureGetDataField(xmlData)
    jsonData = json.loads(jsonData)
    seriData = parser.get_seri(xmlData, item_name)
    newSeriData = [
        OrderedDict(
            list(seriData[0].items()) +
            list(OrderedDict([("data", jsonData)]).items()))
    ]
    print '**API: Create a new record.'
    dataSeri = YTJMeasureSeri(data=newSeriData, many=True, context=seriData)
    if dataSeri.is_valid():
        dataSeri.save()
    else:
        print "**API ERROR(healexaminationViewSet): Data is not valid."
    return ''
示例#5
0
def healthRecordViewUpdate(xmlData):
    parser = XMLParser()
    item_name = {0: ["healthRecord"], 1: ["pastHistory"]}
    seriData = parser.get_seri(xmlData, item_name)

    healthFileNumber = getAttributeFromXML(xmlData, "healthFileNumber")
    record = Tbhealthrecord.objects.filter(
        healthFileNumber=str(healthFileNumber))

    if len(record) == 0:
        print '**API: No such record.'
        return ''
    print '**API: Update exist record.'
    dataSeri = TbhealthrecordSeri(record,
                                  data=seriData,
                                  many=True,
                                  context=seriData)
    if dataSeri.is_valid():
        dataSeri.save()
    else:
        print "**API ERROR(healthRecordViewSet): Data is not valid."
    return ''
示例#6
0
def diabetesFlupViewSet(xmlData):  #糖尿病随访新增 M0100070201
    print "In dbFVS **********************"
    parser = XMLParser()
    #     specialNo = getAttributeFromXML(xmlData, "specialNo")
    #     print specialNo
    item_name = {0: ["diabetesFlup"]}
    #     xmlData = addNodeToXML(xmlData, "hypertensionFlup", "businessKey", str(uuid.uuid1()))
    #     xmlData = addNodeToXML(xmlData, "hypertensionFlup", "healthFileNumber", specialNo)
    #     xmlData = delNodeFromXML(xmlData, "hypertensionFlup", "personId")

    print(xmlData)
    seriData = parser.get_seri(xmlData, item_name)
    print seriData
    print '**API: Create a new record. 11111'

    dataSeri = TbdiabetesflupSeri(data=seriData, many=True, context=seriData)
    print dataSeri
    if dataSeri.is_valid():
        print "AAAAAAAAAAAAAAAACCCCCCCCCCCCCCCC"
        dataSeri.save()
        print "AAAAAAAAAAAAAAAABBBBBBBBBBBBBBBBBB"
    else:
        print "**API ERROR(hypertensionFlup): Data is not valid."
    return ''
示例#7
0
def healexaminationViewSet(xmlData):
    # healthFileNumber = getAttributeFromXML(xmlData, "healthFileNumber")

    xmlData = delNodeFromXML(xmlData, "healthExamination",
                             "personId")  # default: 12
    healthFileNum = getAttributeFromXML(xmlData, "healthFileNumber")
    machineNo = getAttributeFromXML(xmlData, "machineNo")
    name = getAttributeFromXML(xmlData, "name")

    parser = XMLParser()
    item_name = {0: ["healthExamination"]}
    seriData = parser.get_seri(xmlData, item_name)
    print '**API: Create a new record.'
    dataSeri = TbhealexaminationSeri(data=seriData,
                                     many=True,
                                     context=seriData)
    print dataSeri

    if dataSeri.is_valid():
        dataSeri.save()
        doc = Document()
        baseNode = doc.createElement("responseDatas")
        doc.appendChild(baseNode)
        rootNode = doc.createElement("healthExamination")
        baseNode.appendChild(rootNode)

        nodeName = doc.createElement("businesskey")
        rootNode.appendChild(nodeName)
        nodeVal = doc.createTextNode(machineNo)
        nodeName.appendChild(nodeVal)

        nodeName = doc.createElement("personId")
        rootNode.appendChild(nodeName)
        nodeVal = doc.createTextNode(healthFileNum)
        nodeName.appendChild(nodeVal)

        nodeName = doc.createElement("machineNo")
        rootNode.appendChild(nodeName)
        nodeVal = doc.createTextNode(machineNo)
        nodeName.appendChild(nodeVal)

        nodeName = doc.createElement("name")
        rootNode.appendChild(nodeName)
        nodeVal = doc.createTextNode(name)

        nodeName.appendChild(nodeVal)
        nodeName = doc.createElement("recordResultCode")
        rootNode.appendChild(nodeName)
        nodeVal = doc.createTextNode("0")
        nodeName.appendChild(nodeVal)

        nodeName = doc.createElement("recordResultDesc")
        rootNode.appendChild(nodeName)
        nodeVal = doc.createTextNode("操作成功")
        nodeName.appendChild(nodeVal)

        data = doc.toprettyxml(indent="", newl="", encoding="utf-8")
        print data
        return data
    else:
        print "**API ERROR(healexaminationViewSet): Data is not valid."
        return ''
示例#8
0
def healthRecordViewCreate(xmlData):
    xmlData = addNodeToXML(xmlData, "healthRecord", "birthday", "1996-07-08")

    xmlData = delNodeFromXML(xmlData, "healthRecord",
                             "personId")  # default: 12
    healthFileNum = str(int(time.time())) + str(
        datetime.datetime.now().microsecond)  # default: random
    xmlData = addNodeToXML(xmlData, "healthRecord", "healthFileNumber",
                           healthFileNum)
    machineNo = getAttributeFromXML(xmlData, "machineNo")
    name = getAttributeFromXML(xmlData, "name")
    idCard = getAttributeFromXML(xmlData, "idCard")

    try:
        nowLiveCode = getAttributeFromXML(xmlData, "nowLiveCode")
    except:
        print "Can not get nowLiveCode in nowLiveCode"
        xmlData = addNodeToXML(xmlData, "healthRecord", "nowLiveCode", "5")
    else:
        if len(nowLiveCode) == 0:
            xmlData = addNodeToXML(xmlData, "healthRecord", "nowLiveCode", "5")

    parser = XMLParser()
    item_name = {0: ["healthRecord"], 1: ["pastHistory"]}
    seriData = parser.get_seri(xmlData, item_name)
    print '**API: Create a new record.'
    dataSeri = TbhealthrecordSeri(data=seriData, many=True, context=seriData)
    if dataSeri.is_valid():
        dataSeri.save()

        doc = Document()

        baseNode = doc.createElement("responseDatas")
        doc.appendChild(baseNode)

        rootNode = doc.createElement("healthRecord")
        baseNode.appendChild(rootNode)

        nodeName = doc.createElement("personId")
        rootNode.appendChild(nodeName)
        nodeVal = doc.createTextNode(healthFileNum)
        nodeName.appendChild(nodeVal)

        nodeName = doc.createElement("machineNo")
        rootNode.appendChild(nodeName)
        nodeVal = doc.createTextNode(machineNo)
        nodeName.appendChild(nodeVal)

        nodeName = doc.createElement("name")
        rootNode.appendChild(nodeName)
        nodeVal = doc.createTextNode(name)
        nodeName.appendChild(nodeVal)

        nodeName = doc.createElement("recordResultCode")
        rootNode.appendChild(nodeName)
        nodeVal = doc.createTextNode("0")
        nodeName.appendChild(nodeVal)

        nodeName = doc.createElement("recordResultDesc")
        rootNode.appendChild(nodeName)
        nodeVal = doc.createTextNode("身份证号码[" + idCard + "] 已经建档!")
        nodeName.appendChild(nodeVal)

        data = doc.toprettyxml(indent="", newl="", encoding="utf-8")

        print data
        return data
    else:
        print "**API ERROR(healthRecordViewCreate): Data is not valid."
        return ''